1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <QInputDialog>
27 #include <QStackedWidget>
29 #include <QtxTreeView.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewManager.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_DataObject.h>
37 #include <SUIT_DataBrowser.h>
38 #include <SUIT_FileDlg.h>
40 #include <SVTK_ViewManager.h>
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewWindow.h>
44 #include <VTKViewer_ViewModel.h>
46 #include <vtkActorCollection.h>
47 #include <VTKViewer_Algorithm.h>
48 #include <vtkRenderer.h>
52 #include <SOCC_ViewModel.h>
53 #include <SOCC_ViewWindow.h>
54 #include <OCCViewer_ViewWindow.h>
55 #include <SALOME_Prs.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_Study.hxx>
61 #include <SALOMEDSClient_StudyBuilder.hxx>
62 #include <SALOMEDSClient_SComponent.hxx>
63 #include <SALOMEDSClient_ClientFactory.hxx>
64 #include <SALOMEDSClient_IParameters.hxx>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataModel.h>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
78 #include <SALOME_LifeCycleCORBA.hxx>
80 #include <LightApp_VTKSelector.h>
82 #include <OCCViewer_ViewManager.h>
84 #include <QtxPopupMgr.h>
86 #include "Resource.hxx"
88 #include "HEXABLOCKGUI.hxx"
89 #include "HEXABLOCKGUI_Export.hxx"
90 #include "HEXABLOCKGUI_Trace.hxx"
91 #include "HEXABLOCKGUI_Resource.hxx"
93 #include "HEXABLOCKGUI_DocumentModel.hxx"
94 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
95 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
96 #include "HEXABLOCKGUI_DocumentPanel.hxx"
97 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
98 #include "HEXABLOCKGUI_OccGraphicView.hxx"
99 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
101 #include <HEXABLOCK_version.h>
103 #include "MyBasicGUI_PointDlg.hxx"
105 // #include "HEXABLOCK.hxx" del Hexa6
106 // #include "HexDocument_impl.hxx" del Hexa6
110 #include <Visual3d_ViewManager.hxx>
111 #include <Graphic3d_Structure.hxx>
112 #include <Graphic3d_Group.hxx>
113 #include <V3d_PerspectiveView.hxx>
114 #include <V3d_AmbientLight.hxx>
115 #include <Graphic3d_GraphicDevice.hxx>
116 #include <Graphic3d_Array1OfVertex.hxx>
117 #include <V3d_DirectionalLight.hxx>
118 #include <Xw_Window.hxx>
119 #include <V3d_TypeOfShadingModel.hxx>
120 #include <TCollection_ExtendedString.hxx>
122 #include <BRepAlgoAPI_Fuse.hxx>
124 #include <AIS_ListIteratorOfListOfInteractive.hxx>
127 #define DW_MINIMUM_WIDTH 50
128 #define DWINPUT_MINIMUM_HEIGHT 50
129 #define DWINPUT_MINIMUM_WIDTH 50//255
132 using namespace HEXABLOCK::GUI;
134 int HEXABLOCKGUI::_oldStudyId = -1;
136 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
138 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
139 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
140 bool HEXABLOCKGUI::assocInProgress = false;
141 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
143 HEXABLOCKGUI::HEXABLOCKGUI() :
144 SalomeApp_Module( "HEXABLOCK" ),
145 // LightApp_Module( "HEXABLOCK" ),
153 _patternDataTreeView(0),
154 // _patternBuilderTreeView(0),
155 _patternGeomTreeView(0),
158 // _treeViewDelegate(0),
160 moduleActivatedOnce(false),
169 _makeCylinderDiag(0),
171 _makeCylindersDiag(0),
179 _makeTransformationDiag(0),
180 _makeSymmetryDiag(0),
181 _performTransformationDiag(0),
182 _performSymmetryDiag(0),
191 _quadRevolutionDiag(0),
192 _makeHemiSphereDiag(0),
193 _modelInfoDiag(NULL),
195 _vertexInfoDialog(NULL),
196 _edgeInfoDialog(NULL),
197 _quadInfoDialog(NULL),
198 _hexaInfoDialog(NULL),
199 _vectorInfoDialog(NULL),
200 _groupInfoDialog(NULL),
201 _lawInfoDialog(NULL),
202 _propagationInfoDialog(NULL),
205 lastVtkDocGView(NULL)
207 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
209 graphicViewsHandler = new GraphicViewsHandler();
210 loadDocLastPath = new QDir();
211 saveDocLastPath = new QDir();
212 hexa_root = HEXA_NS::Hex::getInstance ();
215 HEXABLOCKGUI::~HEXABLOCKGUI()
220 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
222 SUIT_Application* app = SUIT_Session::session()->activeApplication();
224 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
230 // Gets an reference to the module's engine
231 /****************************************************
232 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
234 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
235 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
236 ASSERT(!CORBA::is_nil(clr));
239 **************************************************** */
241 void HEXABLOCKGUI::initialize( CAM_Application* app )
243 DEBTRACE("HEXABLOCKGUI::initialize");
244 SalomeApp_Module::initialize( app );
246 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
248 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
250 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
251 setResource(aResourceMgr);
253 createAndFillDockWidget();
260 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
262 DEBTRACE("HEXABLOCKGUI::viewManagers");
263 // list.append( QxScene_Viewer::Type() );
264 // list.append( OCCViewer_Viewer::Type() );
265 // list.append( SVTK_Viewer::Type() );
269 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
271 DEBTRACE("HEXABLOCKGUI::activateModule");
273 /*HexaBlock can be launched in only one application*/
274 if (myApplication == NULL)
275 //remember the first application
276 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
278 //application verification: if it's not the one known by HexaBlock,
279 //leave without activating
280 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
281 if (myApplication != currentApplication) return false;
283 bool bOk = SalomeApp_Module::activateModule( theStudy );
284 if ( !bOk ) return false;
286 showDockWidgets(true);
288 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
289 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
290 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
291 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
293 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
295 SUIT_ViewManager* vm;
296 ViewManagerList OCCViewManagers, VTKViewManagers;
298 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
299 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
300 while ( itOCC.hasNext() && (vm = itOCC.next()) )
301 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
303 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
304 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
305 while ( itVTK.hasNext() && (vm = itVTK.next()) )
306 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
309 SALOME_ListIO selected;
310 sm->selectedObjects( selected );
313 // disable OCC selectors
314 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
315 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
316 while ( itOCCSel.hasNext() )
317 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
318 sr->setEnabled(true);
320 // disable VTK selectors
321 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
322 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
323 while ( itVTKSel.hasNext() )
324 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
325 sr->setEnabled(true);
327 sm->setSelectedObjects( selected, true ); //NPAL 19674
329 //connect close signal to vtk view manager
330 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
333 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
334 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
337 //connect close signal to occ view manager
338 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
341 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
342 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
345 /* ************************************ TODO Hexa6
346 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
347 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
348 if ( _PTR(Study) aStudy = s->studyDS()) {
349 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
350 updateObjBrowser(); // objects can be removed
352 ************************************ */
354 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
355 currentOccGView->getViewWindow()->installEventFilter(this);
357 if (currentDocGView != NULL)
359 switchModel(currentDocGView);
362 if (currentDocGView->getViewWindow() != NULL)
363 currentDocGView->getViewWindow()->installEventFilter(this);
372 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
374 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
375 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
376 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
377 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
379 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
380 if ( vtkView != NULL)
382 //default selectionMode in VTKView
383 vtkView->SetSelectionMode( ActorSelection );
384 vtkView->removeEventFilter(this);
388 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
391 //defaut selectionMode in OccView
392 selectionMgr()->clearSelected();
393 currentOccGView->globalSelection();
394 occView->removeEventFilter(this);
398 qDeleteAll(myOCCSelectors);
399 myOCCSelectors.clear();
400 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
402 qDeleteAll(myVTKSelectors);
403 myVTKSelectors.clear();
404 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
406 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
408 //switch off current document graphic view
409 switchOffGraphicView(currentDocGView);
412 setMenuShown( false );
413 setToolShown( false );
414 showDockWidgets( false );
416 _dwInputPanel->close();
423 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
425 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
426 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
427 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
428 int aStudyID = theStudy->StudyId();
429 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
430 return aDSStudy._retn();
433 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
434 QMap<QString, QString>& docShapesEntry,
435 QMap<QString, QString>& docShapesName)
437 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
438 return; //there's nothing to publish in this case
440 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
441 if(!appStudy) return;
442 _PTR(Study) aStudy = appStudy->studyDS();
443 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
444 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
445 QString entry = currentDocGView->getDocumentModel()->documentEntry();
446 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
447 if (aFatherSO->_is_nil())
450 // * get a presentation
451 bool isNewPrs = false;
452 SOCC_Prs* prs = getOccPrs(currentDocGView);
455 prs = new SOCC_Prs();
459 // * init the presentation with the given shapes
460 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
461 while (i != topo_shapes.constEnd())
463 QString shapeName = i.key();
464 TopoDS_Shape shapeValue = i.value();
465 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
466 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
467 QString objStudyEntry = aSO->GetID(); //the entry of the published object
468 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
469 "HEXABLOCK", shapeName.toStdString().c_str());
470 ais_shape->SetOwner(io);
471 prs->AddObject(ais_shape);
472 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
473 docShapesEntry[shapeName] = objStudyEntry;
474 docShapesName[objStudyEntry] = shapeName;
475 currentOccGView->addShape(objStudyEntry, ais_shape);
476 i++; //handle next shape
480 prs->AddObject(currentOccGView->getPreviewShape());
482 occPrs[currentDocGView] = prs;
483 getApp()->updateObjectBrowser();
488 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
490 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
491 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
492 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
494 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
498 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
502 // Pas de renommage des shapes pour le moment, juste les documents
503 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
504 if (dgview == NULL || dgview->getDocumentModel() == NULL)
507 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
508 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
513 _PTR(Study) aStudy = appStudy->studyDS();
518 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
519 _PTR(GenericAttribute) anAttr;
521 if ( obj->FindAttribute(anAttr, "AttributeName") ){
522 _PTR(AttributeName) aName (anAttr);
523 DocumentModel* docModel = dgview->getDocumentModel();
524 docModel->setName( name );
525 aName->SetValue( name.toLatin1().data() );
526 getApp()->updateObjectBrowser();
527 _dwPattern->setWindowTitle( name );
534 // --- Default windows
535 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
537 DEBTRACE("HEXABLOCKGUI::windows");
539 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
540 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
543 QString HEXABLOCKGUI::engineIOR() const
545 DEBTRACE("HEXABLOCKGUI::engineIOR");
547 /* ************************************ TODO Hexa6
548 CORBA::ORB_var anORB = getApp()->orb();
549 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
550 return QString( anIOR.in() );
551 ************************************ */
555 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
557 if (docs.count(studyObject->entry()) == 0)
559 //Object's document not acquired yet
560 VtkDocumentGraphicView* dgview;
561 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
562 if (directory == NULL)
563 return NULL; //No working director found
565 //------------------ Load the document -----------------
566 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
567 if (document == NULL)
568 return NULL; //No document found
570 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
572 MESSAGE("Doc model creation failed!");
575 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
576 if (dgview == NULL) return NULL;
578 //update the data tree
579 docs[studyObject->entry()] = dgview;
582 return docs[studyObject->entry()];
585 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
587 // ** we want to switch automatically to the right view windows
589 //first, find selected item
591 DataObjectList dol = getApp()->objectBrowser()->getSelected();
592 if (dol.isEmpty()) return;
593 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
594 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
595 item->entry().isEmpty())
598 // find the document corresponding to it
599 VtkDocumentGraphicView* docGView = NULL;
600 if (docs.contains(item->entry()))
601 docGView = docs[item->entry()];
603 docGView = getOrCreateDocument(item);
605 //Init OCC if necessary
606 if (currentOccGView == NULL)
608 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
609 currentOccGView->getViewWindow()->installEventFilter(this);
611 else if (currentOccGView->getViewWindow() == NULL)
613 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
614 currentOccGView->getViewWindow()->installEventFilter(this);
617 //Init the vtk view if necessary
618 if (docGView->getViewWindow() == NULL)
620 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
622 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
623 docGView->getViewWindow()->installEventFilter(this);
626 docGView->setViewWindow(currentDocGView->getViewWindow());
628 if (docGView->getDocumentActor() == NULL)
632 if (docGView == NULL || docGView == currentDocGView)
638 //update the current document
639 switchModel(docGView);
643 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
645 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
648 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
650 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
652 //Decharger le model correspondant (VTK)
653 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
658 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
659 { //HexaBlock Vtk Window has been closed
661 if (currentDialog != NULL) currentDialog->close();
662 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
663 if (currentDocGView != NULL)
664 currentDocGView->setViewWindow(NULL);
671 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
672 if (dgview == NULL) return; //The window has no document to close
674 //Save the document? (Ask only if the document is not empty
675 int answerCode = SUIT_MessageBox::question(
678 tr("Save the document ?"),
679 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
680 SUIT_MessageBox::Cancel);
681 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
682 else if (answerCode == SUIT_MessageBox::Yes)
683 saveDocument(); //Save the document
685 // switchOffGraphicView(window); //disconnect all connected signals
686 // currentVtkView = NULL;
687 // graphicViewsHandler->closeDocumentGraphicView(window);
689 //create a new one (empty document)
691 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
695 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
697 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
698 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
699 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
700 if (currentDialog != NULL) currentDialog->close();
701 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
703 currentOccGView->getViewWindow()->removeEventFilter(this);
705 currentOccGView->setViewWindow(NULL);
709 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
711 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
713 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
714 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
716 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
718 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
719 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
720 // disable OCC selectors
721 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
722 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
723 while ( itOCCSel.hasNext() )
724 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
725 sr->setEnabled(true);
727 else if ( vm->getType() == SVTK_Viewer::Type() )
729 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
730 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
732 // disable VTK selectors
733 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
734 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
735 while ( itVTKSel.hasNext() )
736 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
737 sr->setEnabled(true);
741 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
743 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
745 SUIT_ViewModel* viewer = vm->getViewModel();
746 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
748 //VTK View Manager removed
749 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
751 //Process only if it's our view manager
752 SUIT_ViewManager* myVm = NULL;
753 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
754 myVm = currentDocGView->getViewWindow()->getViewManager();
758 //close opened dialog
759 if (currentDialog != NULL) currentDialog->close();
760 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
766 //remove its selector
767 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
768 while ( itVTKSel.hasNext() )
769 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
770 if ( sr->viewer() == viewer )
772 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
779 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
781 //OCC View removed: remove its selector
782 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
783 while ( itOCCSel.hasNext() )
784 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
785 if ( sr->viewer() == viewer )
787 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
793 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
795 QModelIndexList l = selected.indexes();
796 if ( l.count() == 0 ) return;
797 if ( !l[0].isValid() ) return;
798 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
799 if ( currentGraphicView == NULL) return;
801 QTreeView* theTree = NULL;
802 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
803 theTree = _patternDataTreeView;
805 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
806 theTree = _patternBuilderTreeView;
808 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
809 theTree = _patternGeomTreeView;
811 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
812 theTree = _groupsTreeView;
813 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
814 theTree = _meshTreeView;
817 theTree->scrollTo ( l[0] );
821 bool HEXABLOCKGUI::createSComponent() //addComponent
823 DEBTRACE("HEXABLOCKGUI::createSComponent");
824 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
826 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
827 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
828 _PTR(GenericAttribute) anAttr;
829 _PTR(AttributeName) aName;
830 _PTR(AttributeGraphic) aGraphic;
832 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
833 if ( !aComponent ){ //Create hexablock component if there's not one yet
834 aComponent = aBuilder->NewComponent("HEXABLOCK");
835 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
836 aName = _PTR(AttributeName) (anAttr);
837 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
839 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
840 _PTR(AttributePixMap) aPixmap(anAttr);
841 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
843 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
844 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
850 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
852 DEBTRACE("HEXABLOCKGUI::setResource");
853 _myresource = new HEXABLOCKGUI_Resource(r);
854 _myresource->preferencesChanged();
857 void HEXABLOCKGUI::createPreferences()
859 DEBTRACE("HEXABLOCKGUI::createPreferences");
860 _myresource->createPreferences(this);
863 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
865 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
866 _myresource->preferencesChanged(sect, name);
867 // if(name=="userCatalog")
868 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
871 void HEXABLOCKGUI::studyActivated() //CS_TODO
873 int newStudyId = getApp()->activeStudy()->id();
874 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
875 // if (_oldStudyId != -1)
877 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
878 // if (_studyContextMap.count(newStudyId))
880 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
881 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
885 // DEBTRACE("no switch to null context");
888 _oldStudyId = newStudyId;
891 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
893 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
894 QVariant currentAssocVariant;
895 QString currentAssocEntry;
897 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
898 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
899 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
900 QMenu menu( _patternDataTreeView );
902 QAction *clearAct = menu.addAction( "Remove association(s)" );
903 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
904 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
908 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
909 if (currentVtkGraphicView == NULL) return;
910 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
912 //We don't do anything for single items
913 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
914 item->type() == QUADITEM || item->type() == HEXAITEM)
917 //No associations for HEXA
918 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
919 if ( !treeVariant.isValid() ) return;
920 int eltType = treeVariant.toInt();
921 if (eltType == HEXA_DIR_TREE) return;
922 QMenu menu( _patternDataTreeView );
924 //Show association(s)
925 QAction *showAssocAct = menu.addAction( "Show associations" );
926 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
928 //Clear all associations
929 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
930 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
932 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
937 void HEXABLOCKGUI::createAndFillDockWidget()
939 QMainWindow *aParent = application()->desktop();
941 // Create dock widget (3 dock)
943 //1) *********** user input panel ( contain user's edit dialog box )
944 _dwInputPanel = new QDockWidget(aParent);
945 _dwInputPanel->setVisible(false);
946 _dwInputPanel->setWindowTitle("Input Panel");
947 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
949 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
951 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
953 _dwPattern = new QDockWidget(aParent);
954 _dwPattern->setVisible(false);
955 _dwPattern->setWindowTitle("Model");
956 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
958 QFrame* patternFrame = new QFrame(_dwPattern);
959 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
960 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
961 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
962 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
963 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
964 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
965 _patternGeomTreeView = new QTreeView(patternFrame);
966 splitter->addWidget(_patternDataTreeView);
967 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
968 splitter->addWidget(_patternGeomTreeView);
969 patternLayout->addWidget(splitter);
971 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
972 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
973 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
976 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
977 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
979 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
980 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
982 _dwPattern->setWidget(patternFrame);
983 patternFrame->show();
986 _dwGroups = new QDockWidget(aParent);
988 _dwGroups->setVisible(false);
989 _dwGroups->setWindowTitle("Groups");
990 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
991 _groupsTreeView = new QTreeView(_dwGroups);
992 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
993 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
994 _dwGroups->setWidget(_groupsTreeView);
995 _groupsTreeView->show();
998 _dwMesh = new QDockWidget(aParent);
999 _dwMesh->setVisible(false);
1000 _dwMesh->setWindowTitle("Mesh");
1001 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1002 _meshTreeView = new QTreeView(_dwMesh);
1003 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1004 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1005 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1006 _dwMesh->setWidget(_meshTreeView);
1007 _meshTreeView->show();
1009 QDockWidget *_dwObjectBrowser = 0;
1010 QWidget* wid = getApp()->objectBrowser()->treeView();
1011 QWidget *w = wid->parentWidget();
1012 while ( w && !_dwObjectBrowser ) {
1013 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1014 w = w->parentWidget();
1016 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1017 _dwObjectBrowser->setWindowTitle("Study");
1019 // dock widget position
1020 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1021 // aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1022 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1024 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1025 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1026 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1029 #if QT_VERSION >= 0x040500
1030 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1034 // popup menu on data tree view
1035 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1036 connect(_patternDataTreeView,
1037 SIGNAL(customContextMenuRequested(const QPoint &)),
1039 SLOT(treeContextMenu(const QPoint &)),
1040 Qt::UniqueConnection );
1043 void HEXABLOCKGUI::createActions()
1045 QMainWindow *aParent = application()->desktop();
1046 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1049 _newAct = createAction(_menuId++,
1050 tr("Create a new document"),
1051 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1053 tr("Create a new document"),
1054 0, aParent, false, this, SLOT(newDocument()));
1055 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1057 _importAct = createAction(_menuId++,
1058 tr("Load a document"),
1059 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1060 tr("Load Document"),
1061 tr("Load a document"),
1062 0, aParent, false, this, SLOT(loadDocument()));
1063 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1065 _saveAct = createAction(_menuId++,
1066 tr("Save the document"),
1067 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1068 tr("Save Document"),
1069 tr("Save the document"),
1070 0, aParent, false, this, SLOT(saveDocument()));
1072 // Pattern Data creation
1073 _addVertex = createAction(_menuId++,
1074 tr("Create a vertex"),
1075 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1077 tr("Create a new vertex"),
1078 0, aParent, false, this, SLOT(addVertex()));
1080 _addEdge = createAction(_menuId++,
1081 tr("Create an edge"),
1082 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1084 tr("Create a new edge"),
1085 0, aParent, false, this, SLOT(addEdge()));
1087 _addQuad = createAction(_menuId++,
1088 tr("Create a quadrangle"),
1089 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1090 tr("Add Quadrangle"),
1091 tr("Create a new quadrangle"),
1092 0, aParent, false, this, SLOT(addQuad()));
1094 _addHexa = createAction(_menuId++,
1095 tr("Create an hexahedron"),
1096 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1097 tr("Add Hexahedron"),
1098 tr("Create a new hexahedron"),
1099 0, aParent, false, this, SLOT(addHexa()));
1101 // Builder Data creation
1102 _addVector = createAction(_menuId++,
1103 tr("Create a vector"),
1104 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1106 tr("Create a new vector"),
1107 0, aParent, false, this, SLOT(addVector()));
1109 // _addCylinder = createAction(_menuId++,
1110 // tr("Create a cylinder"),
1111 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1112 // tr("Add Cylinder"),
1113 // tr("Create a new cylinder"),
1114 // 0, aParent, false, this, SLOT(addCylinder()));
1116 // _addPipe = createAction(_menuId++,
1117 // tr("Create a pipe"),
1118 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1120 // tr("Create a new pipe"),
1121 // 0, aParent, false, this, SLOT(addPipe()));
1123 _makeGrid = createAction(_menuId++,
1125 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1128 0, aParent, false, this, SLOT(makeGrid()));
1130 _makeCylinder = createAction(_menuId++,
1131 tr("Make a cylinder"),
1132 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1133 tr("Make Cylinder"),
1134 tr("Make a cylinder"),
1135 0, aParent, false, this, SLOT(makeCylinder()));
1137 _makePipe = createAction(_menuId++,
1139 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1142 0, aParent, false, this, SLOT(makePipe()));
1144 _makeCylinders = createAction(_menuId++,
1145 tr("Make cylinders"),
1146 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1147 tr("Make Cylinders"),
1148 tr("Make cylinders"),
1149 0, aParent, false, this, SLOT(makeCylinders()));
1151 _makePipes = createAction(_menuId++,
1153 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1156 0, aParent, false, this, SLOT(makePipes()));
1158 _makeHemiSphere = createAction(_menuId++,
1159 tr("Make an hemisphere"),
1160 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1161 tr("Make Hemisphere"),
1162 tr("Make an hemisphere"),
1163 0, aParent, false, this, SLOT(makeHemiSphere()));
1165 // Pattern Data edition
1166 _removeHexa = createAction(_menuId++,
1167 tr("Remove hexahedra"),
1168 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1169 tr("Remove Hexahedra"),
1170 tr("Remove hexahedra"),
1171 0, aParent, false, this, SLOT(removeHexa()));
1173 _prismQuad = createAction(_menuId++,
1174 tr("Prism quadrangles"),
1175 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1176 tr("Prism Quadrangles"),
1177 tr("Prism quadrangles"),
1178 0, aParent, false, this, SLOT(prismQuad()));
1180 _joinQuad = createAction(_menuId++,
1181 tr("Join quadrangles"),
1182 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1183 tr("Join Quadrangles"),
1184 tr("Join quadrangles with hexahedra"),
1185 0, aParent, false, this, SLOT(joinQuad()));
1187 _merge = createAction(_menuId++,
1189 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1192 0, aParent, false, this, SLOT(merge()));
1194 _disconnect = createAction(_menuId++,
1196 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1198 tr("Disconnect edges, vertexes or quadrangles"),
1199 0, aParent, false, this, SLOT(disconnectElts()));
1201 _cutEdge = createAction(_menuId++,
1203 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1206 0, aParent, false, this, SLOT(cutEdge()));
1208 _makeTransformation = createAction(_menuId++,
1209 tr("Make transformation"),
1210 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1211 tr("Make Transformation"),
1212 tr("Make transformation"),
1213 0, aParent, false, this, SLOT(makeTransformation()));
1215 _makeSymmetry = createAction(_menuId++,
1216 tr("Make symmetry"),
1217 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1218 tr("Make Symmetry"),
1219 tr("Make symmetry"),
1220 0, aParent, false, this, SLOT(makeSymmetry()));
1222 _performTransformation = createAction(_menuId++,
1223 tr("Perform transformation"),
1224 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1225 tr("Perform Transformation"),
1226 tr("Perform transformation"),
1227 0, aParent, false, this, SLOT(performTransformation()));
1229 _performSymmetry = createAction(_menuId++,
1230 tr("Perform symmetry"),
1231 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1232 tr("Perform Symmetry"),
1233 tr("Perform symmetry"),
1234 0, aParent, false, this, SLOT(performSymmetry()));
1236 _replaceHexa = createAction(_menuId++,
1237 tr("Replace hexahedron"),
1238 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1239 tr("Replace Hexahedron"),
1240 tr("Replace hexahedron"),
1241 0, aParent, false, this, SLOT(replaceHexa()));
1243 _quadRevolution = createAction(_menuId++,
1244 tr("Quad revolution"),
1245 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1246 tr("Quad Revolution"),
1247 tr("Quad revolution"),
1248 0, aParent, false, this, SLOT(quadRevolution()));
1251 _assocVertex = createAction(_menuId++,
1252 tr("Make vertex association"),
1253 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1254 tr("Make Vertex association"),
1255 tr("Make vertex association"),
1256 0, aParent, false, this, SLOT(assocVertex()));
1258 _assocEdge = createAction(_menuId++,
1259 tr("Make edge association"),
1260 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1261 tr("Make Edge Association"),
1262 tr("Make edge association"),
1263 0, aParent, false, this, SLOT(assocEdge()));
1265 _assocQuad = createAction(_menuId++,
1266 tr("Make quad association"),
1267 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1268 tr("Make Quad Association"),
1269 tr("Make quad association"),
1270 0, aParent, false, this, SLOT(assocQuad()));
1273 _addGroup = createAction(_menuId++,
1275 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1278 0, aParent, false, this, SLOT(addGroup()));
1280 _removeGroup = createAction(_menuId++,
1281 tr("Remove a group"),
1282 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1284 tr("Remove a group"),
1285 0, aParent, false, this, SLOT(removeGroup()));
1288 _addLaw = createAction(_menuId++,
1290 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1293 0, aParent, false, this, SLOT(addLaw()));
1295 _removeLaw = createAction(_menuId++,
1297 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1300 0, aParent, false, this, SLOT(removeLaw()));
1302 _setPropagation = createAction(_menuId++,
1303 tr("Set propagation"),
1304 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1305 tr("Set Propagation"),
1306 tr("Set propagation"),
1307 0, aParent, false, this, SLOT(setPropagation()));
1309 _computeMesh = createAction(_menuId++,
1311 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1314 0, aParent, false, this, SLOT(computeMesh()));
1316 _showModelInfoAct = createAction(_menuId++,
1317 tr("Show Model Info"),
1318 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1321 0, aParent, false, this, SLOT(showModelInfo()));
1323 _addShapeAct = createAction(_menuId++,
1325 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1328 0, aParent, false, this, SLOT(addShape()));
1330 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1331 // QAction* createAction(const int id,
1332 // const QString& toolTip,
1333 // const QIcon& icon,
1334 // const QString& menu,
1335 // const QString& status,
1336 // const int shortCut,
1337 // QObject* parent =0,
1338 // bool checkable = false,
1339 // QObject* receiver =0,
1340 // const char* member =0);
1342 _sep1 = separator();
1343 _sep2 = separator();
1344 _sep3 = separator();
1345 _sep4 = separator();
1349 void HEXABLOCKGUI::createMenus()
1351 int aMenuId, subMenuId,aMenuIdMain;
1353 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1355 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1356 createMenu( actionId(_newAct), aMenuId );
1357 createMenu( actionId(_importAct), aMenuId );
1358 createMenu( _saveAct, aMenuId );
1361 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1362 createMenu( _newAct, aMenuDocId );//, 10
1363 createMenu( _importAct, aMenuDocId );
1364 createMenu( _saveAct, aMenuDocId );
1366 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1367 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1368 createMenu( _addVertex, subMenuId );
1369 createMenu( _addEdge, subMenuId );
1370 createMenu( _addQuad, subMenuId );
1371 createMenu( _addHexa, subMenuId );
1372 createMenu( _sep1, subMenuId);
1375 createMenu( _addVector, subMenuId );
1376 // createMenu( _addCylinder, subMenuId );
1377 // createMenu( _addPipe, subMenuId );
1379 createMenu( _sep2, subMenuId);
1381 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1382 createMenu( _makeHemiSphere,subMenuId );
1384 createMenu( _sep3, subMenuId);
1386 createMenu( _makeCylinder, subMenuId );
1387 createMenu( _makePipe, subMenuId );
1388 createMenu( _makeCylinders,subMenuId );
1389 createMenu( _makePipes, subMenuId );
1391 // Pattern Data Edition
1392 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1393 createMenu( _removeHexa, subMenuId );
1394 createMenu( _prismQuad, subMenuId );
1395 createMenu( _joinQuad, subMenuId );
1396 createMenu( _merge, subMenuId );
1397 createMenu( _disconnect, subMenuId );
1398 createMenu( _cutEdge, subMenuId );
1399 createMenu( _makeTransformation, subMenuId );
1400 createMenu( _makeSymmetry, subMenuId );
1401 createMenu( _performTransformation, subMenuId );
1402 createMenu( _performSymmetry, subMenuId );
1403 createMenu( _replaceHexa, subMenuId );
1404 createMenu( _quadRevolution, subMenuId );
1405 createMenu( _sep4, aMenuId );
1406 createMenu( _showModelInfoAct, aMenuId );
1409 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1410 createMenu( _addShapeAct, aMenuId );
1411 createMenu( _assocVertex, aMenuId );
1412 createMenu( _assocEdge, aMenuId );
1413 createMenu( _assocQuad, aMenuId );
1416 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1417 createMenu( _addGroup, aMenuId );
1418 createMenu( _removeGroup, aMenuId ); //CS_TODO
1421 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1422 createMenu( _addLaw, aMenuId );
1423 createMenu( _removeLaw, aMenuId );
1424 createMenu( _setPropagation, aMenuId );
1425 createMenu( _computeMesh, aMenuId );
1427 //show model infomation menu
1428 QString aRule = "$component={'HEXABLOCK'}";
1429 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1430 popupMgr()->setRule( _showModelInfoAct, aRule);
1432 //associate shape to a document menu
1433 popupMgr()->insert( _addShapeAct, -1, -1 );
1434 popupMgr()->setRule( _addShapeAct, aRule );
1436 //-------------------------------------------------
1438 //-------------------------------------------------
1439 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1440 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1441 // QString isNotEmpty("numberOfNodes <> 0");
1442 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1443 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1444 //// aType = aType.arg( mesh_part );
1446 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1447 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1448 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1450 // popupMgr()->insert( separator(), -1, -1 );
1451 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1452 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1453 // // MESSAGE("aClient = " << aClient.toStdString());
1454 // // MESSAGE("aType = " << aType.toStdString());
1455 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1456 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1457 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1458 // // MESSAGE("aRule = " << aRule.toStdString());
1459 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1460 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1462 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1463 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1465 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1466 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1468 // popupMgr()->insert( separator(), -1, -1 );
1472 void HEXABLOCKGUI::createTools()
1476 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1477 createTool( _newAct, aToolId );
1478 createTool( _importAct, aToolId );
1479 createTool( _saveAct, aToolId );
1480 createTool( _showModelInfoAct, aToolId );
1481 // createTool( _testAct, aToolId );
1482 //createTool( separator(), aToolId );
1485 aToolId = createTool ( tr( "Construction" ) );
1486 createTool( _addVertex, aToolId );
1487 createTool( _addEdge, aToolId );
1488 createTool( _addQuad, aToolId );
1489 createTool( _addHexa, aToolId );
1491 createTool( _sep1, aToolId );
1494 createTool( _addVector, aToolId );
1495 // createTool( _addCylinder, aToolId );
1496 // createTool( _addPipe, aToolId );
1498 createTool( _sep2, aToolId );
1500 createTool( _makeGrid, aToolId );
1501 createTool( _makeHemiSphere, aToolId );
1503 createTool( _sep3, aToolId );
1505 createTool( _makeCylinder, aToolId );
1506 createTool( _makePipe, aToolId );
1507 createTool( _makeCylinders,aToolId );
1508 createTool( _makePipes, aToolId );
1510 // Pattern Data Edition
1511 aToolId = createTool ( tr( "Operation" ) );
1512 createTool( _removeHexa, aToolId );
1513 createTool( _prismQuad, aToolId );
1514 createTool( _joinQuad, aToolId );
1515 createTool( _merge, aToolId );
1516 createTool( _disconnect, aToolId );
1517 createTool( _cutEdge, aToolId );
1518 createTool( _makeTransformation, aToolId );
1519 createTool( _makeSymmetry, aToolId );
1520 createTool( _performTransformation, aToolId );
1521 createTool( _performSymmetry, aToolId );
1522 createTool( _replaceHexa, aToolId );
1523 createTool( _quadRevolution, aToolId );
1526 aToolId = createTool ( tr( "Association" ) );
1527 createTool( _assocVertex, aToolId );
1528 createTool( _assocEdge, aToolId );
1529 createTool( _assocQuad, aToolId );
1530 createTool( _addShapeAct, aToolId );
1533 aToolId = createTool ( tr( "Group" ) );
1534 createTool( _addGroup, aToolId );
1535 createTool( _removeGroup, aToolId ); //CS_TODO
1538 aToolId = createTool ( tr( "Mesh" ) );
1539 createTool( _addLaw, aToolId );
1540 createTool( _removeLaw, aToolId );
1541 createTool( _setPropagation, aToolId );
1542 createTool( _computeMesh, aToolId );
1546 void HEXABLOCKGUI::initialMenus()
1548 showDocumentMenus( true );
1549 showPatternMenus( false );
1550 showAssociationMenus( false );
1551 showGroupsMenus( false );
1552 showMeshMenus( false );
1555 void HEXABLOCKGUI::showAllMenus()
1557 showDocumentMenus( true );
1558 showPatternMenus( true );
1559 showAssociationMenus( true );
1560 showGroupsMenus( true );
1561 showMeshMenus( true );
1565 void HEXABLOCKGUI::showDocumentMenus(bool show)
1567 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1569 setMenuShown(_newAct, show);
1570 setToolShown(_newAct, show);
1571 setMenuShown(_importAct, show);
1572 setToolShown(_importAct, show);
1573 setMenuShown(_showModelInfoAct, show);
1574 setToolShown(_showModelInfoAct, show);
1575 setMenuShown(_saveAct, show);
1576 setToolShown(_saveAct, show);
1579 void HEXABLOCKGUI::showPatternMenus(bool show)
1581 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1582 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1583 if ( show && !getCurrentModel() ) return;
1585 setMenuShown(_addVertex, show );
1586 setToolShown(_addVertex, show);
1587 setMenuShown(_addEdge, show );
1588 setToolShown(_addEdge, show);
1589 setMenuShown(_addQuad, show );
1590 setToolShown(_addQuad, show);
1591 setMenuShown(_addHexa, show );
1592 setToolShown(_addHexa, show);
1594 setMenuShown(_sep1, show );
1595 setToolShown(_sep1, show);
1597 setMenuShown( _addVector, show );
1598 setToolShown( _addVector, show);
1599 // setMenuShown( _addCylinder, show );
1600 // setToolShown( _addCylinder, show);
1601 // setMenuShown( _addPipe, show );
1602 // setToolShown( _addPipe, show);
1604 setMenuShown(_sep2, show );
1605 setToolShown(_sep2, show);
1607 setMenuShown( _makeGrid, show );
1608 setToolShown( _makeGrid, show);
1609 setMenuShown( _makePipe, show );
1610 setToolShown( _makePipe, show);
1612 setMenuShown(_sep3, show );
1613 setToolShown(_sep3, show);
1615 setMenuShown( _makeCylinder, show );
1616 setToolShown( _makeCylinder, show);
1617 setMenuShown( _makeCylinders, show );
1618 setToolShown( _makeCylinders, show);
1619 setMenuShown( _makePipes, show );
1620 setToolShown( _makePipes, show);
1621 setMenuShown( _makeHemiSphere, show );
1622 setToolShown( _makeHemiSphere, show);
1624 // Pattern Data Edition
1625 setMenuShown( _removeHexa, show );
1626 setToolShown( _removeHexa, show);
1627 setMenuShown( _prismQuad, show );
1628 setToolShown( _prismQuad, show);
1629 setMenuShown( _joinQuad, show );
1630 setToolShown( _joinQuad, show);
1631 setMenuShown( _merge, show );
1632 setToolShown( _merge, show);
1633 setMenuShown( _disconnect, show );
1634 setToolShown( _disconnect, show);
1635 setMenuShown( _cutEdge, show );
1636 setToolShown( _cutEdge, show);
1637 setMenuShown( _makeTransformation, show );
1638 setToolShown( _makeTransformation, show);
1639 setMenuShown( _makeSymmetry, show );
1640 setToolShown( _makeSymmetry, show);
1641 setMenuShown( _performTransformation, show );
1642 setToolShown( _performTransformation, show);
1643 setMenuShown( _performSymmetry, show );
1644 setToolShown( _performSymmetry, show);
1645 setMenuShown( _replaceHexa, show );
1646 setToolShown( _replaceHexa, show);
1647 setMenuShown( _quadRevolution, show );
1648 setToolShown( _quadRevolution, show);
1650 setMenuShown( _sep4, show );
1651 setMenuShown( _showModelInfoAct, show );
1655 void HEXABLOCKGUI::showAssociationMenus(bool show)
1657 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1658 if ( show && !getCurrentModel() ) return;
1660 // Association Edition
1661 setMenuShown( _assocVertex, show );
1662 setToolShown( _assocVertex, show );
1663 setMenuShown( _assocEdge, show );
1664 setToolShown( _assocEdge, show );
1665 setMenuShown( _assocQuad, show );
1666 setToolShown( _assocQuad, show );
1667 setMenuShown( _addShapeAct, show );
1668 setToolShown( _addShapeAct, show );
1672 void HEXABLOCKGUI::showGroupsMenus(bool show)
1674 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1675 if ( show && !getCurrentModel() ) return;
1676 setMenuShown( _addGroup, show );
1677 setToolShown( _addGroup, show);
1678 setMenuShown( _removeGroup , show );
1679 setToolShown( _removeGroup , show);
1682 void HEXABLOCKGUI::showMeshMenus(bool show)
1684 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1685 if ( show && !getCurrentModel() ) return;
1686 setMenuShown( _addLaw, show );
1687 setToolShown( _addLaw, show);
1688 setMenuShown( _removeLaw, show );
1689 setToolShown( _removeLaw, show);;
1690 setMenuShown( _setPropagation, show );
1691 setToolShown( _setPropagation, show);
1692 setMenuShown( _computeMesh, show);
1693 setToolShown( _computeMesh, show);
1696 void HEXABLOCKGUI::showActor()
1698 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1699 if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
1700 currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
1703 currentVtkGView->getViewWindow()->setFocus();
1704 currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
1705 currentVtkGView->update();
1706 currentVtkGView->getViewWindow()->onFitAll();
1708 //update the visibility state now
1709 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1710 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1711 if (aStudy == NULL || vman == NULL) return;
1713 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1714 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1715 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1718 //SOCC_Prs* currentPrs = NULL;
1719 void HEXABLOCKGUI::showOnlyActor()
1721 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1722 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1723 currentVtkGView->getDocumentActor() == NULL)
1725 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1726 if (vtkView == NULL)
1729 SUIT_ViewManager* vman = vtkView->getViewManager();
1730 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1732 //show only the current actor -----------------
1733 vtkView->setFocus();
1734 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1735 Document_Actor *lastDocActor, *currentDocActor = currentVtkGView->getDocumentActor();
1736 if (lastVtkDocGView != NULL)
1738 lastDocActor = lastVtkDocGView->getDocumentActor();
1739 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1740 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1742 vtkView->Erase(lastActorIO);
1743 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1744 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1747 currentVtkGView->update();
1748 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1749 if (!anIO.IsNull() && anIO->hasEntry())
1751 vtkView->Display(anIO);
1752 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1753 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1755 vtkView->onFitAll();
1757 // //showOnly in occ viewer -------------
1759 if (currentOccGView == NULL)
1761 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1762 if (occView == NULL)
1764 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1769 if (lastOccPrs != NULL)
1770 vf->Erase(lastOccPrs);
1771 currentOccGView->globalSelection();
1772 SOCC_Prs* prs = getOccPrs(currentDocGView);
1773 currentOccGView->setPrs(prs);
1776 occView->onFitAll();
1779 void HEXABLOCKGUI::hideActor()
1782 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1783 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1784 currentVtkGView->getViewWindow() == NULL ||
1785 currentVtkGView->getDocumentActor() == NULL) return;
1787 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1788 currentVtkGView->getViewWindow()->onResetView();
1790 //update the visibility state now
1791 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1792 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1793 if (aStudy == NULL || vman == NULL) return;
1795 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1796 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1797 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1800 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1801 DocumentModel* docModel = currentVtkGView->getDocumentModel();
1802 if (occView == NULL || docModel == NULL)
1804 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1809 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1810 if (currentOccPrs != NULL)
1811 vf->Erase(currentOccPrs);
1813 occView->onResetView();
1817 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1819 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1821 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1822 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1824 if (_dwPattern) _dwPattern->setVisible(isVisible);
1825 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1827 if (_dwMesh) _dwMesh->setVisible(isVisible);
1828 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1830 if (_dwGroups) _dwGroups->setVisible(isVisible);
1831 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1835 //clear all used dialogs by the current model
1836 void HEXABLOCKGUI::clearDialogs()
1838 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1839 fin (currentModelDialogs.end());
1840 for(;debut!=fin;++debut) (*debut)->clear();
1842 currentModelDialogs.clear(); //empty the used dialogs list
1845 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1847 if (!gViewDlgBox.contains(dgview)) return NULL;
1848 return gViewDlgBox[dgview];
1851 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1853 if (dgview == NULL) return;
1855 switchOffGraphicView(dgview, false); //to avoid double connect
1858 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1859 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1860 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1861 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1862 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1863 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1864 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1865 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1866 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1867 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1868 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1869 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1874 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1876 if (dgview == NULL) return;
1878 //disconnect signals
1879 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1880 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1881 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1882 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1883 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1884 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1885 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1886 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1887 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1888 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1889 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1890 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1893 gViewDlgBox[dgview] = currentDialog;
1895 //close opened dialog
1896 if (currentDialog != NULL) currentDialog->close();
1897 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1903 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1905 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1909 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1913 //switch off the current document graphic view (disconnect signals...)
1914 if (currentDocGView != NULL)
1916 //Hide current actor
1918 switchOffGraphicView(currentDocGView);
1921 //clear the dialogs used by the current model so they can be used by the new model
1922 if (currentDocGView != dgview) clearDialogs();
1924 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1925 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1926 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1927 _groupsTreeView->setModel(dgview->getGroupsModel());
1928 _meshTreeView->setModel(dgview->getMeshModel());
1930 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1931 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1933 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1934 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1936 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1937 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1939 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1940 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1942 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1943 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1946 // = * init occ view * =
1947 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1949 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1950 currentOccGView->getViewWindow()->installEventFilter(this);
1955 // = * init vtk view * =
1956 if (currentDocGView != NULL)
1958 if (currentDocGView->getViewWindow() != NULL)
1959 dgview->setViewWindow(currentDocGView->getViewWindow());
1962 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1963 dgview->getViewWindow()->installEventFilter(this);
1969 switchOnGraphicView(dgview);
1971 if (currentDocGView != NULL)
1973 lastVtkDocGView = currentDocGView;
1974 lastOccPrs = getOccPrs(currentDocGView);
1978 lastVtkDocGView = dgview;
1979 lastOccPrs = getOccPrs(dgview);
1982 currentDocGView = dgview;
1984 currentDocGView->getDocumentModel()->refresh();
1985 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1989 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1991 if (currentDocGView == NULL) return NULL;
1992 return currentDocGView->getDocumentModel();
1996 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1998 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1999 if (anApp == NULL) return UNKNOWN;
2000 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2001 if (activeVm == NULL) return UNKNOWN;
2003 QString vmType = activeVm->getType();
2004 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2006 else if ( vmType == OCCViewer_Viewer::Type() )
2012 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2014 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2018 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2021 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2023 // Create Document from HEXABLOCK ENGINE
2024 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2025 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2027 // looking doc impl ( c++ )
2028 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2029 // ^Hexa6 ASSERT( dServant );
2030 // ^Hexa6 if ( dServant)
2031 // ^Hexa6 doc = dServant->GetImpl();
2033 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2034 QString docEntry = addDocInStudy (doc);
2036 // looking for docEntry
2037 /* ****************************************************************
2038 if ( !CORBA::is_nil(docIn) ){
2039 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2040 QString docIOR = anIOR.in();
2041 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2042 if ( !docIOR.isEmpty() ) {
2043 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2045 docEntry = SO->GetID().c_str();
2048 **************************************************************** */
2049 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2051 return make_pair (docEntry, doc);
2055 void HEXABLOCKGUI::newDocument()
2057 DEBTRACE("HEXABLOCKGUI::newDocument");
2060 QMainWindow *aParent = application()->desktop();
2061 QWidget *central = aParent->centralWidget();
2063 central->setFocus();
2065 DEBTRACE("No Central Widget");
2068 if (currentOccGView == NULL)
2070 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2071 application()->desktop());
2072 currentOccGView->getViewWindow()->installEventFilter(this);
2074 else if (currentOccGView->getViewWindow() == NULL)
2076 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2077 currentOccGView->getViewWindow()->installEventFilter(this);
2081 // Create Document from HEXABLOCK ENGINE
2082 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2084 VtkDocumentGraphicView* newGraphicView = NULL;
2085 //One document at a time
2086 if (currentDocGView != NULL)
2088 if (currentDocGView->getViewWindow() == NULL)
2090 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2091 currentDocGView->getViewWindow()->installEventFilter(this);
2094 // Create a new document with the current window
2095 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2096 new DocumentModel( docEntry_Doc.second,
2097 docEntry_Doc.first, this ),
2098 currentDocGView->getViewWindow(),
2099 application()->desktop() );
2103 // Create the new Document Graphic View with a new window
2104 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2105 new DocumentModel( docEntry_Doc.second,
2106 docEntry_Doc.first, this ),
2107 graphicViewsHandler->createVtkWindow(),
2108 application()->desktop() );
2109 newGraphicView->getViewWindow()->installEventFilter(this);
2112 if (newGraphicView == NULL)
2113 //We couldn't create a new document graphic view
2114 //we'd better show a dialog box info to inform the user
2117 docs[docEntry_Doc.first] = newGraphicView;
2118 switchModel(newGraphicView); //select the corresponding document in the browser instead
2120 getApp()->updateObjectBrowser();
2125 //Loads the model from the xmlFile in the current graphic view
2126 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2128 DEBTRACE("HEXABLOCKGUI::loadDocument");
2131 QMainWindow *aParent = application()->desktop();
2132 QString selectedFile;
2134 if ( inFile.isNull() ){
2135 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2136 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2137 dialog.setHistory( getQuickDirList() );
2139 //use the last path as default
2140 if (!(loadDocLastPath->absolutePath()).isEmpty())
2141 dialog.setDirectory(*loadDocLastPath);
2144 QStringList selectedFiles = dialog.selectedFiles();
2145 if (!selectedFiles.isEmpty())
2146 selectedFile = selectedFiles.first();
2148 //remember the selected path
2149 *loadDocLastPath = dialog.directory();
2152 selectedFile = inFile;
2154 if (selectedFile.isEmpty())
2157 //we create a new document if necessary
2158 if (currentDocGView == NULL)
2159 //Need a new document
2161 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2163 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2164 currentDocGView->getViewWindow()->installEventFilter(this);
2167 if (!currentDocGView->isEmpty())
2168 //we can only have one document for a graphic view
2171 //we load the selected file in the current graphic view
2172 currentDocGView->loadDocument(selectedFile);
2173 DocumentModel* currentModel = getCurrentModel();
2174 renameObject( currentModel->documentEntry(), currentModel->getName() );
2179 void HEXABLOCKGUI::saveDocument()
2181 QMainWindow *aParent = application()->desktop();
2183 QString aDocName = "document", aFilename;
2185 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2186 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2188 //use the last selected directory as default path for file selection
2189 aFilename = saveDocLastPath->absolutePath();
2190 if (!aFilename.isEmpty())
2191 aFilename += QString("/") + aDocName;
2193 //show the dialog for file selection
2194 aFilename = SUIT_FileDlg::getFileName( aParent,
2197 tr( "Save HexaBlock Document" ),
2200 //save the document in the selected file
2201 if ( !aFilename.isEmpty() ) {
2202 getCurrentVtkGraphicView()->saveDocument( aFilename );
2204 //Remember the path for next save
2205 QFileInfo fileInfo(aFilename);
2206 *saveDocLastPath = fileInfo.dir();
2212 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2214 _patternDataTreeView->openPersistentEditor( topLeft );
2217 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2219 if (diag == NULL || _dwInputPanel == NULL ||
2220 getCurrentVtkGraphicView() == NULL) return;
2222 //mark this dialog as used by the current model
2223 currentModelDialogs.insert(diag);
2225 //close the current dialog box info
2226 // if (_treeViewDelegate != NULL)
2227 // _treeViewDelegate->closeDialog();
2229 // if (_dwInputPanel->widget())
2230 // _dwInputPanel->widget()->close();
2232 //Temporary for debugging EdgeAssoc Faked InfoDialog
2233 if (diag == _edgeAssocDiag)
2234 diag->debugEdgeAssoc = true;
2236 diag->debugEdgeAssoc = false;
2238 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2239 diag == _quadAssocDiag || diag == _addShapeDiag)
2240 assocInProgress = true;
2242 assocInProgress = false;
2244 //show the dialog box in the dockwidget
2245 diag->resetSizeAndShow(_dwInputPanel);
2247 //clear the current selections
2248 selectionMgr()->clearSelected();
2250 currentDialog = diag;
2253 if (currentDocGView != NULL)
2254 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2257 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2259 if (vertex == NULL || _dwInputPanel == NULL)
2262 if (_vertexInfoDialog == NULL)
2263 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2265 _vertexInfoDialog->setValue(vertex);
2266 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2267 currentDialog = _vertexInfoDialog;
2270 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2272 if (edge == NULL || _dwInputPanel == NULL)
2275 if (_edgeInfoDialog == NULL)
2276 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2278 _edgeInfoDialog->setValue(edge);
2279 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2280 currentDialog = _edgeInfoDialog;
2283 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2285 if (quad == NULL || _dwInputPanel == NULL)
2288 if (_quadInfoDialog == NULL)
2289 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2291 _quadInfoDialog->setValue(quad);
2292 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2293 currentDialog = _quadInfoDialog;
2296 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2298 if (hexa == NULL || _dwInputPanel == NULL)
2301 if (_hexaInfoDialog == NULL)
2302 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2304 _hexaInfoDialog->setValue(hexa);
2305 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2306 currentDialog = _hexaInfoDialog;
2309 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2311 if (vector == NULL || _dwInputPanel == NULL)
2314 if (_vectorInfoDialog == NULL)
2315 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2317 _vectorInfoDialog->setValue(vector);
2318 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2319 currentDialog = _vectorInfoDialog;
2322 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2324 if (group == NULL || _dwInputPanel == NULL)
2327 if (_groupInfoDialog == NULL)
2328 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2330 _groupInfoDialog->setValue(group);
2331 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2332 currentDialog = _groupInfoDialog;
2335 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2337 if (law == NULL || _dwInputPanel == NULL)
2340 if (_lawInfoDialog == NULL)
2341 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2343 _lawInfoDialog->setValue(law);
2344 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2345 currentDialog = _lawInfoDialog;
2348 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2350 if (propagation == NULL || _dwInputPanel == NULL)
2353 if (_propagationInfoDialog == NULL)
2354 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2356 _propagationInfoDialog->setValue(propagation);
2357 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2358 currentDialog = _propagationInfoDialog;
2361 void HEXABLOCKGUI::addVertex()
2363 if ( !_vertexDiag ){
2364 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2366 _showDialogBox( _vertexDiag );
2369 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2370 if (_vertexDiag != NULL && doc != NULL)
2371 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2374 void HEXABLOCKGUI::addEdge()
2377 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2379 _showDialogBox( _edgeDiag );
2382 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2383 if (_edgeDiag != NULL && doc != NULL)
2384 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2387 void HEXABLOCKGUI::addQuad()
2390 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2393 _showDialogBox( _quadDiag );
2396 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2397 if (_quadDiag != NULL && doc != NULL)
2398 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2401 void HEXABLOCKGUI::addHexa()
2404 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2406 _showDialogBox( _hexaDiag );
2409 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2410 if (_hexaDiag != NULL && doc != NULL)
2411 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2414 void HEXABLOCKGUI::addVector()
2416 if ( !_vectorDiag ){
2417 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2419 _showDialogBox( _vectorDiag );
2422 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2423 if (_vectorDiag != NULL && doc != NULL)
2424 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2427 //void HEXABLOCKGUI::addCylinder()
2429 // if ( !_cylinderDiag ){
2430 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2432 // _showDialogBox( _cylinderDiag );
2434 // //set default name
2435 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2436 // if (_cylinderDiag != NULL && doc != NULL)
2437 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2441 //void HEXABLOCKGUI::addPipe()
2443 // if ( !_pipeDiag){
2444 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2446 // _showDialogBox( _pipeDiag );
2448 // //set default name
2449 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2450 // if (_pipeDiag != NULL && doc != NULL)
2451 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2455 void HEXABLOCKGUI::makeGrid()
2457 if ( !_makeGridDiag ){
2458 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2460 _showDialogBox( _makeGridDiag );
2464 void HEXABLOCKGUI::makeCylinder()
2466 if ( !_makeCylinderDiag ){
2467 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2469 _showDialogBox( _makeCylinderDiag );
2472 void HEXABLOCKGUI::makePipe()
2474 if ( !_makePipeDiag ){
2475 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2477 _showDialogBox( _makePipeDiag );
2480 void HEXABLOCKGUI::makeCylinders()
2482 if ( !_makeCylindersDiag ){
2483 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2485 _showDialogBox( _makeCylindersDiag );
2488 void HEXABLOCKGUI::makePipes()
2490 if ( !_makePipesDiag ){
2491 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2493 _showDialogBox( _makePipesDiag );
2497 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2499 if ( !_makeHemiSphereDiag ){
2500 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2502 _showDialogBox( _makeHemiSphereDiag );
2506 void HEXABLOCKGUI::removeHexa()
2508 if ( !_removeHexaDiag ){
2509 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2511 _showDialogBox( _removeHexaDiag );
2515 void HEXABLOCKGUI::prismQuad()
2517 if ( !_prismQuadDiag ){
2518 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2520 _showDialogBox( _prismQuadDiag );
2524 void HEXABLOCKGUI::joinQuad()
2526 if ( !_joinQuadDiag ){
2527 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2529 _showDialogBox( _joinQuadDiag );
2532 void HEXABLOCKGUI::merge()
2535 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2537 _showDialogBox( _mergeDiag );
2540 void HEXABLOCKGUI::disconnectElts()
2542 if ( !_disconnectDiag ){
2543 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2545 _showDialogBox( _disconnectDiag );
2548 void HEXABLOCKGUI::cutEdge()
2550 if ( !_cutEdgeDiag ){
2551 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2553 _showDialogBox( _cutEdgeDiag );
2556 void HEXABLOCKGUI::makeTransformation()
2558 if ( !_makeTransformationDiag ){
2559 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2561 _showDialogBox( _makeTransformationDiag );
2565 void HEXABLOCKGUI::makeSymmetry()
2567 if ( !_makeSymmetryDiag ){
2568 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2570 _showDialogBox( _makeSymmetryDiag );
2574 void HEXABLOCKGUI::performTransformation()
2576 if ( !_performTransformationDiag ){
2577 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2579 _showDialogBox( _performTransformationDiag );
2583 void HEXABLOCKGUI::performSymmetry()
2585 if ( !_performSymmetryDiag ){
2586 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2588 _showDialogBox( _performSymmetryDiag );
2592 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2594 if ( !_replaceHexaDiag ){
2595 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2597 _showDialogBox( _replaceHexaDiag );
2601 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2603 if ( !_quadRevolutionDiag ){
2604 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2606 _showDialogBox( _quadRevolutionDiag );
2610 void HEXABLOCKGUI::assocVertex()
2612 if (!_dwInputPanel) return;
2613 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2614 if ( !_vertexAssocDiag )
2615 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2616 _showDialogBox( _vertexAssocDiag );
2620 void HEXABLOCKGUI::assocEdge()
2622 if ( !_edgeAssocDiag )
2623 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2624 _showDialogBox( _edgeAssocDiag );
2627 void HEXABLOCKGUI::assocQuad()
2629 if ( !_quadAssocDiag )
2630 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2631 _showDialogBox( _quadAssocDiag );
2635 void HEXABLOCKGUI::addGroup()
2638 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2640 _showDialogBox( _groupDiag );
2641 if (_groupDiag != NULL && getCurrentModel() != NULL)
2643 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2644 if (doc == NULL) return;
2645 char defaultName[16];
2646 sprintf (defaultName, "g%04d", doc->countGroup());
2647 _groupDiag->name_le->setText(defaultName);
2651 void HEXABLOCKGUI::removeGroup()
2653 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2654 if (currentDGView == NULL) return;
2656 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2657 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2658 int nbGroupsRemoved = 0;
2661 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2662 tr( "No group selected!" ) );
2666 foreach( QModelIndex selected, l ){
2667 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2668 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2669 Q_ASSERT(selected.isValid());
2671 //Confirm the deletion of the group
2672 if (SUIT_MessageBox::question(
2675 tr("Remove group : %1 ?").arg(selected.data().toString()),
2676 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2677 SUIT_MessageBox::Cancel
2678 ) == SUIT_MessageBox::Cancel) return;
2680 bool removed = getCurrentModel()->removeGroup( selected );
2682 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2683 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2689 if (!nbGroupsRemoved)
2690 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2691 tr( "No group selected!" ) );
2694 void HEXABLOCKGUI::addLaw()
2697 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2699 _showDialogBox( _lawDiag );
2700 if (_lawDiag != NULL && getCurrentModel() != NULL)
2702 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2703 if (doc == NULL) return;
2704 char defaultName[16];
2705 sprintf (defaultName, "l%04d", doc->countLaw());
2706 _lawDiag->name_le->setText(defaultName);
2710 void HEXABLOCKGUI::removeLaw()
2712 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2713 if (currentDGView == NULL) return;
2715 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2716 int nbLawsRemoved = 0;
2719 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2720 tr( "No law selected!" ) );
2724 foreach( QModelIndex selected, l ){
2725 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2726 selected = currentDGView->getMeshModel()->mapToSource( selected );
2727 Q_ASSERT(selected.isValid());
2729 //Confirm the deletion of the law
2730 if (SUIT_MessageBox::question(
2733 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2734 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2735 SUIT_MessageBox::Cancel
2736 ) == SUIT_MessageBox::Cancel) return;
2738 bool removed = getCurrentModel()->removeLaw(selected);
2740 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2741 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2748 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2749 tr( "No law selected!" ) );
2754 void HEXABLOCKGUI::setPropagation()
2756 if ( !_propagationDiag )
2757 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2759 _showDialogBox( _propagationDiag );
2762 // Dialog box to compute a mesh from a document
2763 // --------------------------------------------
2764 void HEXABLOCKGUI::computeMesh()
2766 if ( !_computeMeshDiag )
2767 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2769 _showDialogBox( _computeMeshDiag );
2772 void HEXABLOCKGUI::clearAssociations()
2774 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2775 if (currentDGView == NULL) return;
2777 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2778 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2779 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2781 getCurrentModel()->clearEltAssociations(iModel);
2783 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2786 void HEXABLOCKGUI::showModelInfo()
2788 //create the info dialog if not yet
2789 if (_modelInfoDiag == NULL)
2790 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2792 //show the model informations dialog
2793 _showDialogBox( _modelInfoDiag );
2796 void HEXABLOCKGUI::addShape()
2798 //create the info dialog if not yet
2799 if (_addShapeDiag == NULL)
2800 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2802 //show the model informations dialog
2803 _showDialogBox( _addShapeDiag );
2806 void HEXABLOCKGUI::clearAllAssociations()
2808 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2809 if (currentDGView == NULL) return;
2811 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2812 if (!currentIndex.isValid()) return;
2813 QVariant currentAssocVariant;
2814 QString currentAssocEntry;
2816 //Confirm the deletion of the associations
2817 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2818 if ( !treeVariant.isValid() ) return;
2819 int eltType = treeVariant.toInt();
2820 QString typeStr = "";
2821 HEXA_NS::EnumElt hexaType;
2822 if (eltType == VERTEX_DIR_TREE)
2824 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2825 hexaType = HEXA_NS::EL_VERTEX;
2827 else if (eltType == EDGE_DIR_TREE)
2829 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2830 hexaType = HEXA_NS::EL_EDGE;
2832 else if (eltType == QUAD_DIR_TREE)
2834 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2835 hexaType = HEXA_NS::EL_QUAD;
2838 if (SUIT_MessageBox::question(
2840 tr("CLEAR_ASSOCIATIONS"),
2841 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2842 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2843 SUIT_MessageBox::Cancel
2844 ) == SUIT_MessageBox::Cancel) return;
2847 DocumentModel* docModel = getCurrentModel();
2848 if (docModel == NULL) return;
2849 docModel->clearAssociation(hexaType);
2852 void HEXABLOCKGUI::showAssociations()
2854 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2855 if (currentDGView == NULL) return;
2857 QModelIndexList elts;
2858 int currentChildIndex = 0;
2859 QVariant currentAssocVariant;
2860 QString currentAssocEntry;
2861 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2862 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2864 while( currentChild.isValid() ) {
2866 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2867 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2868 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2869 elts << currentChild;
2871 currentChild = currentChild.sibling(currentChildIndex++, 0);
2873 currentDocGView->highlight(elts);
2874 currentOccGView->highlight(elts, false);
2878 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2880 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2882 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2887 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2889 if ( event->type() == QEvent::Enter )
2890 { // *** ENTER EVENT
2892 if (currentDialog == NULL || !currentDialog->isVisible())
2893 return QObject::eventFilter(obj, event);
2895 // ** The window acquire the focus when the cursor enter
2897 //OCC - window enter
2898 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2899 if ( occWindow != NULL)
2900 currentDialog->onWindowActivated(occWindow->getViewManager());
2902 //VTK - window enter
2904 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2905 if ( vtkWindow != NULL)
2906 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2910 //standard event processing
2911 return QObject::eventFilter(obj, event);
2914 QStringList HEXABLOCKGUI::getQuickDirList()
2916 QStringList dirList;
2917 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2919 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2925 // --- Export the module
2929 HexaExport CAM_Module* createModule()
2931 return new HEXABLOCKGUI();
2934 HexaExport char* getModuleVersion()
2936 return (char*)HEXABLOCK_VERSION_STR;
2942 // ******************** TESTS ***************************************************
2944 void HEXABLOCKGUI::testDocument()
2948 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2949 // QStandardItem *myItem = new QStandardItem("MyItem");
2950 // parentItem->appendRow(myItem);
2952 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2953 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2954 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2955 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2956 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2957 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2958 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2959 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2962 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2963 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2964 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2965 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2966 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2967 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2969 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2970 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2971 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2972 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2977 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2978 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2979 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2980 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2988 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2989 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2991 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2992 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2996 // newMesh( "toto", 3, "FactoryServer");
3000 void HEXABLOCKGUI::test_make_cart_grid()
3002 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3003 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3004 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3005 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3006 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3007 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3009 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3010 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3017 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3018 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3019 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3020 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3021 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3022 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3027 void HEXABLOCKGUI::test_make_elmts_transform()
3034 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3035 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3038 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3039 // orig.setScalar(2);
3041 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3042 // getCurrentModel()->saveVtk(file_name)
3044 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3045 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3047 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3048 // getCurrentModel()->saveVtk(file_name)
3050 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3053 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3054 // getCurrentModel()->saveVtk(file_name);
3057 // print "...test make elements by transforming elements OK"
3059 // =============================================================== addDocInSudy
3060 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3064 if (document == NULL)
3067 QString docName = document->getName ();
3069 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3070 if (app_study == NULL)
3073 _PTR(Study) study = app_study->studyDS();
3074 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3075 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3076 QString entry = app_study->centry("HEXABLOCK");
3077 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3078 if (aFatherSO->_is_nil())
3081 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3084 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3085 docEntry = aSO->GetID(); //the entry of the published object
3090 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3092 void HEXABLOCKGUI::test()
3094 DEBTRACE("HEXABLOCKGUI::test");
3095 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3096 if (currentDGView == NULL) return;
3097 currentDGView->update();
3101 void HEXABLOCKGUI::test_association()
3103 DEBTRACE("HEXABLOCKGUI::test_association");
3106 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3108 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3109 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3110 DocumentModel::GeomObj q0AssocA, q0AssocB;
3112 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3113 QList<DocumentModel::GeomObj> e1Assocs_test;
3114 DocumentModel::GeomObj q0Assoc_test;
3116 v0 = getCurrentModel()->addVertex(0, 0, 0);
3117 v1 = getCurrentModel()->addVertex(1, 0, 0);
3118 v2 = getCurrentModel()->addVertex(1, 1, 0);
3119 v3 = getCurrentModel()->addVertex(0, 1, 0);
3120 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3121 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3122 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3125 // >>> face3.GetEntry()'0:1:4'
3126 // >>> e1.GetEntry()'0:1:8'
3127 // >>> e2.GetEntry()'0:1:9'
3128 // >>> e3.GetEntry()'0:1:10'
3129 // >>> e4.GetEntry()'0:1:11'
3130 // >>> v1.GetEntry()'0:1:12'
3131 // >>> v2.GetEntry()'0:1:13'
3132 // >>> v3.GetEntry()'0:1:14'
3133 // >>> v4.GetEntry()'0:1:15'
3136 // v0Assoc.name = "geomV0";
3137 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3138 // v0Assoc.brep = "brepV0";
3139 // v1Assoc.name = "geomV1";
3140 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3141 // v1Assoc.brep = "brepV1";
3142 // v2Assoc.name = "geomV2";
3143 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3144 // v2Assoc.brep = "brepV2";
3145 // v3Assoc.name = "geomV3";
3146 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3147 // v3Assoc.brep = "brepV3";
3151 // e0AssocA.name = "geomE0a";
3152 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3153 // e0AssocA.brep = "brepE0a";
3154 // e0AssocA.start = 0.10;
3155 // e0AssocA.end = 0.95;
3159 // e1AssocA.name = "geomE1a";
3160 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3161 // e1AssocA.brep = "brepE1a";
3162 // e1AssocA.start = 0.12;
3163 // e1AssocA.end = 0.89;
3164 // e1AssocB.name = "geomE1b";
3165 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3166 // e1AssocB.brep = "brepE1b";
3167 // e1AssocB.start = 0.20;
3168 // e1AssocB.end = 0.80;
3169 // e1AssocC.name = "geomE1c";
3170 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3171 // e1AssocC.brep = "brepE1c";
3172 // e1AssocC.start = 0.16;
3173 // e1AssocC.end = 0.96;
3175 // q0AssocA.name = "geomQuad";
3176 // q0AssocA.entry = "0:1:1:1:3";
3177 // q0AssocA.brep = "brepq0";
3179 // q0AssocB.name = "geomQuad";
3180 // q0AssocB.entry = "0:1:1:1:4";
3181 // q0AssocB.brep = "brepq0";
3183 // getCurrentModel()->addAssociation( v0, v0Assoc );
3184 // getCurrentModel()->addAssociation( v1, v1Assoc );
3185 // getCurrentModel()->addAssociation( v2, v2Assoc );
3186 // getCurrentModel()->addAssociation( v3, v3Assoc );
3189 // getCurrentModel()->addAssociation( e0, e0AssocA );
3191 // getCurrentModel()->addAssociation( e1, e1AssocA );
3192 // getCurrentModel()->addAssociation( e1, e1AssocB );
3193 // getCurrentModel()->addAssociation( e1, e1AssocC );
3195 // getCurrentModel()->addAssociation( q0, q0AssocA );
3196 // getCurrentModel()->addAssociation( q0, q0AssocB );
3202 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3203 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3204 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3205 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3206 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3207 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3208 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3209 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3210 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3211 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3212 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3213 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3216 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3217 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3218 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3219 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3220 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3221 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3222 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3223 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3224 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3225 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3226 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3227 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3228 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3230 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3231 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3232 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3235 DEBTRACE("HEXABLOCKGUI::test_association fin");