const ObjectKind KIND_PROFILES_GROUP = 7;
const ObjectKind KIND_GUIDE_LINE = 8;
const ObjectKind KIND_ZONE = 9;
+const ObjectKind KIND_LAST = KIND_ZONE;
DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
if( aDocument.IsNull() )
return;
- LightApp_DataObject* anImageRootObj = createObject( aRootObj, "IMAGES" );
+ LightApp_DataObject* anImageRootObj = createObject( aRootObj, partitionName( KIND_IMAGE ) );
HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
for( ; anIterator.More(); anIterator.Next() )
}
}
- LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, "BATHYMETRIES" );
+ LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, partitionName( KIND_BATHYMETRY ) );
anIterator = HYDROData_Iterator( aDocument, KIND_BATHYMETRY );
for( ; anIterator.More(); anIterator.Next() )
createObject( aBathymetryRootObj, aBathymetryObj );
}
- LightApp_DataObject* aCalculRootObj = createObject( aRootObj, "CALCULATION CASES" );
+ LightApp_DataObject* aCalculRootObj = createObject( aRootObj, partitionName( KIND_CALCULATION ) );
anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
for( ; anIterator.More(); anIterator.Next() )
createObject( aCalculRootObj, aCalculObj );
}
- LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, "POLYLINES" );
+ LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, partitionName( KIND_POLYLINE ) );
anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
for( ; anIterator.More(); anIterator.Next() )
createObject( aPolylineRootObj, aPolylineObj );
}
- LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, "VISUAL_STATES" );
+ LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, partitionName( KIND_VISUAL_STATE ) );
anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
for( ; anIterator.More(); anIterator.Next() )
myCopyingObjects.Assign( theSeq );
}
+QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
+{
+ switch( theObjectKind )
+ {
+ case KIND_IMAGE: return "IMAGES";
+ case KIND_POLYLINE: return "POLYLINES";
+ case KIND_VISUAL_STATE: return "VISUAL_STATES";
+ case KIND_BATHYMETRY: return "BATHYMETRIES";
+ case KIND_CALCULATION: return "CALCULATION_CASES";
+ default: break;
+ }
+ return QString();
+}
+
Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
{
int aStudyId = module()->application()->activeStudy()->id();
/**
* Returns data object corresponding to the model object.
* \param the data model object
- * \returns the only one object referenced to the given data model object, or null if not found
+ * \return the only one object referenced to the given data model object, or null if not found
*/
virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject );
/**
* Returns a data object referenced to the given data object.
* \param the data object
- * \returns the object referenced to the given object, or null if not found
+ * \return the object referenced to the given object, or null if not found
*/
virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
*/
static void changeCopyingObjects( const HYDROData_SequenceOfObjects& );
+ /**
+ * Returns name of the partition containing the objects of the specified kind
+ * \param theObjectKind kind of objects
+ * \return partition name
+ */
+ static QString partitionName( const ObjectKind theObjectKind );
+
protected:
/**
* Returns the document for the current study
{
HYDROGUI_DataModel* aModel = getDataModel();
+ bool anIsObjectBrowser = theClient == "ObjectBrowser";
+ bool anIsGraphicsView = theClient == "GraphicsView";
+ if( !anIsObjectBrowser && !anIsGraphicsView )
+ return;
+
size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( this );
- bool anIsSelection = false;
+ bool anIsSelectedDataObjects = false;
bool anIsVisibleInSelection = false;
bool anIsHiddenInSelection = false;
bool anIsCalculation = false;
bool anIsVisualState = false;
+ // check the selected data model objects
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
if( !anObject.IsNull() )
{
- anIsSelection = true;
+ anIsSelectedDataObjects = true;
bool aVisibility = isObjectVisible( aViewId, anObject );
anIsVisibleInSelection |= aVisibility;
}
}
- if( aSeq.IsEmpty() )
+ // check the selected partitions
+ if( !anIsSelectedDataObjects && anIsObjectBrowser )
{
- theMenu->addAction( action( SaveVisualStateId ) );
- theMenu->addSeparator();
+ ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
+ if( aSelectedPartition != KIND_UNKNOWN )
+ {
+ switch( aSelectedPartition )
+ {
+ case KIND_IMAGE:
+ theMenu->addAction( action( ImportImageId ) );
+ break;
+ case KIND_POLYLINE:
+ theMenu->addAction( action( CreatePolylineId ) );
+ break;
+ case KIND_VISUAL_STATE:
+ theMenu->addAction( action( SaveVisualStateId ) );
+ break;
+ case KIND_BATHYMETRY:
+ theMenu->addAction( action( ImportBathymetryId ) );
+ break;
+ case KIND_CALCULATION:
+ theMenu->addAction( action( CreateCalculationId ) );
+ break;
+ }
+ theMenu->addSeparator();
+ }
}
- if( anIsSelection && anIsMustBeUpdatedImage )
+ if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
{
theMenu->addAction( action( UpdateImageId ) );
theMenu->addSeparator();
}
- if( anIsSelection && aSeq.Length() == 1 )
+ if( anIsSelectedDataObjects && aSeq.Length() == 1 )
{
if( anIsImage )
{
theMenu->addAction( action( ObserveImageId ) );
theMenu->addAction( action( ExportImageId ) );
theMenu->addSeparator();
+
+ theMenu->addAction( action( FuseImagesId ) );
+ theMenu->addAction( action( CutImagesId ) );
+ theMenu->addAction( action( SplitImageId ) );
+ theMenu->addSeparator();
}
else if( anIsPolyline )
{
theMenu->addAction( action( EditCalculationId ) );
theMenu->addSeparator();
}
- else if( anIsVisualState )
+ else if( anIsVisualState && anIsObjectBrowser )
{
theMenu->addAction( action( SaveVisualStateId ) );
theMenu->addAction( action( LoadVisualStateId ) );
}
}
- if( anIsSelection )
+ if( anIsSelectedDataObjects )
{
theMenu->addAction( action( DeleteId ) );
theMenu->addSeparator();
}
- if( anIsSelection && ( anIsImage || anIsPolyline ) )
+ if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline ) )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
theMenu->addSeparator();
}
- theMenu->addAction( action( ShowAllId ) );
- theMenu->addAction( action( HideAllId ) );
- theMenu->addSeparator();
+ if( anIsObjectBrowser || anIsGraphicsView )
+ {
+ theMenu->addAction( action( ShowAllId ) );
+ theMenu->addAction( action( HideAllId ) );
+ theMenu->addSeparator();
+ }
}
void HYDROGUI_Module::update( const int flags )
myObjName->clear();
myBtn->setChecked( false );
}
+
+void HYDROGUI_ObjSelector::SetChecked( const bool theState )
+{
+ myBtn->setChecked( theState );
+}
virtual ~HYDROGUI_ObjSelector();
void Clear();
+ void SetChecked( const bool );
void SetName( const QString& );
QString GetName() const;
createAction( CreatePolylineId, "CREATE_POLYLINE" );
createAction( EditPolylineId, "EDIT_POLYLINE" );
- createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::SHIFT + Qt::Key_I );
+ createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B );
createAction( CreateCalculationId, "CREATE_CALCULATION" );
createAction( EditCalculationId, "EDIT_CALCULATION" );
createMenu( ImportBathymetryId, aHydroId, -1, -1 );
createMenu( CreatePolylineId, aHydroId, -1, -1 );
createMenu( CreateCalculationId, aHydroId, -1, -1 );
+ createMenu( separator(), aHydroId );
createMenu( FuseImagesId, aHydroId, -1, -1 );
createMenu( CutImagesId, aHydroId, -1, -1 );
createMenu( SplitImageId, aHydroId, -1, -1 );
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Prs.h"
return NULL;
}
+ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
+{
+ HYDROGUI_DataModel* aModel = theModule->getDataModel();
+
+ SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
+ SUIT_DataOwnerPtrList anOwners;
+ aSelectionMgr->selected( anOwners );
+
+ if( anOwners.size() != 1 )
+ return KIND_UNKNOWN;
+
+ if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( anOwners.first().operator->() ) )
+ {
+ QString anEntry = anOwner->entry();
+ QString aPrefix = HYDROGUI_DataObject::entryPrefix();
+ if( anEntry.left( aPrefix.length() ) == aPrefix )
+ {
+ anEntry.remove( aPrefix );
+ for( ObjectKind anObjectKind = KIND_UNKNOWN + 1; anObjectKind <= KIND_LAST; anObjectKind++ )
+ if( HYDROGUI_DataModel::partitionName( anObjectKind ) == anEntry )
+ return anObjectKind;
+ }
+ }
+ return KIND_UNKNOWN;
+}
+
Handle(HYDROData_Object) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
const QString& theName,
const ObjectKind theObjectKind )
*/
static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
+ /**
+ * \brief Get kind of objects the selected partition contains.
+ * \param theModule module
+ * \return object kind
+ */
+ static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
+
/**
* \brief Find the data object with the specified name.
* \param theModule module
return !theName1.isEmpty() && !theName2.isEmpty();
}
+void HYDROGUI_TwoImagesDlg::setPreselectedObject( const QString& theName )
+{
+ myImage1->SetName( theName );
+
+ HYDROGUI_ObjSelector* aSelector = myMode == TwoImages ? myImage2 : myPolyline;
+ aSelector->SetChecked( true );
+ aSelector->SetName( QString() );
+}
+
void HYDROGUI_TwoImagesDlg::setColor( const QColor& theColor )
{
if( theColor.alpha() == 0 ) // transparent
bool getSelectedObjects( QString& theName1,
QString& theName2 ) const;
+ void setPreselectedObject( const QString& theName );
+
void setColor( const QColor& theColor );
QColor getColor() const;
aPanel->setColor( aColor );
}
}
+ else if( !myIsEdit )
+ {
+ Handle(HYDROData_Image) aSelectedImage =
+ Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !aSelectedImage.IsNull() )
+ {
+ QString aSelectedName = aSelectedImage->GetName();
+ aPanel->setPreselectedObject( aSelectedName );
+ }
+ }
}
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
</message>
<message>
<source>CALCULATION_BOUNDARY</source>
- <translation>Domain of calculation Case</translation>
+ <translation>Domain of calculation case</translation>
</message>
<message>
<source>CALCULATION_NAME</source>
- <translation>Calculation Case name</translation>
+ <translation>Calculation case name</translation>
</message>
<message>
<source>NAME</source>
<name>HYDROGUI_CalculationOp</name>
<message>
<source>CREATE_CALCULATION</source>
- <translation>Create calculation Case</translation>
+ <translation>Create calculation case</translation>
</message>
<message>
<source>EDIT_CALCULATION</source>
- <translation>Edit calculation Case</translation>
+ <translation>Edit calculation case</translation>
</message>
</context>
</message>
<message>
<source>IMPORT_BATHYMETRY_FROM_FILE</source>
- <translation>Import Bathymetry from file</translation>
+ <translation>Import bathymetry from file</translation>
</message>
<message>
<source>NAME</source>
<name>HYDROGUI_ImportBathymetryOp</name>
<message>
<source>IMPORT_BATHYMETRY</source>
- <translation>Import Bathymetry</translation>
+ <translation>Import bathymetry</translation>
</message>
<message>
<source>BAD_IMPORTED_BATHYMETRY_FILE</source>
<name>HYDROGUI_Module</name>
<message>
<source>DSK_CREATE_CALCULATION</source>
- <translation>Create calculation Case</translation>
+ <translation>Create calculation case</translation>
</message>
<message>
<source>DSK_CREATE_POLYLINE</source>
</message>
<message>
<source>DSK_EDIT_CALCULATION</source>
- <translation>Edit calculation Case</translation>
+ <translation>Edit calculation case</translation>
</message>
<message>
<source>DSK_EDIT_CUT_IMAGE</source>
</message>
<message>
<source>DSK_IMPORT_BATHYMETRY</source>
- <translation>Import Bathymetry</translation>
+ <translation>Import bathymetry</translation>
</message>
<message>
<source>DSK_IMPORT_IMAGE</source>
</message>
<message>
<source>MEN_CREATE_CALCULATION</source>
- <translation>Create new calculation Case</translation>
+ <translation>Create new calculation case</translation>
</message>
<message>
<source>MEN_CREATE_POLYLINE</source>
</message>
<message>
<source>MEN_EDIT_CALCULATION</source>
- <translation>Edit calculation Case</translation>
+ <translation>Edit calculation case</translation>
</message>
<message>
<source>MEN_EDIT_CUT_IMAGE</source>
</message>
<message>
<source>MEN_IMPORT_BATHYMETRY</source>
- <translation>Import Bathymetry</translation>
+ <translation>Import bathymetry</translation>
</message>
<message>
<source>MEN_IMPORT_IMAGE</source>
</message>
<message>
<source>STB_CREATE_CALCULATION</source>
- <translation>Create new calculation Case</translation>
+ <translation>Create new calculation case</translation>
</message>
<message>
<source>STB_CREATE_POLYLINE</source>
</message>
<message>
<source>STB_EDIT_CALCULATION</source>
- <translation>Edit calculation Case</translation>
+ <translation>Edit calculation case</translation>
</message>
<message>
<source>STB_EDIT_CUT_IMAGE</source>
</message>
<message>
<source>STB_IMPORT_BATHYMETRY</source>
- <translation>Import Bathymetry</translation>
+ <translation>Import bathymetry</translation>
</message>
<message>
<source>STB_IMPORT_IMAGE</source>