diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp index 7ae9c269a..e95dd1528 100644 --- a/src/Gui/Flag.cpp +++ b/src/Gui/Flag.cpp @@ -28,7 +28,6 @@ #endif #include #include "View3DInventorViewer.h" -#include "GLPainter.h" #include "Flag.h" @@ -455,4 +454,76 @@ QSize FlagLayout::calculateSize(SizeType sizeType) const return totalSize; } + +TYPESYSTEM_SOURCE_ABSTRACT(Gui::GLFlagWindow, Gui::GLGraphicsItem); + +GLFlagWindow::GLFlagWindow(View3DInventorViewer* view) : _viewer(view), _flagLayout(0) +{ +} + +GLFlagWindow::~GLFlagWindow() +{ + deleteFlags(); + if (_flagLayout) + _flagLayout->deleteLater(); +} + +void GLFlagWindow::deleteFlags() +{ + if (_flagLayout) { + int ct = _flagLayout->count(); + for (int i=0; iitemAt(0)->widget(); + if (flag) { + _flagLayout->removeWidget(flag); + flag->deleteLater(); + } + } + } +} + +void GLFlagWindow::addFlag(Flag* item, FlagLayout::Position pos) +{ + if (!_flagLayout) { + _flagLayout = new FlagLayout(3); + _viewer->getGLWidget()->setLayout(_flagLayout); + } + + item->setParent(_viewer->getGLWidget()); + _flagLayout->addWidget(item, pos); + item->show(); + _viewer->scheduleRedraw(); +} + +void GLFlagWindow::removeFlag(Flag* item) +{ + if (_flagLayout) { + _flagLayout->removeWidget(item); + } +} + +void GLFlagWindow::paintGL() +{ + // draw lines for the flags + if (_flagLayout) { + // it can happen that the GL widget gets replaced internally by SoQt which + // causes to destroy the FlagLayout instance + int ct = _flagLayout->count(); + const SbViewportRegion vp = _viewer->getViewportRegion(); + SbVec2s size = vp.getViewportSizePixels(); + float aspectratio = float(size[0])/float(size[1]); + SbViewVolume vv = _viewer->getCamera()->getViewVolume(aspectratio); + for (int i=0; i(_flagLayout->itemAt(i)->widget()); + if (flag) { + SbVec3f pt = flag->getOrigin(); + vv.projectToScreen(pt, pt); + int tox = (int)(pt[0] * size[0]); + int toy = (int)((1.0f-pt[1]) * size[1]); + flag->drawLine(_viewer, tox, toy); + } + } + } +} + #include "moc_Flag.cpp" diff --git a/src/Gui/Flag.h b/src/Gui/Flag.h index 36d196a05..a5f0aaecf 100644 --- a/src/Gui/Flag.h +++ b/src/Gui/Flag.h @@ -29,9 +29,11 @@ #include #include #include +#include namespace Gui { class View3DInventorViewer; + /** * @author Werner Mayer */ @@ -98,6 +100,8 @@ private: class FlagLayout : public QLayout { + Q_OBJECT + public: enum Position { TopLeft, TopRight, BottomLeft, BottomRight }; @@ -136,6 +140,24 @@ private: QList list; }; +class GuiExport GLFlagWindow : public Gui::GLGraphicsItem +{ + TYPESYSTEM_HEADER(); + +public: + GLFlagWindow(View3DInventorViewer*); + virtual ~GLFlagWindow(); + void addFlag(Flag* item, FlagLayout::Position pos); + void removeFlag(Flag* item); + void deleteFlags(); + + void paintGL(); + +private: + View3DInventorViewer* _viewer; + FlagLayout* _flagLayout; +}; + } // namespace Gui diff --git a/src/Gui/GLPainter.cpp b/src/Gui/GLPainter.cpp index 81bffea6c..bfece7710 100644 --- a/src/Gui/GLPainter.cpp +++ b/src/Gui/GLPainter.cpp @@ -31,6 +31,8 @@ using namespace Gui; +TYPESYSTEM_SOURCE_ABSTRACT(Gui::GLGraphicsItem, Base::BaseClass); + GLPainter::GLPainter() : viewer(0), logicOp(false), lineStipple(false) { } diff --git a/src/Gui/GLPainter.h b/src/Gui/GLPainter.h index 170ce6357..287c9d1e2 100644 --- a/src/Gui/GLPainter.h +++ b/src/Gui/GLPainter.h @@ -33,6 +33,8 @@ #include #endif +#include + namespace Gui { class View3DInventorViewer; class GuiExport GLPainter @@ -71,6 +73,20 @@ private: bool lineStipple; }; +class GuiExport GLGraphicsItem : public Base::BaseClass +{ + TYPESYSTEM_HEADER(); + +public: + GLGraphicsItem() + { + } + virtual ~GLGraphicsItem() + { + } + virtual void paintGL() = 0; +}; + } // namespace Gui #endif // GUI_GLPAINTER_H diff --git a/src/Gui/MouseSelection.cpp b/src/Gui/MouseSelection.cpp index dccf87142..d4c53feae 100644 --- a/src/Gui/MouseSelection.cpp +++ b/src/Gui/MouseSelection.cpp @@ -755,6 +755,118 @@ int RectangleSelection::keyboardEvent( const SoKeyboardEvent * const e ) // ----------------------------------------------------------------------------------- +Rubberband::Rubberband() +{ + m_bWorking = false; +} + +Rubberband::~Rubberband() +{ +} + +void Rubberband::initialize() +{ + _pcView3D->setRenderFramebuffer(true); + _pcView3D->scheduleRedraw(); +} + +void Rubberband::terminate() +{ + _pcView3D->setRenderFramebuffer(false); + _pcView3D->scheduleRedraw(); +} + +void Rubberband::redraw() +{ + draw(); +} + +void Rubberband::draw () +{ + if (m_bWorking) { + const SbViewportRegion vp = _pcView3D->getViewportRegion(); + SbVec2s size = vp.getViewportSizePixels(); + + glMatrixMode(GL_PROJECTION); + glOrtho(0, size[0], size[1], 0, 0, 100); + glMatrixMode(GL_MODELVIEW); + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glLineWidth(4.0); + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); + glRecti(m_iXold, m_iYold, m_iXnew, m_iYnew); + glColor4f(1.0, 1.0, 0.0, 0.5); + glLineStipple(3, 0xAAAA); + glEnable(GL_LINE_STIPPLE); + + glBegin(GL_LINE_LOOP); + glVertex2i(m_iXold, m_iYold); + glVertex2i(m_iXnew, m_iYold); + glVertex2i(m_iXnew, m_iYnew); + glVertex2i(m_iXold, m_iYnew); + glEnd(); + + glLineWidth(1.0); + glDisable(GL_LINE_STIPPLE); + glDisable(GL_BLEND); + } +} + +int Rubberband::mouseButtonEvent(const SoMouseButtonEvent * const e, const QPoint& pos) +{ + const int button = e->getButton(); + const SbBool press = e->getState() == SoButtonEvent::DOWN ? TRUE : FALSE; + + int ret = Continue; + + if (press) { + switch (button) + { + case SoMouseButtonEvent::BUTTON1: + { + m_bWorking = true; + m_iXold = m_iXnew = pos.x(); + m_iYold = m_iYnew = pos.y(); + } break; + default: + { + } break; + } + } + else { + switch (button) { + case SoMouseButtonEvent::BUTTON1: + { + releaseMouseModel(); + m_bWorking = false; + _clPoly.push_back(e->getPosition()); + ret = Finish; + } break; + default: + { + } break; + } + } + + return ret; +} + +int Rubberband::locationEvent(const SoLocation2Event * const e, const QPoint& pos) +{ + m_iXnew = pos.x(); + m_iYnew = pos.y(); + _pcView3D->render(); + return Continue; +} + +int Rubberband::keyboardEvent(const SoKeyboardEvent * const e) +{ + return Continue; +} + +// ----------------------------------------------------------------------------------- + BoxZoomSelection::BoxZoomSelection() { } @@ -765,6 +877,8 @@ BoxZoomSelection::~BoxZoomSelection() void BoxZoomSelection::terminate() { + Rubberband::terminate(); + int xmin = std::min(m_iXold, m_iXnew); int xmax = std::max(m_iXold, m_iXnew); int ymin = std::min(m_iYold, m_iYnew); diff --git a/src/Gui/MouseSelection.h b/src/Gui/MouseSelection.h index b26cdea30..a4d9813d1 100644 --- a/src/Gui/MouseSelection.h +++ b/src/Gui/MouseSelection.h @@ -67,7 +67,7 @@ public: const std::vector& getPositions() const { return _clPoly; } SbBool isInner() const { return m_bInner; } - void redraw(); + virtual void redraw(); /** @name Mouse events*/ //@{ @@ -226,12 +226,43 @@ private: // ----------------------------------------------------------------------------------- +/** + * The selection mouse model class + * Draws a rectangle for selection + * \author Werner Mayer + */ +class GuiExport Rubberband : public BaseMouseSelection +{ +public: + Rubberband(); + virtual ~Rubberband(); + + /// do nothing + virtual void initialize(); + /// do nothing + virtual void terminate(); + +protected: + virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos ); + virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos ); + virtual int keyboardEvent ( const SoKeyboardEvent * const e ); + + /// draw the rectangle + virtual void draw (); + virtual void redraw(); + +private: + bool m_bWorking; +}; + +// ----------------------------------------------------------------------------------- + /** * The box zoom mouse model class * Draws a rectangle for box zooming * \author Werner Mayer */ -class GuiExport BoxZoomSelection : public RectangleSelection +class GuiExport BoxZoomSelection : public Rubberband { public: BoxZoomSelection(); diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 93f02b8e9..692b13d23 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -47,6 +47,7 @@ #include "propertyeditor/PropertyItem.h" #include "NavigationStyle.h" +#include "Flag.h" using namespace Gui; using namespace Gui::Inventor; @@ -130,6 +131,9 @@ void Gui::SoFCDB::init() BlenderNavigationStyle ::init(); TouchpadNavigationStyle ::init(); + GLGraphicsItem ::init(); + GLFlagWindow ::init(); + qRegisterMetaType("Base::Vector3f"); qRegisterMetaType("Base::Vector3d"); init_done = TRUE; diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index c53e8b566..e4e08fa4b 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -109,6 +109,7 @@ #include "NavigationStyle.h" #include "ViewProvider.h" #include "SpaceballEvent.h" +#include "GLPainter.h" #include @@ -137,8 +138,8 @@ SOQT_OBJECT_ABSTRACT_SOURCE(View3DInventorViewer); View3DInventorViewer::View3DInventorViewer (QWidget *parent, const char *name, SbBool embed, Type type, SbBool build) - : inherited (parent, name, embed, type, build), editViewProvider(0),navigation(0), - editing(FALSE), redirected(FALSE), allowredir(FALSE) + : inherited (parent, name, embed, type, build), editViewProvider(0), navigation(0), + framebuffer(0), editing(FALSE), redirected(FALSE), allowredir(FALSE) { Gui::Selection().Attach(this); @@ -883,10 +884,134 @@ void View3DInventorViewer::interactionLoggerCB(void * ud, SoAction* action) Base::Console().Log("%s\n", action->getTypeId().getName().getString()); } +void View3DInventorViewer::addGraphicsItem(GLGraphicsItem* item) +{ + this->graphicsItems.push_back(item); +} + +void View3DInventorViewer::removeGraphicsItem(GLGraphicsItem* item) +{ + this->graphicsItems.remove(item); +} + +std::list View3DInventorViewer::getGraphicsItems() const +{ + return graphicsItems; +} + +std::list View3DInventorViewer::getGraphicsItemsOfType(const Base::Type& type) const +{ + std::list items; + for (std::list::const_iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it) { + if ((*it)->isDerivedFrom(type)) + items.push_back(*it); + } + return items; +} + +void View3DInventorViewer::clearGraphicsItems() +{ + this->graphicsItems.clear(); +} + +void View3DInventorViewer::setRenderFramebuffer(const SbBool enable) +{ + if (!enable) { + delete framebuffer; + framebuffer = 0; + } + else if (!this->framebuffer) { + const SbViewportRegion vp = this->getViewportRegion(); + SbVec2s origin = vp.getViewportOriginPixels(); + SbVec2s size = vp.getViewportSizePixels(); + + this->glLockNormal(); + this->framebuffer = new QGLFramebufferObject(size[0],size[1],QGLFramebufferObject::Depth); + renderToFramebuffer(this->framebuffer); + } +} + +SbBool View3DInventorViewer::isRenderFramebuffer() const +{ + return this->framebuffer != 0; +} + +void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo) +{ + this->glLockNormal(); + fbo->bind(); + + glDisable(GL_TEXTURE_2D); + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LINE_SMOOTH); + + const SbColor col = this->getBackgroundColor(); + glClearColor(col[0], col[1], col[2], 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glDepthRange(0.1,1.0); + + SoGLRenderAction gl(SbViewportRegion(fbo->size().width(),fbo->size().height())); + gl.apply(this->backgroundroot); + gl.apply(this->getSceneManager()->getSceneGraph()); + gl.apply(this->foregroundroot); + if (this->axiscrossEnabled) { this->drawAxisCross(); } + + fbo->release(); + this->glUnlockNormal(); +} + +void View3DInventorViewer::actualRedraw() +{ + if (this->framebuffer) + renderFramebuffer(); + else + renderScene(); +} + +void View3DInventorViewer::renderFramebuffer() +{ + const SbViewportRegion vp = this->getViewportRegion(); + SbVec2s size = vp.getViewportSizePixels(); + + glDisable(GL_LIGHTING); + glViewport(0, 0, size[0], size[1]); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glDisable(GL_DEPTH_TEST); + + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, this->framebuffer->texture()); + glColor3f(1.0, 1.0, 1.0); + + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); + glVertex2f(-1.0, -1.0f); + glTexCoord2f(1.0f, 0.0f); + glVertex2f(1.0f, -1.0f); + glTexCoord2f(1.0f, 1.0f); + glVertex2f(1.0f, 1.0f); + glTexCoord2f(0.0f, 1.0f); + glVertex2f(-1.0f, 1.0f); + glEnd(); + + printDimension(); + navigation->redraw(); + for (std::list::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it) + (*it)->paintGL(); + + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); +} + // Documented in superclass. Overrides this method to be able to draw // the axis cross, if selected, and to keep a continuous animation // upon spin. -void View3DInventorViewer::actualRedraw(void) +void View3DInventorViewer::renderScene(void) { // Must set up the OpenGL viewport manually, as upon resize // operations, Coin won't set it up until the SoGLRenderAction is @@ -935,29 +1060,19 @@ void View3DInventorViewer::actualRedraw(void) // using the main portion of z-buffer again (for frontbuffer highlighting) glDepthRange(0.1,1.0); - // draw lines for the flags - if (_flaglayout) { - // it can happen that the GL widget gets replaced internally by SoQt which - // causes to destroy the FlagLayout instance - int ct = _flaglayout->count(); - SbViewVolume vv = getCamera()->getViewVolume(getGLAspectRatio()); - for (int i=0; i(_flaglayout->itemAt(i)->widget()); - if (flag) { - SbVec3f pt = flag->getOrigin(); - vv.projectToScreen(pt, pt); - int tox = (int)(pt[0] * size[0]); - int toy = (int)((1.0f-pt[1]) * size[1]); - flag->drawLine(this, tox, toy); - } - } - } - // Immediately reschedule to get continous spin animation. if (this->isAnimating()) { this->scheduleRedraw(); } + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + printDimension(); navigation->redraw(); + for (std::list::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it) + (*it)->paintGL(); + + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); } void View3DInventorViewer::setSeekMode(SbBool on) @@ -2056,16 +2171,3 @@ std::vector View3DInventorViewer::getViewProvidersOfType(const Ba } return views; } - -void View3DInventorViewer::addFlag(Flag* item, FlagLayout::Position pos) -{ - if (!_flaglayout) { - _flaglayout = new FlagLayout(3); - this->getGLWidget()->setLayout(_flaglayout); - } - - item->setParent(this->getGLWidget()); - _flaglayout->addWidget(item, pos); - item->show(); - this->scheduleRedraw(); -} diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 8b2e295fb..fa0571292 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -24,17 +24,18 @@ #ifndef GUI_VIEW3DINVENTORVIEWER_H #define GUI_VIEW3DINVENTORVIEWER_H +#include +#include #include -#include +#include #include #include #include #include +#include #include -#include -#include class SoSeparator; @@ -45,6 +46,8 @@ class SbSphereSheetProjector; class SoEventCallback; class SbBox2s; class SoVectorizeAction; +class QGLFramebufferObject; +class QImage; namespace Gui { @@ -54,6 +57,7 @@ class NavigationStyle; class SoFCUnifiedSelection; class Document; class SoFCUnifiedSelection; +class GLGraphicsItem; /** The Inventor viewer * @@ -121,9 +125,19 @@ public: void setFeedbackSize(const int size); int getFeedbackSize(void) const; + void setRenderFramebuffer(const SbBool enable); + SbBool isRenderFramebuffer() const; + void renderToFramebuffer(QGLFramebufferObject*); + virtual void setViewing(SbBool enable); virtual void setCursorEnabled(SbBool enable); + void addGraphicsItem(GLGraphicsItem*); + void removeGraphicsItem(GLGraphicsItem*); + std::list getGraphicsItems() const; + std::list getGraphicsItemsOfType(const Base::Type&) const; + void clearGraphicsItems(); + /** @name Handling of view providers */ //@{ SbBool hasViewProvider(ViewProvider*) const; @@ -267,6 +281,8 @@ public: void setDocument(Gui::Document *pcDocument); protected: + void renderScene(); + void renderFramebuffer(); virtual void actualRedraw(void); virtual void setSeekMode(SbBool enable); virtual void afterRealizeHook(void); @@ -287,10 +303,15 @@ private: static void selectCB(void * closure, SoPath * p); static void deselectCB(void * closure, SoPath * p); static SoPath * pickFilterCB(void * data, const SoPickedPoint * pick); + void initialize(); + void drawAxisCross(void); + static void drawArrow(void); + void setCursorRepresentation(int mode); private: std::set _ViewProviderSet; std::map _ViewProviderMap; + std::list graphicsItems; ViewProvider* editViewProvider; SoFCBackgroundGradient *pcBackGround; SoSeparator * backgroundroot; @@ -302,27 +323,16 @@ private: SoEventCallback* pEventCallback; NavigationStyle* navigation; SoFCUnifiedSelection* selectionRoot; + QGLFramebufferObject* framebuffer; - void initialize(); SbBool axiscrossEnabled; int axiscrossSize; - void drawAxisCross(void); - static void drawArrow(void); - SbBool editing; QCursor editCursor; SbBool redirected; SbBool allowredir; - void setCursorRepresentation(int mode); - -public: - void addFlag(Flag*, FlagLayout::Position); - -private: - QPointer _flaglayout; - // friends friend class NavigationStyle; friend class GLPainter; diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index 1783b6380..b31eb4bd9 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -388,21 +389,30 @@ public: this->deleteLater(); } + static void addFlag(Gui::View3DInventorViewer* view, const QString& text, const SoPickedPoint * point) + { + Gui::Flag* flag = new Gui::Flag; + QPalette p; + p.setColor(QPalette::Window, QColor(85,0,127)); + p.setColor(QPalette::Text, QColor(220,220,220)); + flag->setPalette(p); + flag->setText(text); + flag->setOrigin(point->getPoint()); + Gui::GLFlagWindow* flags = 0; + std::list glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId()); + if (glItems.empty()) { + flags = new Gui::GLFlagWindow(view); + view->addGraphicsItem(flags); + } + else { + flags = static_cast(glItems.front()); + } + flags->addFlag(flag, Gui::FlagLayout::BottomLeft); + } + private: QPointer widget; }; - -void addFlag(Gui::View3DInventorViewer* view, const QString& text, const SoPickedPoint * point) -{ - Gui::Flag* flag = new Gui::Flag; - QPalette p; - p.setColor(QPalette::Window, QColor(85,0,127)); - p.setColor(QPalette::Text, QColor(220,220,220)); - flag->setPalette(p); - flag->setText(text); - flag->setOrigin(point->getPoint()); - view->addFlag(flag, Gui::FlagLayout::BottomLeft); -} } void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n) @@ -456,7 +466,7 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n) QString info = that->inspectDistance(point); Gui::getMainWindow()->setPaneText(1,info); if (addflag) - addFlag(view, info, point); + ViewProviderProxyObject::addFlag(view, info, point); else Gui::ToolTip::showText(QCursor::pos(), info); } @@ -476,7 +486,7 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n) QString info = that->inspectDistance(point); Gui::getMainWindow()->setPaneText(1,info); if (addflag) - addFlag(view, info, point); + ViewProviderProxyObject::addFlag(view, info, point); else Gui::ToolTip::showText(QCursor::pos(), info); break; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 3682f76e0..5bd84aaa6 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -1258,6 +1259,11 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n) view->setEditing(false); view->getWidget()->setCursor(QCursor(Qt::ArrowCursor)); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), faceInfoCallback,ud); + std::list glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId()); + for (std::list::iterator it = glItems.begin(); it != glItems.end(); ++it) { + view->removeGraphicsItem(*it); + delete *it; + } } } else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) { @@ -1276,14 +1282,24 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n) return; ViewProviderMesh* that = static_cast(vp); const SoDetail* detail = point->getDetail(that->getShapeNode()); - if ( detail && detail->getTypeId() == SoFaceDetail::getClassTypeId() ) { + if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) { // get the boundary to the picked facet unsigned long uFacet = ((SoFaceDetail*)detail)->getFaceIndex(); that->faceInfo(uFacet); + Gui::GLFlagWindow* flags = 0; + std::list glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId()); + if (glItems.empty()) { + flags = new Gui::GLFlagWindow(view); + view->addGraphicsItem(flags); + } + else { + flags = static_cast(glItems.front()); + } + Gui::Flag* flag = new Gui::Flag; flag->setText(QObject::tr("Index: %1").arg(uFacet)); flag->setOrigin(point->getPoint()); - view->addFlag(flag, Gui::FlagLayout::TopRight); + flags->addFlag(flag, Gui::FlagLayout::TopRight); } } } diff --git a/src/Mod/Part/Gui/ViewProvider.cpp b/src/Mod/Part/Gui/ViewProvider.cpp index ac9956fe5..9bf99796a 100644 --- a/src/Mod/Part/Gui/ViewProvider.cpp +++ b/src/Mod/Part/Gui/ViewProvider.cpp @@ -73,6 +73,7 @@ # include # include # include +# include #endif /// Here the FreeCAD includes sorted by Base,App,Gui...... diff --git a/src/Mod/Sandbox/Gui/Command.cpp b/src/Mod/Sandbox/Gui/Command.cpp index ea224c528..1a7e9313d 100644 --- a/src/Mod/Sandbox/Gui/Command.cpp +++ b/src/Mod/Sandbox/Gui/Command.cpp @@ -23,6 +23,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# ifdef FC_OS_WIN32 +# include +# endif # include # include # include