Added View->View All menu entry

master
Marius Kintel 2014-06-21 16:12:55 -04:00
parent 4097aa887d
commit d066648390
15 changed files with 56 additions and 15 deletions

View File

@ -6,9 +6,9 @@ class CGALRenderer : public Renderer
{
public:
CGALRenderer(shared_ptr<const class Geometry> geom);
~CGALRenderer();
void draw(bool showfaces, bool showedges) const;
BoundingBox getBoundingBox() const;
virtual ~CGALRenderer();
virtual void draw(bool showfaces, bool showedges) const;
virtual BoundingBox getBoundingBox() const;
public:
shared_ptr<class Polyhedron> polyhedron;

View File

@ -28,7 +28,7 @@ public:
Camera(enum CameraType camtype = NONE);
void setup(std::vector<double> params);
void gimbalDefaultTranslate();
void viewAll(const BoundingBox &bbox, float scalefactor);
void viewAll(const BoundingBox &bbox, float scalefactor = 1.0f);
// Vectorcam
Eigen::Vector3d eye;

View File

@ -3,6 +3,7 @@
#include "stdio.h"
#include "rendersettings.h"
#include "mathc99.h"
#include "renderer.h"
#ifdef _WIN32
#include <GL/wglew.h>

View File

@ -25,14 +25,14 @@ Some actions (showCrossHairs) only work properly on Gimbal Camera.
#endif
#include "system-gl.h"
#include <iostream>
#include "renderer.h"
#include "Camera.h"
class GLView
{
public:
GLView();
void setRenderer(Renderer* r);
void setRenderer(class Renderer* r);
Renderer *getRenderer() const { return this->renderer; }
void initializeGL();
void resizeGL(int w, int h);

View File

@ -203,6 +203,7 @@ public slots:
void viewPerspective();
void viewOrthogonal();
void viewResetView();
void viewAll();
void hideConsole();
void animateUpdateDocChanged();
void animateUpdate();

View File

@ -120,7 +120,7 @@
<x>0</x>
<y>0</y>
<width>936</width>
<height>34</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@ -234,6 +234,7 @@
<addaction name="viewActionBack"/>
<addaction name="viewActionDiagonal"/>
<addaction name="viewActionCenter"/>
<addaction name="viewActionViewAll"/>
<addaction name="separator"/>
<addaction name="viewActionZoomIn"/>
<addaction name="viewActionZoomOut"/>
@ -961,6 +962,11 @@
<string>Ctrl+[</string>
</property>
</action>
<action name="viewActionViewAll">
<property name="text">
<string>View All</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -147,3 +147,10 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
}
std::for_each(primitives.begin(), primitives.end(), del_fun<OpenCSG::Primitive>());
}
BoundingBox OpenCSGRenderer::getBoundingBox() const
{
BoundingBox bbox;
if (this->root_chain) bbox = this->root_chain->getBoundingBox();
return bbox;
}

View File

@ -8,7 +8,8 @@ class OpenCSGRenderer : public Renderer
public:
OpenCSGRenderer(class CSGChain *root_chain, CSGChain *highlights_chain,
CSGChain *background_chain, GLint *shaderinfo);
void draw(bool showfaces, bool showedges) const;
virtual void draw(bool showfaces, bool showedges) const;
virtual BoundingBox getBoundingBox() const;
private:
void renderCSGChain(class CSGChain *chain, GLint *shaderinfo,
bool highlight, bool background) const;

View File

@ -88,6 +88,15 @@ void QGLView::resetView()
cam.viewer_distance = 140;
}
void QGLView::viewAll()
{
if (Renderer *r = this->getRenderer()) {
BoundingBox bbox = r->getBoundingBox();
cam.object_trans = -bbox.center();
cam.viewAll(r->getBoundingBox());
}
}
void QGLView::initializeGL()
{
GLenum err = glewInit();

View File

@ -44,6 +44,7 @@ public:
#endif
bool save(const char *filename);
void resetView();
void viewAll();
public slots:
void ZoomIn(void);

View File

@ -123,3 +123,10 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
glPopMatrix();
}
}
BoundingBox ThrownTogetherRenderer::getBoundingBox() const
{
BoundingBox bbox;
if (this->root_chain) bbox = this->root_chain->getBoundingBox();
return bbox;
}

View File

@ -7,7 +7,8 @@ class ThrownTogetherRenderer : public Renderer
public:
ThrownTogetherRenderer(class CSGChain *root_chain,
CSGChain *highlights_chain, CSGChain *background_chain);
void draw(bool showfaces, bool showedges) const;
virtual void draw(bool showfaces, bool showedges) const;
virtual BoundingBox getBoundingBox() const;
private:
void renderCSGChain(CSGChain *chain, bool highlight, bool background, bool showedges,
bool fberror) const;

View File

@ -68,11 +68,6 @@ void export_png_preview_common(Tree &tree, Camera &cam, std::ostream &output, Pr
#endif
ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain);
BoundingBox bbox;
if (csgInfo.root_chain) bbox = csgInfo.root_chain->getBoundingBox();
setupCamera(cam, bbox, 2.7);
csgInfo.glview->setCamera(cam);
#ifdef ENABLE_OPENCSG
if (previewer == OPENCSG)
csgInfo.glview->setRenderer(&openCSGRenderer);
@ -80,6 +75,10 @@ void export_png_preview_common(Tree &tree, Camera &cam, std::ostream &output, Pr
#endif
csgInfo.glview->setRenderer(&thrownTogetherRenderer);
#ifdef ENABLE_OPENCSG
BoundingBox bbox = csgInfo.glview->getRenderer()->getBoundingBox();
setupCamera(cam, bbox, 2.7);
csgInfo.glview->setCamera(cam);
OpenCSG::setContext(0);
OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
#endif

View File

@ -372,6 +372,7 @@ MainWindow::MainWindow(const QString &filename)
connect(this->viewActionDiagonal, SIGNAL(triggered()), this, SLOT(viewAngleDiagonal()));
connect(this->viewActionCenter, SIGNAL(triggered()), this, SLOT(viewCenter()));
connect(this->viewActionResetView, SIGNAL(triggered()), this, SLOT(viewResetView()));
connect(this->viewActionViewAll, SIGNAL(triggered()), this, SLOT(viewAll()));
connect(this->viewActionPerspective, SIGNAL(triggered()), this, SLOT(viewPerspective()));
connect(this->viewActionOrthogonal, SIGNAL(triggered()), this, SLOT(viewOrthogonal()));
connect(this->viewActionHide, SIGNAL(triggered()), this, SLOT(hideConsole()));
@ -2141,6 +2142,12 @@ void MainWindow::viewResetView()
this->qglview->updateGL();
}
void MainWindow::viewAll()
{
this->qglview->viewAll();
this->qglview->updateGL();
}
void MainWindow::on_editorDock_visibilityChanged(bool visible)
{
if (isClosing) {

View File

@ -13,7 +13,8 @@ class Renderer
public:
virtual ~Renderer() {}
virtual void draw(bool showfaces, bool showedges) const = 0;
virtual BoundingBox getBoundingBox() const = 0;
#define CSGMODE_DIFFERENCE_FLAG 0x10
enum csgmode_e {
CSGMODE_NONE = 0x00,