From: mkr Date: Fri, 15 May 2015 14:52:37 +0000 (+0300) Subject: refs #514: use specific cursors for edition operations. X-Git-Tag: v1.4.1~25^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=87ec03822dde901d88878980cb7d9e7cc2b1b6db;p=modules%2Fhydro.git refs #514: use specific cursors for edition operations. --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 6a28b637..12a71ec5 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -622,6 +622,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) } myPreviewPrs->setIsTransformationPointPreview( true ); + myPreviewPrs->setTransformationPointCursorShape( module()->getPrefEditCursor().shape() ); } connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ), this, SLOT( onPointSelected() ) ); @@ -774,6 +775,8 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) myRefPreviewPrs->setIsByTwoPoints( aPanel->isByTwoPoints() ); + myRefPreviewPrs->setTransformationPointCursorShape( module()->getPrefEditCursor().shape() ); + // Add the new reference image presentation to the appropriate view aViewPort->addItem( myRefPreviewPrs ); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index a9690cdb..c97dbd87 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -731,6 +731,15 @@ void HYDROGUI_Module::createPreferences() setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList ); } +QCursor HYDROGUI_Module::getPrefEditCursor() const +{ + int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor ); + if ( aCursorType >= Qt::BlankCursor) + aCursorType++; + QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) ); + return aCursor; +} + void HYDROGUI_Module::update( const int flags ) { if( !isUpdateEnabled() ) diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 6aa6f6da..6829fcbc 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -62,12 +62,8 @@ class HYDROGUI_Module : public LightApp_Module CT_ArrowCursor = 0, CT_UpArrowCursor, CT_CrossCursor, - CT_IBeamCursor, CT_WaitCursor, - CT_BusyCursor, - CT_ForbiddenCursor, - CT_PointingHandCursor, - CT_WhatsThisCursor, + CT_IBeamCursor, CT_SizeVerCursor, CT_SizeHorCursor, CT_SizeBDiagCursor, @@ -75,6 +71,10 @@ class HYDROGUI_Module : public LightApp_Module CT_SizeAllCursor, CT_SplitVCursor, CT_SplitHCursor, + CT_PointingHandCursor, + CT_ForbiddenCursor, + CT_WhatsThisCursor, + CT_BusyCursor, CT_OpenHandCursor, CT_ClosedHandCursor, CT_User @@ -202,6 +202,12 @@ public: QStack& getActiveOperations(); HYDROGUI_Operation* activeOperation(); + /** + * Returns the cursor defined for edition operations in module preferences. + * \return specific cursor + */ + QCursor getPrefEditCursor() const; + protected: CAM_DataModel* createDataModel(); diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 4762d58e..38281c81 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -38,6 +38,10 @@ #include #include +#include +#include +#include + #include HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule ) @@ -154,6 +158,53 @@ void HYDROGUI_Operation::setPreviewManager( OCCViewer_ViewManager* theManager ) setPreviewZLayer( module()->getOCCDisplayer()->AddPreviewZLayer( myPreviewManager ) ); } +void HYDROGUI_Operation::setCursor() +{ + if ( myPreviewManager ) + { + QVector winList = myPreviewManager->getViews(); + for ( QVector::iterator it = winList.begin(); it != winList.end(); ++it ) + { + OCCViewer_ViewWindow* occWin = ::qobject_cast( *it ); + if ( occWin ) + { + OCCViewer_ViewPort3d* vp = occWin->getViewPort(); + if ( vp ) + { + // Save old cursor + myCursor = vp->cursor(); + // Set specific cursor chosen in preferences + QCursor aCursor = module()->getPrefEditCursor(); + vp->setDefaultCursor( aCursor.shape() ); + vp->setCursor( *vp->getDefaultCursor() ); + } + } + } + } +} + +void HYDROGUI_Operation::restoreCursor() +{ + if ( myPreviewManager ) + { + QVector winList = myPreviewManager->getViews(); + for ( QVector::iterator it = winList.begin(); it != winList.end(); ++it ) + { + OCCViewer_ViewWindow* occWin = ::qobject_cast( *it ); + if ( occWin ) + { + OCCViewer_ViewPort3d* vp = occWin->getViewPort(); + if ( vp ) + { + // Restore old cursor + vp->setDefaultCursor( myCursor.shape() ); + vp->setCursor( myCursor ); + } + } + } + } +} + void HYDROGUI_Operation::startOperation() { LightApp_Operation::startOperation(); diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 74f9ca62..89f6c9d2 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -25,6 +25,8 @@ #include +#include + class HYDROGUI_Module; class HYDROGUI_InputPanel; class HYDROGUI_Shape; @@ -105,6 +107,15 @@ protected: OCCViewer_ViewManager* getPreviewManager(); void setPreviewManager( OCCViewer_ViewManager* theManager ); + /** + * Set specific cursor chosen in preferences for edition operations. + */ + virtual void setCursor(); + /** + * Restore the default cursor. + */ + virtual void restoreCursor(); + private: HYDROGUI_Module* myModule; @@ -114,6 +125,8 @@ private: bool myIsPrintErrorMessage; bool myIsTransactionOpened; int myPreviewZLayer; + + QCursor myCursor; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 61634ca7..dff33ecf 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -140,6 +140,8 @@ void HYDROGUI_PolylineOp::startOperation() aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 ); setPreviewManager( aViewManager ); + setCursor(); + QString aPolylineName; if( !myEditedObject.IsNull() ) { @@ -186,6 +188,8 @@ void HYDROGUI_PolylineOp::startOperation() void HYDROGUI_PolylineOp::abortOperation() { + restoreCursor(); + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); if ( aPanel ) aPanel->setOCCViewer( 0 ); @@ -196,6 +200,8 @@ void HYDROGUI_PolylineOp::abortOperation() void HYDROGUI_PolylineOp::commitOperation() { + restoreCursor(); + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); if ( aPanel ) aPanel->setOCCViewer( 0 ); diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index bfe34090..4ede95d7 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -161,6 +161,16 @@ void HYDROGUI_PrsImage::updateTransformationPoint( const int thePointType, } } +//================================================================ +// Function : setTransformationPointCursorShape +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setTransformationPointCursorShape(Qt::CursorShape theCursorShape) +{ + if ( myTransformationPointCursor ) + myTransformationPointCursor->setShape(theCursorShape); +} + //================================================================ // Function : boundingRect // Purpose : diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h index 674c64d3..6a7822b4 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.h +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -73,6 +73,12 @@ public: const bool theIsY, const int theValue ); + /** + * Set shape of the transformation point cursor. + * @param theCursorShape a cursor shape to be set + */ + void setTransformationPointCursorShape(Qt::CursorShape theCursorShape); + public: // from QGraphicsItem virtual QRectF boundingRect() const; diff --git a/src/HYDROGUI/resources/icon_cursor_10.png b/src/HYDROGUI/resources/icon_cursor_10.png index 1edbab27..69f13eb3 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_10.png and b/src/HYDROGUI/resources/icon_cursor_10.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_11.png b/src/HYDROGUI/resources/icon_cursor_11.png index a9f40cbc..1beda257 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_11.png and b/src/HYDROGUI/resources/icon_cursor_11.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_12.png b/src/HYDROGUI/resources/icon_cursor_12.png index f37d7b91..a5667e3f 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_12.png and b/src/HYDROGUI/resources/icon_cursor_12.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_13.png b/src/HYDROGUI/resources/icon_cursor_13.png index 3b127a05..d2004aef 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_13.png and b/src/HYDROGUI/resources/icon_cursor_13.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_14.png b/src/HYDROGUI/resources/icon_cursor_14.png index 69f13eb3..2b08c4e2 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_14.png and b/src/HYDROGUI/resources/icon_cursor_14.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_15.png b/src/HYDROGUI/resources/icon_cursor_15.png index 1beda257..b47601c3 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_15.png and b/src/HYDROGUI/resources/icon_cursor_15.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_16.png b/src/HYDROGUI/resources/icon_cursor_16.png index a5667e3f..53717e49 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_16.png and b/src/HYDROGUI/resources/icon_cursor_16.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_4.png b/src/HYDROGUI/resources/icon_cursor_4.png index 097fc5fa..69056c47 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_4.png and b/src/HYDROGUI/resources/icon_cursor_4.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_5.png b/src/HYDROGUI/resources/icon_cursor_5.png index 69056c47..097fc5fa 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_5.png and b/src/HYDROGUI/resources/icon_cursor_5.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_6.png b/src/HYDROGUI/resources/icon_cursor_6.png index 53717e49..1edbab27 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_6.png and b/src/HYDROGUI/resources/icon_cursor_6.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_7.png b/src/HYDROGUI/resources/icon_cursor_7.png index 2b08c4e2..a9f40cbc 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_7.png and b/src/HYDROGUI/resources/icon_cursor_7.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_8.png b/src/HYDROGUI/resources/icon_cursor_8.png index d2004aef..f37d7b91 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_8.png and b/src/HYDROGUI/resources/icon_cursor_8.png differ diff --git a/src/HYDROGUI/resources/icon_cursor_9.png b/src/HYDROGUI/resources/icon_cursor_9.png index b47601c3..3b127a05 100644 Binary files a/src/HYDROGUI/resources/icon_cursor_9.png and b/src/HYDROGUI/resources/icon_cursor_9.png differ