1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include <QInputDialog>
27 #include <QStackedWidget>
29 #include <QtxTreeView.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewManager.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_DataObject.h>
37 #include <SUIT_DataBrowser.h>
38 #include <SUIT_FileDlg.h>
40 #include <SVTK_ViewManager.h>
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewWindow.h>
44 #include <VTKViewer_ViewModel.h>
46 #include <vtkActorCollection.h>
47 #include <VTKViewer_Algorithm.h>
48 #include <vtkRenderer.h>
52 #include <SOCC_ViewModel.h>
53 #include <SOCC_ViewWindow.h>
54 #include <OCCViewer_ViewWindow.h>
55 #include <SALOME_Prs.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_Study.hxx>
61 #include <SALOMEDSClient_StudyBuilder.hxx>
62 #include <SALOMEDSClient_SComponent.hxx>
63 #include <SALOMEDSClient_ClientFactory.hxx>
64 #include <SALOMEDSClient_IParameters.hxx>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataModel.h>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
78 #include <SALOME_LifeCycleCORBA.hxx>
80 #include <LightApp_VTKSelector.h>
82 #include <OCCViewer_ViewManager.h>
84 #include <QtxPopupMgr.h>
86 #include "Resource.hxx"
88 #include "HEXABLOCKGUI.hxx"
89 #include "HEXABLOCKGUI_Export.hxx"
90 #include "HEXABLOCKGUI_Trace.hxx"
91 #include "HEXABLOCKGUI_Resource.hxx"
93 #include "HEXABLOCKGUI_DocumentModel.hxx"
94 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
95 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
96 #include "HEXABLOCKGUI_DocumentPanel.hxx"
97 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
98 #include "HEXABLOCKGUI_OccGraphicView.hxx"
99 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
101 #include "HEXABLOCK_version.h"
103 #include "MyBasicGUI_PointDlg.hxx"
105 // #include "HEXABLOCK.hxx" del Hexa6
106 // #include "HexDocument_impl.hxx" del Hexa6
110 #include <Visual3d_ViewManager.hxx>
111 #include <V3d_PerspectiveView.hxx>
112 #include <V3d_AmbientLight.hxx>
113 #include <V3d_DirectionalLight.hxx>
114 #include <Xw_Window.hxx>
115 #include <V3d_TypeOfShadingModel.hxx>
116 #include <TCollection_ExtendedString.hxx>
118 #include <BRepAlgoAPI_Fuse.hxx>
120 #include <AIS_ListIteratorOfListOfInteractive.hxx>
123 #define DW_MINIMUM_WIDTH 50
124 #define DWINPUT_MINIMUM_HEIGHT 50
125 #define DWINPUT_MINIMUM_WIDTH 50//255
128 using namespace HEXABLOCK::GUI;
130 int HEXABLOCKGUI::_oldStudyId = -1;
132 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
134 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
135 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
136 bool HEXABLOCKGUI::assocInProgress = false;
137 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
139 HEXABLOCKGUI::HEXABLOCKGUI() :
140 SalomeApp_Module( "HEXABLOCK" ),
141 // LightApp_Module( "HEXABLOCK" ),
149 _patternDataTreeView(0),
150 // _patternBuilderTreeView(0),
151 _patternGeomTreeView(0),
154 // _treeViewDelegate(0),
156 moduleActivatedOnce(false),
165 _makeCylinderDiag(0),
167 _makeCylindersDiag(0),
175 _makeTransformationDiag(0),
176 _makeSymmetryDiag(0),
177 _performTransformationDiag(0),
178 _performSymmetryDiag(0),
187 _quadRevolutionDiag(0),
188 _makeHemiSphereDiag(0),
189 _modelInfoDiag(NULL),
191 _vertexInfoDialog(NULL),
192 _edgeInfoDialog(NULL),
193 _quadInfoDialog(NULL),
194 _hexaInfoDialog(NULL),
195 _vectorInfoDialog(NULL),
196 _groupInfoDialog(NULL),
197 _lawInfoDialog(NULL),
198 _propagationInfoDialog(NULL),
201 lastVtkDocGView(NULL)
203 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
205 graphicViewsHandler = new GraphicViewsHandler();
206 loadDocLastPath = new QDir();
207 saveDocLastPath = new QDir();
208 hexa_root = HEXA_NS::Hex::getInstance ();
211 HEXABLOCKGUI::~HEXABLOCKGUI()
216 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
218 SUIT_Application* app = SUIT_Session::session()->activeApplication();
220 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
226 // Gets an reference to the module's engine
227 /****************************************************
228 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
230 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
231 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
232 ASSERT(!CORBA::is_nil(clr));
235 **************************************************** */
237 void HEXABLOCKGUI::initialize( CAM_Application* app )
239 MESSAGE("HEXABLOCKGUI::initialize");
240 DEBTRACE("HEXABLOCKGUI::initialize");
241 SalomeApp_Module::initialize( app );
243 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
245 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
247 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
248 setResource(aResourceMgr);
250 createAndFillDockWidget();
257 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
259 DEBTRACE("HEXABLOCKGUI::viewManagers");
260 // list.append( QxScene_Viewer::Type() );
261 // list.append( OCCViewer_Viewer::Type() );
262 // list.append( SVTK_Viewer::Type() );
266 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
268 DEBTRACE("HEXABLOCKGUI::activateModule");
270 /*HexaBlock can be launched in only one application*/
271 if (myApplication == NULL)
272 //remember the first application
273 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
275 //application verification: if it's not the one known by HexaBlock,
276 //leave without activating
277 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
278 if (myApplication != currentApplication) return false;
280 bool bOk = SalomeApp_Module::activateModule( theStudy );
281 if ( !bOk ) return false;
283 showDockWidgets(true);
285 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
286 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
287 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
288 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
290 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
292 SUIT_ViewManager* vm;
293 ViewManagerList OCCViewManagers, VTKViewManagers;
295 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
296 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
297 while ( itOCC.hasNext() && (vm = itOCC.next()) )
298 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
300 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
301 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
302 while ( itVTK.hasNext() && (vm = itVTK.next()) )
303 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
306 SALOME_ListIO selected;
307 sm->selectedObjects( selected );
310 // disable OCC selectors
311 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
312 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
313 while ( itOCCSel.hasNext() )
314 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
315 sr->setEnabled(true);
317 // disable VTK selectors
318 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
319 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
320 while ( itVTKSel.hasNext() )
321 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
322 sr->setEnabled(true);
324 sm->setSelectedObjects( selected, true ); //NPAL 19674
326 //connect close signal to vtk view manager
327 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
330 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
331 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
334 //connect close signal to occ view manager
335 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
338 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
339 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
342 /* ************************************ TODO Hexa6
343 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
344 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
345 if ( _PTR(Study) aStudy = s->studyDS()) {
346 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
347 updateObjBrowser(); // objects can be removed
349 ************************************ */
351 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
352 currentOccGView->getViewWindow()->installEventFilter(this);
354 if (currentDocGView != NULL)
356 switchModel(currentDocGView);
359 if (currentDocGView->getViewWindow() != NULL)
360 currentDocGView->getViewWindow()->installEventFilter(this);
369 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
371 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
372 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
373 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
374 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
376 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
377 if ( vtkView != NULL)
379 //default selectionMode in VTKView
380 vtkView->SetSelectionMode( ActorSelection );
381 vtkView->removeEventFilter(this);
385 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
388 //defaut selectionMode in OccView
389 selectionMgr()->clearSelected();
390 currentOccGView->globalSelection();
391 occView->removeEventFilter(this);
395 qDeleteAll(myOCCSelectors);
396 myOCCSelectors.clear();
397 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
399 qDeleteAll(myVTKSelectors);
400 myVTKSelectors.clear();
401 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
403 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
405 //switch off current document graphic view
406 switchOffGraphicView(currentDocGView);
409 setMenuShown( false );
410 setToolShown( false );
411 showDockWidgets( false );
413 _dwInputPanel->close();
420 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
422 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
423 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
424 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
425 int aStudyID = theStudy->StudyId();
426 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
427 return aDSStudy._retn();
430 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
431 QMap<QString, QString>& docShapesEntry,
432 QMap<QString, QString>& docShapesName)
434 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
435 return; //there's nothing to publish in this case
437 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
438 if(!appStudy) return;
439 _PTR(Study) aStudy = appStudy->studyDS();
440 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
441 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
442 QString entry = currentDocGView->getDocumentModel()->documentEntry();
443 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
444 if (aFatherSO->_is_nil())
447 // * get a presentation
448 bool isNewPrs = false;
449 SOCC_Prs* prs = getOccPrs(currentDocGView);
452 prs = new SOCC_Prs();
456 // * init the presentation with the given shapes
457 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
458 while (i != topo_shapes.constEnd())
460 QString shapeName = i.key();
461 TopoDS_Shape shapeValue = i.value();
462 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
463 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
464 QString objStudyEntry = aSO->GetID(); //the entry of the published object
465 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
466 "HEXABLOCK", shapeName.toStdString().c_str());
467 ais_shape->SetOwner(io);
468 prs->AddObject(ais_shape);
469 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
470 docShapesEntry[shapeName] = objStudyEntry;
471 docShapesName[objStudyEntry] = shapeName;
472 currentOccGView->addShape(objStudyEntry, ais_shape);
473 i++; //handle next shape
477 prs->AddObject(currentOccGView->getPreviewShape());
479 occPrs[currentDocGView] = prs;
480 getApp()->updateObjectBrowser();
485 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
487 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
488 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
489 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
491 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
495 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
499 // Pas de renommage des shapes pour le moment, juste les documents
500 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
501 if (dgview == NULL || dgview->getDocumentModel() == NULL)
504 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
505 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
510 _PTR(Study) aStudy = appStudy->studyDS();
515 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
516 _PTR(GenericAttribute) anAttr;
518 if ( obj->FindAttribute(anAttr, "AttributeName") ){
519 _PTR(AttributeName) aName (anAttr);
520 DocumentModel* docModel = dgview->getDocumentModel();
521 docModel->setName( name );
522 aName->SetValue( name.toLatin1().data() );
523 getApp()->updateObjectBrowser();
524 // _dwPattern->setWindowTitle( name );
531 // --- Default windows
532 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
534 DEBTRACE("HEXABLOCKGUI::windows");
536 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
537 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
540 QString HEXABLOCKGUI::engineIOR() const
542 DEBTRACE("HEXABLOCKGUI::engineIOR");
544 /* ************************************ TODO Hexa6
545 CORBA::ORB_var anORB = getApp()->orb();
546 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
547 return QString( anIOR.in() );
548 ************************************ */
552 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
554 if (docs.count(studyObject->entry()) == 0)
556 //Object's document not acquired yet
557 VtkDocumentGraphicView* dgview;
558 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
559 if (directory == NULL)
560 return NULL; //No working director found
562 //------------------ Load the document -----------------
563 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
564 if (document == NULL)
565 return NULL; //No document found
567 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
569 MESSAGE("Doc model creation failed!");
572 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
573 if (dgview == NULL) return NULL;
575 //update the data tree
576 docs[studyObject->entry()] = dgview;
579 return docs[studyObject->entry()];
582 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
584 // ** we want to switch automatically to the right view windows
586 //first, find selected item
588 DataObjectList dol = getApp()->objectBrowser()->getSelected();
589 if (dol.isEmpty()) return;
590 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
591 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
592 item->entry().isEmpty())
595 // find the document corresponding to it
596 VtkDocumentGraphicView* docGView = NULL;
597 if (docs.contains(item->entry()))
598 docGView = docs[item->entry()];
600 docGView = getOrCreateDocument(item);
602 //Init OCC if necessary
603 if (currentOccGView == NULL)
605 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
606 currentOccGView->getViewWindow()->installEventFilter(this);
608 else if (currentOccGView->getViewWindow() == NULL)
610 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
611 currentOccGView->getViewWindow()->installEventFilter(this);
614 //Init the vtk view if necessary
615 if (docGView->getViewWindow() == NULL)
617 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
619 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
620 docGView->getViewWindow()->installEventFilter(this);
624 docGView->setViewWindow(currentDocGView->getViewWindow());
626 if (docGView->getDocumentActor() == NULL)
630 if (docGView == NULL || docGView == currentDocGView)
636 //update the current document
637 switchModel(docGView);
641 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
643 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
646 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
648 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
650 //Decharger le model correspondant (VTK)
651 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
655 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
656 { //HexaBlock Vtk Window has been closed
658 if (currentDialog != NULL) currentDialog->close();
659 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
660 if (currentDocGView != NULL)
661 currentDocGView->setViewWindow(NULL);
668 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
669 if (dgview == NULL) return; //The window has no document to close
671 //Save the document? (Ask only if the document is not empty
672 int answerCode = SUIT_MessageBox::question(
675 tr("Save the document ?"),
676 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
677 SUIT_MessageBox::Cancel);
678 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
679 else if (answerCode == SUIT_MessageBox::Yes)
680 saveDocument(); //Save the document
682 // switchOffGraphicView(window); //disconnect all connected signals
683 // currentVtkView = NULL;
684 // graphicViewsHandler->closeDocumentGraphicView(window);
686 //create a new one (empty document)
688 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
692 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
694 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
695 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
696 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
697 if (currentDialog != NULL) currentDialog->close();
698 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
700 currentOccGView->getViewWindow()->removeEventFilter(this);
701 currentOccGView->setViewWindow(NULL);
705 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
707 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
709 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
710 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
712 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
714 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
715 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
716 // disable OCC selectors
717 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
718 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
719 while ( itOCCSel.hasNext() )
720 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
721 sr->setEnabled(true);
723 else if ( vm->getType() == SVTK_Viewer::Type() )
725 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
726 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
728 // disable VTK selectors
729 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
730 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
731 while ( itVTKSel.hasNext() )
732 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
733 sr->setEnabled(true);
737 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
739 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
741 SUIT_ViewModel* viewer = vm->getViewModel();
742 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
744 //VTK View Manager removed
745 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
747 //Process only if it's our view manager
748 SUIT_ViewManager* myVm = NULL;
749 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
750 myVm = currentDocGView->getViewWindow()->getViewManager();
754 //close opened dialog
755 if (currentDialog != NULL) currentDialog->close();
756 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
762 //remove its selector
763 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
764 while ( itVTKSel.hasNext() )
765 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
766 if ( sr->viewer() == viewer )
768 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
775 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
777 //OCC View removed: remove its selector
778 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
779 while ( itOCCSel.hasNext() )
780 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
781 if ( sr->viewer() == viewer )
783 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
789 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
791 QModelIndexList l = selected.indexes();
792 if ( l.count() == 0 ) return;
793 if ( !l[0].isValid() ) return;
794 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
795 if ( currentGraphicView == NULL) return;
797 QTreeView* theTree = NULL;
798 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
799 theTree = _patternDataTreeView;
801 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
802 theTree = _patternBuilderTreeView;
804 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
805 theTree = _patternGeomTreeView;
807 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
808 theTree = _groupsTreeView;
809 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
810 theTree = _meshTreeView;
813 theTree->scrollTo ( l[0] );
817 bool HEXABLOCKGUI::createSComponent() //addComponent
819 DEBTRACE("HEXABLOCKGUI::createSComponent");
820 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
822 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
823 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
824 _PTR(GenericAttribute) anAttr;
825 _PTR(AttributeName) aName;
826 _PTR(AttributeGraphic) aGraphic;
828 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
829 if ( !aComponent ){ //Create hexablock component if there's not one yet
830 aComponent = aBuilder->NewComponent("HEXABLOCK");
831 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
832 aName = _PTR(AttributeName) (anAttr);
833 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
835 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
836 _PTR(AttributePixMap) aPixmap(anAttr);
837 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
839 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
840 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
846 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
848 DEBTRACE("HEXABLOCKGUI::setResource");
849 _myresource = new HEXABLOCKGUI_Resource(r);
850 _myresource->preferencesChanged();
853 void HEXABLOCKGUI::createPreferences()
855 DEBTRACE("HEXABLOCKGUI::createPreferences");
856 _myresource->createPreferences(this);
859 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
861 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
862 _myresource->preferencesChanged(sect, name);
863 // if(name=="userCatalog")
864 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
867 void HEXABLOCKGUI::studyActivated() //CS_TODO
869 int newStudyId = getApp()->activeStudy()->id();
870 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
871 // if (_oldStudyId != -1)
873 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
874 // if (_studyContextMap.count(newStudyId))
876 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
877 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
881 // DEBTRACE("no switch to null context");
884 _oldStudyId = newStudyId;
887 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
889 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
890 QVariant currentAssocVariant;
891 QString currentAssocEntry;
893 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
894 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
895 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
896 QMenu menu( _patternDataTreeView );
898 QAction *clearAct = menu.addAction( "Remove association(s)" );
899 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
900 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
904 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
905 if (currentVtkGraphicView == NULL) return;
906 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
908 //We don't do anything for single items
909 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
910 item->type() == QUADITEM || item->type() == HEXAITEM)
913 //No associations for HEXA
914 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
915 if ( !treeVariant.isValid() ) return;
916 int eltType = treeVariant.toInt();
917 if (eltType == HEXA_DIR_TREE) return;
918 QMenu menu( _patternDataTreeView );
920 //Show association(s)
921 QAction *showAssocAct = menu.addAction( "Show associations" );
922 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
924 //Clear all associations
925 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
926 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
928 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
933 void HEXABLOCKGUI::createAndFillDockWidget()
936 QMainWindow *aParent = application()->desktop();
938 // Create dock widget (3 dock)
940 //1) *********** user input panel ( contain user's edit dialog box )
941 _dwInputPanel = new QDockWidget(aParent);
942 _dwInputPanel->setVisible(false);
943 _dwInputPanel->setWindowTitle("Input Panel");
944 _dwInputPanel->setObjectName("InputPanelDockWidget");
945 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
947 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
949 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
951 _dwPattern = new QDockWidget(aParent);
952 _dwPattern->setVisible(false);
953 _dwPattern->setWindowTitle("Model");
954 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
955 _dwPattern->setObjectName("ModelDockWidget");
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 _dwGroups->setObjectName("GroupsDockWidget");
991 _groupsTreeView = new QTreeView(_dwGroups);
992 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
993 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
994 _dwGroups->setWidget(_groupsTreeView);
995 _groupsTreeView->show();
998 _dwMesh = new QDockWidget(aParent);
999 _dwMesh->setVisible(false);
1000 _dwMesh->setWindowTitle("Mesh");
1001 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1002 _dwMesh->setObjectName("MeshDockWidget");
1003 _meshTreeView = new QTreeView(_dwMesh);
1004 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1005 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1006 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1007 _dwMesh->setWidget(_meshTreeView);
1008 _meshTreeView->show();
1010 // QDockWidget *_dwObjectBrowser = 0;
1011 QWidget* wid = getApp()->objectBrowser()->treeView();
1012 QWidget *w = wid->parentWidget();
1013 while ( w && !_dwObjectBrowser ) {
1014 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1015 w = w->parentWidget();
1017 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1018 _dwObjectBrowser->setWindowTitle("Study");
1020 // dock widget position
1021 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1022 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1024 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1025 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1026 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1028 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1029 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1030 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1032 #if QT_VERSION >= 0x040500
1033 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1036 // popup menu on data tree view
1037 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1038 connect(_patternDataTreeView,
1039 SIGNAL(customContextMenuRequested(const QPoint &)),
1041 SLOT(treeContextMenu(const QPoint &)),
1042 Qt::UniqueConnection );
1045 void HEXABLOCKGUI::createActions()
1047 QMainWindow *aParent = application()->desktop();
1048 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1051 _newAct = createAction(_menuId++,
1052 tr("Create a new document"),
1053 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1055 tr("Create a new document"),
1056 0, aParent, false, this, SLOT(newDocument()));
1057 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1059 _importAct = createAction(_menuId++,
1060 tr("Load a document"),
1061 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1062 tr("Load Document"),
1063 tr("Load a document"),
1064 0, aParent, false, this, SLOT(loadDocument()));
1065 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1067 _saveAct = createAction(_menuId++,
1068 tr("Save the document"),
1069 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1070 tr("Save Document"),
1071 tr("Save the document"),
1072 0, aParent, false, this, SLOT(saveDocument()));
1074 // Pattern Data creation
1075 _addVertex = createAction(_menuId++,
1076 tr("Create a vertex"),
1077 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1079 tr("Create a new vertex"),
1080 0, aParent, false, this, SLOT(addVertex()));
1082 _addEdge = createAction(_menuId++,
1083 tr("Create an edge"),
1084 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1086 tr("Create a new edge"),
1087 0, aParent, false, this, SLOT(addEdge()));
1089 _addQuad = createAction(_menuId++,
1090 tr("Create a quadrangle"),
1091 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1092 tr("Add Quadrangle"),
1093 tr("Create a new quadrangle"),
1094 0, aParent, false, this, SLOT(addQuad()));
1096 _addHexa = createAction(_menuId++,
1097 tr("Create an hexahedron"),
1098 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1099 tr("Add Hexahedron"),
1100 tr("Create a new hexahedron"),
1101 0, aParent, false, this, SLOT(addHexa()));
1103 // Builder Data creation
1104 _addVector = createAction(_menuId++,
1105 tr("Create a vector"),
1106 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1108 tr("Create a new vector"),
1109 0, aParent, false, this, SLOT(addVector()));
1111 // _addCylinder = createAction(_menuId++,
1112 // tr("Create a cylinder"),
1113 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1114 // tr("Add Cylinder"),
1115 // tr("Create a new cylinder"),
1116 // 0, aParent, false, this, SLOT(addCylinder()));
1118 // _addPipe = createAction(_menuId++,
1119 // tr("Create a pipe"),
1120 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1122 // tr("Create a new pipe"),
1123 // 0, aParent, false, this, SLOT(addPipe()));
1125 _makeGrid = createAction(_menuId++,
1127 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1130 0, aParent, false, this, SLOT(makeGrid()));
1132 _makeCylinder = createAction(_menuId++,
1133 tr("Make a cylinder"),
1134 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1135 tr("Make Cylinder"),
1136 tr("Make a cylinder"),
1137 0, aParent, false, this, SLOT(makeCylinder()));
1139 _makePipe = createAction(_menuId++,
1141 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1144 0, aParent, false, this, SLOT(makePipe()));
1146 _makeCylinders = createAction(_menuId++,
1147 tr("Make cylinders"),
1148 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1149 tr("Make Cylinders"),
1150 tr("Make cylinders"),
1151 0, aParent, false, this, SLOT(makeCylinders()));
1153 _makePipes = createAction(_menuId++,
1155 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1158 0, aParent, false, this, SLOT(makePipes()));
1160 _makeHemiSphere = createAction(_menuId++,
1161 tr("Make an hemisphere"),
1162 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1163 tr("Make Hemisphere"),
1164 tr("Make an hemisphere"),
1165 0, aParent, false, this, SLOT(makeHemiSphere()));
1167 // Pattern Data edition
1168 _removeHexa = createAction(_menuId++,
1169 tr("Remove hexahedra"),
1170 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1171 tr("Remove Hexahedra"),
1172 tr("Remove hexahedra"),
1173 0, aParent, false, this, SLOT(removeHexa()));
1175 _prismQuad = createAction(_menuId++,
1176 tr("Prism quadrangles"),
1177 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1178 tr("Prism Quadrangles"),
1179 tr("Prism quadrangles"),
1180 0, aParent, false, this, SLOT(prismQuad()));
1182 _joinQuad = createAction(_menuId++,
1183 tr("Join quadrangles"),
1184 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1185 tr("Join Quadrangles"),
1186 tr("Join quadrangles with hexahedra"),
1187 0, aParent, false, this, SLOT(joinQuad()));
1189 _merge = createAction(_menuId++,
1191 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1194 0, aParent, false, this, SLOT(merge()));
1196 _disconnect = createAction(_menuId++,
1198 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1200 tr("Disconnect edges, vertexes or quadrangles"),
1201 0, aParent, false, this, SLOT(disconnectElts()));
1203 _cutEdge = createAction(_menuId++,
1205 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1208 0, aParent, false, this, SLOT(cutEdge()));
1210 _makeTransformation = createAction(_menuId++,
1211 tr("Make transformation"),
1212 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1213 tr("Make Transformation"),
1214 tr("Make transformation"),
1215 0, aParent, false, this, SLOT(makeTransformation()));
1217 _makeSymmetry = createAction(_menuId++,
1218 tr("Make symmetry"),
1219 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1220 tr("Make Symmetry"),
1221 tr("Make symmetry"),
1222 0, aParent, false, this, SLOT(makeSymmetry()));
1224 _performTransformation = createAction(_menuId++,
1225 tr("Perform transformation"),
1226 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1227 tr("Perform Transformation"),
1228 tr("Perform transformation"),
1229 0, aParent, false, this, SLOT(performTransformation()));
1231 _performSymmetry = createAction(_menuId++,
1232 tr("Perform symmetry"),
1233 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1234 tr("Perform Symmetry"),
1235 tr("Perform symmetry"),
1236 0, aParent, false, this, SLOT(performSymmetry()));
1238 _replaceHexa = createAction(_menuId++,
1239 tr("Replace hexahedron"),
1240 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1241 tr("Replace Hexahedron"),
1242 tr("Replace hexahedron"),
1243 0, aParent, false, this, SLOT(replaceHexa()));
1245 _quadRevolution = createAction(_menuId++,
1246 tr("Quad revolution"),
1247 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1248 tr("Quad Revolution"),
1249 tr("Quad revolution"),
1250 0, aParent, false, this, SLOT(quadRevolution()));
1253 _assocVertex = createAction(_menuId++,
1254 tr("Make vertex association"),
1255 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1256 tr("Make Vertex association"),
1257 tr("Make vertex association"),
1258 0, aParent, false, this, SLOT(assocVertex()));
1260 _assocEdge = createAction(_menuId++,
1261 tr("Make edge association"),
1262 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1263 tr("Make Edge Association"),
1264 tr("Make edge association"),
1265 0, aParent, false, this, SLOT(assocEdge()));
1267 _assocQuad = createAction(_menuId++,
1268 tr("Make quad association"),
1269 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1270 tr("Make Quad Association"),
1271 tr("Make quad association"),
1272 0, aParent, false, this, SLOT(assocQuad()));
1275 _addGroup = createAction(_menuId++,
1277 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1280 0, aParent, false, this, SLOT(addGroup()));
1282 _removeGroup = createAction(_menuId++,
1283 tr("Remove a group"),
1284 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1286 tr("Remove a group"),
1287 0, aParent, false, this, SLOT(removeGroup()));
1290 _addLaw = createAction(_menuId++,
1292 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1295 0, aParent, false, this, SLOT(addLaw()));
1297 _removeLaw = createAction(_menuId++,
1299 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1302 0, aParent, false, this, SLOT(removeLaw()));
1304 _setPropagation = createAction(_menuId++,
1305 tr("Set propagation"),
1306 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1307 tr("Set Propagation"),
1308 tr("Set propagation"),
1309 0, aParent, false, this, SLOT(setPropagation()));
1311 _computeMesh = createAction(_menuId++,
1313 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1316 0, aParent, false, this, SLOT(computeMesh()));
1318 _showModelInfoAct = createAction(_menuId++,
1319 tr("Show Model Info"),
1320 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1323 0, aParent, false, this, SLOT(showModelInfo()));
1325 _addShapeAct = createAction(_menuId++,
1327 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1330 0, aParent, false, this, SLOT(addShape()));
1332 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1333 // QAction* createAction(const int id,
1334 // const QString& toolTip,
1335 // const QIcon& icon,
1336 // const QString& menu,
1337 // const QString& status,
1338 // const int shortCut,
1339 // QObject* parent =0,
1340 // bool checkable = false,
1341 // QObject* receiver =0,
1342 // const char* member =0);
1344 _sep1 = separator();
1345 _sep2 = separator();
1346 _sep3 = separator();
1347 _sep4 = separator();
1351 void HEXABLOCKGUI::createMenus()
1353 int aMenuId, subMenuId,aMenuIdMain;
1355 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1357 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1358 createMenu( actionId(_newAct), aMenuId );
1359 createMenu( actionId(_importAct), aMenuId );
1360 createMenu( _saveAct, aMenuId );
1363 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1364 createMenu( _newAct, aMenuDocId );//, 10
1365 createMenu( _importAct, aMenuDocId );
1366 createMenu( _saveAct, aMenuDocId );
1368 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1369 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1370 createMenu( _addVertex, subMenuId );
1371 createMenu( _addEdge, subMenuId );
1372 createMenu( _addQuad, subMenuId );
1373 createMenu( _addHexa, subMenuId );
1374 createMenu( _sep1, subMenuId);
1377 createMenu( _addVector, subMenuId );
1378 // createMenu( _addCylinder, subMenuId );
1379 // createMenu( _addPipe, subMenuId );
1381 createMenu( _sep2, subMenuId);
1383 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1384 createMenu( _makeHemiSphere,subMenuId );
1386 createMenu( _sep3, subMenuId);
1388 createMenu( _makeCylinder, subMenuId );
1389 createMenu( _makePipe, subMenuId );
1390 createMenu( _makeCylinders,subMenuId );
1391 createMenu( _makePipes, subMenuId );
1393 // Pattern Data Edition
1394 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1395 createMenu( _removeHexa, subMenuId );
1396 createMenu( _prismQuad, subMenuId );
1397 createMenu( _joinQuad, subMenuId );
1398 createMenu( _merge, subMenuId );
1399 createMenu( _disconnect, subMenuId );
1400 createMenu( _cutEdge, subMenuId );
1401 createMenu( _makeTransformation, subMenuId );
1402 createMenu( _makeSymmetry, subMenuId );
1403 createMenu( _performTransformation, subMenuId );
1404 createMenu( _performSymmetry, subMenuId );
1405 createMenu( _replaceHexa, subMenuId );
1406 createMenu( _quadRevolution, subMenuId );
1407 createMenu( _sep4, aMenuId );
1408 createMenu( _showModelInfoAct, aMenuId );
1411 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1412 createMenu( _addShapeAct, aMenuId );
1413 createMenu( _assocVertex, aMenuId );
1414 createMenu( _assocEdge, aMenuId );
1415 createMenu( _assocQuad, aMenuId );
1418 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1419 createMenu( _addGroup, aMenuId );
1420 createMenu( _removeGroup, aMenuId ); //CS_TODO
1423 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1424 createMenu( _addLaw, aMenuId );
1425 createMenu( _removeLaw, aMenuId );
1426 createMenu( _setPropagation, aMenuId );
1427 createMenu( _computeMesh, aMenuId );
1429 //show model infomation menu
1430 QString aRule = "$component={'HEXABLOCK'}";
1431 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1432 popupMgr()->setRule( _showModelInfoAct, aRule);
1434 //associate shape to a document menu
1435 popupMgr()->insert( _addShapeAct, -1, -1 );
1436 popupMgr()->setRule( _addShapeAct, aRule );
1438 //-------------------------------------------------
1440 //-------------------------------------------------
1441 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1442 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1443 // QString isNotEmpty("numberOfNodes <> 0");
1444 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1445 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1446 //// aType = aType.arg( mesh_part );
1448 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1449 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1450 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1452 // popupMgr()->insert( separator(), -1, -1 );
1453 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1454 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1455 // // MESSAGE("aClient = " << aClient.toStdString());
1456 // // MESSAGE("aType = " << aType.toStdString());
1457 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1458 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1459 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1460 // // MESSAGE("aRule = " << aRule.toStdString());
1461 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1462 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1464 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1465 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1467 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1468 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1470 // popupMgr()->insert( separator(), -1, -1 );
1474 void HEXABLOCKGUI::createTools()
1478 aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
1479 createTool( _newAct, aToolId );
1480 createTool( _importAct, aToolId );
1481 createTool( _saveAct, aToolId );
1482 createTool( _showModelInfoAct, aToolId );
1483 // createTool( _testAct, aToolId );
1484 //createTool( separator(), aToolId );
1487 aToolId = createTool ( tr( "Construction" ) );
1488 createTool( _addVertex, aToolId );
1489 createTool( _addEdge, aToolId );
1490 createTool( _addQuad, aToolId );
1491 createTool( _addHexa, aToolId );
1493 createTool( _sep1, aToolId );
1496 createTool( _addVector, aToolId );
1497 // createTool( _addCylinder, aToolId );
1498 // createTool( _addPipe, aToolId );
1500 createTool( _sep2, aToolId );
1502 createTool( _makeGrid, aToolId );
1503 createTool( _makeHemiSphere, aToolId );
1505 createTool( _sep3, aToolId );
1507 createTool( _makeCylinder, aToolId );
1508 createTool( _makePipe, aToolId );
1509 createTool( _makeCylinders,aToolId );
1510 createTool( _makePipes, aToolId );
1512 // Pattern Data Edition
1513 aToolId = createTool ( tr( "Operation" ) );
1514 createTool( _removeHexa, aToolId );
1515 createTool( _prismQuad, aToolId );
1516 createTool( _joinQuad, aToolId );
1517 createTool( _merge, aToolId );
1518 createTool( _disconnect, aToolId );
1519 createTool( _cutEdge, aToolId );
1520 createTool( _makeTransformation, aToolId );
1521 createTool( _makeSymmetry, aToolId );
1522 createTool( _performTransformation, aToolId );
1523 createTool( _performSymmetry, aToolId );
1524 createTool( _replaceHexa, aToolId );
1525 createTool( _quadRevolution, aToolId );
1528 aToolId = createTool ( tr( "Association" ) );
1529 createTool( _assocVertex, aToolId );
1530 createTool( _assocEdge, aToolId );
1531 createTool( _assocQuad, aToolId );
1532 createTool( _addShapeAct, aToolId );
1535 aToolId = createTool ( tr( "Group" ) );
1536 createTool( _addGroup, aToolId );
1537 createTool( _removeGroup, aToolId ); //CS_TODO
1540 aToolId = createTool ( tr( "Mesh" ) );
1541 createTool( _addLaw, aToolId );
1542 createTool( _removeLaw, aToolId );
1543 createTool( _setPropagation, aToolId );
1544 createTool( _computeMesh, aToolId );
1548 void HEXABLOCKGUI::initialMenus()
1550 showDocumentMenus( true );
1551 showPatternMenus( false );
1552 showAssociationMenus( false );
1553 showGroupsMenus( false );
1554 showMeshMenus( false );
1557 void HEXABLOCKGUI::showAllMenus()
1559 showDocumentMenus( true );
1560 showPatternMenus( true );
1561 showAssociationMenus( true );
1562 showGroupsMenus( true );
1563 showMeshMenus( true );
1567 void HEXABLOCKGUI::showDocumentMenus(bool show)
1569 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1571 setMenuShown(_newAct, show);
1572 setToolShown(_newAct, show);
1573 setMenuShown(_importAct, show);
1574 setToolShown(_importAct, show);
1575 setMenuShown(_showModelInfoAct, show);
1576 setToolShown(_showModelInfoAct, show);
1577 setMenuShown(_saveAct, show);
1578 setToolShown(_saveAct, show);
1581 void HEXABLOCKGUI::showPatternMenus(bool show)
1583 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1584 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1585 if ( show && !getCurrentModel() ) return;
1587 setMenuShown(_addVertex, show );
1588 setToolShown(_addVertex, show);
1589 setMenuShown(_addEdge, show );
1590 setToolShown(_addEdge, show);
1591 setMenuShown(_addQuad, show );
1592 setToolShown(_addQuad, show);
1593 setMenuShown(_addHexa, show );
1594 setToolShown(_addHexa, show);
1596 setMenuShown(_sep1, show );
1597 setToolShown(_sep1, show);
1599 setMenuShown( _addVector, show );
1600 setToolShown( _addVector, show);
1601 // setMenuShown( _addCylinder, show );
1602 // setToolShown( _addCylinder, show);
1603 // setMenuShown( _addPipe, show );
1604 // setToolShown( _addPipe, show);
1606 setMenuShown(_sep2, show );
1607 setToolShown(_sep2, show);
1609 setMenuShown( _makeGrid, show );
1610 setToolShown( _makeGrid, show);
1611 setMenuShown( _makePipe, show );
1612 setToolShown( _makePipe, show);
1614 setMenuShown(_sep3, show );
1615 setToolShown(_sep3, show);
1617 setMenuShown( _makeCylinder, show );
1618 setToolShown( _makeCylinder, show);
1619 setMenuShown( _makeCylinders, show );
1620 setToolShown( _makeCylinders, show);
1621 setMenuShown( _makePipes, show );
1622 setToolShown( _makePipes, show);
1623 setMenuShown( _makeHemiSphere, show );
1624 setToolShown( _makeHemiSphere, show);
1626 // Pattern Data Edition
1627 setMenuShown( _removeHexa, show );
1628 setToolShown( _removeHexa, show);
1629 setMenuShown( _prismQuad, show );
1630 setToolShown( _prismQuad, show);
1631 setMenuShown( _joinQuad, show );
1632 setToolShown( _joinQuad, show);
1633 setMenuShown( _merge, show );
1634 setToolShown( _merge, show);
1635 setMenuShown( _disconnect, show );
1636 setToolShown( _disconnect, show);
1637 setMenuShown( _cutEdge, show );
1638 setToolShown( _cutEdge, show);
1639 setMenuShown( _makeTransformation, show );
1640 setToolShown( _makeTransformation, show);
1641 setMenuShown( _makeSymmetry, show );
1642 setToolShown( _makeSymmetry, show);
1643 setMenuShown( _performTransformation, show );
1644 setToolShown( _performTransformation, show);
1645 setMenuShown( _performSymmetry, show );
1646 setToolShown( _performSymmetry, show);
1647 setMenuShown( _replaceHexa, show );
1648 setToolShown( _replaceHexa, show);
1649 setMenuShown( _quadRevolution, show );
1650 setToolShown( _quadRevolution, show);
1652 setMenuShown( _sep4, show );
1653 setMenuShown( _showModelInfoAct, show );
1657 void HEXABLOCKGUI::showAssociationMenus(bool show)
1659 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1660 if ( show && !getCurrentModel() ) return;
1662 // Association Edition
1663 setMenuShown( _assocVertex, show );
1664 setToolShown( _assocVertex, show );
1665 setMenuShown( _assocEdge, show );
1666 setToolShown( _assocEdge, show );
1667 setMenuShown( _assocQuad, show );
1668 setToolShown( _assocQuad, show );
1669 setMenuShown( _addShapeAct, show );
1670 setToolShown( _addShapeAct, show );
1674 void HEXABLOCKGUI::showGroupsMenus(bool show)
1676 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1677 if ( show && !getCurrentModel() ) return;
1678 setMenuShown( _addGroup, show );
1679 setToolShown( _addGroup, show);
1680 setMenuShown( _removeGroup , show );
1681 setToolShown( _removeGroup , show);
1684 void HEXABLOCKGUI::showMeshMenus(bool show)
1686 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1687 if ( show && !getCurrentModel() ) return;
1688 setMenuShown( _addLaw, show );
1689 setToolShown( _addLaw, show);
1690 setMenuShown( _removeLaw, show );
1691 setToolShown( _removeLaw, show);;
1692 setMenuShown( _setPropagation, show );
1693 setToolShown( _setPropagation, show);
1694 setMenuShown( _computeMesh, show);
1695 setToolShown( _computeMesh, show);
1698 void HEXABLOCKGUI::showVtkActor()
1700 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1701 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1702 currentVtkGView->getDocumentActor() == NULL)
1705 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1706 if (vtkView == NULL)
1709 SUIT_ViewManager* vman = vtkView->getViewManager();
1710 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1712 //show only the current actor -----------------
1713 vtkView->setFocus();
1714 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1715 Document_Actor *lastDocActor;
1716 if (lastVtkDocGView != NULL)
1718 lastDocActor = lastVtkDocGView->getDocumentActor();
1719 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1720 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1722 vtkView->Erase(lastActorIO);
1723 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1724 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1727 currentVtkGView->update();
1728 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1729 if (!anIO.IsNull() && anIO->hasEntry())
1731 vtkView->Display(anIO);
1732 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1733 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1735 vtkView->onFitAll();
1738 void HEXABLOCKGUI::showOccActor()
1740 if (currentOccGView == NULL)
1742 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1743 if (occView == NULL)
1745 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1749 if (lastOccPrs != NULL)
1750 vf->Erase(lastOccPrs);
1751 currentOccGView->globalSelection();
1752 SOCC_Prs* prs = getOccPrs(currentDocGView);
1753 currentOccGView->setPrs(prs);
1756 occView->onFitAll();
1759 void HEXABLOCKGUI::hideVtkActor()
1761 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1762 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1763 currentVtkGView->getViewWindow() == NULL ||
1764 currentVtkGView->getDocumentActor() == NULL) return;
1766 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1767 currentVtkGView->getViewWindow()->onResetView();
1769 //update the visibility state now
1770 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1771 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1772 if (aStudy == NULL || vman == NULL) return;
1774 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1775 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1776 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1779 void HEXABLOCKGUI::hideOccActor()
1781 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1782 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1783 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1784 if (occView == NULL || docModel == NULL)
1786 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1790 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1791 if (currentOccPrs != NULL)
1792 vf->Erase(currentOccPrs);
1794 occView->onResetView();
1797 void HEXABLOCKGUI::showOnlyActor()
1803 void HEXABLOCKGUI::hideActor()
1810 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1812 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1814 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1815 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1817 if (_dwPattern) _dwPattern->setVisible(isVisible);
1818 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1820 if (_dwMesh) _dwMesh->setVisible(isVisible);
1821 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1823 if (_dwGroups) _dwGroups->setVisible(isVisible);
1824 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
1828 //clear all used dialogs by the current model
1829 void HEXABLOCKGUI::clearDialogs()
1831 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
1832 fin (currentModelDialogs.end());
1833 for(;debut!=fin;++debut) (*debut)->clear();
1835 currentModelDialogs.clear(); //empty the used dialogs list
1838 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
1840 if (!gViewDlgBox.contains(dgview)) return NULL;
1841 return gViewDlgBox[dgview];
1844 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
1846 if (dgview == NULL) return;
1848 switchOffGraphicView(dgview, false); //to avoid double connect
1851 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1852 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
1853 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1854 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1855 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1856 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1857 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1858 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1859 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1860 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1861 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1862 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
1867 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
1869 if (dgview == NULL) return;
1871 //disconnect signals
1872 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
1873 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
1874 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1875 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1876 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1877 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1878 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1879 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1880 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1881 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1882 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
1883 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1886 gViewDlgBox[dgview] = currentDialog;
1888 //close opened dialog
1889 if (currentDialog != NULL) currentDialog->close();
1890 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
1896 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
1898 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
1902 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
1906 //switch off the current document graphic view (disconnect signals...)
1907 if (currentDocGView != NULL)
1909 //Hide current actor
1911 switchOffGraphicView(currentDocGView);
1914 //clear the dialogs used by the current model so they can be used by the new model
1915 if (currentDocGView != dgview) clearDialogs();
1917 _patternDataTreeView->setModel(dgview->getPatternDataModel());
1918 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
1919 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
1920 _groupsTreeView->setModel(dgview->getGroupsModel());
1921 _meshTreeView->setModel(dgview->getMeshModel());
1923 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
1924 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1926 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
1927 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
1929 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
1930 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1932 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
1933 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1935 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
1936 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1939 // = * init occ view * =
1940 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
1942 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
1943 currentOccGView->getViewWindow()->installEventFilter(this);
1948 // = * init vtk view * =
1949 if (currentDocGView != NULL)
1951 if (currentDocGView->getViewWindow() != NULL)
1952 dgview->setViewWindow(currentDocGView->getViewWindow());
1955 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
1956 dgview->getViewWindow()->installEventFilter(this);
1962 switchOnGraphicView(dgview);
1964 if (currentDocGView != NULL)
1966 lastVtkDocGView = currentDocGView;
1967 lastOccPrs = getOccPrs(currentDocGView);
1971 lastVtkDocGView = dgview;
1972 lastOccPrs = getOccPrs(dgview);
1975 currentDocGView = dgview;
1977 currentDocGView->getDocumentModel()->refresh();
1978 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
1982 DocumentModel* HEXABLOCKGUI::getCurrentModel()
1984 if (currentDocGView == NULL) return NULL;
1985 return currentDocGView->getDocumentModel();
1989 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
1991 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1992 if (anApp == NULL) return UNKNOWN;
1993 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1994 if (activeVm == NULL) return UNKNOWN;
1996 QString vmType = activeVm->getType();
1997 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
1999 else if ( vmType == OCCViewer_Viewer::Type() )
2005 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2007 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2011 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2014 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2016 // Create Document from HEXABLOCK ENGINE
2017 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2018 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2020 // looking doc impl ( c++ )
2021 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2022 // ^Hexa6 ASSERT( dServant );
2023 // ^Hexa6 if ( dServant)
2024 // ^Hexa6 doc = dServant->GetImpl();
2026 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2027 QString docEntry = addDocInStudy (doc);
2029 // looking for docEntry
2030 /* ****************************************************************
2031 if ( !CORBA::is_nil(docIn) ){
2032 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2033 QString docIOR = anIOR.in();
2034 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2035 if ( !docIOR.isEmpty() ) {
2036 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2038 docEntry = SO->GetID().c_str();
2041 **************************************************************** */
2042 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2044 return make_pair (docEntry, doc);
2048 void HEXABLOCKGUI::newDocument()
2050 DEBTRACE("HEXABLOCKGUI::newDocument");
2053 QMainWindow *aParent = application()->desktop();
2054 QWidget *central = aParent->centralWidget();
2056 central->setFocus();
2058 DEBTRACE("No Central Widget");
2061 if (currentOccGView == NULL)
2063 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2064 application()->desktop());
2065 currentOccGView->getViewWindow()->installEventFilter(this);
2067 else if (currentOccGView->getViewWindow() == NULL)
2069 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2070 currentOccGView->getViewWindow()->installEventFilter(this);
2074 // Create Document from HEXABLOCK ENGINE
2075 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2077 VtkDocumentGraphicView* newGraphicView = NULL;
2078 //One document at a time
2079 if (currentDocGView != NULL)
2081 if (currentDocGView->getViewWindow() == NULL)
2083 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2084 currentDocGView->getViewWindow()->installEventFilter(this);
2087 // Create a new document with the current window
2088 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2089 new DocumentModel( docEntry_Doc.second,
2090 docEntry_Doc.first, this ),
2091 currentDocGView->getViewWindow(),
2092 application()->desktop() );
2096 // Create the new Document Graphic View with a new window
2097 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2098 new DocumentModel( docEntry_Doc.second,
2099 docEntry_Doc.first, this ),
2100 graphicViewsHandler->createVtkWindow(),
2101 application()->desktop() );
2102 newGraphicView->getViewWindow()->installEventFilter(this);
2105 if (newGraphicView == NULL)
2106 //We couldn't create a new document graphic view
2107 //we'd better show a dialog box info to inform the user
2110 docs[docEntry_Doc.first] = newGraphicView;
2111 switchModel(newGraphicView); //select the corresponding document in the browser instead
2113 getApp()->updateObjectBrowser();
2118 //Loads the model from the xmlFile in the current graphic view
2119 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2121 DEBTRACE("HEXABLOCKGUI::loadDocument");
2124 QMainWindow *aParent = application()->desktop();
2125 QString selectedFile;
2127 if ( inFile.isNull() ){
2128 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2129 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2130 dialog.setHistory( getQuickDirList() );
2132 //use the last path as default
2133 if (!(loadDocLastPath->absolutePath()).isEmpty())
2134 dialog.setDirectory(*loadDocLastPath);
2137 QStringList selectedFiles = dialog.selectedFiles();
2138 if (!selectedFiles.isEmpty())
2139 selectedFile = selectedFiles.first();
2141 //remember the selected path
2142 *loadDocLastPath = dialog.directory();
2145 selectedFile = inFile;
2147 if (selectedFile.isEmpty())
2150 //we create a new document if necessary
2151 if (currentDocGView == NULL)
2152 //Need a new document
2154 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2156 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2157 currentDocGView->getViewWindow()->installEventFilter(this);
2160 if (!currentDocGView->isEmpty())
2161 //we can only have one document for a graphic view
2164 //we load the selected file in the current graphic view
2165 currentDocGView->loadDocument(selectedFile);
2166 DocumentModel* currentModel = getCurrentModel();
2167 renameObject( currentModel->documentEntry(), currentModel->getName() );
2172 void HEXABLOCKGUI::saveDocument()
2174 QMainWindow *aParent = application()->desktop();
2176 QString aDocName = "document", aFilename;
2178 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2179 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2181 //use the last selected directory as default path for file selection
2182 aFilename = saveDocLastPath->absolutePath();
2183 if (!aFilename.isEmpty())
2184 aFilename += QString("/") + aDocName;
2186 //show the dialog for file selection
2187 aFilename = SUIT_FileDlg::getFileName( aParent,
2190 tr( "Save HexaBlock Document" ),
2193 //save the document in the selected file
2194 if ( !aFilename.isEmpty() ) {
2195 getCurrentVtkGraphicView()->saveDocument( aFilename );
2197 //Remember the path for next save
2198 QFileInfo fileInfo(aFilename);
2199 *saveDocLastPath = fileInfo.dir();
2205 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2207 _patternDataTreeView->openPersistentEditor( topLeft );
2210 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2212 if (diag == NULL || _dwInputPanel == NULL ||
2213 getCurrentVtkGraphicView() == NULL) return;
2215 //mark this dialog as used by the current model
2216 currentModelDialogs.insert(diag);
2218 //close the current dialog box info
2219 // if (_treeViewDelegate != NULL)
2220 // _treeViewDelegate->closeDialog();
2222 // if (_dwInputPanel->widget())
2223 // _dwInputPanel->widget()->close();
2225 //Temporary for debugging EdgeAssoc Faked InfoDialog
2226 if (diag == _edgeAssocDiag)
2227 diag->debugEdgeAssoc = true;
2229 diag->debugEdgeAssoc = false;
2231 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2232 diag == _quadAssocDiag || diag == _addShapeDiag)
2233 assocInProgress = true;
2235 assocInProgress = false;
2237 //show the dialog box in the dockwidget
2238 diag->resetSizeAndShow(_dwInputPanel);
2240 //clear the current selections
2241 selectionMgr()->clearSelected();
2243 currentDialog = diag;
2246 if (currentDocGView != NULL)
2247 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2250 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2252 if (vertex == NULL || _dwInputPanel == NULL)
2255 if (_vertexInfoDialog == NULL)
2256 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2258 _vertexInfoDialog->setValue(vertex);
2259 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2260 currentDialog = _vertexInfoDialog;
2263 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2265 if (edge == NULL || _dwInputPanel == NULL)
2268 if (_edgeInfoDialog == NULL)
2269 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2271 _edgeInfoDialog->setValue(edge);
2272 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2273 currentDialog = _edgeInfoDialog;
2276 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2278 if (quad == NULL || _dwInputPanel == NULL)
2281 if (_quadInfoDialog == NULL)
2282 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2284 _quadInfoDialog->setValue(quad);
2285 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2286 currentDialog = _quadInfoDialog;
2289 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2291 if (hexa == NULL || _dwInputPanel == NULL)
2294 if (_hexaInfoDialog == NULL)
2295 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2297 _hexaInfoDialog->setValue(hexa);
2298 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2299 currentDialog = _hexaInfoDialog;
2302 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2304 if (vector == NULL || _dwInputPanel == NULL)
2307 if (_vectorInfoDialog == NULL)
2308 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2310 _vectorInfoDialog->setValue(vector);
2311 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2312 currentDialog = _vectorInfoDialog;
2315 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2317 if (group == NULL || _dwInputPanel == NULL)
2320 if (_groupInfoDialog == NULL)
2321 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2323 _groupInfoDialog->setValue(group);
2324 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2325 currentDialog = _groupInfoDialog;
2328 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2330 if (law == NULL || _dwInputPanel == NULL)
2333 if (_lawInfoDialog == NULL)
2334 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2336 _lawInfoDialog->setValue(law);
2337 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2338 currentDialog = _lawInfoDialog;
2341 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2343 if (propagation == NULL || _dwInputPanel == NULL)
2346 if (_propagationInfoDialog == NULL)
2347 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2349 _propagationInfoDialog->setValue(propagation);
2350 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2351 currentDialog = _propagationInfoDialog;
2354 void HEXABLOCKGUI::addVertex()
2356 if ( !_vertexDiag ){
2357 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2359 _showDialogBox( _vertexDiag );
2362 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2363 if (_vertexDiag != NULL && doc != NULL)
2364 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2367 void HEXABLOCKGUI::addEdge()
2370 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2372 _showDialogBox( _edgeDiag );
2375 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2376 if (_edgeDiag != NULL && doc != NULL)
2377 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2380 void HEXABLOCKGUI::addQuad()
2383 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2386 _showDialogBox( _quadDiag );
2389 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2390 if (_quadDiag != NULL && doc != NULL)
2391 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2394 void HEXABLOCKGUI::addHexa()
2397 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2399 _showDialogBox( _hexaDiag );
2402 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2403 if (_hexaDiag != NULL && doc != NULL)
2404 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2407 void HEXABLOCKGUI::addVector()
2409 if ( !_vectorDiag ){
2410 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2412 _showDialogBox( _vectorDiag );
2415 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2416 if (_vectorDiag != NULL && doc != NULL)
2417 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2420 //void HEXABLOCKGUI::addCylinder()
2422 // if ( !_cylinderDiag ){
2423 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2425 // _showDialogBox( _cylinderDiag );
2427 // //set default name
2428 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2429 // if (_cylinderDiag != NULL && doc != NULL)
2430 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2434 //void HEXABLOCKGUI::addPipe()
2436 // if ( !_pipeDiag){
2437 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2439 // _showDialogBox( _pipeDiag );
2441 // //set default name
2442 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2443 // if (_pipeDiag != NULL && doc != NULL)
2444 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2448 void HEXABLOCKGUI::makeGrid()
2450 if ( !_makeGridDiag ){
2451 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2453 _showDialogBox( _makeGridDiag );
2457 void HEXABLOCKGUI::makeCylinder()
2459 if ( !_makeCylinderDiag ){
2460 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2462 _showDialogBox( _makeCylinderDiag );
2465 void HEXABLOCKGUI::makePipe()
2467 if ( !_makePipeDiag ){
2468 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2470 _showDialogBox( _makePipeDiag );
2473 void HEXABLOCKGUI::makeCylinders()
2475 if ( !_makeCylindersDiag ){
2476 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2478 _showDialogBox( _makeCylindersDiag );
2481 void HEXABLOCKGUI::makePipes()
2483 if ( !_makePipesDiag ){
2484 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2486 _showDialogBox( _makePipesDiag );
2490 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2492 if ( !_makeHemiSphereDiag ){
2493 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2495 _showDialogBox( _makeHemiSphereDiag );
2499 void HEXABLOCKGUI::removeHexa()
2501 if ( !_removeHexaDiag ){
2502 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2504 _showDialogBox( _removeHexaDiag );
2508 void HEXABLOCKGUI::prismQuad()
2510 if ( !_prismQuadDiag ){
2511 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2513 _showDialogBox( _prismQuadDiag );
2517 void HEXABLOCKGUI::joinQuad()
2519 if ( !_joinQuadDiag ){
2520 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2522 _showDialogBox( _joinQuadDiag );
2525 void HEXABLOCKGUI::merge()
2528 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2530 _showDialogBox( _mergeDiag );
2533 void HEXABLOCKGUI::disconnectElts()
2535 if ( !_disconnectDiag ){
2536 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2538 _showDialogBox( _disconnectDiag );
2541 void HEXABLOCKGUI::cutEdge()
2543 if ( !_cutEdgeDiag ){
2544 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2546 _showDialogBox( _cutEdgeDiag );
2549 void HEXABLOCKGUI::makeTransformation()
2551 if ( !_makeTransformationDiag ){
2552 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2554 _showDialogBox( _makeTransformationDiag );
2558 void HEXABLOCKGUI::makeSymmetry()
2560 if ( !_makeSymmetryDiag ){
2561 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2563 _showDialogBox( _makeSymmetryDiag );
2567 void HEXABLOCKGUI::performTransformation()
2569 if ( !_performTransformationDiag ){
2570 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2572 _showDialogBox( _performTransformationDiag );
2576 void HEXABLOCKGUI::performSymmetry()
2578 if ( !_performSymmetryDiag ){
2579 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2581 _showDialogBox( _performSymmetryDiag );
2585 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2587 if ( !_replaceHexaDiag ){
2588 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2590 _showDialogBox( _replaceHexaDiag );
2594 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2596 if ( !_quadRevolutionDiag ){
2597 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2599 _showDialogBox( _quadRevolutionDiag );
2603 void HEXABLOCKGUI::assocVertex()
2605 if (!_dwInputPanel) return;
2606 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2607 if ( !_vertexAssocDiag )
2608 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2609 _showDialogBox( _vertexAssocDiag );
2613 void HEXABLOCKGUI::assocEdge()
2615 if ( !_edgeAssocDiag )
2616 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2617 _showDialogBox( _edgeAssocDiag );
2620 void HEXABLOCKGUI::assocQuad()
2622 if ( !_quadAssocDiag )
2623 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2624 _showDialogBox( _quadAssocDiag );
2628 void HEXABLOCKGUI::addGroup()
2631 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2633 _showDialogBox( _groupDiag );
2634 if (_groupDiag != NULL && getCurrentModel() != NULL)
2636 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2637 if (doc == NULL) return;
2638 char defaultName[16];
2639 sprintf (defaultName, "g%04d", doc->countGroup());
2640 _groupDiag->name_le->setText(defaultName);
2644 void HEXABLOCKGUI::removeGroup()
2646 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2647 if (currentDGView == NULL) return;
2649 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2650 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2651 int nbGroupsRemoved = 0;
2654 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2655 tr( "No group selected!" ) );
2659 foreach( QModelIndex selected, l ){
2660 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2661 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2662 Q_ASSERT(selected.isValid());
2664 //Confirm the deletion of the group
2665 if (SUIT_MessageBox::question(
2668 tr("Remove group : %1 ?").arg(selected.data().toString()),
2669 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2670 SUIT_MessageBox::Cancel
2671 ) == SUIT_MessageBox::Cancel) return;
2673 bool removed = getCurrentModel()->removeGroup( selected );
2675 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2676 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2682 if (!nbGroupsRemoved)
2683 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2684 tr( "No group selected!" ) );
2687 void HEXABLOCKGUI::addLaw()
2690 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2692 _showDialogBox( _lawDiag );
2693 if (_lawDiag != NULL && getCurrentModel() != NULL)
2695 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2696 if (doc == NULL) return;
2697 char defaultName[16];
2698 sprintf (defaultName, "l%04d", doc->countLaw());
2699 _lawDiag->name_le->setText(defaultName);
2703 void HEXABLOCKGUI::removeLaw()
2705 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2706 if (currentDGView == NULL) return;
2708 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2709 int nbLawsRemoved = 0;
2712 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2713 tr( "No law selected!" ) );
2717 foreach( QModelIndex selected, l ){
2718 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2719 selected = currentDGView->getMeshModel()->mapToSource( selected );
2720 Q_ASSERT(selected.isValid());
2722 //Confirm the deletion of the law
2723 if (SUIT_MessageBox::question(
2726 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2727 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2728 SUIT_MessageBox::Cancel
2729 ) == SUIT_MessageBox::Cancel) return;
2731 bool removed = getCurrentModel()->removeLaw(selected);
2733 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2734 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2741 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2742 tr( "No law selected!" ) );
2747 void HEXABLOCKGUI::setPropagation()
2749 if ( !_propagationDiag )
2750 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2752 _showDialogBox( _propagationDiag );
2755 // Dialog box to compute a mesh from a document
2756 // --------------------------------------------
2757 void HEXABLOCKGUI::computeMesh()
2759 if ( !_computeMeshDiag )
2760 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2762 _showDialogBox( _computeMeshDiag );
2765 void HEXABLOCKGUI::clearAssociations()
2767 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2768 if (currentDGView == NULL) return;
2770 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2771 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2772 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2774 getCurrentModel()->clearEltAssociations(iModel);
2776 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2779 void HEXABLOCKGUI::showModelInfo()
2781 //create the info dialog if not yet
2782 if (_modelInfoDiag == NULL)
2783 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2785 //show the model informations dialog
2786 _showDialogBox( _modelInfoDiag );
2789 void HEXABLOCKGUI::addShape()
2791 //create the info dialog if not yet
2792 if (_addShapeDiag == NULL)
2793 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2795 //show the model informations dialog
2796 _showDialogBox( _addShapeDiag );
2799 void HEXABLOCKGUI::clearAllAssociations()
2801 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2802 if (currentDGView == NULL) return;
2804 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2805 if (!currentIndex.isValid()) return;
2806 QVariant currentAssocVariant;
2807 QString currentAssocEntry;
2809 //Confirm the deletion of the associations
2810 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2811 if ( !treeVariant.isValid() ) return;
2812 int eltType = treeVariant.toInt();
2813 QString typeStr = "";
2814 HEXA_NS::EnumElt hexaType;
2815 if (eltType == VERTEX_DIR_TREE)
2817 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2818 hexaType = HEXA_NS::EL_VERTEX;
2820 else if (eltType == EDGE_DIR_TREE)
2822 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2823 hexaType = HEXA_NS::EL_EDGE;
2825 else if (eltType == QUAD_DIR_TREE)
2827 typeStr = tr("TREE_ITEM_QUAD").toUpper();
2828 hexaType = HEXA_NS::EL_QUAD;
2831 if (SUIT_MessageBox::question(
2833 tr("CLEAR_ASSOCIATIONS"),
2834 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
2835 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2836 SUIT_MessageBox::Cancel
2837 ) == SUIT_MessageBox::Cancel) return;
2840 DocumentModel* docModel = getCurrentModel();
2841 if (docModel == NULL) return;
2842 docModel->clearAssociation(hexaType);
2845 void HEXABLOCKGUI::showAssociations()
2847 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2848 if (currentDGView == NULL) return;
2850 QModelIndexList elts;
2851 int currentChildIndex = 0;
2852 QVariant currentAssocVariant;
2853 QString currentAssocEntry;
2854 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
2855 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
2857 while( currentChild.isValid() ) {
2859 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
2860 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
2861 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
2862 elts << currentChild;
2864 currentChild = currentChild.sibling(currentChildIndex++, 0);
2866 currentDocGView->highlight(elts);
2867 currentOccGView->highlight(elts, false);
2871 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
2873 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2875 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2880 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
2882 if ( event->type() == QEvent::Enter )
2883 { // *** ENTER EVENT
2885 if (currentDialog == NULL || !currentDialog->isVisible())
2886 return QObject::eventFilter(obj, event);
2888 // ** The window acquire the focus when the cursor enter
2890 //OCC - window enter
2891 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
2892 if ( occWindow != NULL)
2893 currentDialog->onWindowActivated(occWindow->getViewManager());
2895 //VTK - window enter
2897 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
2898 if ( vtkWindow != NULL)
2899 currentDialog->onWindowActivated(vtkWindow->getViewManager());
2903 //standard event processing
2904 return QObject::eventFilter(obj, event);
2907 QStringList HEXABLOCKGUI::getQuickDirList()
2909 QStringList dirList;
2910 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2912 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
2918 // --- Export the module
2922 HEXABLOCK_EXPORT CAM_Module* createModule()
2924 return new HEXABLOCKGUI();
2927 HEXABLOCK_EXPORT char* getModuleVersion()
2929 return (char*)HEXABLOCK_VERSION_STR;
2935 // ******************** TESTS ***************************************************
2937 void HEXABLOCKGUI::testDocument()
2941 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
2942 // QStandardItem *myItem = new QStandardItem("MyItem");
2943 // parentItem->appendRow(myItem);
2945 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
2946 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
2947 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
2948 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
2949 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
2950 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
2951 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
2952 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
2955 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
2956 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
2957 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
2958 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
2959 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
2960 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
2962 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
2963 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
2964 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
2965 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
2970 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
2971 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
2972 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
2973 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
2981 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
2982 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
2984 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
2985 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
2989 // newMesh( "toto", 3, "FactoryServer");
2993 void HEXABLOCKGUI::test_make_cart_grid()
2995 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
2996 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
2997 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
2998 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
2999 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3000 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3002 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3003 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3010 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3011 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3012 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3013 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3014 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3015 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3020 void HEXABLOCKGUI::test_make_elmts_transform()
3027 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3028 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3031 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3032 // orig.setScalar(2);
3034 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3035 // getCurrentModel()->saveVtk(file_name)
3037 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3038 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3040 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3041 // getCurrentModel()->saveVtk(file_name)
3043 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3046 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3047 // getCurrentModel()->saveVtk(file_name);
3050 // print "...test make elements by transforming elements OK"
3052 // =============================================================== addDocInSudy
3053 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3057 if (document == NULL)
3060 QString docName = document->getName ();
3062 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3063 if (app_study == NULL)
3066 _PTR(Study) study = app_study->studyDS();
3067 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3068 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3069 QString entry = app_study->centry("HEXABLOCK");
3070 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3071 if (aFatherSO->_is_nil())
3074 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3077 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3078 docEntry = aSO->GetID(); //the entry of the published object
3083 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3085 void HEXABLOCKGUI::test()
3087 DEBTRACE("HEXABLOCKGUI::test");
3088 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3089 if (currentDGView == NULL) return;
3090 currentDGView->update();
3094 void HEXABLOCKGUI::test_association()
3096 DEBTRACE("HEXABLOCKGUI::test_association");
3099 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3101 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3102 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3103 DocumentModel::GeomObj q0AssocA, q0AssocB;
3105 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3106 QList<DocumentModel::GeomObj> e1Assocs_test;
3107 DocumentModel::GeomObj q0Assoc_test;
3109 v0 = getCurrentModel()->addVertex(0, 0, 0);
3110 v1 = getCurrentModel()->addVertex(1, 0, 0);
3111 v2 = getCurrentModel()->addVertex(1, 1, 0);
3112 v3 = getCurrentModel()->addVertex(0, 1, 0);
3113 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3114 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3115 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3118 // >>> face3.GetEntry()'0:1:4'
3119 // >>> e1.GetEntry()'0:1:8'
3120 // >>> e2.GetEntry()'0:1:9'
3121 // >>> e3.GetEntry()'0:1:10'
3122 // >>> e4.GetEntry()'0:1:11'
3123 // >>> v1.GetEntry()'0:1:12'
3124 // >>> v2.GetEntry()'0:1:13'
3125 // >>> v3.GetEntry()'0:1:14'
3126 // >>> v4.GetEntry()'0:1:15'
3129 // v0Assoc.name = "geomV0";
3130 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3131 // v0Assoc.brep = "brepV0";
3132 // v1Assoc.name = "geomV1";
3133 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3134 // v1Assoc.brep = "brepV1";
3135 // v2Assoc.name = "geomV2";
3136 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3137 // v2Assoc.brep = "brepV2";
3138 // v3Assoc.name = "geomV3";
3139 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3140 // v3Assoc.brep = "brepV3";
3144 // e0AssocA.name = "geomE0a";
3145 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3146 // e0AssocA.brep = "brepE0a";
3147 // e0AssocA.start = 0.10;
3148 // e0AssocA.end = 0.95;
3152 // e1AssocA.name = "geomE1a";
3153 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3154 // e1AssocA.brep = "brepE1a";
3155 // e1AssocA.start = 0.12;
3156 // e1AssocA.end = 0.89;
3157 // e1AssocB.name = "geomE1b";
3158 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3159 // e1AssocB.brep = "brepE1b";
3160 // e1AssocB.start = 0.20;
3161 // e1AssocB.end = 0.80;
3162 // e1AssocC.name = "geomE1c";
3163 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3164 // e1AssocC.brep = "brepE1c";
3165 // e1AssocC.start = 0.16;
3166 // e1AssocC.end = 0.96;
3168 // q0AssocA.name = "geomQuad";
3169 // q0AssocA.entry = "0:1:1:1:3";
3170 // q0AssocA.brep = "brepq0";
3172 // q0AssocB.name = "geomQuad";
3173 // q0AssocB.entry = "0:1:1:1:4";
3174 // q0AssocB.brep = "brepq0";
3176 // getCurrentModel()->addAssociation( v0, v0Assoc );
3177 // getCurrentModel()->addAssociation( v1, v1Assoc );
3178 // getCurrentModel()->addAssociation( v2, v2Assoc );
3179 // getCurrentModel()->addAssociation( v3, v3Assoc );
3182 // getCurrentModel()->addAssociation( e0, e0AssocA );
3184 // getCurrentModel()->addAssociation( e1, e1AssocA );
3185 // getCurrentModel()->addAssociation( e1, e1AssocB );
3186 // getCurrentModel()->addAssociation( e1, e1AssocC );
3188 // getCurrentModel()->addAssociation( q0, q0AssocA );
3189 // getCurrentModel()->addAssociation( q0, q0AssocB );
3195 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3196 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3197 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3198 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3199 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3200 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3201 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3202 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3203 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3204 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3205 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3206 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3209 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3210 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3211 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3212 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3213 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3214 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3215 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3216 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3217 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3218 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3219 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3220 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3221 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3223 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3224 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3225 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3228 DEBTRACE("HEXABLOCKGUI::test_association fin");