Commit 036eb88e authored by Jan Möbius's avatar Jan Möbius
Browse files

First test version of a widget node. Problem is a not really integrated widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9186 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8b102fe5
......@@ -67,12 +67,7 @@ void
QtWidgetNode::
boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{
std::cerr << "QtWidgetNode Got boundingbox call " << std::endl;
// ConstPointIter p_it=points_.begin(), p_end=points_.end();
// for (; p_it!=p_end; ++p_it) {
// _bbMin.minimize(*p_it);
// _bbMax.maximize(*p_it);
// }
// No bounding box as this experiment is not really in the scene but above it
}
......@@ -94,34 +89,20 @@ void
QtWidgetNode::
draw(GLState& _state , DrawModes::DrawMode _drawMode)
{
QPixmap pixmap = QPixmap::grabWidget(widget_);
std::cerr << "QtWidgetNode Got draw call " << std::endl;
}
void
QtWidgetNode::mouseEvent(GLState& _state, QMouseEvent* _event)
{
double height = 0.0;
double width = 0.0;
Vec2i newPoint2D(_event->pos().x(), _event->pos().y());
// Project 3d point onto screen
ACG::Vec3d projected = _state.project(position_);
// if ( _event == QEvent::MouseButtonPress ) {
//
// } else if ( _event == QEvent::MouseButtonDblClick ) {
//
// } else if ( _event == QEvent::MouseButtonRelease ) {
//
// } else if ( _event == QEvent::MouseMove ) {
// widget_->mouse
// }
std::cerr << "QtWidgetNode Got Mouse Event " << newPoint2D << std::endl;
// Vec3d newPoint3D;
// Translate widget position to be at the correct position
QTransform transform;
transform.translate(projected[0],_state.viewport_height() - projected[1]);
item_->setTransform(transform);
}
//=============================================================================
} // namespace SceneGraph
} // namespace ACG
......
......@@ -58,6 +58,8 @@
#include <ACG/Scenegraph/BaseNode.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <QGraphicsScene>
#include <QGraphicsProxyWidget>
#include <QWidget>
#include <vector>
......@@ -80,12 +82,20 @@ class ACGDLLEXPORT QtWidgetNode : public BaseNode
public:
/// default constructor
QtWidgetNode( QWidget* _widget,
QtWidgetNode( QWidget* _widget,
QGraphicsScene* _scene,
BaseNode* _parent = 0,
std::string _name="<QtWidgetNode>" )
: BaseNode(_parent, _name),
position_(ACG::Vec3d(0.0,0.0,0.0)),
widget_(_widget)
{}
{
// Get the 3d proxxy of the widget
QGraphicsProxyWidget *proxy = _scene->addWidget(_widget);
// Store the Graphicsitem to apply transforms to it
item_ = proxy->graphicsItem ();
}
/// destructor
~QtWidgetNode() {}
......@@ -102,12 +112,17 @@ public:
/// draw points and normals
void draw(GLState& _state, DrawModes::DrawMode _drawMode);
/// get mouse events
virtual void mouseEvent(GLState& _state, QMouseEvent* _event);
void position(ACG::Vec3d _position) { position_ = _position; };
ACG::Vec3d position() { return position_; };
private:
// The 3d point which should be followed by the widget
ACG::Vec3d position_;
QWidget* widget_;
QGraphicsItem* item_;
};
......
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