]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for the bug #45: check and warning when the same image is used in 2 arguments.
authorrkv <rkv@opencascade.com>
Thu, 5 Dec 2013 13:49:23 +0000 (13:49 +0000)
committerrkv <rkv@opencascade.com>
Thu, 5 Dec 2013 13:49:23 +0000 (13:49 +0000)
src/HYDROGUI/HYDROGUI_ObjSelector.cxx
src/HYDROGUI/HYDROGUI_ObjSelector.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_msg_en.ts

index 19ddb76ec31d5b748bccaf6063817fc9a7315983..f3b0ae6992d5880c8b7742f0d54f0a457110343d 100644 (file)
@@ -102,8 +102,25 @@ void HYDROGUI_ObjSelector::OnSelectionChanged()
   Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::GetSelectedObject( myModule );
   if( !anObject.IsNull() )
     if( myObjectKind == KIND_UNKNOWN || myObjectKind == anObject->GetKind() )
+    {
       anObjName = anObject->GetName();
 
+      // Check if the same object has not been selected in other selectors of the same parent widget.
+      if ( !anObjName.isEmpty() )
+      {
+        QList<HYDROGUI_ObjSelector*> aSelectors = parentWidget()->findChildren<HYDROGUI_ObjSelector*>();
+        foreach( HYDROGUI_ObjSelector* aSelector, aSelectors )
+        {
+          if( aSelector != this  && ( aSelector->GetName() == anObjName ) )
+          {
+            // Forbid selection of the same object
+            emit alreadySelected( anObjName );
+            return;
+          }
+        }
+      }
+    }
+
   SetName( anObjName );
 }
 
index 717d700106646f4ff3b597b366b29da6a05a0a2b..e44ba07a2e3faad9b78a7d76febb95941fb2e805 100644 (file)
@@ -47,6 +47,13 @@ public:
   void SetName( const QString& );
   QString GetName() const;
 
+signals:
+  /** Signal is emitted if the name has already been selected 
+   *  in other selector of the same parent widget. 
+   * @param theName the selected object name
+   */
+  void alreadySelected( const QString& theName );
+
 protected:
   virtual void paintEvent( QPaintEvent* );
   virtual bool hitButton( const QPoint& thePnt ) const;
index 44b0283ea9cdc0fa9e429102a5e9b6e9b0d54f22..d8edd5962fc28c9536760a1db835484ffced4642 100644 (file)
@@ -99,6 +99,10 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const
            this, SLOT( onModifySelectedImage( bool ) ) );
   connect( myTransparent, SIGNAL( toggled( bool ) ), 
     myColorBox, SLOT( setDisabled( bool ) ) );
+  connect( myImage1, SIGNAL( alreadySelected( const QString& ) ),
+    this, SIGNAL( alreadySelected( const QString& ) ) );
+  connect( myImage2, SIGNAL( alreadySelected( const QString& ) ),
+    this, SIGNAL( alreadySelected( const QString& ) ) );
 
   setMode( myMode, myIsEdit );
 }
index 5f9522664c3e884009ee329203c5681691e4d76b..76dbe97c99f4950445095ab25571370ea8f77bed 100644 (file)
@@ -63,6 +63,13 @@ public:
   void                       setColor( const QColor& theColor );
   QColor                     getColor() const;
 
+signals:
+  /** Signal is emitted if the name has already been selected 
+   *  in other selector of the same parent widget. 
+   * @param theName the selected object name
+   */
+  void                       alreadySelected( const QString& theName );
+
 protected slots:
   void                       onModifySelectedImage( bool theState );
 
index def6f125d65f33131c22b13850072e659661ecda..885fff83946e677c3a371990824e165b701c1c49 100644 (file)
 #include <ImageComposer_CropOperator.h>
 #include <ImageComposer_FuseOperator.h>
 
+#include <LightApp_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+
 HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule,
                                             const int theType,
                                             const bool theIsEdit )
@@ -132,6 +136,14 @@ void HYDROGUI_TwoImagesOp::startOperation()
       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,
index 83ef1de94f2e4ae824acf17180492e2299c1d46e..095d47f100cae27538e2b148d3040e45bbcacec7 100644 (file)
@@ -45,6 +45,13 @@ protected:
 
   virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
 
+protected slots:
+  /** Show warning if the name has already been selected 
+   *  in other selector of the same parent widget. 
+   * @param theName the selected object name
+   */
+  void                       onAlreadySelected( const QString& theName );
+
 private:
   int                        myType;
   bool                       myIsEdit;
index 51e6887396561932da8587fa033d7ad50e4a0fa7..5c4fc3de347be1a50390e621b1adb84490089f72 100644 (file)
@@ -1308,6 +1308,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>SPLIT_IMAGE</source>
       <translation>Split image</translation>
     </message>
+    <message>
+      <source>OBJECT_ALREADY_SELECTED</source>
+      <translation>The object "%1" has been already selected. Please select another one to perform the operation.</translation>
+    </message>
   </context>
 
   <context>