+ QString aSelectedName1, aSelectedName2;
+ if( !aPanel->getSelectedObjects( aSelectedName1, aSelectedName2 ) )
+ return false;
+
+ if( !anIsModifySelected &&
+ ( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) ) )
+ {
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
+ if( !anObject.IsNull() )
+ {
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
+ return false;
+ }
+ }
+
+ 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;
+
+ HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
+
+ Handle(HYDROData_Image) aResult;
+ ImageComposer_Operator* anOperator = 0;
+ if( myIsEdit )
+ {
+ aResult = myEditedObject;
+ aResult->ClearReferences();
+ anOperator = aFactory->Operator( aResult );
+ }
+ else
+ {
+ QString anOperatorName;
+ switch( myType )
+ {
+ case Fuse: anOperatorName = ImageComposer_FuseOperator::Type(); break;
+ case Cut: anOperatorName = ImageComposer_CutOperator::Type(); break;
+ case Split: anOperatorName = ImageComposer_CropOperator::Type(); break;
+ default: break;
+ }
+
+ anOperator = aFactory->Operator( anOperatorName );
+
+ aResult = aFactory->CreateImage( doc(), anOperator );
+ }
+
+ if( aResult.IsNull() || !anOperator )
+ return false;
+
+ // Setting the operator arguments
+ anOperator->setArgs( aPanel->getColor() );
+ aResult->SetArgs( anOperator->getBinArgs() );
+
+ aResult->SetName( anImageName );
+ aResult->AppendReference( anObject1 );
+ aResult->AppendReference( anObject2 );
+
+ aResult->Update();
+
+ if( anIsModifySelected )
+ {
+ Handle(HYDROData_Image) aSelectedImage = Handle(HYDROData_Image)::DownCast( anObject1 );
+ if( !aSelectedImage.IsNull() )
+ {
+ aSelectedImage->SetIsSelfSplitted( true );
+ aSelectedImage->SetImage( aResult->Image() );
+ aSelectedImage->SetTrsf( aResult->Trsf() );
+ aResult->Remove();
+ }
+ }
+
+ if( !myIsEdit && !anIsModifySelected )
+ {
+ size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+ module()->setObjectVisible( aViewId, anObject1, false );
+ module()->setObjectVisible( aViewId, anObject2, false );
+ module()->setObjectVisible( aViewId, aResult, true );
+ }