]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Image composing.
authorouv <ouv@opencascade.com>
Thu, 15 Aug 2013 13:32:40 +0000 (13:32 +0000)
committerouv <ouv@opencascade.com>
Thu, 15 Aug 2013 13:32:40 +0000 (13:32 +0000)
24 files changed:
src/HYDROGUI/HYDROGUI_ColorWidget.cxx
src/HYDROGUI/HYDROGUI_ColorWidget.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_InputPanel.cxx
src/HYDROGUI/HYDROGUI_InputPanel.h
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_ObjSelector.cxx
src/HYDROGUI/HYDROGUI_ObjSelector.h
src/HYDROGUI/HYDROGUI_Operation.cxx
src/HYDROGUI/HYDROGUI_Operation.h
src/HYDROGUI/HYDROGUI_PolylineDlg.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx
src/HYDROGUI/HYDROGUI_TwoImagesDlg.h
src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
src/HYDROGUI/HYDROGUI_TwoImagesOp.h
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/icon_select.png [new file with mode: 0644]
src/HYDROOperations/HYDROOperations_Factory.cxx

index 68ad84a7c2dd297503fc8ea3925205c82daca10c..c6ad0db1816409a9bef27218ea1a4c257094c9ad 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "HYDROGUI_ColorWidget.h"
 
+#include <QApplication>
 #include <QColorDialog>
 
 HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent )
@@ -52,6 +53,13 @@ void HYDROGUI_ColorWidget::setColor( const QColor& c )
   setPalette( aPalette );
 }
 
+void HYDROGUI_ColorWidget::resetColor()
+{
+  QPalette aDefPalette = QApplication::palette();
+  QColor aColor = aDefPalette.color( QPalette::Window );
+  setColor( aColor );
+}
+
 void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* )
 {
   QColor c = QColorDialog::getColor( color(), this );
index 800486a60484b38f1029e220be8dea640ba59d97..c80439e7b51c45c8ee3747bcc1a02bb866567750 100644 (file)
@@ -44,6 +44,8 @@ public:
   QColor color() const;
   /** Sets color value */
   void   setColor( const QColor& );
+  /** Resets the default color value */
+  void   resetColor();
   /** \return color value in the integer form */
   //int    intColor() const;
   /** Sets color value in the integer form */
index 71fe1237cedfffeeba1819c3cd764f1daa0fd0f8..abcc62743d6b4bc4045b06f76bfa6453acc5ecaa 100644 (file)
@@ -148,8 +148,7 @@ bool HYDROGUI_DataModel::close()
 
 bool HYDROGUI_DataModel::isModified() const
 {
-  int aStudyId = module()->application()->activeStudy()->id();
-  return HYDROData_Document::Document( aStudyId )->IsModified();
+  return getDocument()->IsModified();
 }
 
 bool HYDROGUI_DataModel::isSaved() const
@@ -256,8 +255,7 @@ void HYDROGUI_DataModel::updateModel()
 Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
                                                             const ObjectKind theObjectKind )
 {
-  const int aStudyId = module()->application()->activeStudy()->id();
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
+  Handle(HYDROData_Document) aDocument = getDocument();
   if( !aDocument.IsNull() )
   {
     HYDROData_Iterator anIterator( aDocument, theObjectKind );
index a99292ae0a714423475286734f15a47418d14626..7a254ac8b191a4460bd0881d5ea345486a774703 100644 (file)
@@ -97,13 +97,9 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId )
 void HYDROGUI_Displayer::DisplayAll( const int theViewerId,
                                      const bool theIsForced )
 {
-  HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel();
-  if( aModel ) 
-  {
-    HYDROData_SequenceOfObjects aSeq;
-    HYDROGUI_Tool::GetPrsSubObjects( aModel, theViewerId, aSeq );
-    Update( aSeq, theViewerId, theIsForced );
-  }
+  HYDROData_SequenceOfObjects aSeq;
+  HYDROGUI_Tool::GetPrsSubObjects( myModule, theViewerId, aSeq );
+  Update( aSeq, theViewerId, theIsForced );
 }
 
 void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs,
index 9e3e173bfa54c83799ebb6629346d50f6e76beef..a5c99eddb8251a12784871d2a2d02c3ca8bd7d59 100644 (file)
@@ -193,11 +193,10 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   aMappingLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
 
   // Common
-  addWidget( myFileNameGroup, 0, 0 );
-  addWidget( myImageNameGroup, 1, 0 );
-  addWidget( myMappingGroup, 2, 0 );
-
-  setRowStretch();
+  addWidget( myFileNameGroup );
+  addWidget( myImageNameGroup );
+  addWidget( myMappingGroup );
+  addStretch();
 
   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
 }
