diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index c47e628f8..895d4ec4e 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -85,6 +85,14 @@ void MDIView::deleteSelf() delete this; } +void MDIView::setOverrideCursor(const QCursor& c) +{ +} + +void MDIView::restoreOverrideCursor() +{ +} + void MDIView::onRelabel(Gui::Document *pDoc) { if (!bIsPassive) { diff --git a/src/Gui/MDIView.h b/src/Gui/MDIView.h index e96f7e172..3a787b5fa 100644 --- a/src/Gui/MDIView.h +++ b/src/Gui/MDIView.h @@ -77,7 +77,10 @@ public: /** @name Printing */ //@{ public Q_SLOTS: + virtual void setOverrideCursor(const QCursor&); + virtual void restoreOverrideCursor(); virtual void print(QPrinter* printer); + public: /** Print content of view */ virtual void print(); diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index ad67904fd..a42da3a64 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -465,32 +465,30 @@ bool SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectN if (DocName != "") rmvPreselect(); - if(ActiveGate) - { + if (ActiveGate) { App::Document* pDoc = getDocument(pDocName); - if (pDoc) { - if(pObjectName){ + if (pObjectName) { App::DocumentObject* pObject = pDoc->getObject(pObjectName); - if(! ActiveGate->allow(pDoc,pObject,pSubName)){ + if (!ActiveGate->allow(pDoc,pObject,pSubName)) { snprintf(buf,512,"Not allowed: %s.%s.%s ",pDocName ,pObjectName ,pSubName ); - if (getMainWindow()){ + if (getMainWindow()) { getMainWindow()->showMessage(QString::fromAscii(buf),3000); Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView(); - if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) { - static_cast(mdi)->setCursor(Qt::ForbiddenCursor); - } + mdi->setOverrideCursor(QCursor(Qt::ForbiddenCursor)); } return false; } - }else + } + else return ActiveGate->allow(pDoc,0,0); - }else + } + else return false; } @@ -520,13 +518,13 @@ bool SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectN ,Chng.pSubName ,x,y,z); - if (getMainWindow()){ - getMainWindow()->showMessage(QString::fromAscii(buf),3000); - Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView(); - if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) { - static_cast(mdi)->setCursor(Qt::ArrowCursor); - } - } + //FIXME: We shouldn't replace the possibly defined edit cursor + //with the arrow cursor. But it seems that we don't even have to. + //if (getMainWindow()){ + // getMainWindow()->showMessage(QString::fromAscii(buf),3000); + // Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView(); + // mdi->restoreOverrideCursor(); + //} Notify(Chng); signalSelectionChanged(Chng); @@ -587,11 +585,9 @@ void SelectionSingleton::rmvPreselect() hy = 0; hz = 0; - if (getMainWindow()){ + if (ActiveGate && getMainWindow()) { Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView(); - if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) { - static_cast(mdi)->setCursor(Qt::ArrowCursor); - } + mdi->restoreOverrideCursor(); } //Base::Console().Log("Sel : Rmv preselect \n"); @@ -605,7 +601,7 @@ const SelectionChanges &SelectionSingleton::getPreselection(void) const // add a SelectionGate to control what is selectable void SelectionSingleton::addSelectionGate(Gui::SelectionGate *gate) { - if(ActiveGate) + if (ActiveGate) rmvSelectionGate(); ActiveGate = gate; @@ -621,9 +617,7 @@ void SelectionSingleton::rmvSelectionGate(void) Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (doc) { Gui::MDIView* mdi = doc->getActiveView(); - if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) { - static_cast(mdi)->setCursor(Qt::ArrowCursor); - } + mdi->restoreOverrideCursor(); } } } @@ -654,15 +648,12 @@ bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectN temp.pObject = 0; // check for a Selection Gate - if(ActiveGate) - { - if(! ActiveGate->allow(temp.pDoc,temp.pObject,pSubName)){ - if (getMainWindow()){ + if (ActiveGate) { + if (!ActiveGate->allow(temp.pDoc,temp.pObject,pSubName)) { + if (getMainWindow()) { getMainWindow()->showMessage(QString::fromAscii("Selection not allowed by filter"),5000); Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView(); - if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) { - static_cast(mdi)->setCursor(Qt::ForbiddenCursor); - } + mdi->setOverrideCursor(Qt::ForbiddenCursor); } QApplication::beep(); return false; diff --git a/src/Gui/SplitView3DInventor.cpp b/src/Gui/SplitView3DInventor.cpp index 5ea8d3fa0..102cb781e 100644 --- a/src/Gui/SplitView3DInventor.cpp +++ b/src/Gui/SplitView3DInventor.cpp @@ -354,7 +354,7 @@ bool AbstractSplitView::onHasMsg(const char* pMsg) const return false; } -void AbstractSplitView::setCursor(const QCursor& aCursor) +void AbstractSplitView::setOverrideCursor(const QCursor& aCursor) { //_viewer->getWidget()->setCursor(aCursor); } diff --git a/src/Gui/SplitView3DInventor.h b/src/Gui/SplitView3DInventor.h index de7254ec4..2131f93a1 100644 --- a/src/Gui/SplitView3DInventor.h +++ b/src/Gui/SplitView3DInventor.h @@ -54,7 +54,7 @@ public: View3DInventorViewer *getViewer(unsigned int) const; - void setCursor(const QCursor&); + void setOverrideCursor(const QCursor&); protected: void setupSettings(); diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 6c9c207f4..1b2b934ca 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -789,14 +789,14 @@ void View3DInventor::removeOverlayWidget() if (overlay) stack->removeWidget(overlay); } -void View3DInventor::setCursor(const QCursor& aCursor) +void View3DInventor::setOverrideCursor(const QCursor& aCursor) { _viewer->getWidget()->setCursor(aCursor); } -void View3DInventor::setCursor(Qt::CursorShape aCursor) +void View3DInventor::restoreOverrideCursor() { - _viewer->getWidget()->setCursor(aCursor); + _viewer->getWidget()->setCursor(QCursor(Qt::ArrowCursor)); } void View3DInventor::dump(const char* filename) diff --git a/src/Gui/View3DInventor.h b/src/Gui/View3DInventor.h index cfc1f9253..e6aba94f2 100644 --- a/src/Gui/View3DInventor.h +++ b/src/Gui/View3DInventor.h @@ -107,8 +107,8 @@ public: public Q_SLOTS: /// override the cursor in this view - void setCursor(const QCursor&); - void setCursor(Qt::CursorShape s); + void setOverrideCursor(const QCursor&); + void restoreOverrideCursor(); void dump(const char* filename); diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index cc83bdaa0..1bc39d291 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -1046,7 +1046,7 @@ void CmdMeshRemoveCompByHand::activated(int iMsg) if (view) { Gui::View3DInventorViewer* viewer = view->getViewer(); viewer->setEditing(true); - //viewer->setEditingCursor(QCursor(Gui::BitmapFactory().pixmap("mesh_pipette"),4,29)); + viewer->setEditingCursor(QCursor(Qt::OpenHandCursor)); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::markPartCallback); } }