From ef6978e9dfaa9cd2a95c1ea9848c606937cf5841 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 22 Nov 2013 15:14:15 +0100 Subject: [PATCH] +Add method to get mdi view by view provider, add method to get flag widgets --- src/Gui/Document.cpp | 13 +++++++++++++ src/Gui/Document.h | 1 + src/Gui/Flag.cpp | 18 ++++++++++++++++++ src/Gui/Flag.h | 2 ++ 4 files changed, 34 insertions(+) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index c5194a277..19f6f71df 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1111,6 +1111,19 @@ MDIView* Document::getActiveView(void) const return active; } +Gui::MDIView* Document::getViewOfViewProvider(Gui::ViewProvider* vp) const +{ + std::list mdis = getMDIViews(); + for (std::list::const_iterator it = mdis.begin(); it != mdis.end(); ++it) { + if ((*it)->getTypeId().isDerivedFrom(View3DInventor::getClassTypeId())) { + View3DInventor* view = static_cast(*it); + if (view->getViewer()->hasViewProvider(vp)) + return *it; + } + } + + return 0; +} //-------------------------------------------------------------------------- // UNDO REDO transaction handling diff --git a/src/Gui/Document.h b/src/Gui/Document.h index 85736c6b9..cdc6a8f99 100644 --- a/src/Gui/Document.h +++ b/src/Gui/Document.h @@ -135,6 +135,7 @@ public: //@{ /// Getter for the active view Gui::MDIView* getActiveView(void) const; + Gui::MDIView* getViewOfViewProvider(Gui::ViewProvider*) const; /// Creat a new view void createView(const char* sType); /** send messages to the active view diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp index 43c66e38e..f0ab28da1 100644 --- a/src/Gui/Flag.cpp +++ b/src/Gui/Flag.cpp @@ -503,6 +503,24 @@ void GLFlagWindow::removeFlag(Flag* item) } } +Flag* GLFlagWindow::getFlag(int index) const +{ + if (_flagLayout) { + QWidget* flag = _flagLayout->itemAt(index)->widget(); + return qobject_cast(flag); + } + return 0; +} + +int GLFlagWindow::countFlags() const +{ + if (_flagLayout) { + return _flagLayout->count(); + } + + return 0; +} + void GLFlagWindow::paintGL() { // draw lines for the flags diff --git a/src/Gui/Flag.h b/src/Gui/Flag.h index a5f0aaecf..79a77760b 100644 --- a/src/Gui/Flag.h +++ b/src/Gui/Flag.h @@ -150,6 +150,8 @@ public: void addFlag(Flag* item, FlagLayout::Position pos); void removeFlag(Flag* item); void deleteFlags(); + Flag* getFlag(int) const; + int countFlags() const; void paintGL();