index 3d844bc1e70cd2a2632a13b295070090375a268e..14c081255003be9a86e6ba8439faed75c4d14714 100644 (file)
@@ -29,8 +29,6 @@
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 
-#include <HYDROData_Document.h>
-
 #include <GraphicsView_ViewManager.h>
 #include <GraphicsView_ViewPort.h>
 #include <GraphicsView_Viewer.h>
@@ -138,7 +136,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
   if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
   {
     // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Object) anObject = findObjectByName( anImageName, KIND_UNKNOWN );
+    Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
     if( !anObject.IsNull() )
     {
       theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
@@ -257,18 +255,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
       anImageName = myEditedObject->GetName();
   }
   else
-  {
-    int anImageId = 1;
-    while( anImageId < 100 )
-    {
-      anImageName = QString( "Image_%1" ).arg( QString::number( anImageId++ ) );
-
-      // check that there are no other objects with the same name in the document
-      Handle(HYDROData_Object) anObject = findObjectByName( anImageName, KIND_UNKNOWN );
-      if( anObject.IsNull() )
-        break;
-    }
-  }
+    anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" );
   aPanel->setImageName( anImageName );
 
   aPanel->initializePointSelection();
index 2186f2791da388f55693e551ce68eb438d7be587..78b42edef35c5004797f2c05f61b1244e41b48e7 100644 (file)
@@ -41,12 +41,12 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr
   setWidget( aFrame );
   QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
   
-  myMainFrame = new QFrame( this );
-  QGridLayout* aMainLayout = new QGridLayout( myMainFrame );
+  myMainFrame = new QFrame( aFrame );
+  QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
   aMainLayout->setMargin( 0 );
   aMainLayout->setSpacing( 5 );
 
-  myBtnFrame = new QFrame( this );
+  myBtnFrame = new QFrame( aFrame );
   aLayout->addWidget( myMainFrame, 1 );
   aLayout->addWidget( myBtnFrame, 0 );
 
@@ -91,37 +91,14 @@ void HYDROGUI_InputPanel::onHelp()
 {
 }
 
-void HYDROGUI_InputPanel::addWidget( const QString& theLabel, QWidget* theWidget )
+void HYDROGUI_InputPanel::addWidget( QWidget* theWidget )
 {
-  QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
-  int aRow = aMainLayout->rowCount();
-  aMainLayout->addWidget( new QLabel( theLabel, this ), aRow, 0 );
-  aMainLayout->addWidget( theWidget, aRow, 1 );
+  QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
+  aMainLayout->addWidget( theWidget );
 }
 
-void HYDROGUI_InputPanel::addWidget( QWidget* theWidget,
-                                     const int theRow,
-                                     const int theColumn )
+void HYDROGUI_InputPanel::addStretch()
 {
-  QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
-  aMainLayout->addWidget( theWidget, theRow, theColumn );
-}
-
-void HYDROGUI_InputPanel::addSeparator()
-{
-  QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
-  int aRow = aMainLayout->rowCount();
-
-  QFrame* aLine = new QFrame();
-  aLine->setFrameShape( QFrame::HLine );
-  aLine->setFrameShadow( QFrame::Sunken );
-
-  aMainLayout->addWidget( aLine, aRow, 0, 1, 2 );
-}
-
-void HYDROGUI_InputPanel::setRowStretch()
-{
-  QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
-  int aRow = aMainLayout->rowCount();
-  aMainLayout->setRowStretch( aRow, 1 );
+  QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
+  aMainLayout->addStretch();
 }
index b05302e8ae6eaf6fbe9a7092669671de05ba7cd8..6799c2478b44008f01ab41e05b5351461f2434fe 100644 (file)
@@ -41,10 +41,8 @@ public:
   HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_InputPanel();
 
-  void addWidget( const QString& theLabel, QWidget* theWidget );
-  void addWidget( QWidget* theWidget, const int theRow, const int theColumn );
-  void addSeparator();
-  void setRowStretch();
+  void addWidget( QWidget* theWidget );
+  void addStretch();
 
   HYDROGUI_Module* module() const;
 
index 91276860faab946b4b7ec09861d9499581d18e47..ea02a0084cd87d459d473b011104c4afbad64ee8 100644 (file)
@@ -220,16 +220,10 @@ void HYDROGUI_Module::update( const int flags )
   setUpdateEnabled( false );
 
   if( ( flags & UF_Model ) && getDataModel() )
-  {
     getDataModel()->update( getStudyId() );
-  }
-  else
-  {
-    /* to do
-    if( ( flags & UF_ObjBrowser ) && getObjectBrowser() )
-      updateObjectBrowser();
-    */
-  }
+
+  if( ( flags & UF_ObjBrowser ) && getApp() )
+    getApp()->updateObjectBrowser( true );
 
   if( ( flags & UF_Viewer ) )
     updateGV( flags & UF_GV_Init,
index f087c09dd135fc88aa89744c280e292c590cd83e..737b19f3702e83acd49d40a45126fd30efc8ff42 100644 (file)
@@ -32,6 +32,9 @@
 #include <LightApp_GVSelector.h>
 #include <LightApp_SelectionMgr.h>
 
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
 #include <QLayout>
 #include <QLineEdit>
 #include <QToolButton>
@@ -40,6 +43,8 @@ HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget*
 : QAbstractButton( theParent ), myModule( theModule )
 {
   QHBoxLayout* aLayout = new QHBoxLayout( this );
+  aLayout->setMargin( 0 );
+  aLayout->setSpacing( 5 );
   myBtn = new QToolButton( this );
   myBtn->setCheckable( true );
   myBtn->setChecked( false );
@@ -48,6 +53,9 @@ HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget*
   aLayout->addWidget( myBtn, 0 );
   aLayout->addWidget( myObjName, 1 );
 
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  myBtn->setIcon( QIcon( aResMgr->loadPixmap( "HYDRO", tr( "SELECT_ICO" ) ) ) );
+
   SUIT_SelectionMgr* aSelMgr = theModule->getApp()->selectionMgr();
 
   connect( myBtn, SIGNAL( toggled( bool ) ), this, SLOT( OnToggled( bool ) ) );
@@ -114,3 +122,9 @@ QString HYDROGUI_ObjSelector::GetName() const
 {
   return myObjName->text();
 }
+
+void HYDROGUI_ObjSelector::Clear()
+{
+  myObjName->clear();
+  myBtn->setChecked( false );
+}
index b3e1019e62de7484b45a35788e03c686f4dace4a..7327df516017f2cbb64f01df7297e69048297342 100644 (file)
@@ -37,6 +37,8 @@ public:
   HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent );
   virtual ~HYDROGUI_ObjSelector();
 
+  void Clear();
+
   QString GetName() const;
 
 protected:
index aacf5dfc377ed80cecbdffa0a656eba0189a94ef..9bdf11e031f00ae0908c53a7286c1df6894fbcdd 100644 (file)
@@ -128,19 +128,7 @@ void HYDROGUI_Operation::processCancel()
 
 Handle_HYDROData_Document HYDROGUI_Operation::doc() const
 {
-  int aStudyId = myModule->application()->activeStudy()->id();
-  return HYDROData_Document::Document( aStudyId );
-}
-
-Handle_HYDROData_Object HYDROGUI_Operation::findObjectByName( const QString& theName, int theKind ) const
-{
-  HYDROData_Iterator anIt( doc(), theKind );
-  for( ; anIt.More(); anIt.Next() )
-  {
-    if( anIt.Current()->GetName() == theName )
-      return anIt.Current();
-  }
-  return Handle_HYDROData_Object();
+  return HYDROData_Document::Document( myModule->getStudyId() );
 }
 
 void HYDROGUI_Operation::onApply()
index 6ab80bd16282b7240571bf9856a6cf94ca33eed8..76eab3707d1f54157cf8fafde5ed83f1fb5faa50 100644 (file)
@@ -57,7 +57,6 @@ protected:
   virtual void processCancel();
 
   Handle_HYDROData_Document doc() const;
-  Handle_HYDROData_Object findObjectByName( const QString& theName, int theKind ) const;
 
 protected slots:
   virtual void onApply();
index ef39f2af19e89049bc54a3d7e8ab925f2a82ef4a..384a0ceecd3ed406331ff8b0b0a32deabc33002b 100755 (executable)
 HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle )
 {
-   CurveCreator_Curve *aStaticCurve = NULL;
+  CurveCreator_Curve *aStaticCurve = NULL;
 
-   aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d);
+  aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d);
 
