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 );
}
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;
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 );
}
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 );
#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 )
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,
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;
<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>