From 87ec03822dde901d88878980cb7d9e7cc2b1b6db Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 15 May 2015 17:52:37 +0300 Subject: [PATCH] refs #514: use specific cursors for edition operations. --- src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 3 ++ src/HYDROGUI/HYDROGUI_Module.cxx | 9 ++++ src/HYDROGUI/HYDROGUI_Module.h | 16 ++++--- src/HYDROGUI/HYDROGUI_Operation.cxx | 51 ++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_Operation.h | 13 ++++++ src/HYDROGUI/HYDROGUI_PolylineOp.cxx | 6 +++ src/HYDROGUI/HYDROGUI_PrsImage.cxx | 10 +++++ src/HYDROGUI/HYDROGUI_PrsImage.h | 6 +++ src/HYDROGUI/resources/icon_cursor_10.png | Bin 141 -> 174 bytes src/HYDROGUI/resources/icon_cursor_11.png | Bin 145 -> 161 bytes src/HYDROGUI/resources/icon_cursor_12.png | Bin 161 -> 155 bytes src/HYDROGUI/resources/icon_cursor_13.png | Bin 161 -> 159 bytes src/HYDROGUI/resources/icon_cursor_14.png | Bin 174 -> 199 bytes src/HYDROGUI/resources/icon_cursor_15.png | Bin 161 -> 191 bytes src/HYDROGUI/resources/icon_cursor_16.png | Bin 155 -> 201 bytes src/HYDROGUI/resources/icon_cursor_4.png | Bin 124 -> 172 bytes src/HYDROGUI/resources/icon_cursor_5.png | Bin 172 -> 124 bytes src/HYDROGUI/resources/icon_cursor_6.png | Bin 201 -> 141 bytes src/HYDROGUI/resources/icon_cursor_7.png | Bin 199 -> 145 bytes src/HYDROGUI/resources/icon_cursor_8.png | Bin 159 -> 161 bytes src/HYDROGUI/resources/icon_cursor_9.png | Bin 191 -> 161 bytes 21 files changed, 109 insertions(+), 5 deletions(-) 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 1edbab27a5b05555aaf515931f69ad6bf7e417f0..69f13eb347a6c299e06844729a14f657b282fe8f 100644 GIT binary patch delta 111 zcmV-#0FeKU0j>d%Mrcz>L_t&tTVr6r09*?ov}Oi`UK$0an5Kp`fa%asFs;GppaG(n zFgi$qgr_h%hyf+ILKq!HfhKT<0zm?ThKa+}!Sun+ftd@l2WBta9WZxc1pwQ06~n6M RPFMf{002ovPDHLkV1il~D+d4o delta 78 zcmZ3-*vmM<&E3e;#W92qnReGaqIj%zl`A;O+wf09FSS1(de8PXGV_07*qoM6N<$ Ef|9f$NdN!< delta 82 zcmZ3;IFWIJo41*#i(?2!baKK1kqiTag2orBJUltPJUl+Z5)u*O3`dHIt;*U!3eBO)+61E2R9QPg0@HwW0s{k6 y7?6%&VBic5Wep8O@L}?B^)UUU+6#9t7ytmQP!qP-+^XpS0000}i(?4K%;W?Gp0Kr943~qQ6}M=d#Wzp$P!q C+ac@# diff --git a/src/HYDROGUI/resources/icon_cursor_13.png b/src/HYDROGUI/resources/icon_cursor_13.png index 3b127a05d34b48a2f4f9b9cc77b681c6b43afcdd..d2004aefa7337edc3e15327992e1d69fda5b1831 100644 GIT binary patch delta 122 zcmZ3;IG=HXPVxW${}~t<`o0`~1Ed&Bg8YIR9G=}s19DtET^vI=qLUL61QHt>d^Bu( zBdQpu^kp?%m?){>l^m5KHG_NUaz9>P=8LNq3d|DjP2=M2byz03tW9mfh1FrY2fP+D ZFqmJH3RRtZQvzrngQu&X%Q~loCIGo?D~tdD delta 124 zcmbQwxR7yzPALNe!~g&P>)!YK16hnEL4Lsu4$p3+0Xc4-E{-7_*OL&an+c zF$e@uyC55cd7KSgiLfT#p8-#2r$ELH37ZAy3l2 zRVy;~+3Ahv*0o>O)?^Y~Z1pSo4O-O$dXX1A8^0%VI>pG`>>SD7{3HMRnGc0GBozNI RbI$+(002ovPDHLkV1k8-NMHZ} delta 138 zcmX@kxQ=mxPCWwy!~g&P>)!YK16hnEL4Lsu4$p3+0Xe~*E{-7_(a8x17-F~;wxqGO z#7VI(o3X6TwBhB20E4v$Uo2o;G~K|;qp@YVfmH{i>JBFfS(iq&f;J{crlz*e!&eS| qIe4~lCiiCcH2piW2IYyY47W=}53hRe7XdV$!PC{xWgW9qLK6TaNiL59RLGuTpf8VsdEq+OT~Tw87C;38om{D5bL fNHFu^21W*zFYM`U1 diff --git a/src/HYDROGUI/resources/icon_cursor_16.png b/src/HYDROGUI/resources/icon_cursor_16.png index a5667e3ffba185fd0138ddfca3d4d88049928812..53717e49928a5d0e791baf971e95adc0bbe318d2 100644 GIT binary patch delta 174 zcmbQuc#=`EGr-TCmrII^fq{Y7)59eQNGpIa6El$H6Pc7gQBk!%&(p;*q#|zZ*^Rud z1_I0h%XjkDF3vF`+N>(k1pKDP9};ZZm}Y>*Z+Nd*Z+wk#OCCyX23TBHJ~~ zj+HqbYMX_h-%pg?RJc{@(!tK01IGemMY(6N*D33seKujWu;)_+hIbY}j{c}Nx&NGP Z%?`PbZ%a*jfG%M0boFy#S?83{1OOgCKz9HD delta 127 zcmX@fIGa(iGr-TCmrII^fq{Y7)59eQNK1k+6El$9*`E7hqM~Z3gQtsQ2*=Figa&3k zJ&v`fZaHwBU3lsi%c83xk=Bk(mm5l$n3;nmCiEpFJmBF?<>ht$koc+KtHIwTx46so bB^Vgi1PE`terMH7pqUJwu6{1-oD!M<@+>J) diff --git a/src/HYDROGUI/resources/icon_cursor_4.png b/src/HYDROGUI/resources/icon_cursor_4.png index 097fc5fa7287da71ffd907b3a11adbda4516aca6..69056c479e9b2f009e366dfd71999a7c74f97620 100644 GIT binary patch delta 135 zcmb5y%4-ykMUxU_hGdL-cxg)G8h^NCl#bkVRosz#nSQXf~vsh nWs7Dp8=LFuvd*s#U}RW+M)u44NNx$B;S8RxelF{r5*V8RQY|x| delta 86 zcmZ3(STjKb%7 diff --git a/src/HYDROGUI/resources/icon_cursor_5.png b/src/HYDROGUI/resources/icon_cursor_5.png index 69056c479e9b2f009e366dfd71999a7c74f97620..097fc5fa7287da71ffd907b3a11adbda4516aca6 100644 GIT binary patch delta 86 zcmZ3(STjKb%7 delta 135 zcmb5y%4-ykMUxU_hGdL-cxg)G8h^NCl#bkVRosz#nSQXf~vsh nWs7Dp8=LFuvd*s#U}RW+M)u44NNx$B;S8RxelF{r5*V8RQY|x| diff --git a/src/HYDROGUI/resources/icon_cursor_6.png b/src/HYDROGUI/resources/icon_cursor_6.png index 53717e49928a5d0e791baf971e95adc0bbe318d2..1edbab27a5b05555aaf515931f69ad6bf7e417f0 100644 GIT binary patch delta 113 zcmX@f*vqKc8Q|y6%O%Cdz`(%k>ERLtq$NR^i5W=lY|s5LQBl?1$kW9!gd;jR;Q)h= zwt`8xNXs>zY=+C;&f*O(S1#lf=w#q<&6P^CJ7YKFufg{NciNd4On&kPmrb1U4rmI4 Mr>mdKI;Vst0Apz(#sB~S delta 174 zcmeBWJjtlo8Q|y6%O%Cdz`(%k>ERLtq!mDzi5W=piA+kLsHj?>=jq}YQW3ZI>_*;J z0|DlMr6t4|^w;96y^>Q@sJ#pZTNVx96UGm3Ek?opg z$I6@zwavoM?h{>0oEhfn$NOqTDms>y&lRKAW&w*z>6Z!#j%~M}JhC+<(rt ZW{2Fzx1}aMKo>B0y85}WtaD0e0ss`dKxqH~ diff --git a/src/HYDROGUI/resources/icon_cursor_7.png b/src/HYDROGUI/resources/icon_cursor_7.png index 2b08c4e2a3cafc992459a8f484e6c8e6c3e74857..a9f40cbc3d77c566c11c32c0631b4f94f44dd441 100644 GIT binary patch delta 108 zcmX@kIFWIJPAUTf!~g&P>)!YK16hnEL4Lsu4$p3+0Xb%#E{-7_(a8x5L^2Ev3L0Oi z^6=#F^6>ZsOGreBGaPklC}Cq}PS+4{QOKBK;UnuKe@EsM1H)xyF8x`DEzN-@FnGH9 KxvX&an+c zF$e@uyC55cd7KSgiLfT#p8-#2r$ELH37ZAy3l2 zRVy;~+3Ahv*0o>O)?^Y~Z1pSo4O-O$dXX1A8^0%VI>pG`>>SD7{3HMRnGc0GBozNI RbI$+(002ovPDHLkV1jcJNJ9Vs diff --git a/src/HYDROGUI/resources/icon_cursor_8.png b/src/HYDROGUI/resources/icon_cursor_8.png index d2004aefa7337edc3e15327992e1d69fda5b1831..f37d7b91e8cde73243fa78df45c7808aba1c5fa0 100644 GIT binary patch delta 124 zcmbQwxR7yzPALNe!~g&P>)!YK16hnEL4Lsu4$p3+0Xc4-E{-7_Gm{e(c*53ZF}@b?;B+~kP|DElC)_&2%9O>6-QgvNhU~G1BbP0l+XkK;`b{A delta 122 zcmZ3;IG=HXPVxW${}~t<`o0`~1Ed&Bg8YIR9G=}s19DtET^vI=qLUL61QHt>d^Bu( zBdQpu^kp?%m?){>l^m5KHG_NUaz9>P=8LNq3d|DjP2=M2byz03tW9mfh1FrY2fP+D ZFqmJH3RRtZQvzrngQu&X%Q~loCIGo?D~tdD diff --git a/src/HYDROGUI/resources/icon_cursor_9.png b/src/HYDROGUI/resources/icon_cursor_9.png index b47601c3780eec780fdae43bab7481bbfebdddae..3b127a05d34b48a2f4f9b9cc77b681c6b43afcdd 100644 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~)3?z59=Y9ZEoB=)|uK)l42QqD?iBlbDB7>)^pUXO@geCxo C3NS_h literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnH3?%tPCZz)@&H$ef*Z*JuL59RLGuTpf8VsdEq+OT~Tw87C;38om{D5bL fNHFu^21W*zFY