-   CurveCreator_Widget *aWidget =
-       new CurveCreator_Widget( this, aStaticCurve);
+  CurveCreator_Widget *aWidget =
+    new CurveCreator_Widget( this, aStaticCurve);
 
-   addWidget( aWidget, 0, 0 );
-   setRowStretch();
+  addWidget( aWidget );
+  addStretch();
 }
 
 HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
index dbe776593dc5096e680292bf2e48dfcc00dd116d..a159f81ae8dc8412df68844eb7d58b36fcc75272 100644 (file)
@@ -161,16 +161,11 @@ void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
           aWorkstack->setActiveWindow( aViewWindow );
 }
 
-void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theModel,
+void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
                                       const int theViewerId, // currently unused
                                       HYDROData_SequenceOfObjects& theSeq )
 {
-  if( !theModel )
-    return;
-
-  const int aStudyId = theModel->module()->application()->activeStudy()->id();
-
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
   if( aDocument.IsNull() )
     return;
 
@@ -245,3 +240,43 @@ Handle(HYDROData_Object) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theM
     return aSeq.First();
   return NULL;
 }
+
+Handle(HYDROData_Object) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
+                                                          const QString& theName,
+                                                          const ObjectKind theObjectKind )
+{
+  Handle(HYDROData_Object) anObject;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
+  if( aDocument.IsNull() )
+    return anObject;
+
+  HYDROData_Iterator anIter( aDocument, theObjectKind );
+  for( ; anIter.More(); anIter.Next() )
+  {
+    Handle(HYDROData_Object) anObjectRef = anIter.Current();
+    if( !anObjectRef.IsNull() && anObjectRef->GetName() == theName )
+    {
+      anObject = anObjectRef;
+      break;
+    }
+  }
+  return anObject;
+}
+
+QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module* theModule,
+                                           const QString& thePrefix )
+{
+  QString aName;
+  int anId = 1;
+  while( anId < 100 )
+  {
+    aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
+
+    // check that there are no other objects with the same name in the document
+    Handle(HYDROData_Object) anObject = FindObjectByName( theModule, aName, KIND_UNKNOWN );
+    if( anObject.IsNull() )
+      break;
+  }
+  return aName;
+}
index dc2427b78c32d1b45a98611dcb7e5c0dd7892bbb..1af2f5d71912bb47167631692db11fd9fecb81be 100644 (file)
@@ -112,11 +112,11 @@ public:
 
   /**
    * \brief Get sub-objects to build presentations.
-   * \param theModel data model
+   * \param theModule module
    * \param theViewerId viewer id
    * \param theSeq sequence of sub-objects
    */
