// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#include <Python.h>
+
#include "HYDROGUI_Module.h"
#include "HYDROGUI.h"
#include "HYDROGUI_OCCDisplayer.h"
#include "HYDROGUI_OCCSelector.h"
#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_Operation.h"
#include "HYDROGUI_PrsImage.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_Tool2.h"
#include "HYDROGUI_SetColorOp.h"
#include "HYDROGUI_ImportGeomObjectOp.h"
#include "HYDROGUI_ShowHideOp.h"
-
+#include "HYDROGUI_Overview.h"
+#include <HYDROGUI_ProfileDlg.h>
+#include <HYDROGUI_SIProgressIndicator.h>
+#include <HYDROGUI_ZIProgressIndicator.h>
#include <HYDROData_Tool.h>
#include <HYDROData_Image.h>
#include <HYDROData_Stream.h>
#include <HYDROData_Lambert93.h>
#include <HYDROData_Polyline3D.h>
#include <HYDROData_StricklerTable.h>
+#include <HYDROData_ArtificialObject.h>
+#include <HYDROData_NaturalObject.h>
#include <HYDROData_OperationsFactory.h>
#include <QStatusBar>
#include <QCursor>
-static int ViewManagerId = 0;
+//#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
+static size_t ViewManagerId = 1;
extern "C" HYDRO_EXPORT CAM_Module* createModule()
{
: LightApp_Module( "HYDRO" ),
myDisplayer( 0 ),
myOCCDisplayer( 0 ),
- myIsUpdateEnabled( true )
+ myIsUpdateEnabled( true ),
+ myOverview( 0 )
{
+ DEBTRACE("HYDROGUI_Module::HYDROGUI_Module()");
}
HYDROGUI_Module::~HYDROGUI_Module()
{
+ DEBTRACE("HYDROGUI_Module::~HYDROGUI_Module()");
}
int HYDROGUI_Module::getStudyId() const
{
+ DEBTRACE("HYDROGUI_Module::getStudyId()");
LightApp_Application* anApp = getApp();
return anApp ? anApp->activeStudy()->id() : 0;
}
void HYDROGUI_Module::initialize( CAM_Application* theApp )
{
+ DEBTRACE("HYDROGUI_Module::initialize");
LightApp_Module::initialize( theApp );
createActions();
myDisplayer = new HYDROGUI_Displayer( this );
myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
+
+ //HYDROData_Tool::SetSIProgress( new HYDROGUI_SIProgressIndicator( theApp->desktop() ) );
+ //HYDROData_Tool::SetZIProgress( new HYDROGUI_ZIProgressIndicator( theApp->desktop() ) );
}
bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
{
+ DEBTRACE("HYDROGUI_Module::activateModule");
bool aRes = LightApp_Module::activateModule( theStudy );
LightApp_Application* anApp = getApp();
setMenuShown( true );
setToolShown( true );
+ // import Python module that manages HYDRO plugins (need to be here because SalomePyQt API uses active module)
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
+ if ( !pluginsmanager ) {
+ PyErr_Print();
+ }
+ else {
+ PyObject* result =
+ PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "hydro",
+ tr("MEN_DESK_HYDRO").toUtf8().data(),
+ tr("Python plugins").toUtf8().data());
+ if ( !result )
+ PyErr_Print();
+ Py_XDECREF(result);
+ }
+ PyGILState_Release(gstate);
+ // end of GEOM plugins loading
+
#ifndef DISABLE_PYCONSOLE
- aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
+ aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
#endif
// Remove defunct view managers from the map.
// It's essential to do this before "update( UF_All )" call!
- QList<int> anObsoleteIds;
+ QList<size_t> anObsoleteIds;
ViewManagerList anAllViewManagers = anApp->viewManagers();
ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
ViewManagerMapIterator anIter( myViewManagerMap );
while( anIter.hasNext() ) {
- int anId = anIter.next().key();
+ size_t anId = anIter.next().key();
const ViewManagerInfo& anInfo = anIter.value();
-
+
aHydroViewManagers << anInfo.first;
if ( !anAllViewManagers.contains( anInfo.first ) ) {
anObsoleteIds << anId;
}
}
- foreach ( const int anId, anObsoleteIds ) {
+ foreach ( const size_t anId, anObsoleteIds ) {
myViewManagerMap.remove( anId );
myObjectStateMap.remove( anId );
myShapesMap.remove( anId );
ViewManagerList anOCCViewManagers;
anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
- foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
+
+ foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
+ {
connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
- foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
+ connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
+ this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
+
+ OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
+ if( occ_mgr )
+ {
+ occ_mgr->setChainedOperations( true );//TODO: via preferences
+ }
+
+ foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
+ {
OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
- if ( aViewFrame && aViewFrame->getViewPort() ) {
+ if ( aViewFrame && aViewFrame->getViewPort() )
+ {
aViewFrame->getViewPort()->installEventFilter( this );
}
}
}
+ preferencesChanged( "HYDRO", "zoom_shutoff" );
+
+ preferencesChanged( "HYDRO", "chained_panning" );
+
// Load GEOM data
- SalomeApp_Study* aStudy =
+ SalomeApp_Study* aStudy =
dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
if ( aStudy ) {
- SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
+ SALOMEDS::Study_var aDSStudy = GeometryGUI::getStudyServant();
GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
}
}
+
// SUIT_DataBrowser* ob = getApp()->objectBrowser();
// SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
// treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
{
+ DEBTRACE("HYDROGUI_Module::deactivateModule");
/* Issues ## 68, 88.
ViewManagerMapIterator anIter( myViewManagerMap );
while( anIter.hasNext() )
ViewManagerList anOCCViewManagers;
getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
- foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
+ foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
+ {
disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ disconnect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
+ this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
+
+ OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
+ if( occ_mgr )
+ {
+ occ_mgr->setChainedOperations( false );
+ setAutoZoom( occ_mgr, true );
+ }
}
/* Issues ## 68, 88.
HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
myActiveOperationMap.clear();
- return LightApp_Module::deactivateModule( theStudy );
+
+ myViewManagerMap.clear();
+
+ bool ret = LightApp_Module::deactivateModule( theStudy );
+ return ret;
+}
+
+void HYDROGUI_Module::studyClosed(SUIT_Study* theStudy)
+{
+ DEBTRACE("HYDROGUI_Module::studyClosed");
+ HYDROGUI_Operation::myIsClear = false; // force clear of Zlayers on next study
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+ if (!aDoc.IsNull())
+ aDoc->Close();
}
void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
{
+ DEBTRACE("HYDROGUI_Module::windows");
+ static bool inWindows = false;
+ if( inWindows )
+ return;
+
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 );
+ theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
+
+ inWindows = true;
+ LightApp_Application* app = getApp();
+ if( app && app->getWindow( OverviewWindow )==0 )
+ {
+ const_cast<HYDROGUI_Module*>( this )->myOverview =
+ new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
+ app->insertDockWindow( OverviewWindow, myOverview );
+ app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
+ }
+ inWindows = false;
}
void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
{
+ DEBTRACE("HYDROGUI_Module::viewManagers");
theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
}
bool anIsObjectCanBeColored = false;
bool isRoot = false;
bool isStreamHasBottom = false;
+ bool anIsBCPolygon = false;
SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
SUIT_DataOwnerPtrList anOwners;
// Check the selected GEOM objects (take into account the Object Browser only)
if ( anIsObjectBrowser ) {
- QList<GEOM::shape_type> anObstacleTypes =
+ QList<GEOM::shape_type> anObstacleTypes =
HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
- QList<GEOM::shape_type> aPolylineTypes =
+ QList<GEOM::shape_type> aPolylineTypes =
HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
- bool isCanBeImportedAsObstacle =
+ bool isCanBeImportedAsObstacle =
!HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
- bool isCanBeImportedAsPolyline =
+ bool isCanBeImportedAsPolyline =
!HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
// Add import as obstacle action
anIsProfile = true;
aNbOfSelectedProfiles++;
- Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile) aProfile =
Handle(HYDROData_Profile)::DownCast( anObject );
if( !aProfile.IsNull() && aProfile->IsValid() ) {
anIsValidProfile = true;
anIsStricklerTable = true;
else if( anObjectKind == KIND_LAND_COVER_MAP )
anIsLandCoverMap = true;
+ else if (anObjectKind == KIND_BC_POLYGON)
+ anIsBCPolygon = true;
else if( anObjectKind == KIND_STREAM )
{
anIsStream = true;
- Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream) aStream =
Handle(HYDROData_Stream)::DownCast( anObject );
if ( !aStream.IsNull() )
- isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
+ isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
}
else if( anObjectKind == KIND_CHANNEL )
anIsChannel = true;
// Check if all selected objects are profiles
anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
- ( aNbOfSelectedProfiles == aSeq.Length() );
+ ( aNbOfSelectedProfiles == aSeq.Length() );
// check the selected partitions
if( !anIsSelectedDataObjects && anIsObjectBrowser )
{
switch( aSelectedPartition )
{
- case KIND_IMAGE:
- theMenu->addAction( action( ImportImageId ) );
- break;
- case KIND_BATHYMETRY:
- theMenu->addAction( action( ImportBathymetryId ) );
- break;
- case KIND_ARTIFICIAL_OBJECT:
- theMenu->addAction( action( CreateChannelId ) );
- theMenu->addAction( action( CreateDigueId ) );
- break;
- case KIND_NATURAL_OBJECT:
- theMenu->addAction( action( CreateImmersibleZoneId ) );
- theMenu->addAction( action( CreateStreamId ) );
- break;
- case KIND_OBSTACLE:
- theMenu->addAction( action( ImportObstacleFromFileId ) );
- theMenu->addAction( action( CreateBoxId ) );
- theMenu->addAction( action( CreateCylinderId ) );
- break;
- case KIND_STRICKLER_TABLE:
- theMenu->addAction( action( ImportStricklerTableFromFileId ) );
- break;
- case KIND_LAND_COVER_MAP:
- theMenu->addAction( action( CreateLandCoverMapId ) );
- theMenu->addAction( action( ImportLandCoverMapId ) );
- break;
- case KIND_CALCULATION:
- theMenu->addAction( action( CreateCalculationId ) );
- break;
- case KIND_POLYLINEXY:
- theMenu->addAction( action( ImportPolylineId ) );
- theMenu->addAction( action( CreatePolylineId ) );
- break;
- case KIND_POLYLINE:
- theMenu->addAction( action( CreatePolyline3DId ) );
- break;
- case KIND_PROFILE:
- theMenu->addAction( action( CreateProfileId ) );
- theMenu->addAction( action( ImportProfilesId ) );
- theMenu->addAction( action( AllGeoreferencementId ) );
- break;
- case KIND_VISUAL_STATE:
- theMenu->addAction( action( SaveVisualStateId ) );
- break;
+ case KIND_IMAGE:
+ theMenu->addAction( action( ImportImageId ) );
+ break;
+ case KIND_BATHYMETRY:
+ theMenu->addAction( action( ImportBathymetryId ) );
+ break;
+ case KIND_ARTIFICIAL_OBJECT:
+ theMenu->addAction( action( CreateChannelId ) );
+ theMenu->addAction( action( CreateDigueId ) );
+ break;
+ case KIND_NATURAL_OBJECT:
+ theMenu->addAction( action( CreateImmersibleZoneId ) );
+ theMenu->addAction( action( CreateStreamId ) );
+ break;
+ case KIND_OBSTACLE:
+ theMenu->addAction( action( ImportObstacleFromFileId ) );
+ theMenu->addAction( action( CreateBoxId ) );
+ theMenu->addAction( action( CreateCylinderId ) );
+ break;
+ case KIND_STRICKLER_TABLE:
+ theMenu->addAction( action( ImportStricklerTableFromFileId ) );
+ break;
+ case KIND_LAND_COVER_MAP:
+ theMenu->addAction( action( CreateLandCoverMapId ) );
+ theMenu->addAction( action( ImportLandCoverMapId ) );
+ break;
+ case KIND_CALCULATION:
+ theMenu->addAction( action( CreateCalculationId ) );
+ break;
+ case KIND_POLYLINEXY:
+ theMenu->addAction( action( ImportPolylineId ) );
+ theMenu->addAction( action( CreatePolylineId ) );
+ break;
+ case KIND_POLYLINE:
+ theMenu->addAction( action( CreatePolyline3DId ) );
+ theMenu->addAction( action( ImportPolylineId ) );
+ break;
+ case KIND_PROFILE:
+ theMenu->addAction( action( CreateProfileId ) );
+ theMenu->addAction( action( ImportProfilesId ) );
+ theMenu->addAction( action( AllGeoreferencementId ) );
+ break;
+ case KIND_VISUAL_STATE:
+ theMenu->addAction( action( SaveVisualStateId ) );
+ break;
+ case KIND_BC_POLYGON:
+ theMenu->addAction( action( ImportBCPolygonId ) );
+ break;
}
theMenu->addSeparator();
}
+ else
+ {
+ Handle(HYDROData_CalculationCase) aCalcCase;
+ QString outStr;
+ HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
+ if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
+ theMenu->addAction( action( RegenerateRegionColorsId ) );
+ }
}
if( anIsSelectedDataObjects )
theMenu->addAction( action( SplitPolylinesId ) );
theMenu->addAction( action( MergePolylinesId ) );
theMenu->addSeparator();
+ theMenu->addAction( action( ShowAttrPolylinesId ) );
+ theMenu->addSeparator();
}
else if( anIsPolyline3D )
{
{
theMenu->addAction( action( EditCalculationId ) );
theMenu->addAction( action( ExportCalculationId ) );
+ theMenu->addAction( action( CompleteCalculationId ) );
theMenu->addSeparator();
}
else if( anIsImmersibleZone )
theMenu->addAction( action( EditStreamId ) );
if ( action( RiverBottomContextId ) )
{
- theMenu->addAction( action( RiverBottomContextId ) );
- action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
+ theMenu->addAction( action( RiverBottomContextId ) );
+ action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
}
theMenu->addAction( action( ProfileInterpolateId ) );
theMenu->addSeparator();
theMenu->addAction( action( DuplicateStricklerTableId ) );
theMenu->addSeparator();
- Handle(HYDROData_StricklerTable) aTable =
+ Handle(HYDROData_StricklerTable) aTable =
Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
- QString aCurrentTable =
+ QString aCurrentTable =
HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
//
theMenu->addAction( action( ExportToShapeFileID ) );
theMenu->addSeparator();
- }
+ }
else if( anIsVisualState && anIsObjectBrowser )
{
theMenu->addAction( action( SaveVisualStateId ) );
theMenu->addAction( action( LoadVisualStateId ) );
theMenu->addSeparator();
}
+ else if (anIsZone)
+ theMenu->addAction( action( ZoneSetColorId ) );
+ else if (anIsBCPolygon)
+ theMenu->addAction( action( SetBoundaryTypePolygonId ) );
if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
{
theMenu->addAction( action( SetTransparencyId ) );
theMenu->addSeparator();
}
- } else if ( anAllAreProfiles ) {
+ }
+ else if ( anAllAreProfiles )
+ {
+ theMenu->addAction( action( EditProfileId ) );
theMenu->addAction( action( SelectedGeoreferencementId ) );
theMenu->addSeparator();
}
- bool anIsPoly = anIsPolyline || anIsPolyline3D;
- if (anIsPoly && !anIsLandCoverMap)
+ bool isPoly = anIsPolyline || anIsPolyline3D;
+ if (isPoly && !anIsLandCoverMap)
theMenu->addAction( action( ExportToShapeFileID ) );
// Add copy action
theMenu->addSeparator();
- if( anIsImage || anIsPolyline || anIsPolyline3D ||
- anIsImmersibleZone || anIsZone || anIsRegion ||
- anIsBathymetry || anIsObstacle || anIsStream ||
- anIsChannel || anIsDigue || anIsDummyObject3D ||
- anIsValidProfile || anIsGroup || anIsLandCoverMap )
+ if( anIsImage || anIsPolyline || anIsPolyline3D ||
+ anIsImmersibleZone || anIsZone || anIsRegion ||
+ anIsBathymetry || anIsObstacle || anIsStream ||
+ anIsChannel || anIsDigue || anIsDummyObject3D ||
+ anIsValidProfile || anIsGroup || anIsLandCoverMap ||
+ anIsBCPolygon)
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
theMenu->addAction( action( HideAllId ) );
theMenu->addSeparator();
}
-
+
if ( anIsOCCView || anIsVTKView )
{
theMenu->addSeparator();
{
if( aSeq.Size() > 0 )
{
- Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() );
+ Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
+ Handle(HYDROData_Object) anObject;
+ Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
+ Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
+
+ if (!anAObject.IsNull())
+ anObject = anAObject;
+ if (!aNObject.IsNull())
+ anObject = aNObject;
+
if( !anObject.IsNull() )
{
theMenu->addSeparator();
- theMenu->addAction( action( SubmersibleId ) );
- action( SubmersibleId )->setCheckable( true );
- action( SubmersibleId )->setChecked( anObject->IsSubmersible() );
+ bool IsSubmersible = anObject->IsSubmersible();
+ if (!IsSubmersible)
+ {
+ theMenu->addAction( action( SubmersibleId ) );
+ action( SubmersibleId )->setCheckable(true);
+ action( SubmersibleId )->setChecked(true);
+ }
+ else
+ {
+ theMenu->addAction( action( UnSubmersibleId ) );
+ action( UnSubmersibleId )->setCheckable(true);
+ action( UnSubmersibleId )->setChecked(true);
+ }
}
}
}
+
+ theMenu->addSeparator();
+ QAction* a = action( ShowHideArrows );
+ a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
+ theMenu->addAction( a );
}
void HYDROGUI_Module::createPreferences()
{
+ DEBTRACE("HYDROGUI_Module::createPreferences");
int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
+ addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
+
+ addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
+
int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
+
+ int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
+ int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
+ LightApp_Preferences::Selector, "polyline", "arrow_type" );
+
+ QList<QVariant> arrow_types;
+ arrow_types.append( tr( "No" ) );
+ arrow_types.append( tr( "Triangle" ) );
+ arrow_types.append( tr( "Cone" ) );
+ setPreferenceProperty( polylineArrow, "strings", arrow_types );
+
+ QList<QVariant> indices;
+ indices.append( 0 );
+ indices.append( 1 );
+ indices.append( 2 );
+ setPreferenceProperty( polylineArrow, "indexes", indices );
+ setPreferenceProperty( polylineArrow, "ids", indices );
+
+ int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
+ LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
}
void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
{
+ DEBTRACE("HYDROGUI_Module::preferencesChanged");
+ SUIT_ResourceMgr* resMgr = application()->resourceMgr();
if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
{
- SUIT_ResourceMgr* resMgr = application()->resourceMgr();
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
+
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
if ( resMgr && !aDoc.IsNull() )
aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
}
+ else if( theSection == "polyline" )
+ {
+ int aType = -1;
+ int aSize = -1;
+ if( resMgr )
+ {
+ resMgr->value( "polyline", "arrow_type", aType );
+ resMgr->value( "polyline", "arrow_size", aSize );
+ }
+ //Update polylines
+ ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
+ for( ; it!=last; it++ )
+ {
+ size_t aViewerId = it.key();
+ OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
+ if( aMgr )
+ getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
+ }
+ }
+ else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
+ {
+ bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
+ setAutoZoomToAllViewManagers(!aZoomShutoff);
+ }
+ else if (theSection == "HYDRO" && thePref == "chained_panning")
+ {
+ bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
+ if (!aChainedPan)
+ resetViewState();
+ ViewManagerList aViewManagers = getApp()->viewManagers();
+ foreach (SUIT_ViewManager* aVMgr, aViewManagers)
+ {
+ OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
+ if (anOCCViewMgr)
+ anOCCViewMgr->setChainedOperations( aChainedPan );
+ }
+
+ QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
+ foreach (QDockWidget* qw, docW)
+ {
+ HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
+ if (pdlg)
+ pdlg->viewManager()->setChainedOperations(aChainedPan);
+ }
+ }
else
- LightApp_Module::preferencesChanged( theSection, thePref );
+ LightApp_Module::preferencesChanged( theSection, thePref );
}
QCursor HYDROGUI_Module::getPrefEditCursor() const
void HYDROGUI_Module::update( const int flags )
{
+ DEBTRACE("HYDROGUI_Module::update");
if ( !isUpdateEnabled() )
return;
}
if( ( flags & UF_Viewer ) )
- updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
+ updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
if( ( flags & UF_OCCViewer ) )
- updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
+ updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
if( ( flags & UF_VTKViewer ) )
- updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
+ updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
if( ( flags & UF_Model ) && getDataModel() && getApp() )
{
bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
if ( isResizeOnExpandItem && anObjectBrowser ) {
- anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
+ anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
}
getApp()->updateObjectBrowser( true );
if ( isResizeOnExpandItem && anObjectBrowser ) {
- anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
+ anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
}
}
setUpdateEnabled( true );
+ preferencesChanged( "HYDRO", "zoom_shutoff" );
+
+ preferencesChanged( "HYDRO", "chained_panning" );
+
QApplication::restoreOverrideCursor();
}
void HYDROGUI_Module::updateCommandsStatus()
{
+ DEBTRACE("HYDROGUI_Module::updateCommandsStatus");
LightApp_Module::updateCommandsStatus();
updateUndoRedoControls();
void HYDROGUI_Module::selectionChanged()
{
+ DEBTRACE("HYDROGUI_Module::selectionChanged");
LightApp_Module::selectionChanged();
updateCommandsStatus();
}
HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
{
+ //DEBTRACE("HYDROGUI_Module::getDataModel()");
return (HYDROGUI_DataModel*)dataModel();
}
HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
{
+ //DEBTRACE("HYDROGUI_Module::getDisplayer()");
return myDisplayer;
}
HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
{
+ DEBTRACE("HYDROGUI_Module::getOCCDisplayer");
return myOCCDisplayer;
}
HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
{
+ DEBTRACE("HYDROGUI_Module::getVTKDisplayer");
return myVTKDisplayer;
}
-SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
+SUIT_ViewManager* HYDROGUI_Module::getViewManager( const size_t theId ) const
{
+ DEBTRACE("HYDROGUI_Module::getViewManager " << theId);
if( myViewManagerMap.contains( theId ) )
{
return myViewManagerMap[ theId ].first;
return NULL;
}
-GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
+GraphicsView_Viewer* HYDROGUI_Module::getViewer( const size_t theId ) const
{
+ DEBTRACE("HYDROGUI_Module::getViewer " << theId);
if( myViewManagerMap.contains( theId ) )
{
ViewManagerInfo anInfo = myViewManagerMap[ theId ];
return NULL;
}
-OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
+OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const size_t theId ) const
{
+ DEBTRACE("HYDROGUI_Module::getOCCViewer " << theId);
if( myViewManagerMap.contains( theId ) )
{
ViewManagerInfo anInfo = myViewManagerMap[ theId ];
return NULL;
}
-SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
+SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const size_t theId ) const
{
+ DEBTRACE("HYDROGUI_Module::getVTKViewer " << theId);
if( myViewManagerMap.contains( theId ) )
{
ViewManagerInfo anInfo = myViewManagerMap[ theId ];
return NULL;
}
-int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
+size_t HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
{
+ DEBTRACE("HYDROGUI_Module::getViewManagerId");
ViewManagerMapIterator anIter( myViewManagerMap );
while( anIter.hasNext() )
{
- int anId = anIter.next().key();
+ size_t anId = anIter.next().key();
const ViewManagerInfo& anInfo = anIter.value();
if( anInfo.first == theViewManager )
return anId;
}
- return -1;
+ return 0;
}
HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
{
- int anId = getViewManagerId( theViewManager );
- if( anId != -1 )
+ DEBTRACE("HYDROGUI_Module::getViewManagerRole");
+ size_t anId = getViewManagerId( theViewManager );
+ if( anId == 0 )
{
const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
return anInfo.second;
void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
const ViewManagerRole theRole )
{
- int anId = getViewManagerId( theViewManager );
- if( anId != -1 )
+ DEBTRACE("HYDROGUI_Module::setViewManagerRole");
+ size_t anId = getViewManagerId( theViewManager );
+ if( anId != 0 )
{
ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
anInfo.second = theRole;
}
}
-bool HYDROGUI_Module::isObjectVisible( const int theViewId,
+bool HYDROGUI_Module::isObjectVisible( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject ) const
{
if( theObject.IsNull() )
return false;
- if( theViewId < 0 )
+ if( theViewId == 0 )
{
//search in all
- foreach( int aViewId, myObjectStateMap.keys() )
+ foreach( size_t aViewId, myObjectStateMap.keys() )
{
if( isObjectVisible( aViewId, theObject ) )
return true;
return false;
}
-void HYDROGUI_Module::setObjectVisible( const int theViewId,
+void HYDROGUI_Module::setObjectVisible( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject,
const bool theState )
{
+ DEBTRACE("setObjectVisible, theViewId: " << theViewId << " " << theState);
if( !theObject.IsNull() )
{
- Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
- QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
+ DEBTRACE("myObjectStateMap.size: " << myObjectStateMap.size());
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
+ DEBTRACE("anEntry: " << anEntry.toStdString());
+ if (myObjectStateMap.find(theViewId) == myObjectStateMap.end())
+ {
+ DEBTRACE("theViewId is not a valid key for myObjectStateMap");
+ }
+ if (theViewId)
+ {
+ Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ]; // created OK if it does not exist
+ DEBTRACE("myObjectStateMap key created");
- ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
- anObjectState.Visibility = theState;
+ ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
+ anObjectState.Visibility = theState;
+ }
HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
if ( hydroObject )
{
+ DEBTRACE("hydroObject " << hydroObject);
SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
if ( treeModel )
{
+ DEBTRACE("treeModel " << treeModel);
QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
Qtx::VisibilityState visState = treeModel->visibilityState( id );
+ DEBTRACE("id " << id << " visState "<< visState);
if ( visState != Qtx::UnpresentableState )
treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
}
void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
const bool theState )
{
+ DEBTRACE("HYDROGUI_Module::setIsToUpdate");
if( !theObject.IsNull() )
{
// Process OCC shapes
}
/////////////////// OCC SHAPES PROCESSING
-QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
+QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const size_t theViewId,
ObjectKind theKind ) const
{
QList<HYDROGUI_Shape*> aResult;
return aResult;
}
-HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
+HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject ) const
{
HYDROGUI_Shape* aResShape = NULL;
return aResShape;
}
-void HYDROGUI_Module::setObjectShape( const int theViewId,
+void HYDROGUI_Module::setObjectShape( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject,
HYDROGUI_Shape* theShape )
{
aViewShapes.append( theShape );
}
-void HYDROGUI_Module::removeObjectShape( const int theViewId,
+void HYDROGUI_Module::removeObjectShape( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject )
{
if ( !myShapesMap.contains( theViewId ) )
anObject = aShape->getObject();
if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
{
+ DEBTRACE("delete shape :" << aShape->getObject()->GetName().toStdString());
delete aShape;
aViewShapes.removeAt( i );
continue;
}
}
-void HYDROGUI_Module::removeViewShapes( const int theViewId )
+void HYDROGUI_Module::removeViewShapes( const size_t theViewId )
{
if ( !myShapesMap.contains( theViewId ) )
return;
/////////////////// END OF OCC SHAPES PROCESSING
/////////////////// VTKPrs PROCESSING
-HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
+HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject ) const
{
HYDROGUI_VTKPrs* aResShape = NULL;
return aResShape;
}
-void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
+void HYDROGUI_Module::setObjectVTKPrs( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject,
HYDROGUI_VTKPrs* theShape )
{
aViewShapes.append( theShape );
}
-void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
+void HYDROGUI_Module::removeObjectVTKPrs( const size_t theViewId,
const QString& theEntry )
{
if ( !myVTKPrsMap.contains( theViewId ) )
getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
}
-void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
+void HYDROGUI_Module::removeObjectVTKPrs( const size_t theViewId,
const Handle(HYDROData_Entity)& theObject )
{
if ( !myVTKPrsMap.contains( theViewId ) )
getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
}
-void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
+void HYDROGUI_Module::removeViewVTKPrs( const size_t theViewId )
{
if ( !myVTKPrsMap.contains( theViewId ) )
return;
myVTKPrsMap.remove( theViewId );
}
-void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
+void HYDROGUI_Module::updateVTKZRange( const size_t theViewId, double theRange[] )
{
if ( myVTKPrsMap.contains( theViewId ) )
{
void HYDROGUI_Module::clearCache()
{
+ DEBTRACE("HYDROGUI_Module::clearCache");
myObjectStateMap.clear();
}
CAM_DataModel* HYDROGUI_Module::createDataModel()
{
+ DEBTRACE("HYDROGUI_Module::createDataModel");
return new HYDROGUI_DataModel( this );
}
void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
{
+ DEBTRACE("HYDROGUI_Module::onViewManagerAdded");
LightApp_Module::onViewManagerAdded( theViewManager );
if( theViewManager->getType() == GraphicsView_Viewer::Type() )
- {
+ {
connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
}
else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
{
+ OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
+ //mgr->setChainedOperations( true );
+
connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
+ this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
}
else if( theViewManager->getType() == SVTK_Viewer::Type() )
{
myViewManagerMap.insert( ViewManagerId++, anInfo );
}
-void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
+void HYDROGUI_Module::removeViewManager( SUIT_ViewManager* theViewManager)
{
- LightApp_Module::onViewManagerRemoved( theViewManager );
+ DEBTRACE("removeViewManager")
- createSelector( theViewManager ); // replace the default selector
-
- int anId = getViewManagerId( theViewManager );
- if( anId != -1 )
+ size_t anId = getViewManagerId( theViewManager );
+ if( anId != 0 )
{
+ bool isDisableGVSelector = theViewManager->getType() == GraphicsView_Viewer::Type();
+ createSelector( theViewManager, isDisableGVSelector ); // replace the default selector
+
OCCViewer_ViewManager* anOCCViewManager =
::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
if ( anOCCViewManager )
{
OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
if ( anOCCViewer ) {
- int aViewerId = (size_t)anOCCViewer;
+ size_t aViewerId = (size_t)anOCCViewer;
removeViewShapes( aViewerId );
setLandCoversScalarMapModeOff( aViewerId );
}
}
}
+void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
+{
+ DEBTRACE("HYDROGUI_Module::onViewManagerRemoved");
+ removeViewManager(theViewManager);
+ LightApp_Module::onViewManagerRemoved( theViewManager );
+
+}
+
void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
{
+ DEBTRACE("HYDROGUI_Module::onViewCreated");
if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
{
+ DEBTRACE("theViewWindow->inherits( 'GraphicsView_ViewFrame' )");
if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
{
+ DEBTRACE("---");
aViewFrame->installEventFilter( this );
GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
+ aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
}
else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
{
+ DEBTRACE("theViewWindow->inherits( 'OCCViewer_ViewFrame' )");
if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
{
+ DEBTRACE("---");
aViewFrame->onTopView();
HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
-
OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
if ( aViewPort ) {
aViewPort->installEventFilter( this );
}
else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
{
+ DEBTRACE("theViewWindow->inherits( 'SVTK_ViewWindow' )");
if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
{
+ DEBTRACE("---");
aViewFrame->installEventFilter( this );
}
}
*/
}
-void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
- const bool theIsInit,
- const bool theIsForced,
+void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
+ const bool theIsInit,
+ const bool theIsForced,
const bool theDoFitAll )
{
- QList<int> aViewManagerIdList;
+ DEBTRACE("HYDROGUI_Module::updateViewer");
+ QList<size_t> aViewManagerIdList;
// currently, all views are updated
ViewManagerMapIterator anIter( myViewManagerMap );
while( anIter.hasNext() )
- {
+ {
SUIT_ViewManager* aViewManager = anIter.next().value().first;
if ( theDisplayer->IsApplicable( aViewManager ) )
}
}
- QListIterator<int> anIdIter( aViewManagerIdList );
+ QListIterator<size_t> anIdIter( aViewManagerIdList );
while( anIdIter.hasNext() )
{
theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
+ myOverview->setTopView();
}
}
-void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
+void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager, bool isDisableGV )
{
+ DEBTRACE("HYDROGUI_Module::createSelector " << isDisableGV);
if( !theViewManager )
return;
return;
QString aViewType = theViewManager->getType();
+ DEBTRACE("aViewType " << aViewType.toStdString());
if( aViewType != GraphicsView_Viewer::Type() &&
aViewType != OCCViewer_Viewer::Type())
return;
aSelectionMgr->selectors( aViewType, aSelectorList );
// disable all alien selectors
+ bool isGV = false;
+ bool isOCC = false;
QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
{
SUIT_Selector* aSelector = *anIter;
- if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
- !dynamic_cast<SVTK_Selector*>( aSelector ) &&
- !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
- aSelector->setEnabled( false );
+ bool isOk = false;
+ if (aSelector)
+ {
+ DEBTRACE("Selector " << aSelector->type().toStdString());
+ if (dynamic_cast<HYDROGUI_GVSelector*>( aSelector ))
+ {
+ isOk = !isDisableGV;
+ isGV = true;
+ DEBTRACE("HYDROGUI_GVSelector " << isOk);
+ }
+ else if (dynamic_cast<SVTK_Selector*>( aSelector ))
+ {
+ isOk = true;
+ DEBTRACE("SVTK_Selector");
+ }
+ else if (dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ))
+ {
+ isOk = true;
+ isOCC = true;
+ DEBTRACE("HYDROGUI_OCCSelector");
+ }
+ if (isOk)
+ {
+ DEBTRACE("Selector enabled " << aSelector->type().toStdString());
+ aSelector->setEnabled( true );
+ }
+ else
+ {
+ DEBTRACE("Selector disabled " << aSelector->type().toStdString());
+ aSelector->setEnabled( false );
+ }
+ }
}
if ( aViewType == GraphicsView_Viewer::Type() )
GraphicsView_ViewManager* aViewManager =
::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
if( aViewManager )
- new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
+ {
+ HYDROGUI_GVSelector* sel = new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
+ DEBTRACE("new HYDROGUI_GVSelector " << sel << " " << sel->type().toStdString());
+ sel->setEnabled( true );
+ }
}
else if ( aViewType == OCCViewer_Viewer::Type() )
{
OCCViewer_ViewManager* aViewManager =
::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
if( aViewManager )
- new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
+ {
+ HYDROGUI_OCCSelector* sel = new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
+ DEBTRACE("new HYDROGUI_OCCSelector " << sel << " " << sel->type().toStdString());
+ sel->setEnabled( true );
+ }
}
}
bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
{
+ DEBTRACE("HYDROGUI_Module::setUpdateEnabled");
bool aPrevState = myIsUpdateEnabled;
myIsUpdateEnabled = theState;
return aPrevState;
QStringList HYDROGUI_Module::storeSelection() const
{
+ DEBTRACE("HYDROGUI_Module::storeSelection");
QStringList anEntryList;
if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
{
SUIT_DataOwnerPtrList::iterator anIter;
for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
{
- const LightApp_DataOwner* anOwner =
+ const LightApp_DataOwner* anOwner =
dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
if( anOwner )
anEntryList.append( anOwner->entry() );
void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
{
+ DEBTRACE("HYDROGUI_Module::restoreSelection");
if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
{
SUIT_DataOwnerPtrList aList( true );
if ( aDesktop && aDesktop->statusBar() )
{
gp_Pnt aWPnt( X, Y, Z );
- int aStudyId = application()->activeStudy()->id();
- HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
+ HYDROData_Document::Document()->Transform( aWPnt, false );
double WX = aWPnt.X(), WY = aWPnt.Y();
QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
*/
QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
{
+ DEBTRACE("HYDROGUI_Module::getActiveOperations");
return myActiveOperationMap;
}
setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
- update( UF_OCCViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
+ update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
+}
+
+bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
+{
+ return true;
+}
+
+bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
+{
+
+ return true;
+}
+
+void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
+ const int row, Qt::DropAction action )
+{
+ if ( action != Qt::CopyAction && action != Qt::MoveAction )
+ return;
+
+ if (row == -1)
+ return;
+
+ if (where->level() < 2 )
+ return;
+
+ DataObjectList::ConstIterator it = what.constBegin();
+ for (;it != what.constEnd();++it)
+ {
+ if ((*it)->parent() != where)
+ return;
+ }
+
+ it = what.constBegin();
+
+ int i=0;
+ for (;it != what.constEnd();++it)
+ {
+ SUIT_DataObject* objWhat = *it;
+
+ DataObjectList objInSect = where->children();
+
+ //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
+ int ind = objInSect.indexOf(objWhat);
+ if (ind != -1)
+ {
+ HYDROGUI_DataModel* aModel = getDataModel();
+ int pos = -1;
+ if (ind >= row)
+ {
+ pos = row + i;
+ i++;
+ }
+ else
+ pos = row - 1;
+ where->moveChildPos(objWhat, pos);
+ //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
+ }
+ }
+
+ getApp()->updateObjectBrowser(true);
+
}
-Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
+Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const size_t theViewId ) const
{
Handle(HYDROData_StricklerTable) aTable;
return aTable;
}
-void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
+void HYDROGUI_Module::setLandCoverColoringTable( const size_t theViewId,
const Handle(HYDROData_StricklerTable)& theTable )
{
- if ( !theTable.IsNull() ) {
+ if ( !theTable.IsNull() && theViewId ) {
myLandCoverColoringMap.insert( theViewId, theTable );
}
}
-void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
+void HYDROGUI_Module::setLandCoversScalarMapModeOff( const size_t theViewId )
{
myLandCoverColoringMap.remove( theViewId );
}
-bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
+bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const size_t theViewId ) const
{
return myLandCoverColoringMap.contains( theViewId );
}
}
if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
- Handle(HYDROData_StricklerTable) aTable =
+ Handle(HYDROData_StricklerTable) aTable =
Handle(HYDROData_StricklerTable)::DownCast( theObject );
- QList<int> aViewIds;
- QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
+ QMutableMapIterator<size_t, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
while ( anIter.hasNext() ) {
- if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
+ if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
anIter.remove();
}
}
}
}
+
+void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
+{
+ DEBTRACE("HYDROGUI_Module::onViewActivated");
+ if( !theMgr )
+ return;
+
+ SUIT_ViewWindow* wnd = theMgr->getActiveView();
+ OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
+ if( !occwnd )
+ return;
+
+ myOverview->setMainView( occwnd );
+}
+
+void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
+{
+ ViewManagerList aViewManagers = getApp()->viewManagers();
+ foreach (SUIT_ViewManager* aVMgr, aViewManagers)
+ setAutoZoom(aVMgr, bAutoZoom);
+}
+
+void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
+{
+ if (!aVMgr)
+ return;
+ QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
+ foreach (SUIT_ViewWindow* aView, aViews)
+ {
+ if (aView)
+ {
+ OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
+ if (anOCCViewFrame)
+ {
+ anOCCViewFrame->setAutomaticZoom(bAutoZoom);
+ for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
+ {
+ OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
+ if (aV)
+ aV->setAutomaticZoom(bAutoZoom);
+ }
+ }
+ OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
+ if (anOCCViewWindow)
+ anOCCViewWindow->setAutomaticZoom(bAutoZoom);
+ }
+ }
+}
+