#include <ImageComposer_FuseOperator.h>
#include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
#include <LightApp_GVSelector.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
#include <SALOME_Event.h>
+#include <SUIT_Desktop.h>
#include <SUIT_Study.h>
#include <SUIT_ViewManager.h>
{
bool aRes = LightApp_Module::activateModule( theStudy );
+ LightApp_Application* anApp = getApp();
+ SUIT_Desktop* aDesktop = anApp->desktop();
+
+ getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
+
setMenuShown( true );
setToolShown( true );
+#ifndef DISABLE_PYCONSOLE
+ aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
+ HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
+#endif
+
update( UF_All );
updateCommandsStatus();
myObjectStateMap.clear();
+ // clear the data model's list of copying objects
+ HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
+
setMenuShown( false );
setToolShown( false );
+ getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
+
return LightApp_Module::deactivateModule( theStudy );
}
{
theMap.clear();
theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
+#ifndef DISABLE_PYCONSOLE
+ theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
+#endif
theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
}
{
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 anIsMustBeUpdatedImage = false;
bool anIsPolyline = false;
bool anIsCalculation = false;
+ bool anIsZone = 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( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
{
- if( dynamic_cast<ImageComposer_FuseOperator*>( anOperator ) )
+ QString anOperatorName = anOperator->name();
+ if( anOperatorName == ImageComposer_FuseOperator::Type() )
anIsFusedImage = true;
- else if( dynamic_cast<ImageComposer_CutOperator*>( anOperator ) )
+ else if( anOperatorName == ImageComposer_CutOperator::Type() )
anIsCutImage = true;
- else if( dynamic_cast<ImageComposer_CropOperator*>( anOperator ) )
+ else if( anOperatorName == ImageComposer_CropOperator::Type() )
anIsSplittedImage = true;
}
}
anIsPolyline = true;
else if( anObject->GetKind() == KIND_CALCULATION )
anIsCalculation = true;
+ else if( anObject->GetKind() == KIND_ZONE )
+ anIsZone = true;
else if( anObject->GetKind() == KIND_VISUAL_STATE )
anIsVisualState = true;
}
}
- 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;
+ case KIND_ZONE:
+ theMenu->addAction( action( CreateZoneId ) );
+ 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( anIsZone )
+ {
+ theMenu->addAction( action( EditZoneId ) );
+ theMenu->addSeparator();
+ }
+ 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 || anIsZone ) )
{
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 )
// from one of the methods called below
setUpdateEnabled( false );
+ // store selected objects
+ QStringList aSelectedEntries = storeSelection();
+
if( ( flags & UF_Viewer ) )
updateGV( flags & UF_GV_Init,
flags & UF_GV_Forced );
if( ( flags & UF_Controls ) && getApp() )
getApp()->updateActions();
+ // restore selected objects
+ restoreSelection( aSelectedEntries );
+
setUpdateEnabled( true );
QApplication::restoreOverrideCursor();
updateUndoRedoControls();
- // to do
- //action( ... )->setEnabled( ... );
+ action( CopyId )->setEnabled( getDataModel()->canCopy() );
+ action( PasteId )->setEnabled( getDataModel()->canPaste() );
+}
+
+void HYDROGUI_Module::selectionChanged()
+{
+ LightApp_Module::selectionChanged();
+ updateCommandsStatus();
}
HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
{
return myIsUpdateEnabled;
}
+
+QStringList HYDROGUI_Module::storeSelection() const
+{
+ QStringList anEntryList;
+ if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
+ {
+ SUIT_DataOwnerPtrList aList( true );
+ aSelectionMgr->selected( aList );
+
+ SUIT_DataOwnerPtrList::iterator anIter;
+ for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
+ {
+ const LightApp_DataOwner* anOwner =
+ dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
+ if( anOwner )
+ anEntryList.append( anOwner->entry() );
+ }
+ }
+ return anEntryList;
+}
+
+void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
+{
+ if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
+ {
+ SUIT_DataOwnerPtrList aList( true );
+ for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
+ aSelectionMgr->setSelected( aList );
+ }
+}