-  static void                     GetPrsSubObjects( const HYDROGUI_DataModel* theModel,
+  static void                     GetPrsSubObjects( HYDROGUI_Module* theModule,
                                                     const int theViewerId,
                                                     HYDROData_SequenceOfObjects& theSeq );
 
@@ -149,6 +149,26 @@ public:
    * \return selected data object
    */
   static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
+
+  /**
+   * \brief Find the data object with the specified name.
+   * \param theModule module
+   * \param theName name
+   * \param theObjectKind kind of object
+   * \return data object
+   */
+  static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
+                                                    const QString& theName,
+                                                    const ObjectKind theObjectKind = KIND_UNKNOWN );
+
+  /**
+   * \brief Generate name for new object.
+   * \param theModule module
+   * \param thePrefix name prefix
+   * \return generated name
+   */
+  static QString                  GenerateObjectName( HYDROGUI_Module* theModule,
+                                                      const QString& thePrefix );
 };
 
 #endif
index 82fc2b7f745780d7ae2596aa44d3c7304591f5eb..8a313ec962575b95f7418d47b41bb9e169fa09bc 100644 (file)
 
 #include "HYDROGUI_TwoImagesDlg.h"
 
-#include "HYDROGUI_ObjSelector.h"
 #include "HYDROGUI_ColorWidget.h"
