Commit 592561ba authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Some minor improvements to QtBaseViewer (glViewer) and SimpleViewer.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17287 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 93193d30
......@@ -481,6 +481,7 @@ void glViewer::setScenePos(const ACG::Vec3d& _center, double _radius, const bool
}
properties_.setPlanes(nearPlane,farPlane);
properties_.orthoWidth(_radius);
updateProjectionMatrix();
updateGL();
......@@ -1803,7 +1804,7 @@ void glViewer::handleNormalNavigation( QMouseEvent* _event ) {
// if start depth is 1, no object was hit when starting translation
if ( startDepth_ == 1 ) {
if ( startDepth_ == 1 && projectionMode() != ORTHOGRAPHIC_PROJECTION ) {
double value_x = properties_.sceneRadius() * ((newPoint2D.x() - lastPoint2D_.x())) * 2.0 / (double) glWidth();
double value_y = properties_.sceneRadius() * ((newPoint2D.y() - lastPoint2D_.y())) * 2.0 / (double) glHeight();
translation = ACG::Vec3d(value_x * factor, -value_y * factor, 0.0);
......
......@@ -786,6 +786,10 @@ private:
bool fast_pick( const QPoint& _mousePos,
ACG::Vec3d& _hitPoint );
ACG::Vec3d unproject(const ACG::Vec3d &pt) {
return glstate_->unproject(pt);
}
private:
/// pick using colors
......
......@@ -67,16 +67,16 @@
//== CLASS DEFINITION =========================================================
SimpleViewer::SimpleViewer(QWidget* _parent) :
SimpleViewer::SimpleViewer(QWidget* _parent, bool useDefaultSceneGraph) :
QGraphicsView (_parent),
props_(-1),
actionMode_ (Viewer::ExamineMode)
{
QGLWidget *share = PluginFunctions::shareGLWidget ();
if (!share)
initialize (QGLFormat::defaultFormat (), 0);
initialize (QGLFormat::defaultFormat (), 0, useDefaultSceneGraph);
else
initialize (share->format(), share);
initialize (share->format(), share, useDefaultSceneGraph);
}
SimpleViewer::~SimpleViewer()
......@@ -97,7 +97,7 @@ void SimpleViewer::resizeEvent(QResizeEvent *_event) {
//=============================================================================
//=============================================================================
void SimpleViewer::initialize (const QGLFormat & _format, QGLWidget *_shareWidget)
void SimpleViewer::initialize (const QGLFormat & _format, QGLWidget *_shareWidget, bool useDefaultSceneGraph)
{
connect (&props_, SIGNAL( getPickMode(std::string&) ),
......@@ -125,15 +125,20 @@ void SimpleViewer::initialize (const QGLFormat & _format, QGLWidget *_shareWidge
mainWidget_->setGeometry (QRect(QPoint(0, 0), size()));
setFrameStyle(QFrame::NoFrame);
unsigned int maxPases = 1;
ACG::Vec3d bbmin,bbmax;
ACG::SceneGraph::analyzeSceneGraph(PluginFunctions::getSceneGraphRootNode(),maxPases,bbmin,bbmax);
mainWidget_->sceneGraph ( PluginFunctions::getSceneGraphRootNode(), maxPases,bbmin,bbmax,true);
if (useDefaultSceneGraph)
setSceneGraph(PluginFunctions::getSceneGraphRootNode());
props_.drawMode (OpenFlipper::Options::defaultDrawMode(0));
}
void SimpleViewer::setSceneGraph(ACG::SceneGraph::BaseNode *rootNode) {
unsigned int maxPases = 1;
ACG::Vec3d bbmin,bbmax;
ACG::SceneGraph::analyzeSceneGraph(rootNode, maxPases, bbmin, bbmax);
mainWidget_->sceneGraph(rootNode, maxPases, bbmin, bbmax, true);
}
void SimpleViewer::setActionMode(const Viewer::ActionMode _am)
{
actionMode_ = _am;
......
......@@ -83,7 +83,7 @@ class DLLEXPORT SimpleViewer : public QGraphicsView
public:
/// Constructor
SimpleViewer(QWidget* _parent = NULL);
SimpleViewer(QWidget* _parent = NULL, bool useDefaultSceneGraph = true);
/// Destructor
~SimpleViewer();
......@@ -94,13 +94,15 @@ class DLLEXPORT SimpleViewer : public QGraphicsView
/// Viewer
glViewer * viewer ();
void setSceneGraph(ACG::SceneGraph::BaseNode *rootNode);
protected:
// handle resizes
virtual void resizeEvent(QResizeEvent *_event);
private:
// initalisation
void initialize (const QGLFormat &_format, QGLWidget *_shareWidget = NULL);
void initialize (const QGLFormat &_format, QGLWidget *_shareWidget = NULL, bool useDefaultSceneGraph = true);
private slots:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment