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 <V3d_PerspectiveView.hxx>
112 #include <V3d_AmbientLight.hxx>
113 #include <V3d_DirectionalLight.hxx>
114 #include <Xw_Window.hxx>
115 #include <V3d_TypeOfShadingModel.hxx>
116 #include <TCollection_ExtendedString.hxx>
118 #include <BRepAlgoAPI_Fuse.hxx>
120 #include <AIS_ListIteratorOfListOfInteractive.hxx>
123 #define DW_MINIMUM_WIDTH 50
124 #define DWINPUT_MINIMUM_HEIGHT 50
125 #define DWINPUT_MINIMUM_WIDTH 50//255
128 using namespace HEXABLOCK::GUI;
130 int HEXABLOCKGUI::_oldStudyId = -1;
132 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
134 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
135 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
136 bool HEXABLOCKGUI::assocInProgress = false;
137 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
139 HEXABLOCKGUI::HEXABLOCKGUI() :
140 SalomeApp_Module( "HEXABLOCK" ),
148 _patternDataTreeView(0),
149 _patternBuilderTreeView(0),
150 _patternGeomTreeView(0),
153 _treeViewDelegate(0),
155 moduleActivatedOnce(false),
164 _makeCylinderDiag(0),
166 _makeCylindersDiag(0),
174 _makeTransformationDiag(0),
175 _makeSymmetryDiag(0),
176 _performTransformationDiag(0),
177 _performSymmetryDiag(0),
186 _quadRevolutionDiag(0),
187 _makeHemiSphereDiag(0),
188 _modelInfoDiag(NULL),
192 lastVtkDocGView(NULL)
194 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
196 graphicViewsHandler = new GraphicViewsHandler();
197 loadDocLastPath = new QDir();
198 saveDocLastPath = new QDir();
199 hexa_root = HEXA_NS::Hex::getInstance ();
202 HEXABLOCKGUI::~HEXABLOCKGUI()
207 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
209 SUIT_Application* app = SUIT_Session::session()->activeApplication();
211 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
217 // Gets an reference to the module's engine
218 /****************************************************
219 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
221 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
222 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
223 ASSERT(!CORBA::is_nil(clr));
226 **************************************************** */
228 void HEXABLOCKGUI::initialize( CAM_Application* app )
230 DEBTRACE("HEXABLOCKGUI::initialize");
231 SalomeApp_Module::initialize( app );
233 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
235 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
237 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
238 setResource(aResourceMgr);
240 createAndFillDockWidget();
247 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
249 DEBTRACE("HEXABLOCKGUI::viewManagers");
250 // list.append( QxScene_Viewer::Type() );
251 // list.append( OCCViewer_Viewer::Type() );
252 // list.append( SVTK_Viewer::Type() );
256 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
258 DEBTRACE("HEXABLOCKGUI::activateModule");
260 /*HexaBlock can be launched in only one application*/
261 if (myApplication == NULL)
262 //remember the first application
263 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
265 //application verification: if it's not the one known by HexaBlock,
266 //leave without activating
267 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
268 if (myApplication != currentApplication) return false;
270 bool bOk = SalomeApp_Module::activateModule( theStudy );
271 if ( !bOk ) return false;
273 showDockWidgets(true);
275 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
276 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
277 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
278 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
280 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
282 SUIT_ViewManager* vm;
283 ViewManagerList OCCViewManagers, VTKViewManagers;
285 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
286 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
287 while ( itOCC.hasNext() && (vm = itOCC.next()) )
288 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
290 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
291 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
292 while ( itVTK.hasNext() && (vm = itVTK.next()) )
293 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
296 SALOME_ListIO selected;
297 sm->selectedObjects( selected );
300 // disable OCC selectors
301 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
302 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
303 while ( itOCCSel.hasNext() )
304 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
305 sr->setEnabled(true);
307 // disable VTK selectors
308 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
309 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
310 while ( itVTKSel.hasNext() )
311 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
312 sr->setEnabled(true);
314 sm->setSelectedObjects( selected, true ); //NPAL 19674
316 //connect close signal to vtk view manager
317 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
320 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
321 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
324 //connect close signal to occ view manager
325 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
328 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
329 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
332 /* ************************************ TODO Hexa6
333 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
334 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
335 if ( _PTR(Study) aStudy = s->studyDS()) {
336 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
337 updateObjBrowser(); // objects can be removed
339 ************************************ */
341 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
342 currentOccGView->getViewWindow()->installEventFilter(this);
344 if (currentDocGView != NULL)
346 switchModel(currentDocGView);
349 if (currentDocGView->getViewWindow() != NULL)
350 currentDocGView->getViewWindow()->installEventFilter(this);
359 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
361 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
362 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
363 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
364 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
366 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
367 if ( vtkView != NULL)
369 //default selectionMode in VTKView
370 vtkView->SetSelectionMode( ActorSelection );
371 vtkView->removeEventFilter(this);
375 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
378 //defaut selectionMode in OccView
379 selectionMgr()->clearSelected();
380 currentOccGView->globalSelection();
381 occView->removeEventFilter(this);
385 qDeleteAll(myOCCSelectors);
386 myOCCSelectors.clear();
387 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
389 qDeleteAll(myVTKSelectors);
390 myVTKSelectors.clear();
391 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
393 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
395 //switch off current document graphic view
396 switchOffGraphicView(currentDocGView);
399 setMenuShown( false );
400 setToolShown( false );
401 showDockWidgets( false );
403 _dwInputPanel->close();
410 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
412 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
413 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
414 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
415 int aStudyID = theStudy->StudyId();
416 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
417 return aDSStudy._retn();
420 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
421 QMap<QString, QString>& docShapesEntry,
422 QMap<QString, QString>& docShapesName)
424 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
425 return; //there's nothing to publish in this case
427 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
428 if(!appStudy) return;
429 _PTR(Study) aStudy = appStudy->studyDS();
430 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
431 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
432 QString entry = currentDocGView->getDocumentModel()->documentEntry();
433 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
434 if (aFatherSO->_is_nil())
437 // * get a presentation
438 bool isNewPrs = false;
439 SOCC_Prs* prs = getOccPrs(currentDocGView);
442 prs = new SOCC_Prs();
446 // * init the presentation with the given shapes
447 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
448 while (i != topo_shapes.constEnd())
450 QString shapeName = i.key();
451 TopoDS_Shape shapeValue = i.value();
452 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
453 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
454 QString objStudyEntry = aSO->GetID(); //the entry of the published object
455 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
456 "HEXABLOCK", shapeName.toStdString().c_str());
457 ais_shape->SetOwner(io);
458 prs->AddObject(ais_shape);
459 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
460 docShapesEntry[shapeName] = objStudyEntry;
461 docShapesName[objStudyEntry] = shapeName;
462 currentOccGView->addShape(objStudyEntry, ais_shape);
463 i++; //handle next shape
467 prs->AddObject(currentOccGView->getPreviewShape());
469 occPrs[currentDocGView] = prs;
470 getApp()->updateObjectBrowser();
475 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
477 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
478 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
479 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
481 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
485 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
489 // Pas de renommage des shapes pour le moment, juste les documents
490 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
491 if (dgview == NULL || dgview->getDocumentModel() == NULL)
494 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
495 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
500 _PTR(Study) aStudy = appStudy->studyDS();
505 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
506 _PTR(GenericAttribute) anAttr;
508 if ( obj->FindAttribute(anAttr, "AttributeName") ){
509 _PTR(AttributeName) aName (anAttr);
510 DocumentModel* docModel = dgview->getDocumentModel();
511 docModel->setName( name );
512 aName->SetValue( name.toLatin1().data() );
513 getApp()->updateObjectBrowser();
514 _dwPattern->setWindowTitle( name );
521 // --- Default windows
522 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
524 DEBTRACE("HEXABLOCKGUI::windows");
526 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
527 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
530 QString HEXABLOCKGUI::engineIOR() const
532 DEBTRACE("HEXABLOCKGUI::engineIOR");
534 /* ************************************ TODO Hexa6
535 CORBA::ORB_var anORB = getApp()->orb();
536 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
537 return QString( anIOR.in() );
538 ************************************ */
542 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
544 if (docs.count(studyObject->entry()) == 0)
546 //Object's document not acquired yet
547 VtkDocumentGraphicView* dgview;
548 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
549 if (directory == NULL)
550 return NULL; //No working director found
552 //------------------ Load the document -----------------
553 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
554 if (document == NULL)
555 return NULL; //No document found
557 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
559 MESSAGE("Doc model creation failed!");
562 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
563 if (dgview == NULL) return NULL;
565 //update the data tree
566 docs[studyObject->entry()] = dgview;
569 return docs[studyObject->entry()];
572 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
574 // ** we want to switch automatically to the right view windows
576 //first, find selected item
578 DataObjectList dol = getApp()->objectBrowser()->getSelected();
579 if (dol.isEmpty()) return;
580 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
581 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
582 item->entry().isEmpty())
585 // find the document corresponding to it
586 VtkDocumentGraphicView* docGView = NULL;
587 if (docs.contains(item->entry()))
588 docGView = docs[item->entry()];
590 docGView = getOrCreateDocument(item);
592 //Init OCC if necessary
593 if (currentOccGView == NULL)
595 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
596 currentOccGView->getViewWindow()->installEventFilter(this);
598 else if (currentOccGView->getViewWindow() == NULL)
600 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
601 currentOccGView->getViewWindow()->installEventFilter(this);
604 //Init the vtk view if necessary
605 if (docGView->getViewWindow() == NULL)
607 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
609 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
610 docGView->getViewWindow()->installEventFilter(this);
613 docGView->setViewWindow(currentDocGView->getViewWindow());
615 if (docGView->getDocumentActor() == NULL)
619 if (docGView == NULL || docGView == currentDocGView)
625 //update the current document
626 switchModel(docGView);
630 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
632 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
635 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
637 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
639 //Decharger le model correspondant (VTK)
640 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
645 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
646 { //HexaBlock Vtk Window has been closed
648 if (currentDialog != NULL) currentDialog->close();
649 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
650 if (currentDocGView != NULL)
651 currentDocGView->setViewWindow(NULL);
658 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
659 if (dgview == NULL) return; //The window has no document to close
661 //Save the document? (Ask only if the document is not empty
662 int answerCode = SUIT_MessageBox::question(
665 tr("Save the document ?"),
666 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
667 SUIT_MessageBox::Cancel);
668 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
669 else if (answerCode == SUIT_MessageBox::Yes)
670 saveDocument(); //Save the document
672 // switchOffGraphicView(window); //disconnect all connected signals
673 // currentVtkView = NULL;
674 // graphicViewsHandler->closeDocumentGraphicView(window);
676 //create a new one (empty document)
678 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
682 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
684 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
685 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
686 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
687 if (currentDialog != NULL) currentDialog->close();
688 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
690 currentOccGView->getViewWindow()->removeEventFilter(this);
692 currentOccGView->setViewWindow(NULL);
696 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
698 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
700 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
701 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
703 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
705 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
706 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
707 // disable OCC selectors
708 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
709 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
710 while ( itOCCSel.hasNext() )
711 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
712 sr->setEnabled(true);
714 else if ( vm->getType() == SVTK_Viewer::Type() )
716 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
717 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
719 // disable VTK selectors
720 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
721 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
722 while ( itVTKSel.hasNext() )
723 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
724 sr->setEnabled(true);
728 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
730 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
732 SUIT_ViewModel* viewer = vm->getViewModel();
733 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
735 //VTK View Manager removed
736 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
738 //Process only if it's our view manager
739 SUIT_ViewManager* myVm = NULL;
740 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
741 myVm = currentDocGView->getViewWindow()->getViewManager();
745 //close opened dialog
746 if (currentDialog != NULL) currentDialog->close();
747 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
753 //remove its selector
754 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
755 while ( itVTKSel.hasNext() )
756 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
757 if ( sr->viewer() == viewer )
759 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
766 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
768 //OCC View removed: remove its selector
769 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
770 while ( itOCCSel.hasNext() )
771 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
772 if ( sr->viewer() == viewer )
774 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
780 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
782 QModelIndexList l = selected.indexes();
783 if ( l.count() == 0 ) return;
784 if ( !l[0].isValid() ) return;
785 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
786 if ( currentGraphicView == NULL) return;
788 QTreeView* theTree = NULL;
789 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
790 theTree = _patternDataTreeView;
791 } else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
792 theTree = _patternBuilderTreeView;
793 } else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
794 theTree = _patternGeomTreeView;
796 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
797 theTree = _groupsTreeView;
798 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
799 theTree = _meshTreeView;
802 theTree->scrollTo ( l[0] );
806 bool HEXABLOCKGUI::createSComponent() //addComponent
808 DEBTRACE("HEXABLOCKGUI::createSComponent");
809 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
811 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
812 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
813 _PTR(GenericAttribute) anAttr;
814 _PTR(AttributeName) aName;
815 _PTR(AttributeGraphic) aGraphic;
817 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
818 if ( !aComponent ){ //Create hexablock component if there's not one yet
819 aComponent = aBuilder->NewComponent("HEXABLOCK");
820 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
821 aName = _PTR(AttributeName) (anAttr);
822 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
824 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
825 _PTR(AttributePixMap) aPixmap(anAttr);
826 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
828 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
829 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
835 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
837 DEBTRACE("HEXABLOCKGUI::setResource");
838 _myresource = new HEXABLOCKGUI_Resource(r);
839 _myresource->preferencesChanged();
842 void HEXABLOCKGUI::createPreferences()
844 DEBTRACE("HEXABLOCKGUI::createPreferences");
845 _myresource->createPreferences(this);
848 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
850 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
851 _myresource->preferencesChanged(sect, name);
852 // if(name=="userCatalog")
853 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
856 void HEXABLOCKGUI::studyActivated() //CS_TODO
858 int newStudyId = getApp()->activeStudy()->id();
859 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
860 // if (_oldStudyId != -1)
862 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
863 // if (_studyContextMap.count(newStudyId))
865 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
866 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
870 // DEBTRACE("no switch to null context");
873 _oldStudyId = newStudyId;
876 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
878 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
879 QVariant currentAssocVariant;
880 QString currentAssocEntry;
882 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
883 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
884 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
885 QMenu menu( _patternDataTreeView );
887 QAction *clearAct = menu.addAction( "Remove association(s)" );
888 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
889 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
893 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
894 if (currentVtkGraphicView == NULL) return;
895 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
897 //We don't do anything for single items
898 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
899 item->type() == QUADITEM || item->type() == HEXAITEM)
902 //No associations for HEXA
903 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
904 if ( !treeVariant.isValid() ) return;
905 int eltType = treeVariant.toInt();
906 if (eltType == HEXA_DIR_TREE) return;
907 QMenu menu( _patternDataTreeView );
909 //Show association(s)
910 QAction *showAssocAct = menu.addAction( "Show associations" );
911 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
913 //Clear all associations
914 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
915 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
917 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
922 void HEXABLOCKGUI::createAndFillDockWidget()
924 QMainWindow *aParent = application()->desktop();
926 // Create dock widget (3 dock)
928 //1) *********** user input panel ( contain user's edit dialog box )
929 _dwInputPanel = new QDockWidget(aParent);
930 _dwInputPanel->setVisible(false);
931 _dwInputPanel->setWindowTitle("Input Panel");
932 _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
934 _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
936 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
938 _dwPattern = new QDockWidget(aParent);
939 _dwPattern->setVisible(false);
940 _dwPattern->setWindowTitle("Model");
941 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
943 QFrame* patternFrame = new QFrame(_dwPattern);
944 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
945 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
946 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
947 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
948 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
949 _patternBuilderTreeView = new QTreeView(patternFrame);
950 _patternGeomTreeView = new QTreeView(patternFrame);
951 splitter->addWidget(_patternDataTreeView);
952 splitter->addWidget(_patternBuilderTreeView);
953 splitter->addWidget(_patternGeomTreeView);
954 patternLayout->addWidget(splitter);
956 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers/*QAbstractItemView::DoubleClicked*/);
957 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
958 _patternDataTreeView->setItemDelegate(_treeViewDelegate);
961 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
962 _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
964 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
965 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
967 _dwPattern->setWidget(patternFrame);
968 patternFrame->show();
971 _dwGroups = new QDockWidget(aParent);
973 _dwGroups->setVisible(false);
974 _dwGroups->setWindowTitle("Groups");
975 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
976 _groupsTreeView = new QTreeView(_dwGroups);
977 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
978 _groupsTreeView->setItemDelegate(_treeViewDelegate);
979 _dwGroups->setWidget(_groupsTreeView);
980 _groupsTreeView->show();
983 _dwMesh = new QDockWidget(aParent);
984 _dwMesh->setVisible(false);
985 _dwMesh->setWindowTitle("Mesh");
986 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
987 _meshTreeView = new QTreeView(_dwMesh);
988 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
989 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
990 _meshTreeView->setItemDelegate(_treeViewDelegate);
991 _dwMesh->setWidget(_meshTreeView);
992 _meshTreeView->show();
994 QDockWidget *_dwObjectBrowser = 0;
995 QWidget* wid = getApp()->objectBrowser()->treeView();
996 QWidget *w = wid->parentWidget();
997 while ( w && !_dwObjectBrowser ) {
998 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
999 w = w->parentWidget();
1001 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1002 _dwObjectBrowser->setWindowTitle("Study");
1004 // dock widget position
1005 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1006 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1008 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1009 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1010 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1013 #if QT_VERSION >= 0x040500
1014 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1018 // popup menu on data tree view
1019 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1020 connect(_patternDataTreeView,
1021 SIGNAL(customContextMenuRequested(const QPoint &)),
1023 SLOT(treeContextMenu(const QPoint &)),
1024 Qt::UniqueConnection );
1027 void HEXABLOCKGUI::createActions()
1029 QMainWindow *aParent = application()->desktop();
1030 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1033 _newAct = createAction(_menuId++,
1034 tr("Create a new document"),
1035 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1037 tr("Create a new document"),
1038 0, aParent, false, this, SLOT(newDocument()));
1039 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1041 _importAct = createAction(_menuId++,
1042 tr("Load a document"),
1043 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1044 tr("Load Document"),
1045 tr("Load a document"),
1046 0, aParent, false, this, SLOT(loadDocument()));
1047 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1049 _saveAct = createAction(_menuId++,
1050 tr("Save the document"),
1051 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1052 tr("Save Document"),
1053 tr("Save the document"),
1054 0, aParent, false, this, SLOT(saveDocument()));
1056 // Pattern Data creation
1057 _addVertex = createAction(_menuId++,
1058 tr("Create a vertex"),
1059 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1061 tr("Create a new vertex"),
1062 0, aParent, false, this, SLOT(addVertex()));
1064 _addEdge = createAction(_menuId++,
1065 tr("Create an edge"),
1066 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1068 tr("Create a new edge"),
1069 0, aParent, false, this, SLOT(addEdge()));
1071 _addQuad = createAction(_menuId++,
1072 tr("Create a quadrangle"),
1073 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1074 tr("Add Quadrangle"),
1075 tr("Create a new quadrangle"),
1076 0, aParent, false, this, SLOT(addQuad()));
1078 _addHexa = createAction(_menuId++,
1079 tr("Create an hexahedron"),
1080 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1081 tr("Add Hexahedron"),
1082 tr("Create a new hexahedron"),
1083 0, aParent, false, this, SLOT(addHexa()));
1085 // Builder Data creation
1086 _addVector = createAction(_menuId++,
1087 tr("Create a vector"),
1088 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1090 tr("Create a new vector"),
1091 0, aParent, false, this, SLOT(addVector()));
1093 // _addCylinder = createAction(_menuId++,
1094 // tr("Create a cylinder"),
1095 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1096 // tr("Add Cylinder"),
1097 // tr("Create a new cylinder"),
1098 // 0, aParent, false, this, SLOT(addCylinder()));
1100 // _addPipe = createAction(_menuId++,
1101 // tr("Create a pipe"),
1102 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1104 // tr("Create a new pipe"),
1105 // 0, aParent, false, this, SLOT(addPipe()));
1107 _makeGrid = createAction(_menuId++,
1109 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1112 0, aParent, false, this, SLOT(makeGrid()));
1114 _makeCylinder = createAction(_menuId++,
1115 tr("Make a cylinder"),
1116 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1117 tr("Make Cylinder"),
1118 tr("Make a cylinder"),
1119 0, aParent, false, this, SLOT(makeCylinder()));
1121 _makePipe = createAction(_menuId++,
1123 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1126 0, aParent, false, this, SLOT(makePipe()));
1128 _makeCylinders = createAction(_menuId++,
1129 tr("Make cylinders"),
1130 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1131 tr("Make Cylinders"),
1132 tr("Make cylinders"),
1133 0, aParent, false, this, SLOT(makeCylinders()));
1135 _makePipes = createAction(_menuId++,
1137 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1140 0, aParent, false, this, SLOT(makePipes()));
1142 _makeHemiSphere = createAction(_menuId++,
1143 tr("Make an hemisphere"),
1144 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1145 tr("Make Hemisphere"),
1146 tr("Make an hemisphere"),
1147 0, aParent, false, this, SLOT(makeHemiSphere()));
1149 // Pattern Data edition
1150 _removeHexa = createAction(_menuId++,
1151 tr("Remove hexahedra"),
1152 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1153 tr("Remove Hexahedra"),
1154 tr("Remove hexahedra"),
1155 0, aParent, false, this, SLOT(removeHexa()));
1157 _prismQuad = createAction(_menuId++,
1158 tr("Prism quadrangles"),
1159 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1160 tr("Prism Quadrangles"),
1161 tr("Prism quadrangles"),
1162 0, aParent, false, this, SLOT(prismQuad()));
1164 _joinQuad = createAction(_menuId++,
1165 tr("Join quadrangles"),
1166 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1167 tr("Join Quadrangles"),
1168 tr("Join quadrangles with hexahedra"),
1169 0, aParent, false, this, SLOT(joinQuad()));
1171 _merge = createAction(_menuId++,
1173 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1176 0, aParent, false, this, SLOT(merge()));
1178 _disconnect = createAction(_menuId++,
1180 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1182 tr("Disconnect edges, vertexes or quadrangles"),
1183 0, aParent, false, this, SLOT(disconnectElts()));
1185 _cutEdge = createAction(_menuId++,
1187 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1190 0, aParent, false, this, SLOT(cutEdge()));
1192 _makeTransformation = createAction(_menuId++,
1193 tr("Make transformation"),
1194 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1195 tr("Make Transformation"),
1196 tr("Make transformation"),
1197 0, aParent, false, this, SLOT(makeTransformation()));
1199 _makeSymmetry = createAction(_menuId++,
1200 tr("Make symmetry"),
1201 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1202 tr("Make Symmetry"),
1203 tr("Make symmetry"),
1204 0, aParent, false, this, SLOT(makeSymmetry()));
1206 _performTransformation = createAction(_menuId++,
1207 tr("Perform transformation"),
1208 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1209 tr("Perform Transformation"),
1210 tr("Perform transformation"),
1211 0, aParent, false, this, SLOT(performTransformation()));
1213 _performSymmetry = createAction(_menuId++,
1214 tr("Perform symmetry"),
1215 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1216 tr("Perform Symmetry"),
1217 tr("Perform symmetry"),
1218 0, aParent, false, this, SLOT(performSymmetry()));
1220 _replaceHexa = createAction(_menuId++,
1221 tr("Replace hexahedron"),
1222 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1223 tr("Replace Hexahedron"),
1224 tr("Replace hexahedron"),
1225 0, aParent, false, this, SLOT(replaceHexa()));
1227 _quadRevolution = createAction(_menuId++,
1228 tr("Quad revolution"),
1229 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1230 tr("Quad Revolution"),
1231 tr("Quad revolution"),
1232 0, aParent, false, this, SLOT(quadRevolution()));
1235 _assocVertex = createAction(_menuId++,
1236 tr("Make vertex association"),
1237 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1238 tr("Make Vertex association"),
1239 tr("Make vertex association"),
1240 0, aParent, false, this, SLOT(assocVertex()));
1242 _assocEdge = createAction(_menuId++,
1243 tr("Make edge association"),
1244 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1245 tr("Make Edge Association"),
1246 tr("Make edge association"),
1247 0, aParent, false, this, SLOT(assocEdge()));
1249 _assocQuad = createAction(_menuId++,
1250 tr("Make quad association"),
1251 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1252 tr("Make Quad Association"),
1253 tr("Make quad association"),
1254 0, aParent, false, this, SLOT(assocQuad()));
1257 _addGroup = createAction(_menuId++,
1259 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1262 0, aParent, false, this, SLOT(addGroup()));
1264 _removeGroup = createAction(_menuId++,
1265 tr("Remove a group"),
1266 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1268 tr("Remove a group"),
1269 0, aParent, false, this, SLOT(removeGroup()));
1272 _addLaw = createAction(_menuId++,
1274 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1277 0, aParent, false, this, SLOT(addLaw()));
1279 _removeLaw = createAction(_menuId++,
1281 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1284 0, aParent, false, this, SLOT(removeLaw()));
1286 _setPropagation = createAction(_menuId++,
1287 tr("Set propagation"),
1288 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1289 tr("Set Propagation"),
1290 tr("Set propagation"),
1291 0, aParent, false, this, SLOT(setPropagation()));
1293 _computeMesh = createAction(_menuId++,
1295 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1298 0, aParent, false, this, SLOT(computeMesh()));
1300 _showModelInfoAct = createAction(_menuId++,
1301 tr("Show Model Info"),
1302 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1305 0, aParent, false, this, SLOT(showModelInfo()));
1307 _addShapeAct = createAction(_menuId++,
1309 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1312 0, aParent, false, this, SLOT(addShape()));
1314 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1315 // QAction* createAction(const int id,
1316 // const QString& toolTip,
1317 // const QIcon& icon,
1318 // const QString& menu,
1319 // const QString& status,
1320 // const int shortCut,
1321 // QObject* parent =0,
1322 // bool checkable = false,
1323 // QObject* receiver =0,
1324 // const char* member =0);
1326 _sep1 = separator();
1327 _sep2 = separator();
1328 _sep3 = separator();
1329 _sep4 = separator();
1333 void HEXABLOCKGUI::createMenus()
1335 int aMenuId, subMenuId,aMenuIdMain;
1337 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1339 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1340 createMenu( actionId(_newAct), aMenuId );
1341 createMenu( actionId(_importAct), aMenuId );
1342 createMenu( _saveAct, aMenuId );
1345 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1346 createMenu( _newAct, aMenuDocId );//, 10
1347 createMenu( _importAct, aMenuDocId );
1348 createMenu( _saveAct, aMenuDocId );
1350 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1351 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1352 createMenu( _addVertex, subMenuId );
1353 createMenu( _addEdge, subMenuId );
1354 createMenu( _addQuad, subMenuId );
1355 createMenu( _addHexa, subMenuId );
1356 createMenu( _sep1, subMenuId);
1359 createMenu( _addVector, subMenuId );
1360 // createMenu( _addCylinder, subMenuId );
1361 // createMenu( _addPipe, subMenuId );
1363 createMenu( _sep2, subMenuId);
1365 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1366 createMenu( _makeHemiSphere,subMenuId );
1368 createMenu( _sep3, subMenuId);
1370 createMenu( _makeCylinder, subMenuId );
1371 createMenu( _makePipe, subMenuId );
1372 createMenu( _makeCylinders,subMenuId );
1373 createMenu( _makePipes, subMenuId );
1375 // Pattern Data Edition
1376 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1377 createMenu( _removeHexa, subMenuId );
1378 createMenu( _prismQuad, subMenuId );
1379 createMenu( _joinQuad, subMenuId );
1380 createMenu( _merge, subMenuId );
1381 createMenu( _disconnect, subMenuId );
1382 createMenu( _cutEdge, subMenuId );
1383 createMenu( _makeTransformation, subMenuId );
1384 createMenu( _makeSymmetry, subMenuId );
1385 createMenu( _performTransformation, subMenuId );
1386 createMenu( _performSymmetry, subMenuId );
1387 createMenu( _replaceHexa, subMenuId );
1388 createMenu( _quadRevolution, subMenuId );
1389 createMenu( _sep4, aMenuId );
1390 createMenu( _showModelInfoAct, aMenuId );
1393 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1394 createMenu( _addShapeAct, aMenuId );
1395 createMenu( _assocVertex, aMenuId );
1396 createMenu( _assocEdge, aMenuId );
1397 createMenu( _assocQuad, aMenuId );
1400 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1401 createMenu( _addGroup, aMenuId );
1402 createMenu( _removeGroup, aMenuId ); //CS_TODO
1405 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1406 createMenu( _addLaw, aMenuId );
1407 createMenu( _removeLaw, aMenuId );
1408 createMenu( _setPropagation, aMenuId );
1409 createMenu( _computeMesh, aMenuId );
1411 //show model infomation menu
1412 QString aRule = "$component={'HEXABLOCK'}";
1413 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1414 popupMgr()->setRule( _showModelInfoAct, aRule);
1416 //associate shape to a document menu
1417 popupMgr()->insert( _addShapeAct, -1, -1 );
1418 popupMgr()->setRule( _addShapeAct, aRule );
1420 //-------------------------------------------------
1422 //-------------------------------------------------
1423 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1424 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1425 // QString isNotEmpty("numberOfNodes <> 0");
1426 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1427 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1428 //// aType = aType.arg( mesh_part );
1430 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1431 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1432 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1434 // popupMgr()->insert( separator(), -1, -1 );
1435 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1436 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1437 // // MESSAGE("aClient = " << aClient.toStdString());
1438 // // MESSAGE("aType = " << aType.toStdString());
1439 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1440 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1441 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1442 // // MESSAGE("aRule = " << aRule.toStdString());
1443 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1444 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1446 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1447 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1449 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1450 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1452 // popupMgr()->insert( separator(), -1, -1 );
1456 void HEXABLOCKGUI::createTools()
1460 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1461 createTool( _newAct, aToolId );
1462 createTool( _importAct, aToolId );
1463 createTool( _saveAct, aToolId );
1464 createTool( _showModelInfoAct, aToolId );
1465 // createTool( _testAct, aToolId );
1466 //createTool( separator(), aToolId );
1469 aToolId = createTool ( tr( "Construction" ) );
1470 createTool( _addVertex, aToolId );
1471 createTool( _addEdge, aToolId );
1472 createTool( _addQuad, aToolId );
1473 createTool( _addHexa, aToolId );
1475 createTool( _sep1, aToolId );
1478 createTool( _addVector, aToolId );
1479 // createTool( _addCylinder, aToolId );
1480 // createTool( _addPipe, aToolId );
1482 createTool( _sep2, aToolId );
1484 createTool( _makeGrid, aToolId );
1485 createTool( _makeHemiSphere, aToolId );
1487 createTool( _sep3, aToolId );
1489 createTool( _makeCylinder, aToolId );
1490 createTool( _makePipe, aToolId );
1491 createTool( _makeCylinders,aToolId );
1492 createTool( _makePipes, aToolId );
1494 // Pattern Data Edition
1495 aToolId = createTool ( tr( "Operation" ) );
1496 createTool( _removeHexa, aToolId );
1497 createTool( _prismQuad, aToolId );
1498 createTool( _joinQuad, aToolId );
1499 createTool( _merge, aToolId );
1500 createTool( _disconnect, aToolId );
1501 createTool( _cutEdge, aToolId );
1502 createTool( _makeTransformation, aToolId );
1503 createTool( _makeSymmetry, aToolId );
1504 createTool( _performTransformation, aToolId );
1505 createTool( _performSymmetry, aToolId );
1506 createTool( _replaceHexa, aToolId );
1507 createTool( _quadRevolution, aToolId );
1510 aToolId = createTool ( tr( "Association" ) );
1511 createTool( _assocVertex, aToolId );
1512 createTool( _assocEdge, aToolId );
1513 createTool( _assocQuad, aToolId );
1514 createTool( _addShapeAct, aToolId );
1517 aToolId = createTool ( tr( "Group" ) );
1518 createTool( _addGroup, aToolId );
1519 createTool( _removeGroup, aToolId ); //CS_TODO
1522 aToolId = createTool ( tr( "Mesh" ) );
1523 createTool( _addLaw, aToolId );
1524 createTool( _removeLaw, aToolId );
1525 createTool( _setPropagation, aToolId );
1526 createTool( _computeMesh, aToolId );
1530 void HEXABLOCKGUI::initialMenus()
1532 showDocumentMenus( true );
1533 showPatternMenus( false );
1534 showAssociationMenus( false );
1535 showGroupsMenus( false );
1536 showMeshMenus( false );
1539 void HEXABLOCKGUI::showAllMenus()
1541 showDocumentMenus( true );
1542 showPatternMenus( true );
1543 showAssociationMenus( true );
1544 showGroupsMenus( true );
1545 showMeshMenus( true );
1549 void HEXABLOCKGUI::showDocumentMenus(bool show)
1551 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1553 setMenuShown(_newAct, show);
1554 setToolShown(_newAct, show);
1555 setMenuShown(_importAct, show);
1556 setToolShown(_importAct, show);
1557 setMenuShown(_showModelInfoAct, show);
1558 setToolShown(_showModelInfoAct, show);
1559 setMenuShown(_saveAct, show);
1560 setToolShown(_saveAct, show);
1563 void HEXABLOCKGUI::showPatternMenus(bool show)
1565 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1566 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1567 if ( show && !getCurrentModel() ) return;
1569 setMenuShown(_addVertex, show );
1570 setToolShown(_addVertex, show);
1571 setMenuShown(_addEdge, show );
1572 setToolShown(_addEdge, show);
1573 setMenuShown(_addQuad, show );
1574 setToolShown(_addQuad, show);
1575 setMenuShown(_addHexa, show );
1576 setToolShown(_addHexa, show);
1578 setMenuShown(_sep1, show );
1579 setToolShown(_sep1, show);
1581 setMenuShown( _addVector, show );
1582 setToolShown( _addVector, show);
1583 // setMenuShown( _addCylinder, show );
1584 // setToolShown( _addCylinder, show);
1585 // setMenuShown( _addPipe, show );
1586 // setToolShown( _addPipe, show);
1588 setMenuShown(_sep2, show );
1589 setToolShown(_sep2, show);
1591 setMenuShown( _makeGrid, show );
1592 setToolShown( _makeGrid, show);
1593 setMenuShown( _makePipe, show );
1594 setToolShown( _makePipe, show);
1596 setMenuShown(_sep3, show );
1597 setToolShown(_sep3, show);
1599 setMenuShown( _makeCylinder, show );
1600 setToolShown( _makeCylinder, show);
1601 setMenuShown( _makeCylinders, show );
1602 setToolShown( _makeCylinders, show);
1603 setMenuShown( _makePipes, show );
1604 setToolShown( _makePipes, show);
1605 setMenuShown( _makeHemiSphere, show );
1606 setToolShown( _makeHemiSphere, show);
1608 // Pattern Data Edition
1609 setMenuShown( _removeHexa, show );
1610 setToolShown( _removeHexa, show);
1611 setMenuShown( _prismQuad, show );
1612 setToolShown( _prismQuad, show);
1613 setMenuShown( _joinQuad, show );
1614 setToolShown( _joinQuad, show);
1615 setMenuShown( _merge, show );
1616 setToolShown( _merge, show);
1617 setMenuShown( _disconnect, show );
1618 setToolShown( _disconnect, show);
1619 setMenuShown( _cutEdge, show );
1620 setToolShown( _cutEdge, show);
1621 setMenuShown( _makeTransformation, show );
1622 setToolShown( _makeTransformation, show);
1623 setMenuShown( _makeSymmetry, show );
1624 setToolShown( _makeSymmetry, show);
1625 setMenuShown( _performTransformation, show );
1626 setToolShown( _performTransformation, show);
1627 setMenuShown( _performSymmetry, show );
1628 setToolShown( _performSymmetry, show);
1629 setMenuShown( _replaceHexa, show );
1630 setToolShown( _replaceHexa, show);
1631 setMenuShown( _quadRevolution, show );
1632 setToolShown( _quadRevolution, show);
1634 setMenuShown( _sep4, show );
1635 setMenuShown( _showModelInfoAct, show );
1639 void HEXABLOCKGUI::showAssociationMenus(bool show)
1641 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1642 if ( show && !getCurrentModel() ) return;
1644 // Association Edition
1645 setMenuShown( _assocVertex, show );
1646 setToolShown( _assocVertex, show );
1647 setMenuShown( _assocEdge, show );
1648 setToolShown( _assocEdge, show );
1649 setMenuShown( _assocQuad, show );
1650 setToolShown( _assocQuad, show );
1651 setMenuShown( _addShapeAct, show );
1652 setToolShown( _addShapeAct, show );
1656 void HEXABLOCKGUI::showGroupsMenus(bool show)
1658 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1659 if ( show && !getCurrentModel() ) return;
1660 setMenuShown( _addGroup, show );
1661 setToolShown( _addGroup, show);
1662 setMenuShown( _removeGroup , show );
1663 setToolShown( _removeGroup , show);
1666 void HEXABLOCKGUI::showMeshMenus(bool show)
1668 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1669 if ( show && !getCurrentModel() ) return;
1670 setMenuShown( _addLaw, show );
1671 setToolShown( _addLaw, show);
1672 setMenuShown( _removeLaw, show );
1673 setToolShown( _removeLaw, show);;
1674 setMenuShown( _setPropagation, show );
1675 setToolShown( _setPropagation, show);
1676 setMenuShown( _computeMesh, show);
1677 setToolShown( _computeMesh, show);
1680 void HEXABLOCKGUI::showActor()
1682 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1683 if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
1684 currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
1687 currentVtkGView->getViewWindow()->setFocus();
1688 currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
1689 currentVtkGView->update();
1690 currentVtkGView->getViewWindow()->onFitAll();
1692 //update the visibility state now
1693 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1694 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1695 if (aStudy == NULL || vman == NULL) return;
1697 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1698 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1699 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1702 //SOCC_Prs* currentPrs = NULL;
1703 void HEXABLOCKGUI::showOnlyActor()
1705 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1706 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1707 currentVtkGView->getDocumentActor() == NULL)
1709 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1710 if (vtkView == NULL)
1713 SUIT_ViewManager* vman = vtkView->getViewManager();
1714 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1716 //show only the current actor -----------------
1717 vtkView->setFocus();
1718 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1719 Document_Actor *lastDocActor, *currentDocActor = currentVtkGView->getDocumentActor();
1720 if (lastVtkDocGView != NULL)
1722 lastDocActor = lastVtkDocGView->getDocumentActor();
1723 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1724 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1726 vtkView->Erase(lastActorIO);
1727 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1728 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1731 currentVtkGView->update();
1732 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1733 if (!anIO.IsNull() && anIO->hasEntry())
1735 vtkView->Display(anIO);
1736 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1737 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1739 vtkView->onFitAll();
1741 // //showOnly in occ viewer -------------
1743 if (currentOccGView == NULL)
1745 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1746 if (occView == NULL)
1748 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1753 if (lastOccPrs != NULL)
1754 vf->Erase(lastOccPrs);
1755 currentOccGView->globalSelection();
1756 SOCC_Prs* prs = getOccPrs(currentDocGView);
1757 currentOccGView->setPrs(prs);
1760 occView->onFitAll();
1763 void HEXABLOCKGUI::hideActor()
1766 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1767 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1768 currentVtkGView->getViewWindow() == NULL ||
1769 currentVtkGView->getDocumentActor() == NULL) return;
1771 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1772 currentVtkGView->getViewWindow()->onResetView();
1774 //update the visibility state now
1775 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1776 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1777 if (aStudy == NULL || vman == NULL) return;
1779 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1780 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1781 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1784 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1785 DocumentModel* docModel = currentVtkGView->getDocumentModel();
1786 if (occView == NULL || docModel == NULL)
1788 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1793 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1794 if (currentOccPrs != NULL)
1795 vf->Erase(currentOccPrs);
1797 occView->onResetView();
1801 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1803 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1805 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1806 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1808 if (_dwPattern) _dwPattern->setVisible(isVisible);
1809 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1811 if (_dwMesh) _dwMesh->setVisible(isVisible);
1812 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1814 if (_dwGroups) _dwGroups->setVisible(isVisible);
1815 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1819 //clear all used dialogs by the current model
1820 void HEXABLOCKGUI::clearDialogs()
1822 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1823 fin (currentModelDialogs.end());
1824 for(;debut!=fin;++debut) (*debut)->clear();
1826 currentModelDialogs.clear(); //empty the used dialogs list
1829 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1831 if (!gViewDlgBox.contains(dgview)) return NULL;
1832 return gViewDlgBox[dgview];
1835 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1837 if (dgview == NULL) return;
1839 switchOffGraphicView(dgview, false); //to avoid double connect
1842 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1843 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1844 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1845 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1846 connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1847 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1848 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1849 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1850 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1851 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1852 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1853 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1858 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1860 if (dgview == NULL) return;
1862 //disconnect signals
1863 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1864 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1865 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1866 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1867 disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1868 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1869 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1870 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1871 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1872 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1873 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1874 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1877 gViewDlgBox[dgview] = currentDialog;
1879 //close opened dialog
1880 if (currentDialog != NULL) currentDialog->close();
1881 if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1887 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1889 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1893 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1897 //switch off the current document graphic view (disconnect signals...)
1898 if (currentDocGView != NULL)
1900 //Hide current actor
1902 switchOffGraphicView(currentDocGView);
1905 //clear the dialogs used by the current model so they can be used by the new model
1906 if (currentDocGView != dgview) clearDialogs();
1908 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1909 _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1910 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1911 _groupsTreeView->setModel(dgview->getGroupsModel());
1912 _meshTreeView->setModel(dgview->getMeshModel());
1914 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1915 _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1917 _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1918 _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1920 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1921 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1923 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1924 _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1926 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1927 _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1930 // = * init occ view * =
1931 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1933 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1934 currentOccGView->getViewWindow()->installEventFilter(this);
1939 // = * init vtk view * =
1940 if (currentDocGView != NULL)
1942 if (currentDocGView->getViewWindow() != NULL)
1943 dgview->setViewWindow(currentDocGView->getViewWindow());
1946 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1947 dgview->getViewWindow()->installEventFilter(this);
1953 switchOnGraphicView(dgview);
1955 if (currentDocGView != NULL)
1957 lastVtkDocGView = currentDocGView;
1958 lastOccPrs = getOccPrs(currentDocGView);
1962 lastVtkDocGView = dgview;
1963 lastOccPrs = getOccPrs(dgview);
1966 currentDocGView = dgview;
1968 currentDocGView->getDocumentModel()->refresh();
1969 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1973 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1975 if (currentDocGView == NULL) return NULL;
1976 return currentDocGView->getDocumentModel();
1980 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1982 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1983 if (anApp == NULL) return UNKNOWN;
1984 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1985 if (activeVm == NULL) return UNKNOWN;
1987 QString vmType = activeVm->getType();
1988 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1990 else if ( vmType == OCCViewer_Viewer::Type() )
1996 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
1998 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2002 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2005 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2007 // Create Document from HEXABLOCK ENGINE
2008 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2009 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2011 // looking doc impl ( c++ )
2012 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2013 // ^Hexa6 ASSERT( dServant );
2014 // ^Hexa6 if ( dServant)
2015 // ^Hexa6 doc = dServant->GetImpl();
2017 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2018 QString docEntry = addDocInStudy (doc);
2020 // looking for docEntry
2021 /* ****************************************************************
2022 if ( !CORBA::is_nil(docIn) ){
2023 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2024 QString docIOR = anIOR.in();
2025 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2026 if ( !docIOR.isEmpty() ) {
2027 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2029 docEntry = SO->GetID().c_str();
2032 **************************************************************** */
2033 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2035 return make_pair (docEntry, doc);
2039 void HEXABLOCKGUI::newDocument()
2041 DEBTRACE("HEXABLOCKGUI::newDocument");
2044 QMainWindow *aParent = application()->desktop();
2045 QWidget *central = aParent->centralWidget();
2047 central->setFocus();
2049 DEBTRACE("No Central Widget");
2052 if (currentOccGView == NULL)
2054 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2055 application()->desktop());
2056 currentOccGView->getViewWindow()->installEventFilter(this);
2058 else if (currentOccGView->getViewWindow() == NULL)
2060 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2061 currentOccGView->getViewWindow()->installEventFilter(this);
2065 // Create Document from HEXABLOCK ENGINE
2066 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2068 VtkDocumentGraphicView* newGraphicView = NULL;
2069 //One document at a time
2070 if (currentDocGView != NULL)
2072 if (currentDocGView->getViewWindow() == NULL)
2074 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2075 currentDocGView->getViewWindow()->installEventFilter(this);
2078 // Create a new document with the current window
2079 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2080 new DocumentModel( docEntry_Doc.second,
2081 docEntry_Doc.first, this ),
2082 currentDocGView->getViewWindow(),
2083 application()->desktop() );
2087 // Create the new Document Graphic View with a new window
2088 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2089 new DocumentModel( docEntry_Doc.second,
2090 docEntry_Doc.first, this ),
2091 graphicViewsHandler->createVtkWindow(),
2092 application()->desktop() );
2093 newGraphicView->getViewWindow()->installEventFilter(this);
2096 if (newGraphicView == NULL)
2097 //We couldn't create a new document graphic view
2098 //we'd better show a dialog box info to inform the user
2101 docs[docEntry_Doc.first] = newGraphicView;
2102 switchModel(newGraphicView); //select the corresponding document in the browser instead
2104 getApp()->updateObjectBrowser();
2109 //Loads the model from the xmlFile in the current graphic view
2110 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2112 DEBTRACE("HEXABLOCKGUI::loadDocument");
2115 QMainWindow *aParent = application()->desktop();
2116 QString selectedFile;
2118 if ( inFile.isNull() ){
2119 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2120 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2121 dialog.setHistory( getQuickDirList() );
2123 //use the last path as default
2124 if (!(loadDocLastPath->absolutePath()).isEmpty())
2125 dialog.setDirectory(*loadDocLastPath);
2128 QStringList selectedFiles = dialog.selectedFiles();
2129 if (!selectedFiles.isEmpty())
2130 selectedFile = selectedFiles.first();
2132 //remember the selected path
2133 *loadDocLastPath = dialog.directory();
2136 selectedFile = inFile;
2138 if (selectedFile.isEmpty())
2141 //we create a new document if necessary
2142 if (currentDocGView == NULL)
2143 //Need a new document
2145 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2147 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2148 currentDocGView->getViewWindow()->installEventFilter(this);
2151 if (!currentDocGView->isEmpty())
2152 //we can only have one document for a graphic view
2155 //we load the selected file in the current graphic view
2156 currentDocGView->loadDocument(selectedFile);
2157 DocumentModel* currentModel = getCurrentModel();
2158 renameObject( currentModel->documentEntry(), currentModel->getName() );
2163 void HEXABLOCKGUI::saveDocument()
2165 QMainWindow *aParent = application()->desktop();
2167 QString aDocName = "document", aFilename;
2169 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2170 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2172 //use the last selected directory as default path for file selection
2173 aFilename = saveDocLastPath->absolutePath();
2174 if (!aFilename.isEmpty())
2175 aFilename += QString("/") + aDocName;
2177 //show the dialog for file selection
2178 aFilename = SUIT_FileDlg::getFileName( aParent,
2181 tr( "Save HexaBlock Document" ),
2184 //save the document in the selected file
2185 if ( !aFilename.isEmpty() ) {
2186 getCurrentVtkGraphicView()->saveDocument( aFilename );
2188 //Remember the path for next save
2189 QFileInfo fileInfo(aFilename);
2190 *saveDocLastPath = fileInfo.dir();
2196 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2198 _patternDataTreeView->openPersistentEditor( topLeft );
2201 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2203 if (diag == NULL || _dwInputPanel == NULL ||
2204 getCurrentVtkGraphicView() == NULL) return;
2206 //mark this dialog as used by the current model
2207 currentModelDialogs.insert(diag);
2209 //close the current dialog box info
2210 if (_treeViewDelegate != NULL)
2211 _treeViewDelegate->closeDialog();
2213 if (_dwInputPanel->widget())
2214 _dwInputPanel->widget()->close();
2216 //Temporary for debugging EdgeAssoc Faked InfoDialog
2217 if (diag == _edgeAssocDiag)
2218 diag->debugEdgeAssoc = true;
2220 diag->debugEdgeAssoc = false;
2222 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2223 diag == _quadAssocDiag || diag == _addShapeDiag)
2224 assocInProgress = true;
2226 assocInProgress = false;
2228 //show the dialog box in the dockwidget
2229 diag->resetSizeAndShow(_dwInputPanel);
2231 //clear the current selections
2232 selectionMgr()->clearSelected();
2234 currentDialog = diag;
2238 void HEXABLOCKGUI::addVertex()
2240 if ( !_vertexDiag ){
2241 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2243 _showDialogBox( _vertexDiag );
2246 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2247 if (_vertexDiag != NULL && doc != NULL)
2248 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2251 void HEXABLOCKGUI::addEdge()
2254 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2256 _showDialogBox( _edgeDiag );
2259 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2260 if (_edgeDiag != NULL && doc != NULL)
2261 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2264 void HEXABLOCKGUI::addQuad()
2267 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2270 _showDialogBox( _quadDiag );
2273 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2274 if (_quadDiag != NULL && doc != NULL)
2275 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2278 void HEXABLOCKGUI::addHexa()
2281 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2283 _showDialogBox( _hexaDiag );
2286 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2287 if (_hexaDiag != NULL && doc != NULL)
2288 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2291 void HEXABLOCKGUI::addVector()
2293 if ( !_vectorDiag ){
2294 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2296 _showDialogBox( _vectorDiag );
2299 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2300 if (_vectorDiag != NULL && doc != NULL)
2301 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2304 void HEXABLOCKGUI::addCylinder()
2306 if ( !_cylinderDiag ){
2307 _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2309 _showDialogBox( _cylinderDiag );
2312 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2313 if (_cylinderDiag != NULL && doc != NULL)
2314 _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2318 void HEXABLOCKGUI::addPipe()
2321 _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2323 _showDialogBox( _pipeDiag );
2326 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2327 if (_pipeDiag != NULL && doc != NULL)
2328 _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2332 void HEXABLOCKGUI::makeGrid()
2334 if ( !_makeGridDiag ){
2335 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2337 _showDialogBox( _makeGridDiag );
2341 void HEXABLOCKGUI::makeCylinder()
2343 if ( !_makeCylinderDiag ){
2344 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2346 _showDialogBox( _makeCylinderDiag );
2349 void HEXABLOCKGUI::makePipe()
2351 if ( !_makePipeDiag ){
2352 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2354 _showDialogBox( _makePipeDiag );
2357 void HEXABLOCKGUI::makeCylinders()
2359 if ( !_makeCylindersDiag ){
2360 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2362 _showDialogBox( _makeCylindersDiag );
2365 void HEXABLOCKGUI::makePipes()
2367 if ( !_makePipesDiag ){
2368 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2370 _showDialogBox( _makePipesDiag );
2374 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2376 if ( !_makeHemiSphereDiag ){
2377 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2379 _showDialogBox( _makeHemiSphereDiag );
2383 void HEXABLOCKGUI::removeHexa()
2385 if ( !_removeHexaDiag ){
2386 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2388 _showDialogBox( _removeHexaDiag );
2392 void HEXABLOCKGUI::prismQuad()
2394 if ( !_prismQuadDiag ){
2395 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2397 _showDialogBox( _prismQuadDiag );
2401 void HEXABLOCKGUI::joinQuad()
2403 if ( !_joinQuadDiag ){
2404 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2406 _showDialogBox( _joinQuadDiag );
2409 void HEXABLOCKGUI::merge()
2412 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2414 _showDialogBox( _mergeDiag );
2417 void HEXABLOCKGUI::disconnectElts()
2419 if ( !_disconnectDiag ){
2420 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2422 _showDialogBox( _disconnectDiag );
2425 void HEXABLOCKGUI::cutEdge()
2427 if ( !_cutEdgeDiag ){
2428 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2430 _showDialogBox( _cutEdgeDiag );
2433 void HEXABLOCKGUI::makeTransformation()
2435 if ( !_makeTransformationDiag ){
2436 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2438 _showDialogBox( _makeTransformationDiag );
2442 void HEXABLOCKGUI::makeSymmetry()
2444 if ( !_makeSymmetryDiag ){
2445 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2447 _showDialogBox( _makeSymmetryDiag );
2451 void HEXABLOCKGUI::performTransformation()
2453 if ( !_performTransformationDiag ){
2454 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2456 _showDialogBox( _performTransformationDiag );
2460 void HEXABLOCKGUI::performSymmetry()
2462 if ( !_performSymmetryDiag ){
2463 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2465 _showDialogBox( _performSymmetryDiag );
2469 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2471 if ( !_replaceHexaDiag ){
2472 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2474 _showDialogBox( _replaceHexaDiag );
2478 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2480 if ( !_quadRevolutionDiag ){
2481 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2483 _showDialogBox( _quadRevolutionDiag );
2487 void HEXABLOCKGUI::assocVertex()
2489 if (!_dwInputPanel) return;
2490 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2491 if ( !_vertexAssocDiag )
2492 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2493 _showDialogBox( _vertexAssocDiag );
2497 void HEXABLOCKGUI::assocEdge()
2499 if ( !_edgeAssocDiag )
2500 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2501 _showDialogBox( _edgeAssocDiag );
2504 void HEXABLOCKGUI::assocQuad()
2506 if ( !_quadAssocDiag )
2507 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2508 _showDialogBox( _quadAssocDiag );
2512 void HEXABLOCKGUI::addGroup()
2515 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2517 _showDialogBox( _groupDiag );
2518 if (_groupDiag != NULL && getCurrentModel() != NULL)
2520 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2521 if (doc == NULL) return;
2522 char defaultName[16];
2523 sprintf (defaultName, "g%04d", doc->countGroup());
2524 _groupDiag->name_le->setText(defaultName);
2528 void HEXABLOCKGUI::removeGroup()
2530 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2531 if (currentDGView == NULL) return;
2533 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2534 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2535 int nbGroupsRemoved = 0;
2538 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2539 tr( "No group selected!" ) );
2543 foreach( QModelIndex selected, l ){
2544 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2545 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2546 Q_ASSERT(selected.isValid());
2548 //Confirm the deletion of the group
2549 if (SUIT_MessageBox::question(
2552 tr("Remove group : %1 ?").arg(selected.data().toString()),
2553 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2554 SUIT_MessageBox::Cancel
2555 ) == SUIT_MessageBox::Cancel) return;
2557 bool removed = getCurrentModel()->removeGroup( selected );
2559 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2560 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2566 if (!nbGroupsRemoved)
2567 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2568 tr( "No group selected!" ) );
2571 void HEXABLOCKGUI::addLaw()
2574 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2576 _showDialogBox( _lawDiag );
2577 if (_lawDiag != NULL && getCurrentModel() != NULL)
2579 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2580 if (doc == NULL) return;
2581 char defaultName[16];
2582 sprintf (defaultName, "l%04d", doc->countLaw());
2583 _lawDiag->name_le->setText(defaultName);
2587 void HEXABLOCKGUI::removeLaw()
2589 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2590 if (currentDGView == NULL) return;
2592 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2593 int nbLawsRemoved = 0;
2596 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2597 tr( "No law selected!" ) );
2601 foreach( QModelIndex selected, l ){
2602 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2603 selected = currentDGView->getMeshModel()->mapToSource( selected );
2604 Q_ASSERT(selected.isValid());
2606 //Confirm the deletion of the law
2607 if (SUIT_MessageBox::question(
2610 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2611 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2612 SUIT_MessageBox::Cancel
2613 ) == SUIT_MessageBox::Cancel) return;
2615 bool removed = getCurrentModel()->removeLaw(selected);
2617 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2618 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2625 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2626 tr( "No law selected!" ) );
2631 void HEXABLOCKGUI::setPropagation()
2633 if ( !_propagationDiag ){
2634 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2636 _showDialogBox( _propagationDiag );
2639 // Dialog box to compute a mesh from a document
2640 // --------------------------------------------
2641 void HEXABLOCKGUI::computeMesh()
2643 if ( !_computeMeshDiag ){
2644 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2646 _computeMeshDiag->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
2647 _showDialogBox( _computeMeshDiag );
2650 void HEXABLOCKGUI::clearAssociations()
2652 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2653 if (currentDGView == NULL) return;
2655 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2656 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2657 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2659 getCurrentModel()->clearEltAssociations(iModel);
2661 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2664 void HEXABLOCKGUI::showModelInfo()
2666 //create the info dialog if not yet
2667 if (_modelInfoDiag == NULL)
2668 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2670 //show the model informations dialog
2671 _showDialogBox( _modelInfoDiag );
2674 void HEXABLOCKGUI::addShape()
2676 //create the info dialog if not yet
2677 if (_addShapeDiag == NULL)
2678 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2680 //show the model informations dialog
2681 _showDialogBox( _addShapeDiag );
2684 void HEXABLOCKGUI::clearAllAssociations()
2686 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2687 if (currentDGView == NULL) return;
2689 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2690 if (!currentIndex.isValid()) return;
2691 QVariant currentAssocVariant;
2692 QString currentAssocEntry;
2694 //Confirm the deletion of the associations
2695 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2696 if ( !treeVariant.isValid() ) return;
2697 int eltType = treeVariant.toInt();
2698 QString typeStr = "";
2699 HEXA_NS::EnumElt hexaType;
2700 if (eltType == VERTEX_DIR_TREE)
2702 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2703 hexaType = HEXA_NS::EL_VERTEX;
2705 else if (eltType == EDGE_DIR_TREE)
2707 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2708 hexaType = HEXA_NS::EL_EDGE;
2710 else if (eltType == QUAD_DIR_TREE)
2712 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2713 hexaType = HEXA_NS::EL_QUAD;
2716 if (SUIT_MessageBox::question(
2718 tr("CLEAR_ASSOCIATIONS"),
2719 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2720 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2721 SUIT_MessageBox::Cancel
2722 ) == SUIT_MessageBox::Cancel) return;
2725 DocumentModel* docModel = getCurrentModel();
2726 if (docModel == NULL) return;
2727 docModel->clearAssociation(hexaType);
2730 void HEXABLOCKGUI::showAssociations()
2732 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2733 if (currentDGView == NULL) return;
2735 QModelIndexList elts;
2736 int currentChildIndex = 0;
2737 QVariant currentAssocVariant;
2738 QString currentAssocEntry;
2739 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2740 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2742 while( currentChild.isValid() ) {
2744 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2745 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2746 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2747 elts << currentChild;
2749 currentChild = currentChild.sibling(currentChildIndex++, 0);
2751 currentDocGView->highlight(elts);
2752 currentOccGView->highlight(elts, false);
2756 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2758 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2760 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2765 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2767 if ( event->type() == QEvent::Enter )
2768 { // *** ENTER EVENT
2770 if (currentDialog == NULL || !currentDialog->isVisible())
2771 return QObject::eventFilter(obj, event);
2773 // ** The window acquire the focus when the cursor enter
2775 //OCC - window enter
2776 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2777 if ( occWindow != NULL)
2778 currentDialog->onWindowActivated(occWindow->getViewManager());
2780 //VTK - window enter
2782 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2783 if ( vtkWindow != NULL)
2784 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2788 //standard event processing
2789 return QObject::eventFilter(obj, event);
2792 QStringList HEXABLOCKGUI::getQuickDirList()
2794 QStringList dirList;
2795 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2797 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2803 // --- Export the module
2807 HEXABLOCKGUI_EXPORT CAM_Module* createModule()
2809 return new HEXABLOCKGUI();
2812 HEXABLOCKGUI_EXPORT char* getModuleVersion()
2814 return (char*)HEXABLOCK_VERSION_STR;
2820 // ******************** TESTS ***************************************************
2822 void HEXABLOCKGUI::testDocument()
2826 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2827 // QStandardItem *myItem = new QStandardItem("MyItem");
2828 // parentItem->appendRow(myItem);
2830 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2831 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2832 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2833 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2834 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2835 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2836 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2837 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2840 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2841 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2842 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2843 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2844 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2845 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2847 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2848 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2849 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2850 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2855 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2856 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2857 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2858 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2866 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2867 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2869 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2870 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2874 // newMesh( "toto", 3, "FactoryServer");
2878 void HEXABLOCKGUI::test_make_cart_grid()
2880 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2881 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2882 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2883 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2884 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2885 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2887 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
2888 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
2895 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
2896 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
2897 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
2898 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
2899 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
2900 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
2905 void HEXABLOCKGUI::test_make_elmts_transform()
2912 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
2913 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
2916 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
2917 // orig.setScalar(2);
2919 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
2920 // getCurrentModel()->saveVtk(file_name)
2922 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
2923 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
2925 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
2926 // getCurrentModel()->saveVtk(file_name)
2928 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
2931 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
2932 // getCurrentModel()->saveVtk(file_name);
2935 // print "...test make elements by transforming elements OK"
2937 // =============================================================== addDocInSudy
2938 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
2942 if (document == NULL)
2945 QString docName = document->getName ();
2947 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
2948 if (app_study == NULL)
2951 _PTR(Study) study = app_study->studyDS();
2952 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
2953 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
2954 QString entry = app_study->centry("HEXABLOCK");
2955 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
2956 if (aFatherSO->_is_nil())
2959 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
2962 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
2963 docEntry = aSO->GetID(); //the entry of the published object
2968 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
2970 void HEXABLOCKGUI::test()
2972 DEBTRACE("HEXABLOCKGUI::test");
2973 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2974 if (currentDGView == NULL) return;
2975 currentDGView->update();
2979 void HEXABLOCKGUI::test_association()
2981 DEBTRACE("HEXABLOCKGUI::test_association");
2984 QModelIndex v0, v1, v2, v3, e0, e1, q0;
2986 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
2987 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
2988 DocumentModel::GeomObj q0AssocA, q0AssocB;
2990 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
2991 QList<DocumentModel::GeomObj> e1Assocs_test;
2992 DocumentModel::GeomObj q0Assoc_test;
2994 v0 = getCurrentModel()->addVertex(0, 0, 0);
2995 v1 = getCurrentModel()->addVertex(1, 0, 0);
2996 v2 = getCurrentModel()->addVertex(1, 1, 0);
2997 v3 = getCurrentModel()->addVertex(0, 1, 0);
2998 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
2999 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3000 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3003 // >>> face3.GetEntry()'0:1:4'
3004 // >>> e1.GetEntry()'0:1:8'
3005 // >>> e2.GetEntry()'0:1:9'
3006 // >>> e3.GetEntry()'0:1:10'
3007 // >>> e4.GetEntry()'0:1:11'
3008 // >>> v1.GetEntry()'0:1:12'
3009 // >>> v2.GetEntry()'0:1:13'
3010 // >>> v3.GetEntry()'0:1:14'
3011 // >>> v4.GetEntry()'0:1:15'
3014 // v0Assoc.name = "geomV0";
3015 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3016 // v0Assoc.brep = "brepV0";
3017 // v1Assoc.name = "geomV1";
3018 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3019 // v1Assoc.brep = "brepV1";
3020 // v2Assoc.name = "geomV2";
3021 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3022 // v2Assoc.brep = "brepV2";
3023 // v3Assoc.name = "geomV3";
3024 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3025 // v3Assoc.brep = "brepV3";
3029 // e0AssocA.name = "geomE0a";
3030 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3031 // e0AssocA.brep = "brepE0a";
3032 // e0AssocA.start = 0.10;
3033 // e0AssocA.end = 0.95;
3037 // e1AssocA.name = "geomE1a";
3038 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3039 // e1AssocA.brep = "brepE1a";
3040 // e1AssocA.start = 0.12;
3041 // e1AssocA.end = 0.89;
3042 // e1AssocB.name = "geomE1b";
3043 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3044 // e1AssocB.brep = "brepE1b";
3045 // e1AssocB.start = 0.20;
3046 // e1AssocB.end = 0.80;
3047 // e1AssocC.name = "geomE1c";
3048 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3049 // e1AssocC.brep = "brepE1c";
3050 // e1AssocC.start = 0.16;
3051 // e1AssocC.end = 0.96;
3053 // q0AssocA.name = "geomQuad";
3054 // q0AssocA.entry = "0:1:1:1:3";
3055 // q0AssocA.brep = "brepq0";
3057 // q0AssocB.name = "geomQuad";
3058 // q0AssocB.entry = "0:1:1:1:4";
3059 // q0AssocB.brep = "brepq0";
3061 // getCurrentModel()->addAssociation( v0, v0Assoc );
3062 // getCurrentModel()->addAssociation( v1, v1Assoc );
3063 // getCurrentModel()->addAssociation( v2, v2Assoc );
3064 // getCurrentModel()->addAssociation( v3, v3Assoc );
3067 // getCurrentModel()->addAssociation( e0, e0AssocA );
3069 // getCurrentModel()->addAssociation( e1, e1AssocA );
3070 // getCurrentModel()->addAssociation( e1, e1AssocB );
3071 // getCurrentModel()->addAssociation( e1, e1AssocC );
3073 // getCurrentModel()->addAssociation( q0, q0AssocA );
3074 // getCurrentModel()->addAssociation( q0, q0AssocB );
3080 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3081 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3082 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3083 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3084 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3085 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3086 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3087 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3088 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3089 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3090 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3091 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3094 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3095 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3096 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3097 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3098 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3099 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3100 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3101 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3102 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3103 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3104 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3105 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3106 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3108 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3109 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3110 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3113 DEBTRACE("HEXABLOCKGUI::test_association fin");