+#include "HYDROGUI_ObjSelector.h"
 
+#include <QGroupBox>
+#include <QLabel>
 #include <QLayout>
 #include <QLineEdit>
 #include <QRadioButton>
 HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle )
 {
-  myName = new QLineEdit();
-  myImage1 = new HYDROGUI_ObjSelector( module(), 0 );
-  myImage2 = new HYDROGUI_ObjSelector( module(), 0 );
-  myTransparent = new QRadioButton( tr( "TRANSPARENT" ) );
+  // Image name
+  QGroupBox* anImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) );
+
+  QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), anImageNameGroup );
+  myImageName = new QLineEdit( anImageNameGroup );
+
+  QBoxLayout* anImageNameLayout = new QHBoxLayout( anImageNameGroup );
+  anImageNameLayout->setMargin( 5 );
+  anImageNameLayout->setSpacing( 5 );
+  anImageNameLayout->addWidget( anImageNameLabel );
+  anImageNameLayout->addWidget( myImageName );
+
+  // Image name
+  QGroupBox* aParamGroup = new QGroupBox( tr( "PARAMETERS" ) );
+
+  QLabel* anImage1Label = new QLabel( tr( "IMAGE_1" ), aParamGroup );
+  myImage1 = new HYDROGUI_ObjSelector( theModule, aParamGroup );
+
+  QLabel* anImage2Label = new QLabel( tr( "IMAGE_2" ), aParamGroup );
+  myImage2 = new HYDROGUI_ObjSelector( theModule, aParamGroup );
+
+  QFrame* aBackgroundFrame = new QFrame( aParamGroup );
+  QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame );
+  myTransparent = new QRadioButton( tr( "TRANSPARENT" ), aBackgroundFrame );
   myTransparent->setChecked( true );
-  myColor = new QRadioButton( tr( "COLOR" ) );
-  myColorBox = new HYDROGUI_ColorWidget( 0 );
-
-  addWidget( tr( "NAME" ), myName );
-  addSeparator();
-  addWidget( tr( "IMAGE_1" ), myImage1 );
-  addWidget( tr( "IMAGE_2" ), myImage2 );
-
-  QFrame* aBackground = new QFrame();
-  QGridLayout* aLayout = new QGridLayout( aBackground );
-  aLayout->addWidget( myTransparent, 0, 0 );
-  aLayout->addWidget( myColor, 1, 0 );
-  aLayout->addWidget( myColorBox, 1, 1 );
-
-  addWidget( tr( "BACKGROUND" ), aBackground );
-  addSeparator();
-  setRowStretch();
+  myColor = new QRadioButton( tr( "COLOR" ), aBackgroundFrame );
+  myColorBox = new HYDROGUI_ColorWidget( aBackgroundFrame );
+
+  QGridLayout* aBackgroundLayout = new QGridLayout( aBackgroundFrame );
+  aBackgroundLayout->setMargin( 0 );
+  aBackgroundLayout->setSpacing( 5 );
+  aBackgroundLayout->addWidget( aBackgroundLabel, 0, 0, 2, 1 );
+  aBackgroundLayout->addWidget( myTransparent,    0, 1 );
+  aBackgroundLayout->addWidget( myColor,          1, 1 );
+  aBackgroundLayout->addWidget( myColorBox,       1, 2 );
+
+  QGridLayout* aParamLayout = new QGridLayout( aParamGroup );
+  aParamLayout->setMargin( 5 );
+  aParamLayout->setSpacing( 5 );
+  aParamLayout->addWidget( anImage1Label,    0, 0 );
+  aParamLayout->addWidget( myImage1,         0, 1 );
+  aParamLayout->addWidget( anImage2Label,    1, 0 );
+  aParamLayout->addWidget( myImage2,         1, 1 );
+  aParamLayout->addWidget( aBackgroundFrame, 2, 0, 1, 2 );
+
+  // Common
+  addWidget( anImageNameGroup );
+  addWidget( aParamGroup );
+  addStretch();
 }
 
 HYDROGUI_TwoImagesDlg::~HYDROGUI_TwoImagesDlg()
 {
 }
 
-QString HYDROGUI_TwoImagesDlg::GetName() const
+void HYDROGUI_TwoImagesDlg::reset()
+{
+  myImageName->clear();
+  myImage1->Clear();
+  myImage2->Clear();
+  myTransparent->setChecked( true );
+  myColorBox->resetColor();
+}
+
+void HYDROGUI_TwoImagesDlg::setImageName( const QString& theName )
+{
+  myImageName->setText( theName );
+}
+
+QString HYDROGUI_TwoImagesDlg::getImageName() const
 {
-  return myName->text();
+  return myImageName->text();
 }
 
-void HYDROGUI_TwoImagesDlg::GetSelectedImages( QString& theName1, QString& theName2 ) const
+bool HYDROGUI_TwoImagesDlg::getSelectedImages( QString& theName1,
+                                               QString& theName2 ) const
 {
   theName1 = myImage1->GetName();
   theName2 = myImage2->GetName();
+  return !theName1.isEmpty() && !theName2.isEmpty();
 }
index 441a0ad6d40f2f5de9ada612bc06de3c764cd183..e9d38d53a4d44ee49ded02396bd94a558b83fa6b 100644 (file)
@@ -39,14 +39,21 @@ public:
   HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_TwoImagesDlg();
 
-  QString GetName() const;
-  void GetSelectedImages( QString& theEntry1, QString& theEntry2 ) const;
+  void                       reset();
+
+  void                       setImageName( const QString& theName );
+  QString                    getImageName() const;
+
+  bool                       getSelectedImages( QString& theName1,
+                                                QString& theName2 ) const;
 
 private:
-  QLineEdit* myName;
-  HYDROGUI_ObjSelector *myImage1, *myImage2;
-  QRadioButton *myTransparent, *myColor;
-  HYDROGUI_ColorWidget* myColorBox;
+  QLineEdit*                 myImageName;
+  HYDROGUI_ObjSelector*      myImage1;
+  HYDROGUI_ObjSelector*      myImage2;
+  QRadioButton*              myTransparent;
+  QRadioButton*              myColor;
+  HYDROGUI_ColorWidget*      myColorBox;
 };
 
 #endif
index 872a097773acb57a12309e527f72996d95881e16..dec0f974cc981af478bad21c80a2c52555d5fc29 100644 (file)
@@ -23,6 +23,7 @@
 #include "HYDROGUI_TwoImagesOp.h"
 
 #include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
 #include "HYDROGUI_TwoImagesDlg.h"
 #include "HYDROGUI_UpdateFlags.h"
 
@@ -57,23 +58,42 @@ HYDROGUI_InputPanel* HYDROGUI_TwoImagesOp::createInputPanel() const
   return new HYDROGUI_TwoImagesDlg( module(), getName() );
 }
 
+void HYDROGUI_TwoImagesOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel();
+  aPanel->reset();
+
+  QString anImageName = HYDROGUI_Tool::GenerateObjectName( module(), getName() );
+  aPanel->setImageName( anImageName );
+}
+
 bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
                                          QString& theErrorMsg )
 {
   HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
 
-  QString aNewName = aPanel->GetName();
+  QString anImageName = aPanel->getImageName();
+  if( anImageName.isEmpty() )
+    return false;
 
-  QString aName1, aName2;
-  aPanel->GetSelectedImages( aName1, aName2 );
+  QString aSelectedName1, aSelectedName2;
+  if( !aPanel->getSelectedImages( aSelectedName1, aSelectedName2 ) )
+    return false;
 
-  if( aNewName.isEmpty() || aName1.isEmpty() || aName2.isEmpty() )
+  // 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(
-    findObjectByName( aName1, KIND_IMAGE ) );
+    HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_IMAGE ) );
   Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast(
-    findObjectByName( aName2, KIND_IMAGE ) );
+    HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_IMAGE ) );
   if( anImage1.IsNull() || anImage2.IsNull() )
     return false;
 
