X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fview.cpp;h=925fa47c54db2933963922a33747fefb0054f10c;hp=e0efce949b3f0473bdd256be1015617bd083596c;hb=6472d20ee58d2ecc0aee8bc1a12a071b2afc8a27;hpb=53579b1a949fa3e4e193f8dfba2064edbb123f57 diff --git a/src/view.cpp b/src/view.cpp index e0efce9..925fa47 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -3,6 +3,10 @@ #include "screen.h" #include "gl_core44.h" +#ifndef CONTROLPANEL_DISABLED + #include "controlpanel.h" +#endif //CONTROLPANEL_DISABLED + using namespace IPDF; using namespace std; @@ -16,7 +20,9 @@ using namespace std; View::View(Document & document, Screen & screen, const Rect & bounds, const Colour & colour) : m_use_gpu_transform(USE_GPU_TRANSFORM), m_use_gpu_rendering(USE_GPU_RENDERING), m_bounds_dirty(true), m_buffer_dirty(true), m_render_dirty(true), m_document(document), m_screen(screen), m_cached_display(), m_bounds(bounds), m_colour(colour), m_bounds_ubo(), - m_objbounds_vbo(), m_object_renderers(NUMBER_OF_OBJECT_TYPES), m_cpu_rendering_pixels(NULL) + m_objbounds_vbo(), m_object_renderers(NUMBER_OF_OBJECT_TYPES), m_cpu_rendering_pixels(NULL), + m_perform_shading(USE_SHADING), m_show_bezier_bounds(false), m_show_bezier_type(false), + m_show_fill_points(false), m_show_fill_bounds(false) { Debug("View Created - Bounds => {%s}", m_bounds.Str().c_str()); @@ -28,7 +34,7 @@ View::View(Document & document, Screen & screen, const Rect & bounds, const Colo m_object_renderers[RECT_OUTLINE] = new RectOutlineRenderer(); m_object_renderers[CIRCLE_FILLED] = new CircleFilledRenderer(); m_object_renderers[BEZIER] = new BezierRenderer(); - m_object_renderers[GROUP] = new GroupRenderer(); + m_object_renderers[PATH] = new PathRenderer(); // To add rendering for a new type of object; // 1. Add enum to ObjectType in ipdf.h @@ -67,7 +73,22 @@ void View::Translate(Real x, Real y) y *= m_bounds.h; m_bounds.x += x; m_bounds.y += y; - Debug("View Bounds => %s", m_bounds.Str().c_str()); + //Debug("View Bounds => %s", m_bounds.Str().c_str()); + if (!m_use_gpu_transform) + m_buffer_dirty = true; + m_bounds_dirty = true; +} + +/** + * Set View bounds + * @param bounds - New bounds + */ +void View::SetBounds(const Rect & bounds) +{ + m_bounds.x = bounds.x; + m_bounds.y = bounds.y; + m_bounds.w = bounds.w; + m_bounds.h = bounds.h; if (!m_use_gpu_transform) m_buffer_dirty = true; m_bounds_dirty = true; @@ -152,7 +173,7 @@ void View::Render(int width, int height) #ifndef QUADTREE_DISABLED if (m_bounds_dirty) { - if (m_bounds.x > 1.0 || m_bounds.x < 0.0 || m_bounds.y > 1.0 || m_bounds.y < 0.0 || m_bounds.w > 1.0 || m_bounds.h > 1.0) + if (false && (m_bounds.x > 1.0 || m_bounds.x < 0.0 || m_bounds.y > 1.0 || m_bounds.y < 0.0 || m_bounds.w > 1.0 || m_bounds.h > 1.0)) { //TODO: Generate a new parent node. if (m_document.GetQuadTree().nodes[m_current_quadtree_node].parent != QUADTREE_EMPTY) @@ -233,12 +254,17 @@ void View::Render(int width, int height) { m_screen.RenderPixels(0,0,width, height, m_cpu_rendering_pixels); //TODO: Make this work :( // Debug for great victory (do something similar for GPU and compare?) - ObjectRenderer::SaveBMP({m_cpu_rendering_pixels, width, height}, "cpu_rendering_last_frame.bmp"); + //ObjectRenderer::SaveBMP({m_cpu_rendering_pixels, width, height}, "cpu_rendering_last_frame.bmp"); } m_cached_display.UnBind(); // resets render target to the screen m_cached_display.Blit(); // blit FrameBuffer to screen m_buffer_dirty = false; glPopDebugGroup(); + +#ifndef CONTROLPANEL_DISABLED + ControlPanel::Update(); +#endif //CONTROLPANEL_DISABLED + } #ifndef QUADTREE_DISABLED