#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_DataOwner.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
if ( !aPanel )
return;
- myRegionsList.clear();
aPanel->reset();
QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) );
+ connect( aPanel, SIGNAL( hideZones() ), SLOT( onHideZones() ) );
connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ) );
connect( aPanel, SIGNAL( createRegion( const QList<SUIT_DataObject*>& ) ),
SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
+ connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
+ SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
return aPanel;
}
+void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
+{
+ HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
+ HYDROGUI_Zone* aZoneItem;
+ selectionMgr()->clearSelected();
+ if ( aRegionItem )
+ {
+ // Select a region in preview
+ SUIT_DataOwnerPtrList aList( true );
+ DataObjectList aZones = aRegionItem->children();
+ for ( int i = 0; i < aZones.length(); i++ )
+ {
+ aZoneItem = dynamic_cast<HYDROGUI_Zone*>(aZones.at(i));
+ if ( aZoneItem )
+ {
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
+ }
+ }
+ selectionMgr()->setSelected( aList );
+ }
+ else
+ {
+ // select a single zone
+ aZoneItem = dynamic_cast<HYDROGUI_Zone*>(theItem);
+ if ( aZoneItem )
+ {
+ SUIT_DataOwnerPtrList aList( true );
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
+ selectionMgr()->setSelected( aList );
+ }
+ }
+}
+
void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, const QList<SUIT_DataObject*>& theZonesList )
{
HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theRegionItem);
{
aPanel->setEditedObject(myEditedObject);
}
+ createPreview();
}
}
}
{
aPanel->setEditedObject(myEditedObject);
}
+ createPreview();
}
}
if ( aZone )
{
aZone->setMergeType( theMergeType, theBathymetryName );
+ HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() );
+ if ( aShape )
+ {
+ aShape->update();
+ }
}
aPanel->refreshZonesBrowser();
}
void HYDROGUI_CalculationOp::onSplitZones()
{
- HYDROGUI_CalculationDlg* aPanel =
- ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
- if ( !aPanel )
- return;
-
QApplication::setOverrideCursor( Qt::WaitCursor );
- myEditedObject->SplitGeometryObjects();
- aPanel->setEditedObject( myEditedObject );
- createPreview();
+ if ( myEditedObject->IsMustBeUpdated() )
+ {
+ myShowZones = true;
+ myEditedObject->SplitGeometryObjects();
+
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
+ {
+ aPanel->setEditedObject( myEditedObject );
+ }
+
+ createPreview();
+ }
+ else
+ {
+ setZonesVisible( true );
+ }
QApplication::restoreOverrideCursor();
}
+void HYDROGUI_CalculationOp::onHideZones()
+{
+ setZonesVisible( false );
+}
+
+void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
+{
+ myShowZones = theIsVisible;
+ HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
+ HYDROData_SequenceOfObjects aZones;
+ Handle(HYDROData_Region) aRegion;
+ if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ for ( ; aRegionsIter.More(); aRegionsIter.Next() )
+ {
+ aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
+ if ( !aRegion.IsNull() )
+ {
+ aZones = aRegion->GetZones();
+ HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
+ for ( ; aZonesIter.More(); aZonesIter.Next() )
+ {
+ if ( theIsVisible )
+ {
+ showObject( aZonesIter.Value(), aCtx );
+ }
+ else
+ {
+ module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZonesIter.Value() );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
void HYDROGUI_CalculationOp::createPreview()
{
LightApp_Application* anApp = module()->getApp();
HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+ Handle(HYDROData_Entity) anEntity;
+
+ if ( myShowZones )
+ {
+ // Gather zones for displaying
+ HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
+ HYDROData_SequenceOfObjects aZones;
+ Handle(HYDROData_Region) aRegion;
+ for ( ; aRegionsIter.More(); aRegionsIter.Next() )
+ {
+ anEntity = aRegionsIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aRegion = Handle(HYDROData_Region)::DownCast( anEntity );
+ if ( !aRegion.IsNull() )
+ {
+ aZones = aRegion->GetZones();
+ aSeq.Append( aZones );
+ }
+ }
+ }
+ }
+
module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
if ( !myActiveViewManager )
if ( !aCtx.IsNull() )
{
HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
- Handle(HYDROData_Object) anObject;
- Handle(HYDROData_Entity) anEntity;
- HYDROGUI_Shape* aShape;
for ( ; anIter.More(); anIter.Next() )
{
- anEntity = anIter.Value();
- if ( !anEntity.IsNull() )
- {
- anObject = Handle(HYDROData_Object)::DownCast( anEntity );
- if ( !anObject.IsNull() )
- {
- aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
- if ( !aShape )
- {
- aShape = new HYDROGUI_Shape( aCtx, anObject );
- }
- aShape->update();
- module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject, aShape );
- }
- }
+ showObject( anIter.Value(), aCtx );
}
//Process the draw events for viewer
}
}
+void HYDROGUI_CalculationOp::showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx )
+{
+ if ( !theEntity.IsNull() )
+ {
+ HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity );
+ if ( !aShape )
+ {
+ aShape = new HYDROGUI_Shape( theCtx, theEntity );
+ module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity, aShape );
+ }
+ aShape->update();
+ }
+}
+
void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
{
closePreview();