@@ -93,7 +113,7 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
   if( aResult.IsNull() )
     return false;
 
-  aResult->SetName( aNewName );
+  aResult->SetName( anImageName );
   aResult->AppendReference( anImage1 );
   aResult->AppendReference( anImage2 );
   aFactory->UpdateImage( doc(), aResult );
index d5b3306d87a8390b2eadf9f90dc8778b988616a2..ee3bbda7ce5652bce3a32808c86154fad114bbff 100644 (file)
@@ -37,9 +37,11 @@ public:
   virtual ~HYDROGUI_TwoImagesOp();
 
 protected:
+  virtual void               startOperation();
+
   virtual HYDROGUI_InputPanel* createInputPanel() const;
 
-  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
 
 private:
   int myType;
index cbfb166ded2616ac9b09277e2baa2bae23bbd347..633906cf166c3ffe8ed7180fe4908cbab48f85e3 100644 (file)
       <source>REDO_ICO</source>
       <translation>icon_redo.png</translation>
     </message>
+    <message>
+      <source>SELECT_ICO</source>
+      <translation>icon_select.png</translation>
+    </message>
     <message>
       <source>UNDO_ICO</source>
       <translation>icon_undo.png</translation>
index e6ff1d24358eae7f31b0dc5b2c2ae4c7afa77e1c..b2d571e69190e7b2f54a775f66c61dcc8b53645b 100644 (file)
       <source>INPUT_VALID_DATA</source>
       <translation>Please enter valid data and try again.</translation>
     </message>
+    <message>
+      <source>OBJECT_EXISTS_IN_DOCUMENT</source>
+      <translation>Object with name '%1' already exists in the document.</translation>
+    </message>
   </context>
   <context>
     <name>HYDROGUI_DataModel</name>
       <source>MAPPING</source>
       <translation>Mapping</translation>
     </message>
-    <message>
-      <source>OBJECT_EXISTS_IN_DOCUMENT</source>
-      <translation>Object with name '%1' already exists in the document.</translation>
-    </message>
     <message>
       <source>POINTS_A_B_C_BELONG_TO_SINGLE_LINE</source>
       <translation>Points A, B, C belong to a single line.</translation>
       <source>IMAGE_2</source>
       <translation>Image 2</translation>
     </message>
+    <message>
+      <source>IMAGE_NAME</source>
+      <translation>Image name</translation>
+    </message>
     <message>
       <source>NAME</source>
       <translation>Name</translation>
     </message>
+    <message>
+      <source>PARAMETERS</source>
+      <translation>Parameters</translation>
+    </message>
     <message>
       <source>TRANSPARENT</source>
       <translation>Transparent</translation>
diff --git a/src/HYDROGUI/resources/icon_select.png b/src/HYDROGUI/resources/icon_select.png
new file mode 100644 (file)
index 0000000..cd126ad
Binary files /dev/null and b/src/HYDROGUI/resources/icon_select.png differ
index d327fc98e8e36280ff64a8cc1fe5cf1afd55cb93..bfbfbdbf32df934e01e4ac44b1a0528eb804c4c3 100644 (file)
@@ -78,11 +78,13 @@ void HYDROOperations_Factory::UpdateImage(
   // fill by arguments and process the operation
   ImageComposer_Operator* anOp = Operator(theImage);
   if (anOp) { // update image only if there is an operation
+    QTransform aTransform;
     ImageComposer_Image anImage1; // first referenced image
     if (theImage->NbReferences()) {
       Handle(HYDROData_Image) anImage = theImage->Reference(0);
       anImage1 = anImage->Image();
       anImage1.setTransform(anImage->Trsf());
+      aTransform = anImage1.transform();
     }
     ImageComposer_Image anImage2; // second referenced image
     if (theImage->NbReferences() > 1) {
@@ -92,6 +94,7 @@ void HYDROOperations_Factory::UpdateImage(
     }
     ImageComposer_Image aResImg = anOp->process(anImage1, anImage2);
     theImage->SetImage(aResImg);
+    theImage->SetTrsf(aTransform);
   }
   // change the states of this and all depended images
   theImage->MustBeUpdated(true);