1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_CalculationOp.h"
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_CalculationDlg.h"
23 #include "HYDROGUI_Module.h"
24 #include "HYDROGUI_Tool.h"
25 #include "HYDROGUI_UpdateFlags.h"
26 #include "HYDROGUI_Zone.h"
27 #include "HYDROGUI_Region.h"
29 #include <HYDROData_PolylineXY.h>
30 #include <HYDROData_ShapesGroup.h>
31 #include <HYDROData_Iterator.h>
32 #include <HYDROData_ImmersibleZone.h>
33 #include <HYDROData_Object.h>
34 #include <HYDROData_Tool.h>
35 #include <HYDROData_StricklerTable.h>
37 #include <OCCViewer_ViewManager.h>
38 #include <OCCViewer_ViewModel.h>
39 #include <OCCViewer_ViewWindow.h>
41 #include <LightApp_Application.h>
42 #include <LightApp_UpdateFlags.h>
43 #include <LightApp_SelectionMgr.h>
44 #include <LightApp_DataOwner.h>
46 #include <SUIT_MessageBox.h>
47 #include <SUIT_Desktop.h>
48 #include <SUIT_DataBrowser.h>
50 #include <QApplication>
51 #include <QKeySequence>
54 HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit )
55 : HYDROGUI_Operation( theModule ),
56 myIsEdit( theIsEdit ),
57 myActiveViewManager( NULL ),
58 myPreviewViewManager( NULL ),
59 myShowGeomObjects( true ),
60 myShowLandCoverMap( false ),
63 setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) );
66 HYDROGUI_CalculationOp::~HYDROGUI_CalculationOp()
71 void HYDROGUI_CalculationOp::startOperation()
73 HYDROGUI_Operation::startOperation();
78 HYDROGUI_CalculationDlg* aPanel =
79 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
83 SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
84 QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
86 foreach( aShortcut, aShortcuts )
88 if ( aShortcut->key() ==
89 QKeySequence(((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
90 SUIT_DataBrowser::RenameShortcut ) ) )
92 aShortcut->setEnabled( false );
98 QStringList anEntryList;
99 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetGeometryObjects( module() );
100 getNamesAndEntries( aSeq, aList, anEntryList );
101 aPanel->setAllGeomObjects( aList, anEntryList );
106 HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY );
107 Handle(HYDROData_PolylineXY) aPolylineObj;
108 QString aPolylineName;
109 for ( ; anIter.More(); anIter.Next() )
111 aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
113 if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() )
115 // Check the polyline shape
116 TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
117 if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
118 aPolylineName = aPolylineObj->GetName();
119 if ( !aPolylineName.isEmpty() )
121 aList.append( aPolylineName );
122 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
127 aPanel->setPolylineNames( aList, anEntryList );
129 QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CALCULATION_CASE_NAME" ) );
131 myEditedObject.Nullify();
134 myEditedObject = Handle(HYDROData_CalculationCase)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
135 if ( !myEditedObject.IsNull() )
137 aPanel->setMode( myEditedObject->GetAssignmentMode() );
138 anObjectName = myEditedObject->GetName();
139 aPolylineObj = myEditedObject->GetBoundaryPolyline();
140 if ( aPolylineObj.IsNull() )
142 aPanel->setBoundary( QString() );
146 aPolylineName = aPolylineObj->GetName();
147 aPanel->setBoundary( aPolylineName );
150 aSeq = myEditedObject->GetGeometryObjects();
151 getNamesAndEntries( aSeq, aList, anEntryList );
152 aPanel->includeGeomObjects( aList );
155 setRules( HYDROData_CalculationCase::DataTag_CustomRules );
161 Handle(HYDROData_CalculationCase)::DownCast( doc()->CreateObject( KIND_CALCULATION ) );
162 myEditedObject->SetName( anObjectName );
163 myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getMode() );
166 aPanel->setObjectName( anObjectName );
167 aPanel->setEditedObject( myEditedObject );
169 createPreview( false );
172 void HYDROGUI_CalculationOp::getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
173 QStringList& theNames, QStringList& theEntries ) const
178 HYDROData_SequenceOfObjects::Iterator anIter( theSeq );
179 for ( ; anIter.More(); anIter.Next() )
181 Handle(HYDROData_Entity) anEntity = anIter.Value();
182 //if ( !HYDROData_Tool::IsGeometryObject( anEntity ) )
185 theNames.append( anEntity->GetName() );
186 theEntries.append( HYDROGUI_DataObject::dataObjectEntry( anEntity ) );
190 void HYDROGUI_CalculationOp::abortOperation()
195 HYDROGUI_Operation::abortOperation();
196 module()->getApp()->updateObjectBrowser();
199 void HYDROGUI_CalculationOp::commitOperation()
202 // Commit transaction
203 commitDocOperation();
204 HYDROGUI_Operation::commitOperation();
207 HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
209 HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() );
211 // Connect signals and slots
212 connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) );
213 connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
214 connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
215 connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
216 connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
218 connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
220 connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
222 connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
223 connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) );
224 //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
225 connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
226 connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>&, bool ) ),
227 SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>&, bool ) ) );
228 connect( aPanel, SIGNAL( createRegion( const QList<SUIT_DataObject*>& ) ),
229 SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
230 connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
231 SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
232 connect( aPanel, SIGNAL( objectsSelected() ),
233 SLOT( onObjectsSelected() ) );
234 connect( aPanel, SIGNAL( landCoversSelected() ),
235 SLOT( onLandCoversSelected() ) );
236 connect( aPanel, SIGNAL( createLandCoverRegion( const QList<SUIT_DataObject*>& ) ),
237 SLOT( onCreateLandCoverRegion( const QList<SUIT_DataObject*>& ) ) );
238 connect( aPanel, SIGNAL( boundarySelected( const QString & ) ),
239 SLOT( onBoundarySelected( const QString & ) ) );
240 connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ),
241 SLOT( onStricklerTableSelected( const QString & ) ) );
243 connect( aPanel, SIGNAL( regenerateColors() ), this,
244 SLOT( onRegenerateColors() ) );
249 void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
251 bool anIsToUpdateViewer = false;
253 // Remove the old boundary from the operation viewer
254 Handle(HYDROData_PolylineXY) aPrevPolyline =
255 myEditedObject->GetBoundaryPolyline();
256 if ( !aPrevPolyline.IsNull() )
258 setObjectVisibility( aPrevPolyline, false );
259 anIsToUpdateViewer = true;
262 // Set the selected boundary polyline to the calculation case
263 Handle(HYDROData_PolylineXY) aNewPolyline = Handle(HYDROData_PolylineXY)::DownCast(
264 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY ) );
265 myEditedObject->SetBoundaryPolyline( aNewPolyline );
267 if ( myPreviewViewManager )
269 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
272 if ( !aNewPolyline.IsNull() )
274 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
275 if ( !aCtx.IsNull() )
277 setObjectVisibility( aNewPolyline, true );
278 anIsToUpdateViewer = true;
282 if ( anIsToUpdateViewer )
283 module()->update( UF_OCCViewer );
288 void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjName )
290 bool anIsToUpdateViewer = false;
293 // Remove old presentations of land covers from the operation viewer
294 Handle(HYDROData_Entity) anEntity;
295 Handle(HYDROData_LandCover) aLandCover;
296 HYDROData_SequenceOfObjects aLandCovers;
297 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
298 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
299 for ( ; anIter.More(); anIter.Next() )
301 anEntity = anIter.Value();
302 if ( !anEntity.IsNull() )
304 aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
305 if ( !aLandCover.IsNull() )
307 aLandCovers.Append( aLandCover );
308 setObjectVisibility( aLandCover, false );
309 anIsToUpdateViewer = true;
314 // Set the selected Strickler table to the calculation case
315 Handle(HYDROData_StricklerTable) aNewStricklerTable = Handle(HYDROData_StricklerTable)::DownCast(
316 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_STRICKLER_TABLE ) );
317 myEditedObject->SetStricklerTable( aNewStricklerTable );
319 if ( myPreviewViewManager )
321 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
324 if ( !aNewStricklerTable.IsNull() )
326 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
327 if ( !aCtx.IsNull() )
329 HYDROData_SequenceOfObjects::Iterator anIter( aLandCovers );
330 for ( ; anIter.More(); anIter.Next() )
332 anEntity = anIter.Value();
333 if ( !anEntity.IsNull() )
335 aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
336 if ( !aLandCover.IsNull() )
338 setObjectVisibility( aLandCover, true );
339 anIsToUpdateViewer = true;
346 if ( anIsToUpdateViewer )
347 module()->update( UF_OCCViewer );
353 void HYDROGUI_CalculationOp::onObjectsSelected()
355 HYDROGUI_CalculationDlg* aPanel =
356 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
358 QStringList aSelectedObjs = aPanel->getSelectedGeomObjects();
359 QMap<QString, bool> aSelectedObjsMap;
360 foreach( QString aName, aSelectedObjs )
361 aSelectedObjsMap[aName] = true;
364 // Select the appropriate geometry object shape in the viewer
365 selectionMgr()->clearSelected();
367 // Unhighlight all objects except selected
368 HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
369 Handle(HYDROData_Entity) anEntity;
370 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
371 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
374 for ( ; anIter.More(); anIter.Next() )
376 anEntity = anIter.Value();
377 if ( !anEntity.IsNull() )
379 aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
382 aName = anEntity->GetName();
383 isSelected = aSelectedObjsMap.contains( aName );
384 aShape->highlight( isSelected, false );
385 aShape->update( false, false );
391 aLastShape->update( true, false );
394 void HYDROGUI_CalculationOp::onLandCoverMapSelected()
396 HYDROGUI_CalculationDlg* aPanel =
397 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
399 /* TODO: highlight the selected land cover map in the 3d viewer (synchronize slection in the dialog with a preview in the viewer)
400 QStringList aSelectedObjs = aPanel->getSelectedLandCovers();
401 QMap<QString, bool> aSelectedObjsMap;
402 foreach( QString aName, aSelectedObjs )
403 aSelectedObjsMap[aName] = true;
407 // Select the appropriate land cover shape in the viewer
408 selectionMgr()->clearSelected();
410 // Unhighlight all land covers except selected
411 HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
412 Handle(HYDROData_Entity) anEntity;
413 /* TODO: highlight the selected land cover map in the 3d viewer (synchronize slection in the dialog with a preview in the viewer)
414 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
415 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
418 for ( ; anIter.More(); anIter.Next() )
420 anEntity = anIter.Value();
421 if ( !anEntity.IsNull() )
423 aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
426 aName = anEntity->GetName();
427 isSelected = aSelectedObjsMap.contains( aName );
428 aShape->highlight( isSelected, false );
429 aShape->update( false, false );
437 //createPreview( true );
440 aLastShape->update( true, false );
443 void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
445 HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
446 HYDROGUI_Zone* aZoneItem;
447 selectionMgr()->clearSelected();
450 // Select a region in preview
451 SUIT_DataOwnerPtrList aList( true );
452 DataObjectList aZones = aRegionItem->children();
453 for ( int i = 0; i < aZones.length(); i++ )
455 aZoneItem = dynamic_cast<HYDROGUI_Zone*>(aZones.at(i));
458 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
461 selectionMgr()->setSelected( aList );
465 // select a single zone
466 aZoneItem = dynamic_cast<HYDROGUI_Zone*>(theItem);
469 SUIT_DataOwnerPtrList aList( true );
470 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
471 selectionMgr()->setSelected( aList );
476 void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem,
477 const QList<SUIT_DataObject*>& theZonesList )
479 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theRegionItem);
482 QList<HYDROGUI_Zone*> aZonesList;
483 HYDROGUI_Zone* aZone;
484 // Get a list of dropped zones
485 for ( int i = 0; i < theZonesList.length(); i++ )
487 aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
490 aZonesList.append( aZone );
493 if ( aZonesList.length() > 0 )
495 aRegion->addZones( aZonesList );
496 HYDROGUI_CalculationDlg* aPanel =
497 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
499 aPanel->refreshZonesBrowser();
500 createPreview( false );
505 void HYDROGUI_CalculationOp::onCreateRegion( const QList<SUIT_DataObject*>& theZonesList )
507 if ( createRegion( theZonesList ) )
509 HYDROGUI_CalculationDlg* aPanel =
510 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
513 aPanel->refreshZonesBrowser();
515 createPreview( false );
519 void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theMergeObjectName )
521 HYDROGUI_CalculationDlg* aPanel =
522 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
525 HYDROGUI_Zone* aZone = aPanel->getCurrentZone();
528 aZone->setMergeType( theMergeType, theMergeObjectName );
529 HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() );
532 aShape->update( true, false );
535 aPanel->refreshZonesBrowser();
539 void HYDROGUI_CalculationOp::onAddObjects()
541 HYDROGUI_CalculationDlg* aPanel =
542 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
546 // Add geometry objects selected in the module browser to the calculation case
547 QStringList aSelectedList = aPanel->getSelectedAvailableGeomObjects();
548 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
551 QStringList anAddedList;
552 for (int i = 0; i < aSelectedList.length(); i++)
554 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
555 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
556 if ( anObject.IsNull() )
559 if ( myEditedObject->AddGeometryObject( anObject ) )
560 anAddedList.append( anObject->GetName() );
563 if ( !anAddedList.isEmpty() )
565 aPanel->includeGeomObjects( anAddedList );
566 createPreview( false );
570 void HYDROGUI_CalculationOp::onRemoveObjects()
572 // Remove selected objects from the calculation case
573 HYDROGUI_CalculationDlg* aPanel =
574 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
578 QStringList aSelectedList = aPanel->getSelectedGeomObjects();
579 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
582 for (int i = 0; i < aSelectedList.length(); i++)
584 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
585 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
586 if ( anObject.IsNull() )
589 setObjectVisibility( anObject, false );
590 myEditedObject->RemoveGeometryObject( anObject );
593 module()->update( UF_OCCViewer );
594 aPanel->excludeGeomObjects( aSelectedList );
597 bool HYDROGUI_CalculationOp::confirmRegionsChange() const
599 // Check if the case is already modified or not
600 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
603 // If not modified check if the case has already defined regions with zones
604 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
605 if ( aSeq.Length() > 0 )
607 // If there are already defined zones then ask a user to confirm zones recalculation
608 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
609 tr( "REGIONS_CHANGED" ),
610 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
611 QMessageBox::Yes | QMessageBox::No,
612 QMessageBox::No ) == QMessageBox::Yes );
616 isConfirmed = true; // No regions - no zones - nothing to recalculate
622 bool HYDROGUI_CalculationOp::confirmOrderChange() const
624 // Check if the case is already modified or not
625 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
628 // If not modified check if the case has already defined regions with zones
629 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
630 if ( aSeq.Length() > 0 )
632 // If there are already defined zones then ask a user to confirm zones recalculation
633 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
634 tr( "ORDER_CHANGED" ),
635 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
636 QMessageBox::Yes | QMessageBox::No,
637 QMessageBox::No ) == QMessageBox::Yes );
641 isConfirmed = true; // No regions - no zones - nothing to recalculate
647 bool HYDROGUI_CalculationOp::confirmRuleChange() const
649 // Check if the case is already modified or not
650 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
653 // If not modified check if the case has already defined regions with zones
654 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
655 if ( aSeq.Length() > 0 )
657 // If there are already defined zones then ask a user to confirm zones recalculation
658 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
659 tr( "RULE_CHANGED" ),
660 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
661 QMessageBox::Yes | QMessageBox::No,
662 QMessageBox::No ) == QMessageBox::Yes );
666 isConfirmed = true; // No regions - no zones - nothing to recalculate
672 bool HYDROGUI_CalculationOp::confirmModeChange() const
674 // Check if the case is already modified or not
675 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
678 // If not modified check if the case has already defined regions with zones
679 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
680 if ( aSeq.Length() > 0 )
682 // If there are already defined zones then ask a user to confirm zones recalculation
683 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
684 tr( "MODE_CHANGED" ),
685 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_MODE" ),
686 QMessageBox::Yes | QMessageBox::No,
687 QMessageBox::No ) == QMessageBox::Yes );
691 isConfirmed = true; // No regions - no zones - nothing to recalculate
697 bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const
699 HYDROData_WarningType aType = theWarning.Type;
700 if ( aType == WARN_OK ) {
708 case WARN_EMPTY_REGIONS:
709 aTitle = tr( "EMPTY_REGIONS" );
710 aMsg = tr( "CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION" ).arg( theWarning.Data );
713 aTitle = tr( "WARNING" );
714 aMsg = theWarning.Data;
718 int anAnswer = SUIT_MessageBox::warning( module()->getApp()->desktop(),
720 QMessageBox::Yes | QMessageBox::No,
723 return ( anAnswer == QMessageBox::Yes );
726 bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags,
727 QString& theErrorMsg,
728 QStringList& theBrowseObjectsEntries )
730 HYDROGUI_CalculationDlg* aPanel =
731 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
737 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
738 theBrowseObjectsEntries.append( anEntry );
741 // For manual mode priority rules are redundant
742 if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) {
743 myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, false );
746 theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
751 void HYDROGUI_CalculationOp::onApply()
754 HYDROData_Warning aWarning = myEditedObject->GetLastWarning();
755 if ( aWarning.Type != WARN_OK ) {
756 if ( !confirmContinueWithWarning( aWarning ) ) {
757 // Go back to the first page
758 HYDROGUI_CalculationDlg* aPanel =
759 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
761 aPanel->onFirstPage();
767 QApplication::setOverrideCursor( Qt::WaitCursor );
769 int anUpdateFlags = 0;
771 QStringList aBrowseObjectsEntries;
773 bool aResult = false;
777 aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
779 catch ( Standard_Failure )
781 Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
782 anErrorMsg = aFailure->GetMessageString();
790 QApplication::restoreOverrideCursor();
794 module()->update( anUpdateFlags );
796 browseObjects( aBrowseObjectsEntries );
801 QString aMsg = tr( "INPUT_VALID_DATA" );
802 if( !anErrorMsg.isEmpty() )
803 aMsg.prepend( anErrorMsg + "\n" );
804 SUIT_MessageBox::critical( module()->getApp()->desktop(),
805 tr( "INSUFFICIENT_INPUT_DATA" ),
810 void HYDROGUI_CalculationOp::onNext( const int theIndex )
814 setAvailableGroups();
816 else if( theIndex==2 )
818 // Land cover map panel
819 HYDROGUI_CalculationDlg* aPanel =
820 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
824 setLandCoverMapVisible( true );
827 QStringList anEntryList;
828 HYDROData_SequenceOfObjects aSeq;
830 /* TODO: get all land cover map objects to fill in combo-box
831 Handle(HYDROData_StricklerTable) aStricklerTableObj;
832 QString aStricklerTableName;
834 // Get all Strickler table objects to fill in combo-box
837 HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE );
838 for ( ; anIter.More(); anIter.Next() )
840 aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
842 if ( !aStricklerTableObj.IsNull() )
844 aStricklerTableName = aStricklerTableObj->GetName();
845 if ( !aStricklerTableName.isEmpty() )
847 aList.append( aStricklerTableName );
848 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ) );
852 aPanel->setStricklerTableNames( aList, anEntryList );
853 //@ASL: bool anUpdateState = myEditedObject->IsMustBeUpdated();
854 if ( !aList.isEmpty() )
855 aPanel->setStricklerTable( aList.at( 0 ), false );
856 //@ASL: myEditedObject->SetToUpdate( anUpdateState );
858 if ( !myEditedObject.IsNull() )
862 // Select the certain Strickler table object in combo-box
863 aStricklerTableObj = myEditedObject->GetStricklerTable();
864 if ( aStricklerTableObj.IsNull() )
866 aPanel->setStricklerTable( QString() );
870 aStricklerTableName = aStricklerTableObj->GetName();
871 aPanel->setStricklerTable( aStricklerTableName );
877 closePreview( false );
878 createPreview( true );
880 else if( theIndex==3 )
882 HYDROGUI_CalculationDlg* aPanel =
883 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
887 QApplication::setOverrideCursor( Qt::WaitCursor );
889 setGeomObjectsVisible( false );
890 setLandCoverMapVisible( false );
892 QString aNewCaseName = aPanel->getObjectName();
893 QString anOldCaseName = myEditedObject->GetName();
894 bool isNameChanged = anOldCaseName != aNewCaseName;
896 bool anIsToUpdateOb = isNameChanged;
898 // At first we must to update the case name because of
899 // automatic names generation for regions and zones
900 myEditedObject->SetName( aNewCaseName );
902 // Zones: set parameters for automatic mode
903 int aMode = aPanel->getMode();
904 if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
906 // Set objects in the specified order
907 if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
909 myEditedObject->RemoveGeometryObjects();
910 foreach ( const QString& aName, aPanel->getAllGeomObjects() )
912 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
913 HYDROGUI_Tool::FindObjectByName( module(), aName ) );
914 if ( anObject.IsNull() )
918 myEditedObject->AddGeometryObject( anObject );
921 // Clear priority rules
922 //@ASL if ( myEditedObject->GetRulesCount() > 0 ) {
923 myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, true );
925 // Set priority rules
926 foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
927 myEditedObject->AddRule( aRule.Object1, aRule.Priority,
928 aRule.Object2, aRule.MergeType,
929 HYDROData_CalculationCase::DataTag_CustomRules );
933 aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
935 if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
938 myEditedObject->Update();
940 AssignDefaultZonesColors();
942 //aPanel->setEditedObject( myEditedObject );
943 aPanel->refreshZonesBrowser();
945 closePreview( false );
946 createPreview( false );
948 anIsToUpdateOb = true;
953 setZonesVisible( true );
955 if ( isNameChanged ) {
956 module()->getDataModel()->updateObjectTree( myEditedObject );
960 QApplication::restoreOverrideCursor();
964 void HYDROGUI_CalculationOp::onHideZones( const int theIndex )
968 setGeomObjectsVisible( true );
970 closePreview( false );
971 createPreview( false );
975 setLandCoverMapVisible( true );
977 closePreview( false );
978 createPreview( true );
981 setZonesVisible( false );
983 else if( theIndex==3 )
985 AssignDefaultZonesColors();
987 closePreview( false );
988 createPreview( false );
991 setZonesVisible( true );
995 void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
997 myShowZones = theIsVisible;
998 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
999 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1000 HYDROData_SequenceOfObjects aZones;
1001 Handle(HYDROData_Region) aRegion;
1002 if ( myPreviewViewManager )
1004 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1006 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1007 if ( !aCtx.IsNull() )
1009 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1011 aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
1012 if ( !aRegion.IsNull() )
1014 aZones = aRegion->GetZones();
1015 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
1016 for ( ; aZonesIter.More(); aZonesIter.Next() )
1018 setObjectVisibility( aZonesIter.Value(), theIsVisible );
1024 module()->update( UF_OCCViewer );
1029 void HYDROGUI_CalculationOp::setGeomObjectsVisible( bool theIsVisible )
1031 myShowGeomObjects = theIsVisible;
1033 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
1035 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
1036 for ( ; anIter.More(); anIter.Next() ) {
1037 setObjectVisibility( anIter.Value(), theIsVisible );
1041 void HYDROGUI_CalculationOp::setLandCoverMapVisible( bool theIsVisible )
1043 myShowLandCoverMap = theIsVisible;
1044 setObjectVisibility( myEditedObject->GetLandCoverMap(), theIsVisible );
1047 void HYDROGUI_CalculationOp::AssignDefaultZonesColors()
1049 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1050 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1051 HYDROData_SequenceOfObjects aZones;
1052 Handle(HYDROData_Region) aRegion;
1053 if ( myPreviewViewManager )
1055 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1057 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1058 if ( !aCtx.IsNull() )
1061 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1063 aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
1064 if ( !aRegion.IsNull() )
1066 aZones = aRegion->GetZones();
1067 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
1068 for ( ; aZonesIter.More(); aZonesIter.Next() )
1071 Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
1072 if ( !aZone.IsNull() )
1074 QColor aFillingColor = GenerateDefaultZonesColor(++aCounter);
1075 while (aFillingColor == Qt::red)
1076 aFillingColor = GenerateDefaultZonesColor(++aCounter);
1078 aZone->SetColor(aFillingColor);
1088 QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex,
1089 float theSaturation/* = 0.5*/,
1090 float theValue/* = 0.95*/ ) const
1092 float aHue = ( rand()%1000 ) * 0.001f;
1095 aColor.setHsl( (int)(aHue*255.), 128, 128 );
1096 int r = aColor.red();
1097 int g = aColor.green();
1098 int b = aColor.blue();
1099 return ( aColor.isValid() ? aColor : Qt::darkBlue );
1102 void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag )
1104 HYDROGUI_CalculationDlg* aPanel =
1105 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1109 HYDROData_ListOfRules aRules;
1110 Handle(HYDROData_Entity) anObject1, anObject2;
1111 HYDROData_PriorityType aPriority;
1112 HYDROData_Zone::MergeType aMergeType;
1113 HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
1114 for ( int anIndex = 0; ; anIndex++ )
1116 if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType, theDataTag ) ) {
1117 HYDROData_CustomRule aRule;
1118 aRule.Object1 = anObject1;
1119 aRule.Object2 = anObject2;
1120 aRule.Priority = aPriority;
1121 aRule.MergeType = aMergeType;
1129 if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomRules )
1130 aPanel->setRules( aRules );
1133 bool HYDROGUI_CalculationOp::createRegion( const QList<SUIT_DataObject*>& theZonesList )
1135 bool aRetValue = false;
1137 QList<HYDROGUI_Zone*> aZonesList;
1138 HYDROGUI_Zone* aZone;
1139 // Get a list of dropped zones
1140 for ( int i = 0; i < theZonesList.length(); i++ )
1142 aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
1145 aZonesList.append( aZone );
1148 if ( aZonesList.length() > 0 )
1150 module()->getDataModel()->createNewRegion( myEditedObject, aZonesList );
1157 void HYDROGUI_CalculationOp::createPreview( const bool theLandCoverMap )
1159 LightApp_Application* anApp = module()->getApp();
1160 HYDROData_SequenceOfObjects aSeq;
1161 if ( theLandCoverMap && myShowLandCoverMap )
1163 aSeq.Append( myEditedObject->GetLandCoverMap() );
1165 else if ( !theLandCoverMap && myShowGeomObjects )
1167 HYDROData_SequenceOfObjects aSeqGO = myEditedObject->GetGeometryObjects();
1168 aSeq.Append( aSeqGO );
1171 Handle(HYDROData_Entity) anEntity;
1175 // Gather zones for displaying
1176 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1177 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1178 HYDROData_SequenceOfObjects aZones;
1179 Handle(HYDROData_Region) aRegion;
1180 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1182 anEntity = aRegionsIter.Value();
1183 if ( !anEntity.IsNull() )
1185 aRegion = Handle(HYDROData_Region)::DownCast( anEntity );
1186 if ( !aRegion.IsNull() )
1188 aZones = aRegion->GetZones();
1189 aSeq.Append( aZones );
1195 // Get a boundary polyline if any
1196 aSeq.Append( myEditedObject->GetBoundaryPolyline() );
1198 module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
1200 if ( !myActiveViewManager )
1202 if ( aSeq.IsEmpty() )
1205 myActiveViewManager = anApp->activeViewManager();
1208 if ( !myPreviewViewManager )
1210 myPreviewViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
1211 anApp->createViewManager( OCCViewer_Viewer::Type() ) );
1212 if ( myPreviewViewManager )
1214 connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1215 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
1217 module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewCaseZones );
1218 myPreviewViewManager->setTitle( tr( "PREVIEW_CASE_ZONES" ) );
1222 if ( !myPreviewViewManager )
1225 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1227 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1228 if ( !aCtx.IsNull() )
1230 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
1231 for ( ; anIter.More(); anIter.Next() )
1233 setObjectVisibility( anIter.Value(), true );
1236 //Process the draw events for viewer
1237 QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
1238 if ( OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView() )
1242 module()->update( UF_OCCViewer | UF_FitAll );
1246 void HYDROGUI_CalculationOp::setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible )
1248 if ( theEntity.IsNull() || !myPreviewViewManager ) {
1252 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
1254 module()->setObjectVisible( (size_t)aViewer, theEntity, theIsVisible );
1258 void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
1263 void HYDROGUI_CalculationOp::closePreview( bool theRemoveViewManager )
1265 SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
1266 QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
1267 QShortcut* aShortcut;
1268 foreach( aShortcut, aShortcuts )
1270 if ( aShortcut->key() ==
1271 QKeySequence( ((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
1272 SUIT_DataBrowser::RenameShortcut ) ) )
1274 aShortcut->setEnabled( true );
1279 if( myPreviewViewManager )
1281 // Hide all the displayed objects in the preview view
1282 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
1284 size_t aViewId = (size_t)aViewer;
1285 HYDROData_Iterator anIterator( doc() );
1286 for( ; anIterator.More(); anIterator.Next() ) {
1287 Handle(HYDROData_Entity) anObject = anIterator.Current();
1288 if( !anObject.IsNull() ) {
1289 module()->setObjectVisible( aViewId, anObject, false );
1294 if ( theRemoveViewManager )
1296 disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1297 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
1299 module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
1300 myPreviewViewManager = NULL;
1304 if( myActiveViewManager && theRemoveViewManager )
1306 HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
1307 myActiveViewManager = NULL;
1311 void HYDROGUI_CalculationOp::setAvailableGroups()
1313 HYDROGUI_CalculationDlg* aPanel =
1314 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1316 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryGroups();
1317 QStringList aList, anEntryList;
1318 getNamesAndEntries( aSeq, aList, anEntryList );
1320 QStringList aGroupsNames;
1322 HYDROData_SequenceOfObjects anObjs = myEditedObject->GetGeometryObjects();
1323 for( int anIndex = 1, aLength = anObjs.Length(); anIndex <= aLength; anIndex++ )
1325 Handle_HYDROData_Object anObj = Handle_HYDROData_Object::DownCast( anObjs.Value( anIndex ) );
1326 HYDROData_SequenceOfObjects aGroups = anObj->GetGroups();
1327 for( int aGIndex = 1, aGLength = aGroups.Length(); aGIndex <= aGLength; aGIndex++ )
1329 Handle_HYDROData_ShapesGroup aGroup = Handle_HYDROData_ShapesGroup::DownCast( aGroups.Value( aGIndex ) );
1330 aGroupsNames.append( aGroup->GetName() );
1333 if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) {
1334 for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
1335 Handle(HYDROData_ShapesGroup) aGeomGroup =
1336 Handle(HYDROData_ShapesGroup)::DownCast( aSeq.Value( anIndex ) );
1337 if ( !aGeomGroup.IsNull() && !aGroupsNames.contains( aGeomGroup->GetName() ) ) {
1338 myEditedObject->RemoveGeometryGroup( aGeomGroup );
1343 aPanel->setAvailableGroups( aGroupsNames );
1344 aPanel->includeGroups( aList );
1346 //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated();
1349 void HYDROGUI_CalculationOp::onAddGroups()
1351 HYDROGUI_CalculationDlg* aPanel =
1352 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1356 // Add geometry objects selected in the module browser to the calculation case
1357 QStringList aSelectedList = aPanel->getSelectedAvailableGroups();
1358 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
1361 QStringList anAddedList;
1362 for (int i = 0; i < aSelectedList.length(); i++)
1364 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
1365 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
1366 if ( aGroup.IsNull() )
1369 if ( myEditedObject->AddGeometryGroup( aGroup ) )
1370 anAddedList.append( aGroup->GetName() );
1373 if ( !anAddedList.isEmpty() )
1375 aPanel->includeGroups( anAddedList );
1379 void HYDROGUI_CalculationOp::onRemoveGroups()
1381 // Remove selected objects from the calculation case
1382 HYDROGUI_CalculationDlg* aPanel =
1383 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1387 QStringList aSelectedList = aPanel->getSelectedGroups();
1388 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
1391 for (int i = 0; i < aSelectedList.length(); i++)
1393 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
1394 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
1395 if ( aGroup.IsNull() )
1398 myEditedObject->RemoveGeometryGroup( aGroup );
1401 aPanel->excludeGroups( aSelectedList );
1404 void HYDROGUI_CalculationOp::onChangeMode( int theMode )
1406 HYDROGUI_CalculationDlg* aPanel =
1407 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1411 if ( !confirmModeChange() ) {
1412 aPanel->setMode( myEditedObject->GetAssignmentMode() );
1416 myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)theMode );
1417 aPanel->setMode( theMode );
1420 void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
1422 HYDROGUI_CalculationDlg* aPanel =
1423 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1427 isConfirmed = confirmOrderChange();
1429 myEditedObject->Changed( HYDROData_Entity::Geom_2d );
1432 void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
1434 HYDROGUI_CalculationDlg* aPanel =
1435 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1439 isConfirmed = confirmRuleChange();
1441 myEditedObject->Changed( HYDROData_Entity::Geom_2d );
1444 void HYDROGUI_CalculationOp::onRegenerateColors()
1446 // For geometry zones
1447 AssignDefaultZonesColors();
1448 setZonesVisible( false );
1449 setZonesVisible( true );