#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_MessageBox.h>
-
HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule ),
myActiveViewManager( 0 ),
return aPanel;
}
-void HYDROGUI_ImportImageOp::onApply()
+bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags )
{
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
HYDROGUI_ImportImageDlg::TransformationDataMap aMap;
bool anIsOk = aPanel->getTransformationDataMap( aMap );
if( !anIsOk || !myPreviewPrs )
- {
- SUIT_MessageBox::critical( module()->getApp()->desktop(),
- tr( "INSUFFICIENT_INPUT_DATA" ),
- tr( "INPUT_VALID_DATA" ) );
- return;
- }
+ return false;
double xa1 = aMap[ HYDROGUI_PrsImage::PointA ].first.x();
double ya1 = aMap[ HYDROGUI_PrsImage::PointA ].first.y();
int aStudyId = module()->getStudyId();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
- if( !aDocument.IsNull() )
- {
- Handle(HYDROData_Image) anImageObj =
- Handle(HYDROData_Image)::DownCast( aDocument->CreateObject( KIND_IMAGE ) );
- if( !anImageObj.IsNull() )
- {
- static int ImageId = 0;
- anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) );
+ if( aDocument.IsNull() )
+ return false;
- anImageObj->SetImage( anImage );
- anImageObj->SetTrsf( aTransform );
+ Handle(HYDROData_Image) anImageObj =
+ Handle(HYDROData_Image)::DownCast( aDocument->CreateObject( KIND_IMAGE ) );
+ if( anImageObj.IsNull() )
+ return false;
- module()->update( UF_Model | UF_Viewer );
- }
- }
- HYDROGUI_Operation::onApply();
+ static int ImageId = 0;
+ anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) );
+
+ anImageObj->SetImage( anImage );
+ anImageObj->SetTrsf( aTransform );
+
+ theUpdateFlags = UF_Model | UF_Viewer;
+ return true;
}
-void HYDROGUI_ImportImageOp::onCancel()
+void HYDROGUI_ImportImageOp::processCancel()
{
closePreview();
- HYDROGUI_Operation::onCancel();
}
void HYDROGUI_ImportImageOp::onCreatePreview( QString theFileName )
virtual HYDROGUI_InputPanel* createInputPanel() const;
-protected slots:
- virtual void onApply();
- virtual void onCancel();
+ virtual bool processApply( int& theUpdateFlags );
+ virtual void processCancel();
+protected slots:
void onCreatePreview( QString );
void onActivatePointSelection( int );
void onPointSelected();
//
#include "HYDROGUI_ObjSelector.h"
+
+#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
#include <GraphicsView_Object.h>
+
#include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
#include <LightApp_GVSelector.h>
#include <LightApp_SelectionMgr.h>
void HYDROGUI_ObjSelector::OnSelectionChanged()
{
- /* ouv: to do
if( !myBtn->isChecked() )
return;
SUIT_DataOwnerPtrList anOwners;
aSelMgr->selected( anOwners );
+ HYDROGUI_DataModel* aModel = myModule->getDataModel();
+
QString anObjName;
foreach( SUIT_DataOwner* anOwner, anOwners )
{
- LightApp_GVDataOwner* aGrDOwner = dynamic_cast<LightApp_GVDataOwner*>( anOwner );
+ LightApp_DataOwner* aGrDOwner = dynamic_cast<LightApp_DataOwner*>( anOwner );
if( aGrDOwner )
{
- anObjName = aGrDOwner->object()->getName();
- break;
+ QString anEntry = aGrDOwner->entry();
+ Handle(HYDROData_Object) anObject = aModel->objectByEntry( anEntry, KIND_IMAGE );
+ if( !anObject.IsNull() )
+ {
+ anObjName = anObject->GetName();
+ break;
+ }
}
}
myObjName->setText( anObjName );
- */
}
QString HYDROGUI_ObjSelector::GetName() const
#include <LightApp_SelectionMgr.h>
#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
#include <SUIT_Study.h>
HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule )
return myName;
}
+HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const
+{
+ if( !myPanel )
+ {
+ ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel();
+ connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) );
+ connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) );
+ }
+ return myPanel;
+}
+
SUIT_SelectionMgr* HYDROGUI_Operation::selectionMgr() const
{
return myModule->getApp()->selectionMgr();
inputPanel()->hide();
}
-HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const
-{
- if( !myPanel )
- {
- ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel();
- connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) );
- connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) );
- }
- return myPanel;
-}
-
-Handle_HYDROData_Document HYDROGUI_Operation::doc() const
+bool HYDROGUI_Operation::processApply( int& theUpdateFlags )
{
- int aStudyId = myModule->application()->activeStudy()->id();
- return HYDROData_Document::Document( aStudyId );
+ return false;
}
-void HYDROGUI_Operation::onApply()
+void HYDROGUI_Operation::processCancel()
{
- commit();
}
-void HYDROGUI_Operation::onCancel()
+Handle_HYDROData_Document HYDROGUI_Operation::doc() const
{
- abort();
+ int aStudyId = myModule->application()->activeStudy()->id();
+ return HYDROData_Document::Document( aStudyId );
}
Handle_HYDROData_Object HYDROGUI_Operation::FindObjectByName( const QString& theName, int theKind ) const
}
return Handle_HYDROData_Object();
}
+
+void HYDROGUI_Operation::onApply()
+{
+ int anUpdateFlags = 0;
+ if( processApply( anUpdateFlags ) )
+ {
+ module()->update( anUpdateFlags );
+ commit();
+ }
+ else
+ {
+ SUIT_MessageBox::critical( module()->getApp()->desktop(),
+ tr( "INSUFFICIENT_INPUT_DATA" ),
+ tr( "INPUT_VALID_DATA" ) );
+ }
+}
+
+void HYDROGUI_Operation::onCancel()
+{
+ processCancel();
+ abort();
+}
virtual HYDROGUI_InputPanel* createInputPanel() const = 0;
+ virtual bool processApply( int& theUpdateFlags );
+ virtual void processCancel();
+
Handle_HYDROData_Document doc() const;
Handle_HYDROData_Object FindObjectByName( const QString& theName, int theKind ) const;
{
}
+QString HYDROGUI_TwoImagesDlg::GetName() const
+{
+ return myName->text();
+}
+
void HYDROGUI_TwoImagesDlg::GetSelectedImages( QString& theName1, QString& theName2 ) const
{
theName1 = myImage1->GetName();
class HYDROGUI_TwoImagesDlg : public HYDROGUI_InputPanel
{
+ Q_OBJECT
+
public:
HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_TwoImagesDlg();
+ QString GetName() const;
void GetSelectedImages( QString& theEntry1, QString& theEntry2 ) const;
private:
#include "HYDROGUI_TwoImagesOp.h"
+#include "HYDROGUI_Module.h"
#include "HYDROGUI_TwoImagesDlg.h"
+#include "HYDROGUI_UpdateFlags.h"
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROOperations_Factory.h>
+#include <ImageComposer_CutOperator.h>
+#include <ImageComposer_FuseOperator.h>
+
HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType )
: HYDROGUI_Operation( theModule ),
myType( theType )
{
case Fuse: aName = tr( "FUSE" ); break;
case Cut: aName = tr( "CUT" ); break;
+ default: break;
}
setName( aName );
}
return new HYDROGUI_TwoImagesDlg( module(), getName() );
}
-void HYDROGUI_TwoImagesOp::onApply()
+bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags )
{
HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
+
+ QString aNewName = aPanel->GetName();
+
QString aName1, aName2;
aPanel->GetSelectedImages( aName1, aName2 );
- Handle_HYDROData_Image anImage1 = Handle_HYDROData_Image::DownCast(
+ if( aNewName.isEmpty() || aName1.isEmpty() || aName2.isEmpty() )
+ return false;
+
+ Handle(HYDROData_Image) anImage1 = Handle(HYDROData_Image)::DownCast(
FindObjectByName( aName1, KIND_IMAGE ) );
- Handle_HYDROData_Image anImage2 = Handle_HYDROData_Image::DownCast(
+ Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast(
FindObjectByName( aName2, KIND_IMAGE ) );
+ if( anImage1.IsNull() || anImage2.IsNull() )
+ return false;
HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
- ImageComposer_Operator* anOperator = 0; //TODO
+ 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;
Handle(HYDROData_Image) aResult = aFactory->CreateImage( doc(), anOperator );
+ if( aResult.IsNull() )
+ return false;
+
+ aResult->SetName( aNewName );
aResult->AppendReference( anImage1 );
aResult->AppendReference( anImage2 );
aFactory->UpdateImage( doc(), aResult );
+
+ theUpdateFlags = UF_Model | UF_Viewer;
+ return true;
}
protected:
virtual HYDROGUI_InputPanel* createInputPanel() const;
-protected slots:
- virtual void onApply();
+ virtual bool processApply( int& theUpdateFlags );
private:
int myType;
<translation>Undo</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_TwoImagesDlg</name>
+ <message>
+ <source>BACKGROUND</source>
+ <translation>Background</translation>
+ </message>
+ <message>
+ <source>COLOR</source>
+ <translation>Color</translation>
+ </message>
+ <message>
+ <source>IMAGE_1</source>
+ <translation>Image 1</translation>
+ </message>
+ <message>
+ <source>IMAGE_2</source>
+ <translation>Image 2</translation>
+ </message>
+ <message>
+ <source>NAME</source>
+ <translation>Name</translation>
+ </message>
+ <message>
+ <source>TRANSPARENT</source>
+ <translation>Transparent</translation>
+ </message>
+ </context>
<context>
<name>HYDROGUI_TwoImagesOp</name>
<message>