+void HYDROGUI_TwoImagesOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel();
+ aPanel->reset();
+
+ if( myType == Fuse || myType == Cut )
+ aPanel->setMode( HYDROGUI_TwoImagesDlg::TwoImages, myIsEdit );
+ else if( myType == Split )
+ aPanel->setMode( HYDROGUI_TwoImagesDlg::ImageAndPolyline, myIsEdit );
+
+ QString anImageName;
+ if( myIsEdit )
+ {
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !myEditedObject.IsNull() )
+ anImageName = myEditedObject->GetName();
+ }
+ else
+ {
+ QString aPrefix;
+ switch( myType )
+ {
+ case Fuse: aPrefix = tr( "FUSE" ); break;
+ case Cut: aPrefix = tr( "CUT" ); break;
+ case Split: aPrefix = tr( "SPLIT" ); break;
+ default: break;
+ }
+ anImageName = HYDROGUI_Tool::GenerateObjectName( module(), aPrefix );
+ }
+ aPanel->setImageName( anImageName );
+
+ QString aSelectedName1, aSelectedName2;
+ if( myIsEdit && !myEditedObject.IsNull() )
+ {
+ if( myEditedObject->NbReferences() > 0 )
+ {
+ Handle(HYDROData_Entity) anObject1 = myEditedObject->Reference( 0 );
+ if( !anObject1.IsNull() )
+ aSelectedName1 = anObject1->GetName();
+ }
+ if( myEditedObject->NbReferences() > 1 )
+ {
+ Handle(HYDROData_Entity) anObject2 = myEditedObject->Reference( 1 );
+ if( !anObject2.IsNull() )
+ aSelectedName2 = anObject2->GetName();
+ }
+ aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 );
+
+ HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
+ if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
+ {
+ QColor aColor;
+ anOperator->getArgs( aColor );
+ 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,
+ QString& theErrorMsg )