X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_TwoImagesOp.cxx;h=885fff83946e677c3a371990824e165b701c1c49;hb=a1431f03eac1d1aed4203d0568d987c41ce939b3;hp=2e634382f1ceb9087742f3afddf13f33b924bf29;hpb=d63a2e4caa93023bac64aef525cc4f597bc72512;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index 2e634382..885fff83 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -29,14 +29,17 @@ #include #include -#include -#include +#include #include #include #include +#include +#include +#include + HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType, const bool theIsEdit ) @@ -103,19 +106,19 @@ void HYDROGUI_TwoImagesOp::startOperation() { if( myEditedObject->NbReferences() > 0 ) { - Handle(HYDROData_Object) anObject1 = myEditedObject->Reference( 0 ); + Handle(HYDROData_Entity) anObject1 = myEditedObject->Reference( 0 ); if( !anObject1.IsNull() ) aSelectedName1 = anObject1->GetName(); } if( myEditedObject->NbReferences() > 1 ) { - Handle(HYDROData_Object) anObject2 = myEditedObject->Reference( 1 ); + Handle(HYDROData_Entity) anObject2 = myEditedObject->Reference( 1 ); if( !anObject2.IsNull() ) aSelectedName2 = anObject2->GetName(); } aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 ); - HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory(); + HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory(); if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) ) { QColor aColor; @@ -123,6 +126,24 @@ void HYDROGUI_TwoImagesOp::startOperation() aPanel->setColor( aColor ); } } + else if( !myIsEdit ) + { + Handle(HYDROData_Image) aSelectedImage = + Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !aSelectedImage.IsNull() ) + { + QString aSelectedName = aSelectedImage->GetName(); + aPanel->setPreselectedObject( aSelectedName ); + } + } + connect( aPanel, SIGNAL( alreadySelected( const QString& ) ), SLOT( onAlreadySelected( const QString& ) ) ); +} + +void HYDROGUI_TwoImagesOp::onAlreadySelected( const QString& theName ) +{ + QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" ); + QString aMessage = tr( "OBJECT_ALREADY_SELECTED" ).arg( theName ); + SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage ); } bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, @@ -144,7 +165,7 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, ( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) ) ) { // check that there are no other objects with the same name in the document - Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName ); + Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName ); if( !anObject.IsNull() ) { theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName ); @@ -152,14 +173,14 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, } } - Handle(HYDROData_Object) anObject1 = Handle(HYDROData_Object)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_UNKNOWN ) ); - Handle(HYDROData_Object) anObject2 = Handle(HYDROData_Object)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_UNKNOWN ) ); + Handle(HYDROData_Entity) anObject1 = + HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_UNKNOWN ) ; + Handle(HYDROData_Entity) anObject2 = + HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_UNKNOWN ); if( anObject1.IsNull() || anObject2.IsNull() ) return false; - HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory(); + HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory(); Handle(HYDROData_Image) aResult; ImageComposer_Operator* anOperator = 0; @@ -218,6 +239,6 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, module()->setObjectVisible( aViewId, aResult, true ); } - theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced; + theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced; return true; }