+ check returned mdi view to be of the requested type
This commit is contained in:
@@ -1287,19 +1287,6 @@ Gui::MDIView* Document::getEditingViewOfViewProvider(Gui::ViewProvider* vp) cons
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::list<MDIView*> Document::getViewsOfViewProvider(Gui::ViewProvider* vp) const
|
||||
{
|
||||
std::list<MDIView*> views;
|
||||
std::list<MDIView*> mdis = getMDIViewsOfType(View3DInventor::getClassTypeId());
|
||||
for (std::list<MDIView*>::const_iterator it = mdis.begin(); it != mdis.end(); ++it) {
|
||||
View3DInventor* view = static_cast<View3DInventor*>(*it);
|
||||
if (view->getViewer()->hasViewProvider(vp))
|
||||
views.push_back(*it);
|
||||
}
|
||||
|
||||
return views;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// UNDO REDO transaction handling
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -150,7 +150,6 @@ public:
|
||||
Gui::MDIView* getActiveView(void) const;
|
||||
Gui::MDIView* getEditingViewOfViewProvider(Gui::ViewProvider*) const;
|
||||
Gui::MDIView* getViewOfViewProvider(Gui::ViewProvider*) const;
|
||||
std::list<MDIView*> getViewsOfViewProvider(Gui::ViewProvider*) const;
|
||||
/// Create a new view
|
||||
void createView(const Base::Type& typeId);
|
||||
/** send messages to the active view
|
||||
|
||||
@@ -161,20 +161,7 @@ Gui::MDIView* ViewProviderDocumentObject::getActiveView() const
|
||||
{
|
||||
App::Document* pAppDoc = pcObject->getDocument();
|
||||
Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc);
|
||||
|
||||
MDIView* active = getMainWindow()->activeWindow();
|
||||
std::list<MDIView*> views = pGuiDoc->getViewsOfViewProvider(const_cast<ViewProviderDocumentObject*>(this));
|
||||
|
||||
// is the active window a 3d view and does it contain this view provider
|
||||
std::list<MDIView*>::iterator it = std::find(views.begin(), views.end(), active);
|
||||
if (it != views.end())
|
||||
return *it;
|
||||
// if there is a 3d view containing this view provider return the first one
|
||||
else if (!views.empty())
|
||||
return views.front();
|
||||
// no 3d view found containing this view provider
|
||||
else
|
||||
return 0;
|
||||
return pGuiDoc->getActiveView();
|
||||
}
|
||||
|
||||
Gui::MDIView* ViewProviderDocumentObject::getEditingView() const
|
||||
@@ -184,6 +171,19 @@ Gui::MDIView* ViewProviderDocumentObject::getEditingView() const
|
||||
return pGuiDoc->getEditingViewOfViewProvider(const_cast<ViewProviderDocumentObject*>(this));
|
||||
}
|
||||
|
||||
Gui::MDIView* ViewProviderDocumentObject::getInventorView() const
|
||||
{
|
||||
App::Document* pAppDoc = pcObject->getDocument();
|
||||
Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc);
|
||||
|
||||
Gui::MDIView* mdi = pGuiDoc->getEditingViewOfViewProvider(const_cast<ViewProviderDocumentObject*>(this));
|
||||
if (!mdi) {
|
||||
mdi = pGuiDoc->getViewOfViewProvider(const_cast<ViewProviderDocumentObject*>(this));
|
||||
}
|
||||
|
||||
return mdi;
|
||||
}
|
||||
|
||||
SoNode* ViewProviderDocumentObject::findFrontRootOfType(const SoType& type) const
|
||||
{
|
||||
// first get the document this object is part of and get its GUI counterpart
|
||||
|
||||
@@ -90,10 +90,24 @@ public:
|
||||
//@}
|
||||
|
||||
protected:
|
||||
/// Get the active mdi view of a view provider
|
||||
/*! Get the active mdi view of the document this view provider is part of.
|
||||
@note The returned mdi view doesn't need to be a 3d view but can be e.g.
|
||||
an image view, an SVG view or something else.
|
||||
*/
|
||||
Gui::MDIView* getActiveView() const;
|
||||
/// Get the editing mdi view of a view provider in edit mode
|
||||
/*! Get the mdi view of the document this view provider is part of and
|
||||
that is in editing mode.
|
||||
@note In case there is no mdi view in editing mode 0 is returned.
|
||||
If a value different to 0 is returned it is guaranteed to be a 3d view.
|
||||
*/
|
||||
Gui::MDIView* getEditingView() const;
|
||||
/*! Get any mdi view of the document this view provider is part of.
|
||||
In case there is an mdi view in editing mode that contains this
|
||||
view provider that mdi view is returned. Otherwise any other
|
||||
3d view that contains this view provider is returned.
|
||||
If a value different to 0 is returned it is guaranteed to be a 3d view.
|
||||
*/
|
||||
Gui::MDIView* getInventorView() const;
|
||||
/// Gets called by the container whenever a property has been changed
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
/** Searches in all view providers that are attached to an object that
|
||||
|
||||
Reference in New Issue
Block a user