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);
627 docGView->setViewWindow(currentDocGView->getViewWindow());
629 if (docGView->getDocumentActor() == NULL)
633 if (docGView == NULL || docGView == currentDocGView)
639 //update the current document
640 switchModel(docGView);
644 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
646 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
649 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
651 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
653 //Decharger le model correspondant (VTK)
654 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);
704 currentOccGView->setViewWindow(NULL);
708 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
710 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
712 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
713 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
715 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
717 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
718 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
719 // disable OCC selectors
720 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
721 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
722 while ( itOCCSel.hasNext() )
723 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
724 sr->setEnabled(true);
726 else if ( vm->getType() == SVTK_Viewer::Type() )
728 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
729 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
731 // disable VTK selectors
732 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
733 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
734 while ( itVTKSel.hasNext() )
735 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
736 sr->setEnabled(true);
740 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
742 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
744 SUIT_ViewModel* viewer = vm->getViewModel();
745 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
747 //VTK View Manager removed
748 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
750 //Process only if it's our view manager
751 SUIT_ViewManager* myVm = NULL;
752 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
753 myVm = currentDocGView->getViewWindow()->getViewManager();
757 //close opened dialog
758 if (currentDialog != NULL) currentDialog->close();
759 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
765 //remove its selector
766 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
767 while ( itVTKSel.hasNext() )
768 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
769 if ( sr->viewer() == viewer )
771 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
778 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
780 //OCC View removed: remove its selector
781 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
782 while ( itOCCSel.hasNext() )
783 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
784 if ( sr->viewer() == viewer )
786 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
792 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
794 QModelIndexList l = selected.indexes();
795 if ( l.count() == 0 ) return;
796 if ( !l[0].isValid() ) return;
797 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
798 if ( currentGraphicView == NULL) return;
800 QTreeView* theTree = NULL;
801 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
802 theTree = _patternDataTreeView;
804 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
805 theTree = _patternBuilderTreeView;
807 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
808 theTree = _patternGeomTreeView;
810 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
811 theTree = _groupsTreeView;
812 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
813 theTree = _meshTreeView;
816 theTree->scrollTo ( l[0] );
820 bool HEXABLOCKGUI::createSComponent() //addComponent
822 DEBTRACE("HEXABLOCKGUI::createSComponent");
823 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
825 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
826 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
827 _PTR(GenericAttribute) anAttr;
828 _PTR(AttributeName) aName;
829 _PTR(AttributeGraphic) aGraphic;
831 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
832 if ( !aComponent ){ //Create hexablock component if there's not one yet
833 aComponent = aBuilder->NewComponent("HEXABLOCK");
834 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
835 aName = _PTR(AttributeName) (anAttr);
836 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
838 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
839 _PTR(AttributePixMap) aPixmap(anAttr);
840 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
842 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
843 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
849 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
851 DEBTRACE("HEXABLOCKGUI::setResource");
852 _myresource = new HEXABLOCKGUI_Resource(r);
853 _myresource->preferencesChanged();
856 void HEXABLOCKGUI::createPreferences()
858 DEBTRACE("HEXABLOCKGUI::createPreferences");
859 _myresource->createPreferences(this);
862 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
864 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
865 _myresource->preferencesChanged(sect, name);
866 // if(name=="userCatalog")
867 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
870 void HEXABLOCKGUI::studyActivated() //CS_TODO
872 int newStudyId = getApp()->activeStudy()->id();
873 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
874 // if (_oldStudyId != -1)
876 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
877 // if (_studyContextMap.count(newStudyId))
879 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
880 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
884 // DEBTRACE("no switch to null context");
887 _oldStudyId = newStudyId;
890 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
892 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
893 QVariant currentAssocVariant;
894 QString currentAssocEntry;
896 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
897 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
898 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
899 QMenu menu( _patternDataTreeView );
901 QAction *clearAct = menu.addAction( "Remove association(s)" );
902 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
903 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
907 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
908 if (currentVtkGraphicView == NULL) return;
909 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
911 //We don't do anything for single items
912 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
913 item->type() == QUADITEM || item->type() == HEXAITEM)
916 //No associations for HEXA
917 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
918 if ( !treeVariant.isValid() ) return;
919 int eltType = treeVariant.toInt();
920 if (eltType == HEXA_DIR_TREE) return;
921 QMenu menu( _patternDataTreeView );
923 //Show association(s)
924 QAction *showAssocAct = menu.addAction( "Show associations" );
925 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
927 //Clear all associations
928 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
929 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
931 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
936 void HEXABLOCKGUI::createAndFillDockWidget()
938 QMainWindow *aParent = application()->desktop();
940 // Create dock widget (3 dock)
942 //1) *********** user input panel ( contain user's edit dialog box )
943 _dwInputPanel = new QDockWidget(aParent);
944 _dwInputPanel->setVisible(false);
945 _dwInputPanel->setWindowTitle("Input Panel");
946 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
948 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
950 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
952 _dwPattern = new QDockWidget(aParent);
953 _dwPattern->setVisible(false);
954 _dwPattern->setWindowTitle("Model");
955 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
957 QFrame* patternFrame = new QFrame(_dwPattern);
958 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
959 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
960 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
961 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
962 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
963 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
964 _patternGeomTreeView = new QTreeView(patternFrame);
965 splitter->addWidget(_patternDataTreeView);
966 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
967 splitter->addWidget(_patternGeomTreeView);
968 patternLayout->addWidget(splitter);
970 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
971 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
972 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
975 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
976 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
978 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
979 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
981 _dwPattern->setWidget(patternFrame);
982 patternFrame->show();
985 _dwGroups = new QDockWidget(aParent);
987 _dwGroups->setVisible(false);
988 _dwGroups->setWindowTitle("Groups");
989 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
990 _groupsTreeView = new QTreeView(_dwGroups);
991 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
992 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
993 _dwGroups->setWidget(_groupsTreeView);
994 _groupsTreeView->show();
997 _dwMesh = new QDockWidget(aParent);
998 _dwMesh->setVisible(false);
999 _dwMesh->setWindowTitle("Mesh");
1000 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1001 _meshTreeView = new QTreeView(_dwMesh);
1002 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1003 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1004 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1005 _dwMesh->setWidget(_meshTreeView);
1006 _meshTreeView->show();
1008 QDockWidget *_dwObjectBrowser = 0;
1009 QWidget* wid = getApp()->objectBrowser()->treeView();
1010 QWidget *w = wid->parentWidget();
1011 while ( w && !_dwObjectBrowser ) {
1012 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1013 w = w->parentWidget();
1015 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1016 _dwObjectBrowser->setWindowTitle("Study");
1018 // dock widget position
1019 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1020 // aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
1021 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1023 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1024 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1025 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1028 #if QT_VERSION >= 0x040500
1029 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1033 // popup menu on data tree view
1034 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1035 connect(_patternDataTreeView,
1036 SIGNAL(customContextMenuRequested(const QPoint &)),
1038 SLOT(treeContextMenu(const QPoint &)),
1039 Qt::UniqueConnection );
1042 void HEXABLOCKGUI::createActions()
1044 QMainWindow *aParent = application()->desktop();
1045 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1048 _newAct = createAction(_menuId++,
1049 tr("Create a new document"),
1050 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1052 tr("Create a new document"),
1053 0, aParent, false, this, SLOT(newDocument()));
1054 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1056 _importAct = createAction(_menuId++,
1057 tr("Load a document"),
1058 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1059 tr("Load Document"),
1060 tr("Load a document"),
1061 0, aParent, false, this, SLOT(loadDocument()));
1062 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1064 _saveAct = createAction(_menuId++,
1065 tr("Save the document"),
1066 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1067 tr("Save Document"),
1068 tr("Save the document"),
1069 0, aParent, false, this, SLOT(saveDocument()));
1071 // Pattern Data creation
1072 _addVertex = createAction(_menuId++,
1073 tr("Create a vertex"),
1074 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1076 tr("Create a new vertex"),
1077 0, aParent, false, this, SLOT(addVertex()));
1079 _addEdge = createAction(_menuId++,
1080 tr("Create an edge"),
1081 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1083 tr("Create a new edge"),
1084 0, aParent, false, this, SLOT(addEdge()));
1086 _addQuad = createAction(_menuId++,
1087 tr("Create a quadrangle"),
1088 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1089 tr("Add Quadrangle"),
1090 tr("Create a new quadrangle"),
1091 0, aParent, false, this, SLOT(addQuad()));
1093 _addHexa = createAction(_menuId++,
1094 tr("Create an hexahedron"),
1095 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1096 tr("Add Hexahedron"),
1097 tr("Create a new hexahedron"),
1098 0, aParent, false, this, SLOT(addHexa()));
1100 // Builder Data creation
1101 _addVector = createAction(_menuId++,
1102 tr("Create a vector"),
1103 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1105 tr("Create a new vector"),
1106 0, aParent, false, this, SLOT(addVector()));
1108 // _addCylinder = createAction(_menuId++,
1109 // tr("Create a cylinder"),
1110 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1111 // tr("Add Cylinder"),
1112 // tr("Create a new cylinder"),
1113 // 0, aParent, false, this, SLOT(addCylinder()));
1115 // _addPipe = createAction(_menuId++,
1116 // tr("Create a pipe"),
1117 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1119 // tr("Create a new pipe"),
1120 // 0, aParent, false, this, SLOT(addPipe()));
1122 _makeGrid = createAction(_menuId++,
1124 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1127 0, aParent, false, this, SLOT(makeGrid()));
1129 _makeCylinder = createAction(_menuId++,
1130 tr("Make a cylinder"),
1131 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1132 tr("Make Cylinder"),
1133 tr("Make a cylinder"),
1134 0, aParent, false, this, SLOT(makeCylinder()));
1136 _makePipe = createAction(_menuId++,
1138 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1141 0, aParent, false, this, SLOT(makePipe()));
1143 _makeCylinders = createAction(_menuId++,
1144 tr("Make cylinders"),
1145 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1146 tr("Make Cylinders"),
1147 tr("Make cylinders"),
1148 0, aParent, false, this, SLOT(makeCylinders()));
1150 _makePipes = createAction(_menuId++,
1152 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1155 0, aParent, false, this, SLOT(makePipes()));
1157 _makeHemiSphere = createAction(_menuId++,
1158 tr("Make an hemisphere"),
1159 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1160 tr("Make Hemisphere"),
1161 tr("Make an hemisphere"),
1162 0, aParent, false, this, SLOT(makeHemiSphere()));
1164 // Pattern Data edition
1165 _removeHexa = createAction(_menuId++,
1166 tr("Remove hexahedra"),
1167 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1168 tr("Remove Hexahedra"),
1169 tr("Remove hexahedra"),
1170 0, aParent, false, this, SLOT(removeHexa()));
1172 _prismQuad = createAction(_menuId++,
1173 tr("Prism quadrangles"),
1174 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1175 tr("Prism Quadrangles"),
1176 tr("Prism quadrangles"),
1177 0, aParent, false, this, SLOT(prismQuad()));
1179 _joinQuad = createAction(_menuId++,
1180 tr("Join quadrangles"),
1181 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1182 tr("Join Quadrangles"),
1183 tr("Join quadrangles with hexahedra"),
1184 0, aParent, false, this, SLOT(joinQuad()));
1186 _merge = createAction(_menuId++,
1188 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1191 0, aParent, false, this, SLOT(merge()));
1193 _disconnect = createAction(_menuId++,
1195 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1197 tr("Disconnect edges, vertexes or quadrangles"),
1198 0, aParent, false, this, SLOT(disconnectElts()));
1200 _cutEdge = createAction(_menuId++,
1202 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1205 0, aParent, false, this, SLOT(cutEdge()));
1207 _makeTransformation = createAction(_menuId++,
1208 tr("Make transformation"),
1209 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1210 tr("Make Transformation"),
1211 tr("Make transformation"),
1212 0, aParent, false, this, SLOT(makeTransformation()));
1214 _makeSymmetry = createAction(_menuId++,
1215 tr("Make symmetry"),
1216 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1217 tr("Make Symmetry"),
1218 tr("Make symmetry"),
1219 0, aParent, false, this, SLOT(makeSymmetry()));
1221 _performTransformation = createAction(_menuId++,
1222 tr("Perform transformation"),
1223 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1224 tr("Perform Transformation"),
1225 tr("Perform transformation"),
1226 0, aParent, false, this, SLOT(performTransformation()));
1228 _performSymmetry = createAction(_menuId++,
1229 tr("Perform symmetry"),
1230 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1231 tr("Perform Symmetry"),
1232 tr("Perform symmetry"),
1233 0, aParent, false, this, SLOT(performSymmetry()));
1235 _replaceHexa = createAction(_menuId++,
1236 tr("Replace hexahedron"),
1237 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1238 tr("Replace Hexahedron"),
1239 tr("Replace hexahedron"),
1240 0, aParent, false, this, SLOT(replaceHexa()));
1242 _quadRevolution = createAction(_menuId++,
1243 tr("Quad revolution"),
1244 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1245 tr("Quad Revolution"),
1246 tr("Quad revolution"),
1247 0, aParent, false, this, SLOT(quadRevolution()));
1250 _assocVertex = createAction(_menuId++,
1251 tr("Make vertex association"),
1252 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1253 tr("Make Vertex association"),
1254 tr("Make vertex association"),
1255 0, aParent, false, this, SLOT(assocVertex()));
1257 _assocEdge = createAction(_menuId++,
1258 tr("Make edge association"),
1259 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1260 tr("Make Edge Association"),
1261 tr("Make edge association"),
1262 0, aParent, false, this, SLOT(assocEdge()));
1264 _assocQuad = createAction(_menuId++,
1265 tr("Make quad association"),
1266 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1267 tr("Make Quad Association"),
1268 tr("Make quad association"),
1269 0, aParent, false, this, SLOT(assocQuad()));
1272 _addGroup = createAction(_menuId++,
1274 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1277 0, aParent, false, this, SLOT(addGroup()));
1279 _removeGroup = createAction(_menuId++,
1280 tr("Remove a group"),
1281 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1283 tr("Remove a group"),
1284 0, aParent, false, this, SLOT(removeGroup()));
1287 _addLaw = createAction(_menuId++,
1289 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1292 0, aParent, false, this, SLOT(addLaw()));
1294 _removeLaw = createAction(_menuId++,
1296 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1299 0, aParent, false, this, SLOT(removeLaw()));
1301 _setPropagation = createAction(_menuId++,
1302 tr("Set propagation"),
1303 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1304 tr("Set Propagation"),
1305 tr("Set propagation"),
1306 0, aParent, false, this, SLOT(setPropagation()));
1308 _computeMesh = createAction(_menuId++,
1310 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1313 0, aParent, false, this, SLOT(computeMesh()));
1315 _showModelInfoAct = createAction(_menuId++,
1316 tr("Show Model Info"),
1317 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1320 0, aParent, false, this, SLOT(showModelInfo()));
1322 _addShapeAct = createAction(_menuId++,
1324 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1327 0, aParent, false, this, SLOT(addShape()));
1329 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1330 // QAction* createAction(const int id,
1331 // const QString& toolTip,
1332 // const QIcon& icon,
1333 // const QString& menu,
1334 // const QString& status,
1335 // const int shortCut,
1336 // QObject* parent =0,
1337 // bool checkable = false,
1338 // QObject* receiver =0,
1339 // const char* member =0);
1341 _sep1 = separator();
1342 _sep2 = separator();
1343 _sep3 = separator();
1344 _sep4 = separator();
1348 void HEXABLOCKGUI::createMenus()
1350 int aMenuId, subMenuId,aMenuIdMain;
1352 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1354 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1355 createMenu( actionId(_newAct), aMenuId );
1356 createMenu( actionId(_importAct), aMenuId );
1357 createMenu( _saveAct, aMenuId );
1360 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1361 createMenu( _newAct, aMenuDocId );//, 10
1362 createMenu( _importAct, aMenuDocId );
1363 createMenu( _saveAct, aMenuDocId );
1365 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1366 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1367 createMenu( _addVertex, subMenuId );
1368 createMenu( _addEdge, subMenuId );
1369 createMenu( _addQuad, subMenuId );
1370 createMenu( _addHexa, subMenuId );
1371 createMenu( _sep1, subMenuId);
1374 createMenu( _addVector, subMenuId );
1375 // createMenu( _addCylinder, subMenuId );
1376 // createMenu( _addPipe, subMenuId );
1378 createMenu( _sep2, subMenuId);
1380 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1381 createMenu( _makeHemiSphere,subMenuId );
1383 createMenu( _sep3, subMenuId);
1385 createMenu( _makeCylinder, subMenuId );
1386 createMenu( _makePipe, subMenuId );
1387 createMenu( _makeCylinders,subMenuId );
1388 createMenu( _makePipes, subMenuId );
1390 // Pattern Data Edition
1391 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1392 createMenu( _removeHexa, subMenuId );
1393 createMenu( _prismQuad, subMenuId );
1394 createMenu( _joinQuad, subMenuId );
1395 createMenu( _merge, subMenuId );
1396 createMenu( _disconnect, subMenuId );
1397 createMenu( _cutEdge, subMenuId );
1398 createMenu( _makeTransformation, subMenuId );
1399 createMenu( _makeSymmetry, subMenuId );
1400 createMenu( _performTransformation, subMenuId );
1401 createMenu( _performSymmetry, subMenuId );
1402 createMenu( _replaceHexa, subMenuId );
1403 createMenu( _quadRevolution, subMenuId );
1404 createMenu( _sep4, aMenuId );
1405 createMenu( _showModelInfoAct, aMenuId );
1408 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1409 createMenu( _addShapeAct, aMenuId );
1410 createMenu( _assocVertex, aMenuId );
1411 createMenu( _assocEdge, aMenuId );
1412 createMenu( _assocQuad, aMenuId );
1415 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1416 createMenu( _addGroup, aMenuId );
1417 createMenu( _removeGroup, aMenuId ); //CS_TODO
1420 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1421 createMenu( _addLaw, aMenuId );
1422 createMenu( _removeLaw, aMenuId );
1423 createMenu( _setPropagation, aMenuId );
1424 createMenu( _computeMesh, aMenuId );
1426 //show model infomation menu
1427 QString aRule = "$component={'HEXABLOCK'}";
1428 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1429 popupMgr()->setRule( _showModelInfoAct, aRule);
1431 //associate shape to a document menu
1432 popupMgr()->insert( _addShapeAct, -1, -1 );
1433 popupMgr()->setRule( _addShapeAct, aRule );
1435 //-------------------------------------------------
1437 //-------------------------------------------------
1438 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1439 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1440 // QString isNotEmpty("numberOfNodes <> 0");
1441 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1442 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1443 //// aType = aType.arg( mesh_part );
1445 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1446 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1447 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1449 // popupMgr()->insert( separator(), -1, -1 );
1450 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1451 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1452 // // MESSAGE("aClient = " << aClient.toStdString());
1453 // // MESSAGE("aType = " << aType.toStdString());
1454 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1455 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1456 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1457 // // MESSAGE("aRule = " << aRule.toStdString());
1458 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1459 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1461 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1462 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1464 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1465 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1467 // popupMgr()->insert( separator(), -1, -1 );
1471 void HEXABLOCKGUI::createTools()
1475 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1476 createTool( _newAct, aToolId );
1477 createTool( _importAct, aToolId );
1478 createTool( _saveAct, aToolId );
1479 createTool( _showModelInfoAct, aToolId );
1480 // createTool( _testAct, aToolId );
1481 //createTool( separator(), aToolId );
1484 aToolId = createTool ( tr( "Construction" ) );
1485 createTool( _addVertex, aToolId );
1486 createTool( _addEdge, aToolId );
1487 createTool( _addQuad, aToolId );
1488 createTool( _addHexa, aToolId );
1490 createTool( _sep1, aToolId );
1493 createTool( _addVector, aToolId );
1494 // createTool( _addCylinder, aToolId );
1495 // createTool( _addPipe, aToolId );
1497 createTool( _sep2, aToolId );
1499 createTool( _makeGrid, aToolId );
1500 createTool( _makeHemiSphere, aToolId );
1502 createTool( _sep3, aToolId );
1504 createTool( _makeCylinder, aToolId );
1505 createTool( _makePipe, aToolId );
1506 createTool( _makeCylinders,aToolId );
1507 createTool( _makePipes, aToolId );
1509 // Pattern Data Edition
1510 aToolId = createTool ( tr( "Operation" ) );
1511 createTool( _removeHexa, aToolId );
1512 createTool( _prismQuad, aToolId );
1513 createTool( _joinQuad, aToolId );
1514 createTool( _merge, aToolId );
1515 createTool( _disconnect, aToolId );
1516 createTool( _cutEdge, aToolId );
1517 createTool( _makeTransformation, aToolId );
1518 createTool( _makeSymmetry, aToolId );
1519 createTool( _performTransformation, aToolId );
1520 createTool( _performSymmetry, aToolId );
1521 createTool( _replaceHexa, aToolId );
1522 createTool( _quadRevolution, aToolId );
1525 aToolId = createTool ( tr( "Association" ) );
1526 createTool( _assocVertex, aToolId );
1527 createTool( _assocEdge, aToolId );
1528 createTool( _assocQuad, aToolId );
1529 createTool( _addShapeAct, aToolId );
1532 aToolId = createTool ( tr( "Group" ) );
1533 createTool( _addGroup, aToolId );
1534 createTool( _removeGroup, aToolId ); //CS_TODO
1537 aToolId = createTool ( tr( "Mesh" ) );
1538 createTool( _addLaw, aToolId );
1539 createTool( _removeLaw, aToolId );
1540 createTool( _setPropagation, aToolId );
1541 createTool( _computeMesh, aToolId );
1545 void HEXABLOCKGUI::initialMenus()
1547 showDocumentMenus( true );
1548 showPatternMenus( false );
1549 showAssociationMenus( false );
1550 showGroupsMenus( false );
1551 showMeshMenus( false );
1554 void HEXABLOCKGUI::showAllMenus()
1556 showDocumentMenus( true );
1557 showPatternMenus( true );
1558 showAssociationMenus( true );
1559 showGroupsMenus( true );
1560 showMeshMenus( true );
1564 void HEXABLOCKGUI::showDocumentMenus(bool show)
1566 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1568 setMenuShown(_newAct, show);
1569 setToolShown(_newAct, show);
1570 setMenuShown(_importAct, show);
1571 setToolShown(_importAct, show);
1572 setMenuShown(_showModelInfoAct, show);
1573 setToolShown(_showModelInfoAct, show);
1574 setMenuShown(_saveAct, show);
1575 setToolShown(_saveAct, show);
1578 void HEXABLOCKGUI::showPatternMenus(bool show)
1580 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1581 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1582 if ( show && !getCurrentModel() ) return;
1584 setMenuShown(_addVertex, show );
1585 setToolShown(_addVertex, show);
1586 setMenuShown(_addEdge, show );
1587 setToolShown(_addEdge, show);
1588 setMenuShown(_addQuad, show );
1589 setToolShown(_addQuad, show);
1590 setMenuShown(_addHexa, show );
1591 setToolShown(_addHexa, show);
1593 setMenuShown(_sep1, show );
1594 setToolShown(_sep1, show);
1596 setMenuShown( _addVector, show );
1597 setToolShown( _addVector, show);
1598 // setMenuShown( _addCylinder, show );
1599 // setToolShown( _addCylinder, show);
1600 // setMenuShown( _addPipe, show );
1601 // setToolShown( _addPipe, show);
1603 setMenuShown(_sep2, show );
1604 setToolShown(_sep2, show);
1606 setMenuShown( _makeGrid, show );
1607 setToolShown( _makeGrid, show);
1608 setMenuShown( _makePipe, show );
1609 setToolShown( _makePipe, show);
1611 setMenuShown(_sep3, show );
1612 setToolShown(_sep3, show);
1614 setMenuShown( _makeCylinder, show );
1615 setToolShown( _makeCylinder, show);
1616 setMenuShown( _makeCylinders, show );
1617 setToolShown( _makeCylinders, show);
1618 setMenuShown( _makePipes, show );
1619 setToolShown( _makePipes, show);
1620 setMenuShown( _makeHemiSphere, show );
1621 setToolShown( _makeHemiSphere, show);
1623 // Pattern Data Edition
1624 setMenuShown( _removeHexa, show );
1625 setToolShown( _removeHexa, show);
1626 setMenuShown( _prismQuad, show );
1627 setToolShown( _prismQuad, show);
1628 setMenuShown( _joinQuad, show );
1629 setToolShown( _joinQuad, show);
1630 setMenuShown( _merge, show );
1631 setToolShown( _merge, show);
1632 setMenuShown( _disconnect, show );
1633 setToolShown( _disconnect, show);
1634 setMenuShown( _cutEdge, show );
1635 setToolShown( _cutEdge, show);
1636 setMenuShown( _makeTransformation, show );
1637 setToolShown( _makeTransformation, show);
1638 setMenuShown( _makeSymmetry, show );
1639 setToolShown( _makeSymmetry, show);
1640 setMenuShown( _performTransformation, show );
1641 setToolShown( _performTransformation, show);
1642 setMenuShown( _performSymmetry, show );
1643 setToolShown( _performSymmetry, show);
1644 setMenuShown( _replaceHexa, show );
1645 setToolShown( _replaceHexa, show);
1646 setMenuShown( _quadRevolution, show );
1647 setToolShown( _quadRevolution, show);
1649 setMenuShown( _sep4, show );
1650 setMenuShown( _showModelInfoAct, show );
1654 void HEXABLOCKGUI::showAssociationMenus(bool show)
1656 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1657 if ( show && !getCurrentModel() ) return;
1659 // Association Edition
1660 setMenuShown( _assocVertex, show );
1661 setToolShown( _assocVertex, show );
1662 setMenuShown( _assocEdge, show );
1663 setToolShown( _assocEdge, show );
1664 setMenuShown( _assocQuad, show );
1665 setToolShown( _assocQuad, show );
1666 setMenuShown( _addShapeAct, show );
1667 setToolShown( _addShapeAct, show );
1671 void HEXABLOCKGUI::showGroupsMenus(bool show)
1673 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1674 if ( show && !getCurrentModel() ) return;
1675 setMenuShown( _addGroup, show );
1676 setToolShown( _addGroup, show);
1677 setMenuShown( _removeGroup , show );
1678 setToolShown( _removeGroup , show);
1681 void HEXABLOCKGUI::showMeshMenus(bool show)
1683 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1684 if ( show && !getCurrentModel() ) return;
1685 setMenuShown( _addLaw, show );
1686 setToolShown( _addLaw, show);
1687 setMenuShown( _removeLaw, show );
1688 setToolShown( _removeLaw, show);;
1689 setMenuShown( _setPropagation, show );
1690 setToolShown( _setPropagation, show);
1691 setMenuShown( _computeMesh, show);
1692 setToolShown( _computeMesh, show);
1695 void HEXABLOCKGUI::showVtkActor()
1697 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1698 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1699 currentVtkGView->getDocumentActor() == NULL)
1702 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1703 if (vtkView == NULL)
1706 SUIT_ViewManager* vman = vtkView->getViewManager();
1707 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1709 //show only the current actor -----------------
1710 vtkView->setFocus();
1711 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1712 Document_Actor *lastDocActor;
1713 if (lastVtkDocGView != NULL)
1715 lastDocActor = lastVtkDocGView->getDocumentActor();
1716 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1717 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1719 vtkView->Erase(lastActorIO);
1720 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1721 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1724 currentVtkGView->update();
1725 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1726 if (!anIO.IsNull() && anIO->hasEntry())
1728 vtkView->Display(anIO);
1729 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1730 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1732 vtkView->onFitAll();
1735 void HEXABLOCKGUI::showOccActor()
1737 if (currentOccGView == NULL)
1739 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1740 if (occView == NULL)
1742 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1746 if (lastOccPrs != NULL)
1747 vf->Erase(lastOccPrs);
1748 currentOccGView->globalSelection();
1749 SOCC_Prs* prs = getOccPrs(currentDocGView);
1750 currentOccGView->setPrs(prs);
1753 occView->onFitAll();
1756 void HEXABLOCKGUI::hideVtkActor()
1758 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1759 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1760 currentVtkGView->getViewWindow() == NULL ||
1761 currentVtkGView->getDocumentActor() == NULL) return;
1763 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1764 currentVtkGView->getViewWindow()->onResetView();
1766 //update the visibility state now
1767 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1768 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1769 if (aStudy == NULL || vman == NULL) return;
1771 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1772 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1773 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1776 void HEXABLOCKGUI::hideOccActor()
1778 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1779 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1780 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1781 if (occView == NULL || docModel == NULL)
1783 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1787 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1788 if (currentOccPrs != NULL)
1789 vf->Erase(currentOccPrs);
1791 occView->onResetView();
1794 void HEXABLOCKGUI::showOnlyActor()
1800 void HEXABLOCKGUI::hideActor()
1807 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1809 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1811 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1812 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1814 if (_dwPattern) _dwPattern->setVisible(isVisible);
1815 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1817 if (_dwMesh) _dwMesh->setVisible(isVisible);
1818 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1820 if (_dwGroups) _dwGroups->setVisible(isVisible);
1821 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1825 //clear all used dialogs by the current model
1826 void HEXABLOCKGUI::clearDialogs()
1828 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1829 fin (currentModelDialogs.end());
1830 for(;debut!=fin;++debut) (*debut)->clear();
1832 currentModelDialogs.clear(); //empty the used dialogs list
1835 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1837 if (!gViewDlgBox.contains(dgview)) return NULL;
1838 return gViewDlgBox[dgview];
1841 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1843 if (dgview == NULL) return;
1845 switchOffGraphicView(dgview, false); //to avoid double connect
1848 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1849 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1850 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1851 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1852 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1853 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1854 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1855 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1856 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1857 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1858 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1859 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1864 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1866 if (dgview == NULL) return;
1868 //disconnect signals
1869 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1870 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1871 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1872 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1873 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1874 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1875 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1876 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1877 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1878 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1879 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1880 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1883 gViewDlgBox[dgview] = currentDialog;
1885 //close opened dialog
1886 if (currentDialog != NULL) currentDialog->close();
1887 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1893 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1895 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1899 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1903 //switch off the current document graphic view (disconnect signals...)
1904 if (currentDocGView != NULL)
1906 //Hide current actor
1908 switchOffGraphicView(currentDocGView);
1911 //clear the dialogs used by the current model so they can be used by the new model
1912 if (currentDocGView != dgview) clearDialogs();
1914 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1915 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1916 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1917 _groupsTreeView->setModel(dgview->getGroupsModel());
1918 _meshTreeView->setModel(dgview->getMeshModel());
1920 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1921 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1923 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1924 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1926 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1927 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1929 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1930 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1932 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1933 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1936 // = * init occ view * =
1937 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1939 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1940 currentOccGView->getViewWindow()->installEventFilter(this);
1945 // = * init vtk view * =
1946 if (currentDocGView != NULL)
1948 if (currentDocGView->getViewWindow() != NULL)
1949 dgview->setViewWindow(currentDocGView->getViewWindow());
1952 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1953 dgview->getViewWindow()->installEventFilter(this);
1959 switchOnGraphicView(dgview);
1961 if (currentDocGView != NULL)
1963 lastVtkDocGView = currentDocGView;
1964 lastOccPrs = getOccPrs(currentDocGView);
1968 lastVtkDocGView = dgview;
1969 lastOccPrs = getOccPrs(dgview);
1972 currentDocGView = dgview;
1974 currentDocGView->getDocumentModel()->refresh();
1975 _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1979 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1981 if (currentDocGView == NULL) return NULL;
1982 return currentDocGView->getDocumentModel();
1986 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1988 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1989 if (anApp == NULL) return UNKNOWN;
1990 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1991 if (activeVm == NULL) return UNKNOWN;
1993 QString vmType = activeVm->getType();
1994 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1996 else if ( vmType == OCCViewer_Viewer::Type() )
2002 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2004 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2008 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2011 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2013 // Create Document from HEXABLOCK ENGINE
2014 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2015 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2017 // looking doc impl ( c++ )
2018 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2019 // ^Hexa6 ASSERT( dServant );
2020 // ^Hexa6 if ( dServant)
2021 // ^Hexa6 doc = dServant->GetImpl();
2023 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2024 QString docEntry = addDocInStudy (doc);
2026 // looking for docEntry
2027 /* ****************************************************************
2028 if ( !CORBA::is_nil(docIn) ){
2029 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2030 QString docIOR = anIOR.in();
2031 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2032 if ( !docIOR.isEmpty() ) {
2033 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2035 docEntry = SO->GetID().c_str();
2038 **************************************************************** */
2039 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2041 return make_pair (docEntry, doc);
2045 void HEXABLOCKGUI::newDocument()
2047 DEBTRACE("HEXABLOCKGUI::newDocument");
2050 QMainWindow *aParent = application()->desktop();
2051 QWidget *central = aParent->centralWidget();
2053 central->setFocus();
2055 DEBTRACE("No Central Widget");
2058 if (currentOccGView == NULL)
2060 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2061 application()->desktop());
2062 currentOccGView->getViewWindow()->installEventFilter(this);
2064 else if (currentOccGView->getViewWindow() == NULL)
2066 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2067 currentOccGView->getViewWindow()->installEventFilter(this);
2071 // Create Document from HEXABLOCK ENGINE
2072 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2074 VtkDocumentGraphicView* newGraphicView = NULL;
2075 //One document at a time
2076 if (currentDocGView != NULL)
2078 if (currentDocGView->getViewWindow() == NULL)
2080 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2081 currentDocGView->getViewWindow()->installEventFilter(this);
2084 // Create a new document with the current window
2085 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2086 new DocumentModel( docEntry_Doc.second,
2087 docEntry_Doc.first, this ),
2088 currentDocGView->getViewWindow(),
2089 application()->desktop() );
2093 // Create the new Document Graphic View with a new window
2094 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2095 new DocumentModel( docEntry_Doc.second,
2096 docEntry_Doc.first, this ),
2097 graphicViewsHandler->createVtkWindow(),
2098 application()->desktop() );
2099 newGraphicView->getViewWindow()->installEventFilter(this);
2102 if (newGraphicView == NULL)
2103 //We couldn't create a new document graphic view
2104 //we'd better show a dialog box info to inform the user
2107 docs[docEntry_Doc.first] = newGraphicView;
2108 switchModel(newGraphicView); //select the corresponding document in the browser instead
2110 getApp()->updateObjectBrowser();
2115 //Loads the model from the xmlFile in the current graphic view
2116 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2118 DEBTRACE("HEXABLOCKGUI::loadDocument");
2121 QMainWindow *aParent = application()->desktop();
2122 QString selectedFile;
2124 if ( inFile.isNull() ){
2125 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2126 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2127 dialog.setHistory( getQuickDirList() );
2129 //use the last path as default
2130 if (!(loadDocLastPath->absolutePath()).isEmpty())
2131 dialog.setDirectory(*loadDocLastPath);
2134 QStringList selectedFiles = dialog.selectedFiles();
2135 if (!selectedFiles.isEmpty())
2136 selectedFile = selectedFiles.first();
2138 //remember the selected path
2139 *loadDocLastPath = dialog.directory();
2142 selectedFile = inFile;
2144 if (selectedFile.isEmpty())
2147 //we create a new document if necessary
2148 if (currentDocGView == NULL)
2149 //Need a new document
2151 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2153 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2154 currentDocGView->getViewWindow()->installEventFilter(this);
2157 if (!currentDocGView->isEmpty())
2158 //we can only have one document for a graphic view
2161 //we load the selected file in the current graphic view
2162 currentDocGView->loadDocument(selectedFile);
2163 DocumentModel* currentModel = getCurrentModel();
2164 renameObject( currentModel->documentEntry(), currentModel->getName() );
2169 void HEXABLOCKGUI::saveDocument()
2171 QMainWindow *aParent = application()->desktop();
2173 QString aDocName = "document", aFilename;
2175 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2176 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2178 //use the last selected directory as default path for file selection
2179 aFilename = saveDocLastPath->absolutePath();
2180 if (!aFilename.isEmpty())
2181 aFilename += QString("/") + aDocName;
2183 //show the dialog for file selection
2184 aFilename = SUIT_FileDlg::getFileName( aParent,
2187 tr( "Save HexaBlock Document" ),
2190 //save the document in the selected file
2191 if ( !aFilename.isEmpty() ) {
2192 getCurrentVtkGraphicView()->saveDocument( aFilename );
2194 //Remember the path for next save
2195 QFileInfo fileInfo(aFilename);
2196 *saveDocLastPath = fileInfo.dir();
2202 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2204 _patternDataTreeView->openPersistentEditor( topLeft );
2207 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2209 if (diag == NULL || _dwInputPanel == NULL ||
2210 getCurrentVtkGraphicView() == NULL) return;
2212 //mark this dialog as used by the current model
2213 currentModelDialogs.insert(diag);
2215 //close the current dialog box info
2216 // if (_treeViewDelegate != NULL)
2217 // _treeViewDelegate->closeDialog();
2219 // if (_dwInputPanel->widget())
2220 // _dwInputPanel->widget()->close();
2222 //Temporary for debugging EdgeAssoc Faked InfoDialog
2223 if (diag == _edgeAssocDiag)
2224 diag->debugEdgeAssoc = true;
2226 diag->debugEdgeAssoc = false;
2228 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2229 diag == _quadAssocDiag || diag == _addShapeDiag)
2230 assocInProgress = true;
2232 assocInProgress = false;
2234 //show the dialog box in the dockwidget
2235 diag->resetSizeAndShow(_dwInputPanel);
2237 //clear the current selections
2238 selectionMgr()->clearSelected();
2240 currentDialog = diag;
2243 if (currentDocGView != NULL)
2244 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2247 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2249 if (vertex == NULL || _dwInputPanel == NULL)
2252 if (_vertexInfoDialog == NULL)
2253 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2255 _vertexInfoDialog->setValue(vertex);
2256 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2257 currentDialog = _vertexInfoDialog;
2260 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2262 if (edge == NULL || _dwInputPanel == NULL)
2265 if (_edgeInfoDialog == NULL)
2266 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2268 _edgeInfoDialog->setValue(edge);
2269 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2270 currentDialog = _edgeInfoDialog;
2273 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2275 if (quad == NULL || _dwInputPanel == NULL)
2278 if (_quadInfoDialog == NULL)
2279 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2281 _quadInfoDialog->setValue(quad);
2282 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2283 currentDialog = _quadInfoDialog;
2286 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2288 if (hexa == NULL || _dwInputPanel == NULL)
2291 if (_hexaInfoDialog == NULL)
2292 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2294 _hexaInfoDialog->setValue(hexa);
2295 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2296 currentDialog = _hexaInfoDialog;
2299 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2301 if (vector == NULL || _dwInputPanel == NULL)
2304 if (_vectorInfoDialog == NULL)
2305 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2307 _vectorInfoDialog->setValue(vector);
2308 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2309 currentDialog = _vectorInfoDialog;
2312 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2314 if (group == NULL || _dwInputPanel == NULL)
2317 if (_groupInfoDialog == NULL)
2318 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2320 _groupInfoDialog->setValue(group);
2321 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2322 currentDialog = _groupInfoDialog;
2325 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2327 if (law == NULL || _dwInputPanel == NULL)
2330 if (_lawInfoDialog == NULL)
2331 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2333 _lawInfoDialog->setValue(law);
2334 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2335 currentDialog = _lawInfoDialog;
2338 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2340 if (propagation == NULL || _dwInputPanel == NULL)
2343 if (_propagationInfoDialog == NULL)
2344 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2346 _propagationInfoDialog->setValue(propagation);
2347 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2348 currentDialog = _propagationInfoDialog;
2351 void HEXABLOCKGUI::addVertex()
2353 if ( !_vertexDiag ){
2354 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2356 _showDialogBox( _vertexDiag );
2359 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2360 if (_vertexDiag != NULL && doc != NULL)
2361 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2364 void HEXABLOCKGUI::addEdge()
2367 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2369 _showDialogBox( _edgeDiag );
2372 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2373 if (_edgeDiag != NULL && doc != NULL)
2374 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2377 void HEXABLOCKGUI::addQuad()
2380 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2383 _showDialogBox( _quadDiag );
2386 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2387 if (_quadDiag != NULL && doc != NULL)
2388 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2391 void HEXABLOCKGUI::addHexa()
2394 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2396 _showDialogBox( _hexaDiag );
2399 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2400 if (_hexaDiag != NULL && doc != NULL)
2401 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2404 void HEXABLOCKGUI::addVector()
2406 if ( !_vectorDiag ){
2407 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2409 _showDialogBox( _vectorDiag );
2412 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2413 if (_vectorDiag != NULL && doc != NULL)
2414 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2417 //void HEXABLOCKGUI::addCylinder()
2419 // if ( !_cylinderDiag ){
2420 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2422 // _showDialogBox( _cylinderDiag );
2424 // //set default name
2425 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2426 // if (_cylinderDiag != NULL && doc != NULL)
2427 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2431 //void HEXABLOCKGUI::addPipe()
2433 // if ( !_pipeDiag){
2434 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2436 // _showDialogBox( _pipeDiag );
2438 // //set default name
2439 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2440 // if (_pipeDiag != NULL && doc != NULL)
2441 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2445 void HEXABLOCKGUI::makeGrid()
2447 if ( !_makeGridDiag ){
2448 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2450 _showDialogBox( _makeGridDiag );
2454 void HEXABLOCKGUI::makeCylinder()
2456 if ( !_makeCylinderDiag ){
2457 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2459 _showDialogBox( _makeCylinderDiag );
2462 void HEXABLOCKGUI::makePipe()
2464 if ( !_makePipeDiag ){
2465 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2467 _showDialogBox( _makePipeDiag );
2470 void HEXABLOCKGUI::makeCylinders()
2472 if ( !_makeCylindersDiag ){
2473 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2475 _showDialogBox( _makeCylindersDiag );
2478 void HEXABLOCKGUI::makePipes()
2480 if ( !_makePipesDiag ){
2481 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2483 _showDialogBox( _makePipesDiag );
2487 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2489 if ( !_makeHemiSphereDiag ){
2490 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2492 _showDialogBox( _makeHemiSphereDiag );
2496 void HEXABLOCKGUI::removeHexa()
2498 if ( !_removeHexaDiag ){
2499 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2501 _showDialogBox( _removeHexaDiag );
2505 void HEXABLOCKGUI::prismQuad()
2507 if ( !_prismQuadDiag ){
2508 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2510 _showDialogBox( _prismQuadDiag );
2514 void HEXABLOCKGUI::joinQuad()
2516 if ( !_joinQuadDiag ){
2517 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2519 _showDialogBox( _joinQuadDiag );
2522 void HEXABLOCKGUI::merge()
2525 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2527 _showDialogBox( _mergeDiag );
2530 void HEXABLOCKGUI::disconnectElts()
2532 if ( !_disconnectDiag ){
2533 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2535 _showDialogBox( _disconnectDiag );
2538 void HEXABLOCKGUI::cutEdge()
2540 if ( !_cutEdgeDiag ){
2541 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2543 _showDialogBox( _cutEdgeDiag );
2546 void HEXABLOCKGUI::makeTransformation()
2548 if ( !_makeTransformationDiag ){
2549 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2551 _showDialogBox( _makeTransformationDiag );
2555 void HEXABLOCKGUI::makeSymmetry()
2557 if ( !_makeSymmetryDiag ){
2558 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2560 _showDialogBox( _makeSymmetryDiag );
2564 void HEXABLOCKGUI::performTransformation()
2566 if ( !_performTransformationDiag ){
2567 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2569 _showDialogBox( _performTransformationDiag );
2573 void HEXABLOCKGUI::performSymmetry()
2575 if ( !_performSymmetryDiag ){
2576 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2578 _showDialogBox( _performSymmetryDiag );
2582 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2584 if ( !_replaceHexaDiag ){
2585 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2587 _showDialogBox( _replaceHexaDiag );
2591 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2593 if ( !_quadRevolutionDiag ){
2594 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2596 _showDialogBox( _quadRevolutionDiag );
2600 void HEXABLOCKGUI::assocVertex()
2602 if (!_dwInputPanel) return;
2603 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2604 if ( !_vertexAssocDiag )
2605 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2606 _showDialogBox( _vertexAssocDiag );
2610 void HEXABLOCKGUI::assocEdge()
2612 if ( !_edgeAssocDiag )
2613 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2614 _showDialogBox( _edgeAssocDiag );
2617 void HEXABLOCKGUI::assocQuad()
2619 if ( !_quadAssocDiag )
2620 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2621 _showDialogBox( _quadAssocDiag );
2625 void HEXABLOCKGUI::addGroup()
2628 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2630 _showDialogBox( _groupDiag );
2631 if (_groupDiag != NULL && getCurrentModel() != NULL)
2633 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2634 if (doc == NULL) return;
2635 char defaultName[16];
2636 sprintf (defaultName, "g%04d", doc->countGroup());
2637 _groupDiag->name_le->setText(defaultName);
2641 void HEXABLOCKGUI::removeGroup()
2643 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2644 if (currentDGView == NULL) return;
2646 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2647 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2648 int nbGroupsRemoved = 0;
2651 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2652 tr( "No group selected!" ) );
2656 foreach( QModelIndex selected, l ){
2657 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2658 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2659 Q_ASSERT(selected.isValid());
2661 //Confirm the deletion of the group
2662 if (SUIT_MessageBox::question(
2665 tr("Remove group : %1 ?").arg(selected.data().toString()),
2666 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2667 SUIT_MessageBox::Cancel
2668 ) == SUIT_MessageBox::Cancel) return;
2670 bool removed = getCurrentModel()->removeGroup( selected );
2672 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2673 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2679 if (!nbGroupsRemoved)
2680 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2681 tr( "No group selected!" ) );
2684 void HEXABLOCKGUI::addLaw()
2687 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2689 _showDialogBox( _lawDiag );
2690 if (_lawDiag != NULL && getCurrentModel() != NULL)
2692 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2693 if (doc == NULL) return;
2694 char defaultName[16];
2695 sprintf (defaultName, "l%04d", doc->countLaw());
2696 _lawDiag->name_le->setText(defaultName);
2700 void HEXABLOCKGUI::removeLaw()
2702 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2703 if (currentDGView == NULL) return;
2705 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2706 int nbLawsRemoved = 0;
2709 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2710 tr( "No law selected!" ) );
2714 foreach( QModelIndex selected, l ){
2715 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2716 selected = currentDGView->getMeshModel()->mapToSource( selected );
2717 Q_ASSERT(selected.isValid());
2719 //Confirm the deletion of the law
2720 if (SUIT_MessageBox::question(
2723 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2724 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2725 SUIT_MessageBox::Cancel
2726 ) == SUIT_MessageBox::Cancel) return;
2728 bool removed = getCurrentModel()->removeLaw(selected);
2730 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2731 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2738 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2739 tr( "No law selected!" ) );
2744 void HEXABLOCKGUI::setPropagation()
2746 if ( !_propagationDiag )
2747 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2749 _showDialogBox( _propagationDiag );
2752 // Dialog box to compute a mesh from a document
2753 // --------------------------------------------
2754 void HEXABLOCKGUI::computeMesh()
2756 if ( !_computeMeshDiag )
2757 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2759 _showDialogBox( _computeMeshDiag );
2762 void HEXABLOCKGUI::clearAssociations()
2764 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2765 if (currentDGView == NULL) return;
2767 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2768 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2769 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2771 getCurrentModel()->clearEltAssociations(iModel);
2773 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2776 void HEXABLOCKGUI::showModelInfo()
2778 //create the info dialog if not yet
2779 if (_modelInfoDiag == NULL)
2780 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2782 //show the model informations dialog
2783 _showDialogBox( _modelInfoDiag );
2786 void HEXABLOCKGUI::addShape()
2788 //create the info dialog if not yet
2789 if (_addShapeDiag == NULL)
2790 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2792 //show the model informations dialog
2793 _showDialogBox( _addShapeDiag );
2796 void HEXABLOCKGUI::clearAllAssociations()
2798 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2799 if (currentDGView == NULL) return;
2801 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2802 if (!currentIndex.isValid()) return;
2803 QVariant currentAssocVariant;
2804 QString currentAssocEntry;
2806 //Confirm the deletion of the associations
2807 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2808 if ( !treeVariant.isValid() ) return;
2809 int eltType = treeVariant.toInt();
2810 QString typeStr = "";
2811 HEXA_NS::EnumElt hexaType;
2812 if (eltType == VERTEX_DIR_TREE)
2814 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2815 hexaType = HEXA_NS::EL_VERTEX;
2817 else if (eltType == EDGE_DIR_TREE)
2819 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2820 hexaType = HEXA_NS::EL_EDGE;
2822 else if (eltType == QUAD_DIR_TREE)
2824 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2825 hexaType = HEXA_NS::EL_QUAD;
2828 if (SUIT_MessageBox::question(
2830 tr("CLEAR_ASSOCIATIONS"),
2831 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2832 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2833 SUIT_MessageBox::Cancel
2834 ) == SUIT_MessageBox::Cancel) return;
2837 DocumentModel* docModel = getCurrentModel();
2838 if (docModel == NULL) return;
2839 docModel->clearAssociation(hexaType);
2842 void HEXABLOCKGUI::showAssociations()
2844 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2845 if (currentDGView == NULL) return;
2847 QModelIndexList elts;
2848 int currentChildIndex = 0;
2849 QVariant currentAssocVariant;
2850 QString currentAssocEntry;
2851 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2852 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2854 while( currentChild.isValid() ) {
2856 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2857 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2858 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2859 elts << currentChild;
2861 currentChild = currentChild.sibling(currentChildIndex++, 0);
2863 currentDocGView->highlight(elts);
2864 currentOccGView->highlight(elts, false);
2868 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2870 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2872 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2877 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2879 if ( event->type() == QEvent::Enter )
2880 { // *** ENTER EVENT
2882 if (currentDialog == NULL || !currentDialog->isVisible())
2883 return QObject::eventFilter(obj, event);
2885 // ** The window acquire the focus when the cursor enter
2887 //OCC - window enter
2888 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2889 if ( occWindow != NULL)
2890 currentDialog->onWindowActivated(occWindow->getViewManager());
2892 //VTK - window enter
2894 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2895 if ( vtkWindow != NULL)
2896 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2900 //standard event processing
2901 return QObject::eventFilter(obj, event);
2904 QStringList HEXABLOCKGUI::getQuickDirList()
2906 QStringList dirList;
2907 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2909 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2915 // --- Export the module
2919 HexaExport CAM_Module* createModule()
2921 return new HEXABLOCKGUI();
2924 HexaExport char* getModuleVersion()
2926 return (char*)HEXABLOCK_VERSION_STR;
2932 // ******************** TESTS ***************************************************
2934 void HEXABLOCKGUI::testDocument()
2938 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2939 // QStandardItem *myItem = new QStandardItem("MyItem");
2940 // parentItem->appendRow(myItem);
2942 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2943 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2944 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2945 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2946 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2947 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2948 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2949 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2952 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2953 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2954 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2955 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2956 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2957 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2959 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2960 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2961 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2962 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2967 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2968 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2969 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2970 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2978 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2979 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2981 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2982 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2986 // newMesh( "toto", 3, "FactoryServer");
2990 void HEXABLOCKGUI::test_make_cart_grid()
2992 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2993 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2994 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2995 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2996 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
2997 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
2999 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3000 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3007 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3008 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3009 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3010 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3011 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3012 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3017 void HEXABLOCKGUI::test_make_elmts_transform()
3024 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3025 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3028 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3029 // orig.setScalar(2);
3031 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3032 // getCurrentModel()->saveVtk(file_name)
3034 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3035 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3037 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3038 // getCurrentModel()->saveVtk(file_name)
3040 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3043 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3044 // getCurrentModel()->saveVtk(file_name);
3047 // print "...test make elements by transforming elements OK"
3049 // =============================================================== addDocInSudy
3050 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3054 if (document == NULL)
3057 QString docName = document->getName ();
3059 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3060 if (app_study == NULL)
3063 _PTR(Study) study = app_study->studyDS();
3064 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3065 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3066 QString entry = app_study->centry("HEXABLOCK");
3067 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3068 if (aFatherSO->_is_nil())
3071 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3074 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3075 docEntry = aSO->GetID(); //the entry of the published object
3080 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3082 void HEXABLOCKGUI::test()
3084 DEBTRACE("HEXABLOCKGUI::test");
3085 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3086 if (currentDGView == NULL) return;
3087 currentDGView->update();
3091 void HEXABLOCKGUI::test_association()
3093 DEBTRACE("HEXABLOCKGUI::test_association");
3096 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3098 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3099 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3100 DocumentModel::GeomObj q0AssocA, q0AssocB;
3102 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3103 QList<DocumentModel::GeomObj> e1Assocs_test;
3104 DocumentModel::GeomObj q0Assoc_test;
3106 v0 = getCurrentModel()->addVertex(0, 0, 0);
3107 v1 = getCurrentModel()->addVertex(1, 0, 0);
3108 v2 = getCurrentModel()->addVertex(1, 1, 0);
3109 v3 = getCurrentModel()->addVertex(0, 1, 0);
3110 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3111 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3112 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3115 // >>> face3.GetEntry()'0:1:4'
3116 // >>> e1.GetEntry()'0:1:8'
3117 // >>> e2.GetEntry()'0:1:9'
3118 // >>> e3.GetEntry()'0:1:10'
3119 // >>> e4.GetEntry()'0:1:11'
3120 // >>> v1.GetEntry()'0:1:12'
3121 // >>> v2.GetEntry()'0:1:13'
3122 // >>> v3.GetEntry()'0:1:14'
3123 // >>> v4.GetEntry()'0:1:15'
3126 // v0Assoc.name = "geomV0";
3127 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3128 // v0Assoc.brep = "brepV0";
3129 // v1Assoc.name = "geomV1";
3130 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3131 // v1Assoc.brep = "brepV1";
3132 // v2Assoc.name = "geomV2";
3133 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3134 // v2Assoc.brep = "brepV2";
3135 // v3Assoc.name = "geomV3";
3136 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3137 // v3Assoc.brep = "brepV3";
3141 // e0AssocA.name = "geomE0a";
3142 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3143 // e0AssocA.brep = "brepE0a";
3144 // e0AssocA.start = 0.10;
3145 // e0AssocA.end = 0.95;
3149 // e1AssocA.name = "geomE1a";
3150 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3151 // e1AssocA.brep = "brepE1a";
3152 // e1AssocA.start = 0.12;
3153 // e1AssocA.end = 0.89;
3154 // e1AssocB.name = "geomE1b";
3155 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3156 // e1AssocB.brep = "brepE1b";
3157 // e1AssocB.start = 0.20;
3158 // e1AssocB.end = 0.80;
3159 // e1AssocC.name = "geomE1c";
3160 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3161 // e1AssocC.brep = "brepE1c";
3162 // e1AssocC.start = 0.16;
3163 // e1AssocC.end = 0.96;
3165 // q0AssocA.name = "geomQuad";
3166 // q0AssocA.entry = "0:1:1:1:3";
3167 // q0AssocA.brep = "brepq0";
3169 // q0AssocB.name = "geomQuad";
3170 // q0AssocB.entry = "0:1:1:1:4";
3171 // q0AssocB.brep = "brepq0";
3173 // getCurrentModel()->addAssociation( v0, v0Assoc );
3174 // getCurrentModel()->addAssociation( v1, v1Assoc );
3175 // getCurrentModel()->addAssociation( v2, v2Assoc );
3176 // getCurrentModel()->addAssociation( v3, v3Assoc );
3179 // getCurrentModel()->addAssociation( e0, e0AssocA );
3181 // getCurrentModel()->addAssociation( e1, e1AssocA );
3182 // getCurrentModel()->addAssociation( e1, e1AssocB );
3183 // getCurrentModel()->addAssociation( e1, e1AssocC );
3185 // getCurrentModel()->addAssociation( q0, q0AssocA );
3186 // getCurrentModel()->addAssociation( q0, q0AssocB );
3192 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3193 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3194 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3195 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3196 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3197 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3198 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3199 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3200 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3201 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3202 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3203 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3206 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3207 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3208 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3209 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3210 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3211 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3212 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3213 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3214 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3215 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3216 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3217 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3218 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3220 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3221 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3222 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3225 DEBTRACE("HEXABLOCKGUI::test_association fin");