1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <QInputDialog>
27 #include <QStackedWidget>
29 #include <QtxTreeView.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewManager.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_DataObject.h>
37 #include <SUIT_DataBrowser.h>
38 #include <SUIT_FileDlg.h>
40 #include <SVTK_ViewManager.h>
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewWindow.h>
44 #include <VTKViewer_ViewModel.h>
46 #include <vtkActorCollection.h>
47 #include <VTKViewer_Algorithm.h>
48 #include <vtkRenderer.h>
52 #include <SOCC_ViewModel.h>
53 #include <SOCC_ViewWindow.h>
54 #include <OCCViewer_ViewWindow.h>
55 #include <SALOME_Prs.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_Study.hxx>
61 #include <SALOMEDSClient_StudyBuilder.hxx>
62 #include <SALOMEDSClient_SComponent.hxx>
63 #include <SALOMEDSClient_ClientFactory.hxx>
64 #include <SALOMEDSClient_IParameters.hxx>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataModel.h>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
78 #include <SALOME_LifeCycleCORBA.hxx>
80 #include <LightApp_VTKSelector.h>
82 #include <OCCViewer_ViewManager.h>
84 #include <QtxPopupMgr.h>
86 #include "Resource.hxx"
88 #include "HEXABLOCKGUI.hxx"
89 #include "HEXABLOCKGUI_Export.hxx"
90 #include "HEXABLOCKGUI_Trace.hxx"
91 #include "HEXABLOCKGUI_Resource.hxx"
93 #include "HEXABLOCKGUI_DocumentModel.hxx"
94 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
95 #include "HEXABLOCKGUI_DocumentDelegate.hxx"
96 #include "HEXABLOCKGUI_DocumentPanel.hxx"
97 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
98 #include "HEXABLOCKGUI_OccGraphicView.hxx"
99 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
101 #include <HEXABLOCK_version.h>
103 #include "MyBasicGUI_PointDlg.hxx"
105 // #include "HEXABLOCK.hxx" del Hexa6
106 // #include "HexDocument_impl.hxx" del Hexa6
110 #include <Visual3d_ViewManager.hxx>
111 #include <Graphic3d_Structure.hxx>
112 #include <Graphic3d_Group.hxx>
113 #include <V3d_PerspectiveView.hxx>
114 #include <V3d_AmbientLight.hxx>
115 #include <Graphic3d_GraphicDevice.hxx>
116 #include <Graphic3d_Array1OfVertex.hxx>
117 #include <V3d_DirectionalLight.hxx>
118 #include <Xw_Window.hxx>
119 #include <V3d_TypeOfShadingModel.hxx>
120 #include <TCollection_ExtendedString.hxx>
122 #include <BRepAlgoAPI_Fuse.hxx>
124 #include <AIS_ListIteratorOfListOfInteractive.hxx>
127 #define DW_MINIMUM_WIDTH 50
128 #define DWINPUT_MINIMUM_HEIGHT 50
129 #define DWINPUT_MINIMUM_WIDTH 50//255
132 using namespace HEXABLOCK::GUI;
134 int HEXABLOCKGUI::_oldStudyId = -1;
136 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
138 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
139 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
140 bool HEXABLOCKGUI::assocInProgress = false;
141 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
143 HEXABLOCKGUI::HEXABLOCKGUI() :
144 SalomeApp_Module( "HEXABLOCK" ),
152 _patternDataTreeView(0),
153 _patternBuilderTreeView(0),
154 _patternGeomTreeView(0),
157 _treeViewDelegate(0),
159 moduleActivatedOnce(false),
168 _makeCylinderDiag(0),
170 _makeCylindersDiag(0),
178 _makeTransformationDiag(0),
179 _makeSymmetryDiag(0),
180 _performTransformationDiag(0),
181 _performSymmetryDiag(0),
190 _quadRevolutionDiag(0),
191 _makeHemiSphereDiag(0),
192 _modelInfoDiag(NULL),
196 lastVtkDocGView(NULL)
198 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
200 graphicViewsHandler = new GraphicViewsHandler();
201 loadDocLastPath = new QDir();
202 saveDocLastPath = new QDir();
203 hexa_root = HEXA_NS::Hex::getInstance ();
206 HEXABLOCKGUI::~HEXABLOCKGUI()
211 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
213 SUIT_Application* app = SUIT_Session::session()->activeApplication();
215 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
221 // Gets an reference to the module's engine
222 /****************************************************
223 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
225 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
226 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
227 ASSERT(!CORBA::is_nil(clr));
230 **************************************************** */
232 void HEXABLOCKGUI::initialize( CAM_Application* app )
234 DEBTRACE("HEXABLOCKGUI::initialize");
235 SalomeApp_Module::initialize( app );
237 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
239 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
241 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
242 setResource(aResourceMgr);
244 createAndFillDockWidget();
251 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
253 DEBTRACE("HEXABLOCKGUI::viewManagers");
254 // list.append( QxScene_Viewer::Type() );
255 // list.append( OCCViewer_Viewer::Type() );
256 // list.append( SVTK_Viewer::Type() );
260 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
262 DEBTRACE("HEXABLOCKGUI::activateModule");
264 /*HexaBlock can be launched in only one application*/
265 if (myApplication == NULL)
266 //remember the first application
267 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
269 //application verification: if it's not the one known by HexaBlock,
270 //leave without activating
271 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
272 if (myApplication != currentApplication) return false;
274 bool bOk = SalomeApp_Module::activateModule( theStudy );
275 if ( !bOk ) return false;
277 showDockWidgets(true);
279 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
280 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
281 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
282 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
284 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
286 SUIT_ViewManager* vm;
287 ViewManagerList OCCViewManagers, VTKViewManagers;
289 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
290 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
291 while ( itOCC.hasNext() && (vm = itOCC.next()) )
292 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
294 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
295 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
296 while ( itVTK.hasNext() && (vm = itVTK.next()) )
297 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
300 SALOME_ListIO selected;
301 sm->selectedObjects( selected );
304 // disable OCC selectors
305 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
306 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
307 while ( itOCCSel.hasNext() )
308 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
309 sr->setEnabled(true);
311 // disable VTK selectors
312 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
313 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
314 while ( itVTKSel.hasNext() )
315 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
316 sr->setEnabled(true);
318 sm->setSelectedObjects( selected, true ); //NPAL 19674
320 //connect close signal to vtk view manager
321 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
324 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
325 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
328 //connect close signal to occ view manager
329 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
332 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
333 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
336 /* ************************************ TODO Hexa6
337 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
338 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
339 if ( _PTR(Study) aStudy = s->studyDS()) {
340 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
341 updateObjBrowser(); // objects can be removed
343 ************************************ */
345 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
346 currentOccGView->getViewWindow()->installEventFilter(this);
348 if (currentDocGView != NULL)
350 switchModel(currentDocGView);
353 if (currentDocGView->getViewWindow() != NULL)
354 currentDocGView->getViewWindow()->installEventFilter(this);
363 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
365 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
366 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
367 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
368 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
370 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
371 if ( vtkView != NULL)
373 //default selectionMode in VTKView
374 vtkView->SetSelectionMode( ActorSelection );
375 vtkView->removeEventFilter(this);
379 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
382 //defaut selectionMode in OccView
383 selectionMgr()->clearSelected();
384 currentOccGView->globalSelection();
385 occView->removeEventFilter(this);
389 qDeleteAll(myOCCSelectors);
390 myOCCSelectors.clear();
391 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
393 qDeleteAll(myVTKSelectors);
394 myVTKSelectors.clear();
395 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
397 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
399 //switch off current document graphic view
400 switchOffGraphicView(currentDocGView);
403 setMenuShown( false );
404 setToolShown( false );
405 showDockWidgets( false );
407 _dwInputPanel->close();
414 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
416 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
417 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
418 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
419 int aStudyID = theStudy->StudyId();
420 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
421 return aDSStudy._retn();
424 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
425 QMap<QString, QString>& docShapesEntry,
426 QMap<QString, QString>& docShapesName)
428 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
429 return; //there's nothing to publish in this case
431 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
432 if(!appStudy) return;
433 _PTR(Study) aStudy = appStudy->studyDS();
434 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
435 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
436 QString entry = currentDocGView->getDocumentModel()->documentEntry();
437 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
438 if (aFatherSO->_is_nil())
441 // * get a presentation
442 bool isNewPrs = false;
443 SOCC_Prs* prs = getOccPrs(currentDocGView);
446 prs = new SOCC_Prs();
450 // * init the presentation with the given shapes
451 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
452 while (i != topo_shapes.constEnd())
454 QString shapeName = i.key();
455 TopoDS_Shape shapeValue = i.value();
456 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
457 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
458 QString objStudyEntry = aSO->GetID(); //the entry of the published object
459 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
460 "HEXABLOCK", shapeName.toStdString().c_str());
461 ais_shape->SetOwner(io);
462 prs->AddObject(ais_shape);
463 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
464 docShapesEntry[shapeName] = objStudyEntry;
465 docShapesName[objStudyEntry] = shapeName;
466 currentOccGView->addShape(objStudyEntry, ais_shape);
467 i++; //handle next shape
471 prs->AddObject(currentOccGView->getPreviewShape());
473 occPrs[currentDocGView] = prs;
474 getApp()->updateObjectBrowser();
479 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
481 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
482 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
483 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
485 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
489 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
493 // Pas de renommage des shapes pour le moment, juste les documents
494 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
495 if (dgview == NULL || dgview->getDocumentModel() == NULL)
498 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
499 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
504 _PTR(Study) aStudy = appStudy->studyDS();
509 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
510 _PTR(GenericAttribute) anAttr;
512 if ( obj->FindAttribute(anAttr, "AttributeName") ){
513 _PTR(AttributeName) aName (anAttr);
514 DocumentModel* docModel = dgview->getDocumentModel();
515 docModel->setName( name );
516 aName->SetValue( name.toLatin1().data() );
517 getApp()->updateObjectBrowser();
518 _dwPattern->setWindowTitle( name );
525 // --- Default windows
526 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
528 DEBTRACE("HEXABLOCKGUI::windows");
530 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
531 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
534 QString HEXABLOCKGUI::engineIOR() const
536 DEBTRACE("HEXABLOCKGUI::engineIOR");
538 /* ************************************ TODO Hexa6
539 CORBA::ORB_var anORB = getApp()->orb();
540 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
541 return QString( anIOR.in() );
542 ************************************ */
546 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
548 if (docs.count(studyObject->entry()) == 0)
550 //Object's document not acquired yet
551 VtkDocumentGraphicView* dgview;
552 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
553 if (directory == NULL)
554 return NULL; //No working director found
556 //------------------ Load the document -----------------
557 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
558 if (document == NULL)
559 return NULL; //No document found
561 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
563 MESSAGE("Doc model creation failed!");
566 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
567 if (dgview == NULL) return NULL;
569 //update the data tree
570 docs[studyObject->entry()] = dgview;
573 return docs[studyObject->entry()];
576 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
578 // ** we want to switch automatically to the right view windows
580 //first, find selected item
582 DataObjectList dol = getApp()->objectBrowser()->getSelected();
583 if (dol.isEmpty()) return;
584 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
585 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
586 item->entry().isEmpty())
589 // find the document corresponding to it
590 VtkDocumentGraphicView* docGView = NULL;
591 if (docs.contains(item->entry()))
592 docGView = docs[item->entry()];
594 docGView = getOrCreateDocument(item);
596 //Init OCC if necessary
597 if (currentOccGView == NULL)
599 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
600 currentOccGView->getViewWindow()->installEventFilter(this);
602 else if (currentOccGView->getViewWindow() == NULL)
604 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
605 currentOccGView->getViewWindow()->installEventFilter(this);
608 //Init the vtk view if necessary
609 if (docGView->getViewWindow() == NULL)
611 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
613 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
614 docGView->getViewWindow()->installEventFilter(this);
617 docGView->setViewWindow(currentDocGView->getViewWindow());
619 if (docGView->getDocumentActor() == NULL)
623 if (docGView == NULL || docGView == currentDocGView)
629 //update the current document
630 switchModel(docGView);
634 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
636 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
639 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
641 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
643 //Decharger le model correspondant (VTK)
644 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
649 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
650 { //HexaBlock Vtk Window has been closed
652 if (currentDialog != NULL) currentDialog->close();
653 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
654 if (currentDocGView != NULL)
655 currentDocGView->setViewWindow(NULL);
662 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
663 if (dgview == NULL) return; //The window has no document to close
665 //Save the document? (Ask only if the document is not empty
666 int answerCode = SUIT_MessageBox::question(
669 tr("Save the document ?"),
670 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
671 SUIT_MessageBox::Cancel);
672 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
673 else if (answerCode == SUIT_MessageBox::Yes)
674 saveDocument(); //Save the document
676 // switchOffGraphicView(window); //disconnect all connected signals
677 // currentVtkView = NULL;
678 // graphicViewsHandler->closeDocumentGraphicView(window);
680 //create a new one (empty document)
682 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
686 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
688 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
689 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
690 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
691 if (currentDialog != NULL) currentDialog->close();
692 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
694 currentOccGView->getViewWindow()->removeEventFilter(this);
696 currentOccGView->setViewWindow(NULL);
700 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
702 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
704 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
705 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
707 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
709 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
710 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
711 // disable OCC selectors
712 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
713 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
714 while ( itOCCSel.hasNext() )
715 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
716 sr->setEnabled(true);
718 else if ( vm->getType() == SVTK_Viewer::Type() )
720 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
721 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
723 // disable VTK selectors
724 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
725 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
726 while ( itVTKSel.hasNext() )
727 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
728 sr->setEnabled(true);
732 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
734 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
736 SUIT_ViewModel* viewer = vm->getViewModel();
737 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
739 //VTK View Manager removed
740 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
742 //Process only if it's our view manager
743 SUIT_ViewManager* myVm = NULL;
744 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
745 myVm = currentDocGView->getViewWindow()->getViewManager();
749 //close opened dialog
750 if (currentDialog != NULL) currentDialog->close();
751 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
757 //remove its selector
758 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
759 while ( itVTKSel.hasNext() )
760 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
761 if ( sr->viewer() == viewer )
763 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
770 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
772 //OCC View removed: remove its selector
773 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
774 while ( itOCCSel.hasNext() )
775 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
776 if ( sr->viewer() == viewer )
778 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
784 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
786 QModelIndexList l = selected.indexes();
787 if ( l.count() == 0 ) return;
788 if ( !l[0].isValid() ) return;
789 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
790 if ( currentGraphicView == NULL) return;
792 QTreeView* theTree = NULL;
793 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
794 theTree = _patternDataTreeView;
795 } else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
796 theTree = _patternBuilderTreeView;
797 } else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
798 theTree = _patternGeomTreeView;
800 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
801 theTree = _groupsTreeView;
802 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
803 theTree = _meshTreeView;
806 theTree->scrollTo ( l[0] );
810 bool HEXABLOCKGUI::createSComponent() //addComponent
812 DEBTRACE("HEXABLOCKGUI::createSComponent");
813 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
815 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
816 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
817 _PTR(GenericAttribute) anAttr;
818 _PTR(AttributeName) aName;
819 _PTR(AttributeGraphic) aGraphic;
821 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
822 if ( !aComponent ){ //Create hexablock component if there's not one yet
823 aComponent = aBuilder->NewComponent("HEXABLOCK");
824 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
825 aName = _PTR(AttributeName) (anAttr);
826 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
828 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
829 _PTR(AttributePixMap) aPixmap(anAttr);
830 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
832 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
833 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
839 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
841 DEBTRACE("HEXABLOCKGUI::setResource");
842 _myresource = new HEXABLOCKGUI_Resource(r);
843 _myresource->preferencesChanged();
846 void HEXABLOCKGUI::createPreferences()
848 DEBTRACE("HEXABLOCKGUI::createPreferences");
849 _myresource->createPreferences(this);
852 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
854 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
855 _myresource->preferencesChanged(sect, name);
856 // if(name=="userCatalog")
857 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
860 void HEXABLOCKGUI::studyActivated() //CS_TODO
862 int newStudyId = getApp()->activeStudy()->id();
863 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
864 // if (_oldStudyId != -1)
866 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
867 // if (_studyContextMap.count(newStudyId))
869 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
870 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
874 // DEBTRACE("no switch to null context");
877 _oldStudyId = newStudyId;
880 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
882 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
883 QVariant currentAssocVariant;
884 QString currentAssocEntry;
886 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
887 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
888 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
889 QMenu menu( _patternDataTreeView );
891 QAction *clearAct = menu.addAction( "Remove association(s)" );
892 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
893 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
897 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
898 if (currentVtkGraphicView == NULL) return;
899 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
901 //We don't do anything for single items
902 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
903 item->type() == QUADITEM || item->type() == HEXAITEM)
906 //No associations for HEXA
907 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
908 if ( !treeVariant.isValid() ) return;
909 int eltType = treeVariant.toInt();
910 if (eltType == HEXA_DIR_TREE) return;
911 QMenu menu( _patternDataTreeView );
913 //Show association(s)
914 QAction *showAssocAct = menu.addAction( "Show associations" );
915 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
917 //Clear all associations
918 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
919 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
921 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
926 void HEXABLOCKGUI::createAndFillDockWidget()
928 QMainWindow *aParent = application()->desktop();
930 // Create dock widget (3 dock)
932 //1) *********** user input panel ( contain user's edit dialog box )
933 _dwInputPanel = new QDockWidget(aParent);
934 _dwInputPanel->setVisible(false);
935 _dwInputPanel->setWindowTitle("Input Panel");
936 _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
938 _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
940 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
942 _dwPattern = new QDockWidget(aParent);
943 _dwPattern->setVisible(false);
944 _dwPattern->setWindowTitle("Model");
945 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
947 QFrame* patternFrame = new QFrame(_dwPattern);
948 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
949 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
950 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
951 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
952 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
953 _patternBuilderTreeView = new QTreeView(patternFrame);
954 _patternGeomTreeView = new QTreeView(patternFrame);
955 splitter->addWidget(_patternDataTreeView);
956 splitter->addWidget(_patternBuilderTreeView);
957 splitter->addWidget(_patternGeomTreeView);
958 patternLayout->addWidget(splitter);
960 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers/*QAbstractItemView::DoubleClicked*/);
961 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
962 _patternDataTreeView->setItemDelegate(_treeViewDelegate);
965 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
966 _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
968 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
969 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
971 _dwPattern->setWidget(patternFrame);
972 patternFrame->show();
975 _dwGroups = new QDockWidget(aParent);
977 _dwGroups->setVisible(false);
978 _dwGroups->setWindowTitle("Groups");
979 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
980 _groupsTreeView = new QTreeView(_dwGroups);
981 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
982 _groupsTreeView->setItemDelegate(_treeViewDelegate);
983 _dwGroups->setWidget(_groupsTreeView);
984 _groupsTreeView->show();
987 _dwMesh = new QDockWidget(aParent);
988 _dwMesh->setVisible(false);
989 _dwMesh->setWindowTitle("Mesh");
990 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
991 _meshTreeView = new QTreeView(_dwMesh);
992 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
993 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
994 _meshTreeView->setItemDelegate(_treeViewDelegate);
995 _dwMesh->setWidget(_meshTreeView);
996 _meshTreeView->show();
998 QDockWidget *_dwObjectBrowser = 0;
999 QWidget* wid = getApp()->objectBrowser()->treeView();
1000 QWidget *w = wid->parentWidget();
1001 while ( w && !_dwObjectBrowser ) {
1002 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1003 w = w->parentWidget();
1005 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1006 _dwObjectBrowser->setWindowTitle("Study");
1008 // dock widget position
1009 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1010 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1012 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1013 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1014 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1017 #if QT_VERSION >= 0x040500
1018 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1022 // popup menu on data tree view
1023 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1024 connect(_patternDataTreeView,
1025 SIGNAL(customContextMenuRequested(const QPoint &)),
1027 SLOT(treeContextMenu(const QPoint &)),
1028 Qt::UniqueConnection );
1031 void HEXABLOCKGUI::createActions()
1033 QMainWindow *aParent = application()->desktop();
1034 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1037 _newAct = createAction(_menuId++,
1038 tr("Create a new document"),
1039 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1041 tr("Create a new document"),
1042 0, aParent, false, this, SLOT(newDocument()));
1043 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1045 _importAct = createAction(_menuId++,
1046 tr("Load a document"),
1047 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1048 tr("Load Document"),
1049 tr("Load a document"),
1050 0, aParent, false, this, SLOT(loadDocument()));
1051 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1053 _saveAct = createAction(_menuId++,
1054 tr("Save the document"),
1055 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1056 tr("Save Document"),
1057 tr("Save the document"),
1058 0, aParent, false, this, SLOT(saveDocument()));
1060 // Pattern Data creation
1061 _addVertex = createAction(_menuId++,
1062 tr("Create a vertex"),
1063 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1065 tr("Create a new vertex"),
1066 0, aParent, false, this, SLOT(addVertex()));
1068 _addEdge = createAction(_menuId++,
1069 tr("Create an edge"),
1070 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1072 tr("Create a new edge"),
1073 0, aParent, false, this, SLOT(addEdge()));
1075 _addQuad = createAction(_menuId++,
1076 tr("Create a quadrangle"),
1077 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1078 tr("Add Quadrangle"),
1079 tr("Create a new quadrangle"),
1080 0, aParent, false, this, SLOT(addQuad()));
1082 _addHexa = createAction(_menuId++,
1083 tr("Create an hexahedron"),
1084 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1085 tr("Add Hexahedron"),
1086 tr("Create a new hexahedron"),
1087 0, aParent, false, this, SLOT(addHexa()));
1089 // Builder Data creation
1090 _addVector = createAction(_menuId++,
1091 tr("Create a vector"),
1092 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1094 tr("Create a new vector"),
1095 0, aParent, false, this, SLOT(addVector()));
1097 // _addCylinder = createAction(_menuId++,
1098 // tr("Create a cylinder"),
1099 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1100 // tr("Add Cylinder"),
1101 // tr("Create a new cylinder"),
1102 // 0, aParent, false, this, SLOT(addCylinder()));
1104 // _addPipe = createAction(_menuId++,
1105 // tr("Create a pipe"),
1106 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1108 // tr("Create a new pipe"),
1109 // 0, aParent, false, this, SLOT(addPipe()));
1111 _makeGrid = createAction(_menuId++,
1113 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1116 0, aParent, false, this, SLOT(makeGrid()));
1118 _makeCylinder = createAction(_menuId++,
1119 tr("Make a cylinder"),
1120 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1121 tr("Make Cylinder"),
1122 tr("Make a cylinder"),
1123 0, aParent, false, this, SLOT(makeCylinder()));
1125 _makePipe = createAction(_menuId++,
1127 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1130 0, aParent, false, this, SLOT(makePipe()));
1132 _makeCylinders = createAction(_menuId++,
1133 tr("Make cylinders"),
1134 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1135 tr("Make Cylinders"),
1136 tr("Make cylinders"),
1137 0, aParent, false, this, SLOT(makeCylinders()));
1139 _makePipes = createAction(_menuId++,
1141 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1144 0, aParent, false, this, SLOT(makePipes()));
1146 _makeHemiSphere = createAction(_menuId++,
1147 tr("Make an hemisphere"),
1148 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1149 tr("Make Hemisphere"),
1150 tr("Make an hemisphere"),
1151 0, aParent, false, this, SLOT(makeHemiSphere()));
1153 // Pattern Data edition
1154 _removeHexa = createAction(_menuId++,
1155 tr("Remove hexahedra"),
1156 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1157 tr("Remove Hexahedra"),
1158 tr("Remove hexahedra"),
1159 0, aParent, false, this, SLOT(removeHexa()));
1161 _prismQuad = createAction(_menuId++,
1162 tr("Prism quadrangles"),
1163 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1164 tr("Prism Quadrangles"),
1165 tr("Prism quadrangles"),
1166 0, aParent, false, this, SLOT(prismQuad()));
1168 _joinQuad = createAction(_menuId++,
1169 tr("Join quadrangles"),
1170 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1171 tr("Join Quadrangles"),
1172 tr("Join quadrangles with hexahedra"),
1173 0, aParent, false, this, SLOT(joinQuad()));
1175 _merge = createAction(_menuId++,
1177 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1180 0, aParent, false, this, SLOT(merge()));
1182 _disconnect = createAction(_menuId++,
1184 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1186 tr("Disconnect edges, vertexes or quadrangles"),
1187 0, aParent, false, this, SLOT(disconnectElts()));
1189 _cutEdge = createAction(_menuId++,
1191 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1194 0, aParent, false, this, SLOT(cutEdge()));
1196 _makeTransformation = createAction(_menuId++,
1197 tr("Make transformation"),
1198 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1199 tr("Make Transformation"),
1200 tr("Make transformation"),
1201 0, aParent, false, this, SLOT(makeTransformation()));
1203 _makeSymmetry = createAction(_menuId++,
1204 tr("Make symmetry"),
1205 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1206 tr("Make Symmetry"),
1207 tr("Make symmetry"),
1208 0, aParent, false, this, SLOT(makeSymmetry()));
1210 _performTransformation = createAction(_menuId++,
1211 tr("Perform transformation"),
1212 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1213 tr("Perform Transformation"),
1214 tr("Perform transformation"),
1215 0, aParent, false, this, SLOT(performTransformation()));
1217 _performSymmetry = createAction(_menuId++,
1218 tr("Perform symmetry"),
1219 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1220 tr("Perform Symmetry"),
1221 tr("Perform symmetry"),
1222 0, aParent, false, this, SLOT(performSymmetry()));
1224 _replaceHexa = createAction(_menuId++,
1225 tr("Replace hexahedron"),
1226 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1227 tr("Replace Hexahedron"),
1228 tr("Replace hexahedron"),
1229 0, aParent, false, this, SLOT(replaceHexa()));
1231 _quadRevolution = createAction(_menuId++,
1232 tr("Quad revolution"),
1233 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1234 tr("Quad Revolution"),
1235 tr("Quad revolution"),
1236 0, aParent, false, this, SLOT(quadRevolution()));
1239 _assocVertex = createAction(_menuId++,
1240 tr("Make vertex association"),
1241 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1242 tr("Make Vertex association"),
1243 tr("Make vertex association"),
1244 0, aParent, false, this, SLOT(assocVertex()));
1246 _assocEdge = createAction(_menuId++,
1247 tr("Make edge association"),
1248 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1249 tr("Make Edge Association"),
1250 tr("Make edge association"),
1251 0, aParent, false, this, SLOT(assocEdge()));
1253 _assocQuad = createAction(_menuId++,
1254 tr("Make quad association"),
1255 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1256 tr("Make Quad Association"),
1257 tr("Make quad association"),
1258 0, aParent, false, this, SLOT(assocQuad()));
1261 _addGroup = createAction(_menuId++,
1263 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1266 0, aParent, false, this, SLOT(addGroup()));
1268 _removeGroup = createAction(_menuId++,
1269 tr("Remove a group"),
1270 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1272 tr("Remove a group"),
1273 0, aParent, false, this, SLOT(removeGroup()));
1276 _addLaw = createAction(_menuId++,
1278 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1281 0, aParent, false, this, SLOT(addLaw()));
1283 _removeLaw = createAction(_menuId++,
1285 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1288 0, aParent, false, this, SLOT(removeLaw()));
1290 _setPropagation = createAction(_menuId++,
1291 tr("Set propagation"),
1292 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1293 tr("Set Propagation"),
1294 tr("Set propagation"),
1295 0, aParent, false, this, SLOT(setPropagation()));
1297 _computeMesh = createAction(_menuId++,
1299 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1302 0, aParent, false, this, SLOT(computeMesh()));
1304 _showModelInfoAct = createAction(_menuId++,
1305 tr("Show Model Info"),
1306 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1309 0, aParent, false, this, SLOT(showModelInfo()));
1311 _addShapeAct = createAction(_menuId++,
1313 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1316 0, aParent, false, this, SLOT(addShape()));
1318 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1319 // QAction* createAction(const int id,
1320 // const QString& toolTip,
1321 // const QIcon& icon,
1322 // const QString& menu,
1323 // const QString& status,
1324 // const int shortCut,
1325 // QObject* parent =0,
1326 // bool checkable = false,
1327 // QObject* receiver =0,
1328 // const char* member =0);
1330 _sep1 = separator();
1331 _sep2 = separator();
1332 _sep3 = separator();
1333 _sep4 = separator();
1337 void HEXABLOCKGUI::createMenus()
1339 int aMenuId, subMenuId,aMenuIdMain;
1341 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1343 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1344 createMenu( actionId(_newAct), aMenuId );
1345 createMenu( actionId(_importAct), aMenuId );
1346 createMenu( _saveAct, aMenuId );
1349 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1350 createMenu( _newAct, aMenuDocId );//, 10
1351 createMenu( _importAct, aMenuDocId );
1352 createMenu( _saveAct, aMenuDocId );
1354 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1355 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1356 createMenu( _addVertex, subMenuId );
1357 createMenu( _addEdge, subMenuId );
1358 createMenu( _addQuad, subMenuId );
1359 createMenu( _addHexa, subMenuId );
1360 createMenu( _sep1, subMenuId);
1363 createMenu( _addVector, subMenuId );
1364 // createMenu( _addCylinder, subMenuId );
1365 // createMenu( _addPipe, subMenuId );
1367 createMenu( _sep2, subMenuId);
1369 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1370 createMenu( _makeHemiSphere,subMenuId );
1372 createMenu( _sep3, subMenuId);
1374 createMenu( _makeCylinder, subMenuId );
1375 createMenu( _makePipe, subMenuId );
1376 createMenu( _makeCylinders,subMenuId );
1377 createMenu( _makePipes, subMenuId );
1379 // Pattern Data Edition
1380 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1381 createMenu( _removeHexa, subMenuId );
1382 createMenu( _prismQuad, subMenuId );
1383 createMenu( _joinQuad, subMenuId );
1384 createMenu( _merge, subMenuId );
1385 createMenu( _disconnect, subMenuId );
1386 createMenu( _cutEdge, subMenuId );
1387 createMenu( _makeTransformation, subMenuId );
1388 createMenu( _makeSymmetry, subMenuId );
1389 createMenu( _performTransformation, subMenuId );
1390 createMenu( _performSymmetry, subMenuId );
1391 createMenu( _replaceHexa, subMenuId );
1392 createMenu( _quadRevolution, subMenuId );
1393 createMenu( _sep4, aMenuId );
1394 createMenu( _showModelInfoAct, aMenuId );
1397 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1398 createMenu( _addShapeAct, aMenuId );
1399 createMenu( _assocVertex, aMenuId );
1400 createMenu( _assocEdge, aMenuId );
1401 createMenu( _assocQuad, aMenuId );
1404 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1405 createMenu( _addGroup, aMenuId );
1406 createMenu( _removeGroup, aMenuId ); //CS_TODO
1409 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1410 createMenu( _addLaw, aMenuId );
1411 createMenu( _removeLaw, aMenuId );
1412 createMenu( _setPropagation, aMenuId );
1413 createMenu( _computeMesh, aMenuId );
1415 //show model infomation menu
1416 QString aRule = "$component={'HEXABLOCK'}";
1417 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1418 popupMgr()->setRule( _showModelInfoAct, aRule);
1420 //associate shape to a document menu
1421 popupMgr()->insert( _addShapeAct, -1, -1 );
1422 popupMgr()->setRule( _addShapeAct, aRule );
1424 //-------------------------------------------------
1426 //-------------------------------------------------
1427 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1428 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1429 // QString isNotEmpty("numberOfNodes <> 0");
1430 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1431 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1432 //// aType = aType.arg( mesh_part );
1434 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1435 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1436 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1438 // popupMgr()->insert( separator(), -1, -1 );
1439 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1440 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1441 // // MESSAGE("aClient = " << aClient.toStdString());
1442 // // MESSAGE("aType = " << aType.toStdString());
1443 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1444 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1445 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1446 // // MESSAGE("aRule = " << aRule.toStdString());
1447 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1448 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1450 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1451 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1453 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1454 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1456 // popupMgr()->insert( separator(), -1, -1 );
1460 void HEXABLOCKGUI::createTools()
1464 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1465 createTool( _newAct, aToolId );
1466 createTool( _importAct, aToolId );
1467 createTool( _saveAct, aToolId );
1468 createTool( _showModelInfoAct, aToolId );
1469 // createTool( _testAct, aToolId );
1470 //createTool( separator(), aToolId );
1473 aToolId = createTool ( tr( "Construction" ) );
1474 createTool( _addVertex, aToolId );
1475 createTool( _addEdge, aToolId );
1476 createTool( _addQuad, aToolId );
1477 createTool( _addHexa, aToolId );
1479 createTool( _sep1, aToolId );
1482 createTool( _addVector, aToolId );
1483 // createTool( _addCylinder, aToolId );
1484 // createTool( _addPipe, aToolId );
1486 createTool( _sep2, aToolId );
1488 createTool( _makeGrid, aToolId );
1489 createTool( _makeHemiSphere, aToolId );
1491 createTool( _sep3, aToolId );
1493 createTool( _makeCylinder, aToolId );
1494 createTool( _makePipe, aToolId );
1495 createTool( _makeCylinders,aToolId );
1496 createTool( _makePipes, aToolId );
1498 // Pattern Data Edition
1499 aToolId = createTool ( tr( "Operation" ) );
1500 createTool( _removeHexa, aToolId );
1501 createTool( _prismQuad, aToolId );
1502 createTool( _joinQuad, aToolId );
1503 createTool( _merge, aToolId );
1504 createTool( _disconnect, aToolId );
1505 createTool( _cutEdge, aToolId );
1506 createTool( _makeTransformation, aToolId );
1507 createTool( _makeSymmetry, aToolId );
1508 createTool( _performTransformation, aToolId );
1509 createTool( _performSymmetry, aToolId );
1510 createTool( _replaceHexa, aToolId );
1511 createTool( _quadRevolution, aToolId );
1514 aToolId = createTool ( tr( "Association" ) );
1515 createTool( _assocVertex, aToolId );
1516 createTool( _assocEdge, aToolId );
1517 createTool( _assocQuad, aToolId );
1518 createTool( _addShapeAct, aToolId );
1521 aToolId = createTool ( tr( "Group" ) );
1522 createTool( _addGroup, aToolId );
1523 createTool( _removeGroup, aToolId ); //CS_TODO
1526 aToolId = createTool ( tr( "Mesh" ) );
1527 createTool( _addLaw, aToolId );
1528 createTool( _removeLaw, aToolId );
1529 createTool( _setPropagation, aToolId );
1530 createTool( _computeMesh, aToolId );
1534 void HEXABLOCKGUI::initialMenus()
1536 showDocumentMenus( true );
1537 showPatternMenus( false );
1538 showAssociationMenus( false );
1539 showGroupsMenus( false );
1540 showMeshMenus( false );
1543 void HEXABLOCKGUI::showAllMenus()
1545 showDocumentMenus( true );
1546 showPatternMenus( true );
1547 showAssociationMenus( true );
1548 showGroupsMenus( true );
1549 showMeshMenus( true );
1553 void HEXABLOCKGUI::showDocumentMenus(bool show)
1555 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1557 setMenuShown(_newAct, show);
1558 setToolShown(_newAct, show);
1559 setMenuShown(_importAct, show);
1560 setToolShown(_importAct, show);
1561 setMenuShown(_showModelInfoAct, show);
1562 setToolShown(_showModelInfoAct, show);
1563 setMenuShown(_saveAct, show);
1564 setToolShown(_saveAct, show);
1567 void HEXABLOCKGUI::showPatternMenus(bool show)
1569 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1570 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1571 if ( show && !getCurrentModel() ) return;
1573 setMenuShown(_addVertex, show );
1574 setToolShown(_addVertex, show);
1575 setMenuShown(_addEdge, show );
1576 setToolShown(_addEdge, show);
1577 setMenuShown(_addQuad, show );
1578 setToolShown(_addQuad, show);
1579 setMenuShown(_addHexa, show );
1580 setToolShown(_addHexa, show);
1582 setMenuShown(_sep1, show );
1583 setToolShown(_sep1, show);
1585 setMenuShown( _addVector, show );
1586 setToolShown( _addVector, show);
1587 // setMenuShown( _addCylinder, show );
1588 // setToolShown( _addCylinder, show);
1589 // setMenuShown( _addPipe, show );
1590 // setToolShown( _addPipe, show);
1592 setMenuShown(_sep2, show );
1593 setToolShown(_sep2, show);
1595 setMenuShown( _makeGrid, show );
1596 setToolShown( _makeGrid, show);
1597 setMenuShown( _makePipe, show );
1598 setToolShown( _makePipe, show);
1600 setMenuShown(_sep3, show );
1601 setToolShown(_sep3, show);
1603 setMenuShown( _makeCylinder, show );
1604 setToolShown( _makeCylinder, show);
1605 setMenuShown( _makeCylinders, show );
1606 setToolShown( _makeCylinders, show);
1607 setMenuShown( _makePipes, show );
1608 setToolShown( _makePipes, show);
1609 setMenuShown( _makeHemiSphere, show );
1610 setToolShown( _makeHemiSphere, show);
1612 // Pattern Data Edition
1613 setMenuShown( _removeHexa, show );
1614 setToolShown( _removeHexa, show);
1615 setMenuShown( _prismQuad, show );
1616 setToolShown( _prismQuad, show);
1617 setMenuShown( _joinQuad, show );
1618 setToolShown( _joinQuad, show);
1619 setMenuShown( _merge, show );
1620 setToolShown( _merge, show);
1621 setMenuShown( _disconnect, show );
1622 setToolShown( _disconnect, show);
1623 setMenuShown( _cutEdge, show );
1624 setToolShown( _cutEdge, show);
1625 setMenuShown( _makeTransformation, show );
1626 setToolShown( _makeTransformation, show);
1627 setMenuShown( _makeSymmetry, show );
1628 setToolShown( _makeSymmetry, show);
1629 setMenuShown( _performTransformation, show );
1630 setToolShown( _performTransformation, show);
1631 setMenuShown( _performSymmetry, show );
1632 setToolShown( _performSymmetry, show);
1633 setMenuShown( _replaceHexa, show );
1634 setToolShown( _replaceHexa, show);
1635 setMenuShown( _quadRevolution, show );
1636 setToolShown( _quadRevolution, show);
1638 setMenuShown( _sep4, show );
1639 setMenuShown( _showModelInfoAct, show );
1643 void HEXABLOCKGUI::showAssociationMenus(bool show)
1645 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1646 if ( show && !getCurrentModel() ) return;
1648 // Association Edition
1649 setMenuShown( _assocVertex, show );
1650 setToolShown( _assocVertex, show );
1651 setMenuShown( _assocEdge, show );
1652 setToolShown( _assocEdge, show );
1653 setMenuShown( _assocQuad, show );
1654 setToolShown( _assocQuad, show );
1655 setMenuShown( _addShapeAct, show );
1656 setToolShown( _addShapeAct, show );
1660 void HEXABLOCKGUI::showGroupsMenus(bool show)
1662 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1663 if ( show && !getCurrentModel() ) return;
1664 setMenuShown( _addGroup, show );
1665 setToolShown( _addGroup, show);
1666 setMenuShown( _removeGroup , show );
1667 setToolShown( _removeGroup , show);
1670 void HEXABLOCKGUI::showMeshMenus(bool show)
1672 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1673 if ( show && !getCurrentModel() ) return;
1674 setMenuShown( _addLaw, show );
1675 setToolShown( _addLaw, show);
1676 setMenuShown( _removeLaw, show );
1677 setToolShown( _removeLaw, show);;
1678 setMenuShown( _setPropagation, show );
1679 setToolShown( _setPropagation, show);
1680 setMenuShown( _computeMesh, show);
1681 setToolShown( _computeMesh, show);
1684 void HEXABLOCKGUI::showActor()
1686 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1687 if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
1688 currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
1691 currentVtkGView->getViewWindow()->setFocus();
1692 currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
1693 currentVtkGView->update();
1694 currentVtkGView->getViewWindow()->onFitAll();
1696 //update the visibility state now
1697 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1698 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1699 if (aStudy == NULL || vman == NULL) return;
1701 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1702 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1703 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1706 //SOCC_Prs* currentPrs = NULL;
1707 void HEXABLOCKGUI::showOnlyActor()
1709 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1710 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1711 currentVtkGView->getDocumentActor() == NULL)
1713 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1714 if (vtkView == NULL)
1717 SUIT_ViewManager* vman = vtkView->getViewManager();
1718 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1720 //show only the current actor -----------------
1721 vtkView->setFocus();
1722 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1723 Document_Actor *lastDocActor, *currentDocActor = currentVtkGView->getDocumentActor();
1724 if (lastVtkDocGView != NULL)
1726 lastDocActor = lastVtkDocGView->getDocumentActor();
1727 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1728 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1730 vtkView->Erase(lastActorIO);
1731 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1732 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1735 currentVtkGView->update();
1736 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1737 if (!anIO.IsNull() && anIO->hasEntry())
1739 vtkView->Display(anIO);
1740 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1741 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1743 vtkView->onFitAll();
1745 // //showOnly in occ viewer -------------
1747 if (currentOccGView == NULL)
1749 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1750 if (occView == NULL)
1752 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1757 if (lastOccPrs != NULL)
1758 vf->Erase(lastOccPrs);
1759 currentOccGView->globalSelection();
1760 SOCC_Prs* prs = getOccPrs(currentDocGView);
1761 currentOccGView->setPrs(prs);
1764 occView->onFitAll();
1767 void HEXABLOCKGUI::hideActor()
1770 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1771 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1772 currentVtkGView->getViewWindow() == NULL ||
1773 currentVtkGView->getDocumentActor() == NULL) return;
1775 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1776 currentVtkGView->getViewWindow()->onResetView();
1778 //update the visibility state now
1779 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1780 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1781 if (aStudy == NULL || vman == NULL) return;
1783 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1784 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1785 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1788 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1789 DocumentModel* docModel = currentVtkGView->getDocumentModel();
1790 if (occView == NULL || docModel == NULL)
1792 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1797 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1798 if (currentOccPrs != NULL)
1799 vf->Erase(currentOccPrs);
1801 occView->onResetView();
1805 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1807 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1809 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1810 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1812 if (_dwPattern) _dwPattern->setVisible(isVisible);
1813 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1815 if (_dwMesh) _dwMesh->setVisible(isVisible);
1816 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1818 if (_dwGroups) _dwGroups->setVisible(isVisible);
1819 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1823 //clear all used dialogs by the current model
1824 void HEXABLOCKGUI::clearDialogs()
1826 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1827 fin (currentModelDialogs.end());
1828 for(;debut!=fin;++debut) (*debut)->clear();
1830 currentModelDialogs.clear(); //empty the used dialogs list
1833 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1835 if (!gViewDlgBox.contains(dgview)) return NULL;
1836 return gViewDlgBox[dgview];
1839 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1841 if (dgview == NULL) return;
1843 switchOffGraphicView(dgview, false); //to avoid double connect
1846 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1847 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1848 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1849 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1850 connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1851 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1852 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1853 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1854 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1855 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1856 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1857 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1862 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1864 if (dgview == NULL) return;
1866 //disconnect signals
1867 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1868 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1869 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1870 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1871 disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1872 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1873 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1874 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1875 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1876 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1877 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1878 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1881 gViewDlgBox[dgview] = currentDialog;
1883 //close opened dialog
1884 if (currentDialog != NULL) currentDialog->close();
1885 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1891 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1893 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1897 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1901 //switch off the current document graphic view (disconnect signals...)
1902 if (currentDocGView != NULL)
1904 //Hide current actor
1906 switchOffGraphicView(currentDocGView);
1909 //clear the dialogs used by the current model so they can be used by the new model
1910 if (currentDocGView != dgview) clearDialogs();
1912 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1913 _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1914 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1915 _groupsTreeView->setModel(dgview->getGroupsModel());
1916 _meshTreeView->setModel(dgview->getMeshModel());
1918 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1919 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1921 _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1922 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1924 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1925 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1927 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1928 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1930 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1931 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1934 // = * init occ view * =
1935 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1937 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1938 currentOccGView->getViewWindow()->installEventFilter(this);
1943 // = * init vtk view * =
1944 if (currentDocGView != NULL)
1946 if (currentDocGView->getViewWindow() != NULL)
1947 dgview->setViewWindow(currentDocGView->getViewWindow());
1950 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1951 dgview->getViewWindow()->installEventFilter(this);
1957 switchOnGraphicView(dgview);
1959 if (currentDocGView != NULL)
1961 lastVtkDocGView = currentDocGView;
1962 lastOccPrs = getOccPrs(currentDocGView);
1966 lastVtkDocGView = dgview;
1967 lastOccPrs = getOccPrs(dgview);
1970 currentDocGView = dgview;
1972 currentDocGView->getDocumentModel()->refresh();
1973 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1977 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1979 if (currentDocGView == NULL) return NULL;
1980 return currentDocGView->getDocumentModel();
1984 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1986 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1987 if (anApp == NULL) return UNKNOWN;
1988 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1989 if (activeVm == NULL) return UNKNOWN;
1991 QString vmType = activeVm->getType();
1992 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1994 else if ( vmType == OCCViewer_Viewer::Type() )
2000 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2002 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2006 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2009 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2011 // Create Document from HEXABLOCK ENGINE
2012 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2013 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2015 // looking doc impl ( c++ )
2016 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2017 // ^Hexa6 ASSERT( dServant );
2018 // ^Hexa6 if ( dServant)
2019 // ^Hexa6 doc = dServant->GetImpl();
2021 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2022 QString docEntry = addDocInStudy (doc);
2024 // looking for docEntry
2025 /* ****************************************************************
2026 if ( !CORBA::is_nil(docIn) ){
2027 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2028 QString docIOR = anIOR.in();
2029 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2030 if ( !docIOR.isEmpty() ) {
2031 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2033 docEntry = SO->GetID().c_str();
2036 **************************************************************** */
2037 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2039 return make_pair (docEntry, doc);
2043 void HEXABLOCKGUI::newDocument()
2045 DEBTRACE("HEXABLOCKGUI::newDocument");
2048 QMainWindow *aParent = application()->desktop();
2049 QWidget *central = aParent->centralWidget();
2051 central->setFocus();
2053 DEBTRACE("No Central Widget");
2056 if (currentOccGView == NULL)
2058 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2059 application()->desktop());
2060 currentOccGView->getViewWindow()->installEventFilter(this);
2062 else if (currentOccGView->getViewWindow() == NULL)
2064 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2065 currentOccGView->getViewWindow()->installEventFilter(this);
2069 // Create Document from HEXABLOCK ENGINE
2070 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2072 VtkDocumentGraphicView* newGraphicView = NULL;
2073 //One document at a time
2074 if (currentDocGView != NULL)
2076 if (currentDocGView->getViewWindow() == NULL)
2078 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2079 currentDocGView->getViewWindow()->installEventFilter(this);
2082 // Create a new document with the current window
2083 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2084 new DocumentModel( docEntry_Doc.second,
2085 docEntry_Doc.first, this ),
2086 currentDocGView->getViewWindow(),
2087 application()->desktop() );
2091 // Create the new Document Graphic View with a new window
2092 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2093 new DocumentModel( docEntry_Doc.second,
2094 docEntry_Doc.first, this ),
2095 graphicViewsHandler->createVtkWindow(),
2096 application()->desktop() );
2097 newGraphicView->getViewWindow()->installEventFilter(this);
2100 if (newGraphicView == NULL)
2101 //We couldn't create a new document graphic view
2102 //we'd better show a dialog box info to inform the user
2105 docs[docEntry_Doc.first] = newGraphicView;
2106 switchModel(newGraphicView); //select the corresponding document in the browser instead
2108 getApp()->updateObjectBrowser();
2113 //Loads the model from the xmlFile in the current graphic view
2114 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2116 DEBTRACE("HEXABLOCKGUI::loadDocument");
2119 QMainWindow *aParent = application()->desktop();
2120 QString selectedFile;
2122 if ( inFile.isNull() ){
2123 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2124 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2125 dialog.setHistory( getQuickDirList() );
2127 //use the last path as default
2128 if (!(loadDocLastPath->absolutePath()).isEmpty())
2129 dialog.setDirectory(*loadDocLastPath);
2132 QStringList selectedFiles = dialog.selectedFiles();
2133 if (!selectedFiles.isEmpty())
2134 selectedFile = selectedFiles.first();
2136 //remember the selected path
2137 *loadDocLastPath = dialog.directory();
2140 selectedFile = inFile;
2142 if (selectedFile.isEmpty())
2145 //we create a new document if necessary
2146 if (currentDocGView == NULL)
2147 //Need a new document
2149 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2151 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2152 currentDocGView->getViewWindow()->installEventFilter(this);
2155 if (!currentDocGView->isEmpty())
2156 //we can only have one document for a graphic view
2159 //we load the selected file in the current graphic view
2160 currentDocGView->loadDocument(selectedFile);
2161 DocumentModel* currentModel = getCurrentModel();
2162 renameObject( currentModel->documentEntry(), currentModel->getName() );
2167 void HEXABLOCKGUI::saveDocument()
2169 QMainWindow *aParent = application()->desktop();
2171 QString aDocName = "document", aFilename;
2173 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2174 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2176 //use the last selected directory as default path for file selection
2177 aFilename = saveDocLastPath->absolutePath();
2178 if (!aFilename.isEmpty())
2179 aFilename += QString("/") + aDocName;
2181 //show the dialog for file selection
2182 aFilename = SUIT_FileDlg::getFileName( aParent,
2185 tr( "Save HexaBlock Document" ),
2188 //save the document in the selected file
2189 if ( !aFilename.isEmpty() ) {
2190 getCurrentVtkGraphicView()->saveDocument( aFilename );
2192 //Remember the path for next save
2193 QFileInfo fileInfo(aFilename);
2194 *saveDocLastPath = fileInfo.dir();
2200 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2202 _patternDataTreeView->openPersistentEditor( topLeft );
2205 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2207 if (diag == NULL || _dwInputPanel == NULL ||
2208 getCurrentVtkGraphicView() == NULL) return;
2210 //mark this dialog as used by the current model
2211 currentModelDialogs.insert(diag);
2213 //close the current dialog box info
2214 if (_treeViewDelegate != NULL)
2215 _treeViewDelegate->closeDialog();
2217 if (_dwInputPanel->widget())
2218 _dwInputPanel->widget()->close();
2220 //Temporary for debugging EdgeAssoc Faked InfoDialog
2221 if (diag == _edgeAssocDiag)
2222 diag->debugEdgeAssoc = true;
2224 diag->debugEdgeAssoc = false;
2226 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2227 diag == _quadAssocDiag || diag == _addShapeDiag)
2228 assocInProgress = true;
2230 assocInProgress = false;
2232 //show the dialog box in the dockwidget
2233 diag->resetSizeAndShow(_dwInputPanel);
2235 //clear the current selections
2236 selectionMgr()->clearSelected();
2238 currentDialog = diag;
2242 void HEXABLOCKGUI::addVertex()
2244 if ( !_vertexDiag ){
2245 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2247 _showDialogBox( _vertexDiag );
2250 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2251 if (_vertexDiag != NULL && doc != NULL)
2252 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2255 void HEXABLOCKGUI::addEdge()
2258 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2260 _showDialogBox( _edgeDiag );
2263 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2264 if (_edgeDiag != NULL && doc != NULL)
2265 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2268 void HEXABLOCKGUI::addQuad()
2271 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2274 _showDialogBox( _quadDiag );
2277 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2278 if (_quadDiag != NULL && doc != NULL)
2279 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2282 void HEXABLOCKGUI::addHexa()
2285 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2287 _showDialogBox( _hexaDiag );
2290 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2291 if (_hexaDiag != NULL && doc != NULL)
2292 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2295 void HEXABLOCKGUI::addVector()
2297 if ( !_vectorDiag ){
2298 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2300 _showDialogBox( _vectorDiag );
2303 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2304 if (_vectorDiag != NULL && doc != NULL)
2305 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2308 void HEXABLOCKGUI::addCylinder()
2310 if ( !_cylinderDiag ){
2311 _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2313 _showDialogBox( _cylinderDiag );
2316 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2317 if (_cylinderDiag != NULL && doc != NULL)
2318 _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2322 void HEXABLOCKGUI::addPipe()
2325 _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2327 _showDialogBox( _pipeDiag );
2330 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2331 if (_pipeDiag != NULL && doc != NULL)
2332 _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2336 void HEXABLOCKGUI::makeGrid()
2338 if ( !_makeGridDiag ){
2339 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2341 _showDialogBox( _makeGridDiag );
2345 void HEXABLOCKGUI::makeCylinder()
2347 if ( !_makeCylinderDiag ){
2348 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2350 _showDialogBox( _makeCylinderDiag );
2353 void HEXABLOCKGUI::makePipe()
2355 if ( !_makePipeDiag ){
2356 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2358 _showDialogBox( _makePipeDiag );
2361 void HEXABLOCKGUI::makeCylinders()
2363 if ( !_makeCylindersDiag ){
2364 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2366 _showDialogBox( _makeCylindersDiag );
2369 void HEXABLOCKGUI::makePipes()
2371 if ( !_makePipesDiag ){
2372 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2374 _showDialogBox( _makePipesDiag );
2378 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2380 if ( !_makeHemiSphereDiag ){
2381 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2383 _showDialogBox( _makeHemiSphereDiag );
2387 void HEXABLOCKGUI::removeHexa()
2389 if ( !_removeHexaDiag ){
2390 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2392 _showDialogBox( _removeHexaDiag );
2396 void HEXABLOCKGUI::prismQuad()
2398 if ( !_prismQuadDiag ){
2399 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2401 _showDialogBox( _prismQuadDiag );
2405 void HEXABLOCKGUI::joinQuad()
2407 if ( !_joinQuadDiag ){
2408 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2410 _showDialogBox( _joinQuadDiag );
2413 void HEXABLOCKGUI::merge()
2416 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2418 _showDialogBox( _mergeDiag );
2421 void HEXABLOCKGUI::disconnectElts()
2423 if ( !_disconnectDiag ){
2424 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2426 _showDialogBox( _disconnectDiag );
2429 void HEXABLOCKGUI::cutEdge()
2431 if ( !_cutEdgeDiag ){
2432 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2434 _showDialogBox( _cutEdgeDiag );
2437 void HEXABLOCKGUI::makeTransformation()
2439 if ( !_makeTransformationDiag ){
2440 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2442 _showDialogBox( _makeTransformationDiag );
2446 void HEXABLOCKGUI::makeSymmetry()
2448 if ( !_makeSymmetryDiag ){
2449 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2451 _showDialogBox( _makeSymmetryDiag );
2455 void HEXABLOCKGUI::performTransformation()
2457 if ( !_performTransformationDiag ){
2458 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2460 _showDialogBox( _performTransformationDiag );
2464 void HEXABLOCKGUI::performSymmetry()
2466 if ( !_performSymmetryDiag ){
2467 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2469 _showDialogBox( _performSymmetryDiag );
2473 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2475 if ( !_replaceHexaDiag ){
2476 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2478 _showDialogBox( _replaceHexaDiag );
2482 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2484 if ( !_quadRevolutionDiag ){
2485 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2487 _showDialogBox( _quadRevolutionDiag );
2491 void HEXABLOCKGUI::assocVertex()
2493 if (!_dwInputPanel) return;
2494 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2495 if ( !_vertexAssocDiag )
2496 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2497 _showDialogBox( _vertexAssocDiag );
2501 void HEXABLOCKGUI::assocEdge()
2503 if ( !_edgeAssocDiag )
2504 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2505 _showDialogBox( _edgeAssocDiag );
2508 void HEXABLOCKGUI::assocQuad()
2510 if ( !_quadAssocDiag )
2511 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2512 _showDialogBox( _quadAssocDiag );
2516 void HEXABLOCKGUI::addGroup()
2519 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2521 _showDialogBox( _groupDiag );
2522 if (_groupDiag != NULL && getCurrentModel() != NULL)
2524 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2525 if (doc == NULL) return;
2526 char defaultName[16];
2527 sprintf (defaultName, "g%04d", doc->countGroup());
2528 _groupDiag->name_le->setText(defaultName);
2532 void HEXABLOCKGUI::removeGroup()
2534 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2535 if (currentDGView == NULL) return;
2537 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2538 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2539 int nbGroupsRemoved = 0;
2542 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2543 tr( "No group selected!" ) );
2547 foreach( QModelIndex selected, l ){
2548 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2549 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2550 Q_ASSERT(selected.isValid());
2552 //Confirm the deletion of the group
2553 if (SUIT_MessageBox::question(
2556 tr("Remove group : %1 ?").arg(selected.data().toString()),
2557 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2558 SUIT_MessageBox::Cancel
2559 ) == SUIT_MessageBox::Cancel) return;
2561 bool removed = getCurrentModel()->removeGroup( selected );
2563 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2564 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2570 if (!nbGroupsRemoved)
2571 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2572 tr( "No group selected!" ) );
2575 void HEXABLOCKGUI::addLaw()
2578 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2580 _showDialogBox( _lawDiag );
2581 if (_lawDiag != NULL && getCurrentModel() != NULL)
2583 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2584 if (doc == NULL) return;
2585 char defaultName[16];
2586 sprintf (defaultName, "l%04d", doc->countLaw());
2587 _lawDiag->name_le->setText(defaultName);
2591 void HEXABLOCKGUI::removeLaw()
2593 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2594 if (currentDGView == NULL) return;
2596 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2597 int nbLawsRemoved = 0;
2600 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2601 tr( "No law selected!" ) );
2605 foreach( QModelIndex selected, l ){
2606 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2607 selected = currentDGView->getMeshModel()->mapToSource( selected );
2608 Q_ASSERT(selected.isValid());
2610 //Confirm the deletion of the law
2611 if (SUIT_MessageBox::question(
2614 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2615 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2616 SUIT_MessageBox::Cancel
2617 ) == SUIT_MessageBox::Cancel) return;
2619 bool removed = getCurrentModel()->removeLaw(selected);
2621 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2622 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2629 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2630 tr( "No law selected!" ) );
2635 void HEXABLOCKGUI::setPropagation()
2637 if ( !_propagationDiag ){
2638 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2640 _showDialogBox( _propagationDiag );
2643 // Dialog box to compute a mesh from a document
2644 // --------------------------------------------
2645 void HEXABLOCKGUI::computeMesh()
2647 if ( !_computeMeshDiag ){
2648 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2650 _computeMeshDiag->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
2651 _showDialogBox( _computeMeshDiag );
2654 void HEXABLOCKGUI::clearAssociations()
2656 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2657 if (currentDGView == NULL) return;
2659 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2660 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2661 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2663 getCurrentModel()->clearEltAssociations(iModel);
2665 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2668 void HEXABLOCKGUI::showModelInfo()
2670 //create the info dialog if not yet
2671 if (_modelInfoDiag == NULL)
2672 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2674 //show the model informations dialog
2675 _showDialogBox( _modelInfoDiag );
2678 void HEXABLOCKGUI::addShape()
2680 //create the info dialog if not yet
2681 if (_addShapeDiag == NULL)
2682 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2684 //show the model informations dialog
2685 _showDialogBox( _addShapeDiag );
2688 void HEXABLOCKGUI::clearAllAssociations()
2690 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2691 if (currentDGView == NULL) return;
2693 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2694 if (!currentIndex.isValid()) return;
2695 QVariant currentAssocVariant;
2696 QString currentAssocEntry;
2698 //Confirm the deletion of the associations
2699 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2700 if ( !treeVariant.isValid() ) return;
2701 int eltType = treeVariant.toInt();
2702 QString typeStr = "";
2703 HEXA_NS::EnumElt hexaType;
2704 if (eltType == VERTEX_DIR_TREE)
2706 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2707 hexaType = HEXA_NS::EL_VERTEX;
2709 else if (eltType == EDGE_DIR_TREE)
2711 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2712 hexaType = HEXA_NS::EL_EDGE;
2714 else if (eltType == QUAD_DIR_TREE)
2716 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2717 hexaType = HEXA_NS::EL_QUAD;
2720 if (SUIT_MessageBox::question(
2722 tr("CLEAR_ASSOCIATIONS"),
2723 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2724 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2725 SUIT_MessageBox::Cancel
2726 ) == SUIT_MessageBox::Cancel) return;
2729 DocumentModel* docModel = getCurrentModel();
2730 if (docModel == NULL) return;
2731 docModel->clearAssociation(hexaType);
2734 void HEXABLOCKGUI::showAssociations()
2736 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2737 if (currentDGView == NULL) return;
2739 QModelIndexList elts;
2740 int currentChildIndex = 0;
2741 QVariant currentAssocVariant;
2742 QString currentAssocEntry;
2743 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2744 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2746 while( currentChild.isValid() ) {
2748 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2749 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2750 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2751 elts << currentChild;
2753 currentChild = currentChild.sibling(currentChildIndex++, 0);
2755 currentDocGView->highlight(elts);
2756 currentOccGView->highlight(elts, false);
2760 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2762 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2764 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2769 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2771 if ( event->type() == QEvent::Enter )
2772 { // *** ENTER EVENT
2774 if (currentDialog == NULL || !currentDialog->isVisible())
2775 return QObject::eventFilter(obj, event);
2777 // ** The window acquire the focus when the cursor enter
2779 //OCC - window enter
2780 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2781 if ( occWindow != NULL)
2782 currentDialog->onWindowActivated(occWindow->getViewManager());
2784 //VTK - window enter
2786 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2787 if ( vtkWindow != NULL)
2788 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2792 //standard event processing
2793 return QObject::eventFilter(obj, event);
2796 QStringList HEXABLOCKGUI::getQuickDirList()
2798 QStringList dirList;
2799 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2801 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2807 // --- Export the module
2811 HEXABLOCKGUI_EXPORT CAM_Module* createModule()
2813 return new HEXABLOCKGUI();
2816 HEXABLOCKGUI_EXPORT char* getModuleVersion()
2818 return (char*)HEXABLOCK_VERSION_STR;
2824 // ******************** TESTS ***************************************************
2826 void HEXABLOCKGUI::testDocument()
2830 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2831 // QStandardItem *myItem = new QStandardItem("MyItem");
2832 // parentItem->appendRow(myItem);
2834 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2835 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2836 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2837 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2838 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2839 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2840 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2841 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2844 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2845 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2846 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2847 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2848 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2849 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2851 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2852 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2853 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2854 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2859 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2860 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2861 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2862 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2870 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2871 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2873 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2874 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2878 // newMesh( "toto", 3, "FactoryServer");
2882 void HEXABLOCKGUI::test_make_cart_grid()
2884 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2885 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2886 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2887 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2888 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2889 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2891 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
2892 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
2899 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
2900 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
2901 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
2902 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
2903 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
2904 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
2909 void HEXABLOCKGUI::test_make_elmts_transform()
2916 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
2917 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
2920 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
2921 // orig.setScalar(2);
2923 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
2924 // getCurrentModel()->saveVtk(file_name)
2926 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
2927 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
2929 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
2930 // getCurrentModel()->saveVtk(file_name)
2932 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
2935 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
2936 // getCurrentModel()->saveVtk(file_name);
2939 // print "...test make elements by transforming elements OK"
2941 // =============================================================== addDocInSudy
2942 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
2946 if (document == NULL)
2949 QString docName = document->getName ();
2951 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
2952 if (app_study == NULL)
2955 _PTR(Study) study = app_study->studyDS();
2956 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
2957 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
2958 QString entry = app_study->centry("HEXABLOCK");
2959 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
2960 if (aFatherSO->_is_nil())
2963 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
2966 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
2967 docEntry = aSO->GetID(); //the entry of the published object
2972 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
2974 void HEXABLOCKGUI::test()
2976 DEBTRACE("HEXABLOCKGUI::test");
2977 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2978 if (currentDGView == NULL) return;
2979 currentDGView->update();
2983 void HEXABLOCKGUI::test_association()
2985 DEBTRACE("HEXABLOCKGUI::test_association");
2988 QModelIndex v0, v1, v2, v3, e0, e1, q0;
2990 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
2991 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
2992 DocumentModel::GeomObj q0AssocA, q0AssocB;
2994 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
2995 QList<DocumentModel::GeomObj> e1Assocs_test;
2996 DocumentModel::GeomObj q0Assoc_test;
2998 v0 = getCurrentModel()->addVertex(0, 0, 0);
2999 v1 = getCurrentModel()->addVertex(1, 0, 0);
3000 v2 = getCurrentModel()->addVertex(1, 1, 0);
3001 v3 = getCurrentModel()->addVertex(0, 1, 0);
3002 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3003 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3004 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3007 // >>> face3.GetEntry()'0:1:4'
3008 // >>> e1.GetEntry()'0:1:8'
3009 // >>> e2.GetEntry()'0:1:9'
3010 // >>> e3.GetEntry()'0:1:10'
3011 // >>> e4.GetEntry()'0:1:11'
3012 // >>> v1.GetEntry()'0:1:12'
3013 // >>> v2.GetEntry()'0:1:13'
3014 // >>> v3.GetEntry()'0:1:14'
3015 // >>> v4.GetEntry()'0:1:15'
3018 // v0Assoc.name = "geomV0";
3019 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3020 // v0Assoc.brep = "brepV0";
3021 // v1Assoc.name = "geomV1";
3022 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3023 // v1Assoc.brep = "brepV1";
3024 // v2Assoc.name = "geomV2";
3025 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3026 // v2Assoc.brep = "brepV2";
3027 // v3Assoc.name = "geomV3";
3028 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3029 // v3Assoc.brep = "brepV3";
3033 // e0AssocA.name = "geomE0a";
3034 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3035 // e0AssocA.brep = "brepE0a";
3036 // e0AssocA.start = 0.10;
3037 // e0AssocA.end = 0.95;
3041 // e1AssocA.name = "geomE1a";
3042 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3043 // e1AssocA.brep = "brepE1a";
3044 // e1AssocA.start = 0.12;
3045 // e1AssocA.end = 0.89;
3046 // e1AssocB.name = "geomE1b";
3047 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3048 // e1AssocB.brep = "brepE1b";
3049 // e1AssocB.start = 0.20;
3050 // e1AssocB.end = 0.80;
3051 // e1AssocC.name = "geomE1c";
3052 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3053 // e1AssocC.brep = "brepE1c";
3054 // e1AssocC.start = 0.16;
3055 // e1AssocC.end = 0.96;
3057 // q0AssocA.name = "geomQuad";
3058 // q0AssocA.entry = "0:1:1:1:3";
3059 // q0AssocA.brep = "brepq0";
3061 // q0AssocB.name = "geomQuad";
3062 // q0AssocB.entry = "0:1:1:1:4";
3063 // q0AssocB.brep = "brepq0";
3065 // getCurrentModel()->addAssociation( v0, v0Assoc );
3066 // getCurrentModel()->addAssociation( v1, v1Assoc );
3067 // getCurrentModel()->addAssociation( v2, v2Assoc );
3068 // getCurrentModel()->addAssociation( v3, v3Assoc );
3071 // getCurrentModel()->addAssociation( e0, e0AssocA );
3073 // getCurrentModel()->addAssociation( e1, e1AssocA );
3074 // getCurrentModel()->addAssociation( e1, e1AssocB );
3075 // getCurrentModel()->addAssociation( e1, e1AssocC );
3077 // getCurrentModel()->addAssociation( q0, q0AssocA );
3078 // getCurrentModel()->addAssociation( q0, q0AssocB );
3084 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3085 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3086 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3087 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3088 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3089 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3090 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3091 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3092 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3093 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3094 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3095 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3098 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3099 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3100 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3101 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3102 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3103 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3104 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3105 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3106 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3107 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3108 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3109 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3110 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3112 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3113 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3114 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3117 DEBTRACE("HEXABLOCKGUI::test_association fin");