myPreviewPrs( 0 ),
myPointType( HYDROGUI_PrsImage::None )
{
- setName( theIsEdit ? tr( "EDIT_IMAGE" ) : tr( "IMPORT_IMAGE" ) );
+ setName( theIsEdit ? tr( "EDIT_IMPORTED_IMAGE" ) : tr( "IMPORT_IMAGE" ) );
}
HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
+#include <HYDROData_Image.h>
+
#include <GraphicsView_ViewFrame.h>
#include <GraphicsView_ViewManager.h>
#include <GraphicsView_ViewPort.h>
bool anIsHiddenInSelection = false;
bool anIsImage = false;
+ bool anIsCompositeImage = false;
bool anIsPolyline = false;
bool anIsVisualState = false;
anIsHiddenInSelection |= !aVisibility;
if( anObject->GetKind() == KIND_IMAGE )
+ {
anIsImage = true;
+ Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
+ if( !anImage.IsNull() )
+ anIsCompositeImage = anImage->NbReferences() > 0;
+ }
else if( anObject->GetKind() == KIND_POLYLINE )
anIsPolyline = true;
else if( anObject->GetKind() == KIND_VISUAL_STATE )
{
if( anIsImage )
{
- theMenu->addAction( action( EditImageId ) );
+ theMenu->addAction( action( anIsCompositeImage ? EditCompositeImageId : EditImportedImageId ) );
theMenu->addAction( action( ObserveImageId ) );
theMenu->addAction( action( ExportImageId ) );
theMenu->addSeparator();
if( !anObject.IsNull() )
anObjName = anObject->GetName();
- myObjName->setText( anObjName );
+ SetName( anObjName );
+}
+
+void HYDROGUI_ObjSelector::SetName( const QString& theName )
+{
+ myObjName->setText( theName );
}
QString HYDROGUI_ObjSelector::GetName() const
void Clear();
+ void SetName( const QString& );
QString GetName() const;
protected:
createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
- createAction( EditImageId, "EDIT_IMAGE" );
+ createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE" );
+ createAction( EditCompositeImageId, "EDIT_COMPOSITE_IMAGE" );
createAction( ObserveImageId, "OBSERVE_IMAGE" );
createAction( ExportImageId, "EXPORT_IMAGE" );
createAction( CreatePolylineId, "CREATE_POLYLINE" );
anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
break;
case ImportImageId:
- case EditImageId:
- anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId );
+ case EditImportedImageId:
+ anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
break;
case ObserveImageId:
anOp = new HYDROGUI_ObserveImageOp( aModule );
case CutId:
anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut );
break;
+ case EditCompositeImageId:
+ anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Edit );
+ break;
case DeleteId:
anOp = new HYDROGUI_DeleteOp( aModule );
break;
UndoId,
RedoId,
ImportImageId,
- EditImageId,
+ EditImportedImageId,
+ EditCompositeImageId,
ObserveImageId,
ExportImageId,
CreatePolylineId,
return myImageName->text();
}
+void HYDROGUI_TwoImagesDlg::setSelectedImages( const QString& theName1,
+ const QString& theName2 )
+{
+ myImage1->SetName( theName1 );
+ myImage2->SetName( theName2 );
+}
+
bool HYDROGUI_TwoImagesDlg::getSelectedImages( QString& theName1,
QString& theName2 ) const
{
void setImageName( const QString& theName );
QString getImageName() const;
+ void setSelectedImages( const QString& theName1,
+ const QString& theName2 );
bool getSelectedImages( QString& theName1,
QString& theName2 ) const;
HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType )
: HYDROGUI_Operation( theModule ),
- myType( theType )
+ myType( theType ),
+ myIsEdit( false ),
+ myEditedObject( 0 )
{
+ if( myType == Edit )
+ {
+ myIsEdit = true;
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !myEditedObject.IsNull() )
+ {
+ if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
+ {
+ if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
+ {
+ if( dynamic_cast<ImageComposer_FuseOperator*>( anOperator ) )
+ myType = Fuse;
+ else if( dynamic_cast<ImageComposer_CutOperator*>( anOperator ) )
+ myType = Cut;
+ }
+ }
+ }
+ }
+
QString aName;
switch( myType )
{
HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel();
aPanel->reset();
- QString anImageName = HYDROGUI_Tool::GenerateObjectName( module(), getName() );
+ QString anImageName;
+ if( myIsEdit )
+ {
+ if( !myEditedObject.IsNull() )
+ anImageName = myEditedObject->GetName();
+ }
+ else
+ anImageName = HYDROGUI_Tool::GenerateObjectName( module(), getName() );
aPanel->setImageName( anImageName );
+
+ QString aSelectedName1, aSelectedName2;
+ if( myIsEdit && !myEditedObject.IsNull() )
+ {
+ if( myEditedObject->NbReferences() > 0 )
+ {
+ Handle(HYDROData_Image) anImage1 = myEditedObject->Reference( 0 );
+ if( !anImage1.IsNull() )
+ aSelectedName1 = anImage1->GetName();
+ }
+ if( myEditedObject->NbReferences() > 1 )
+ {
+ Handle(HYDROData_Image) anImage2 = myEditedObject->Reference( 1 );
+ if( !anImage2.IsNull() )
+ aSelectedName2 = anImage2->GetName();
+ }
+ aPanel->setSelectedImages( aSelectedName1, aSelectedName2 );
+ }
}
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
if( !aPanel->getSelectedImages( aSelectedName1, aSelectedName2 ) )
return false;
- // check that there are no other objects with the same name in the document
- Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
- if( !anObject.IsNull() )
+ if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
{
- theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
- return false;
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
+ if( !anObject.IsNull() )
+ {
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
+ return false;
+ }
}
Handle(HYDROData_Image) anImage1 = Handle(HYDROData_Image)::DownCast(
return false;
HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
- ImageComposer_Operator* anOperator = 0;
- switch( myType )
+ Handle(HYDROData_Image) aResult = 0;
+ if( myIsEdit )
{
- case Fuse: anOperator = new ImageComposer_FuseOperator(); break;
- case Cut: anOperator = new ImageComposer_CutOperator(); break;
- default: break;
+ aResult = myEditedObject;
+ aResult->ClearReferences();
+ }
+ else
+ {
+ ImageComposer_Operator* anOperator = 0;
+ switch( myType )
+ {
+ case Fuse: anOperator = new ImageComposer_FuseOperator(); break;
+ case Cut: anOperator = new ImageComposer_CutOperator(); break;
+ default: break;
+ }
+
+ if( !anOperator )
+ return false;
+
+ aResult = aFactory->CreateImage( doc(), anOperator );
}
- if( !anOperator )
- return false;
-
- Handle(HYDROData_Image) aResult = aFactory->CreateImage( doc(), anOperator );
if( aResult.IsNull() )
return false;
anImage2->SetVisible( aViewId, false );
aResult->SetVisible( aViewId, true );
- theUpdateFlags = UF_Model | UF_Viewer;
+ theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
return true;
}
#include "HYDROGUI_Operation.h"
+#include <HYDROData_Image.h>
+
class HYDROGUI_TwoImagesOp : public HYDROGUI_Operation
{
Q_OBJECT
public:
- enum OperationType { Fuse, Cut };
+ enum OperationType { Fuse, Cut, Edit };
public:
HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType );
virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
private:
- int myType;
+ int myType;
+ bool myIsEdit;
+ Handle(HYDROData_Image) myEditedObject;
};
#endif