1 // Copyright (C) 2009-2016 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, or (at your option) any later version.
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>
31 #include <QtxTreeView.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Desktop.h>
36 #include <SUIT_ViewManager.h>
37 #include <SUIT_ViewWindow.h>
38 #include <SUIT_DataObject.h>
39 #include <SUIT_DataBrowser.h>
40 #include <SUIT_FileDlg.h>
42 #include <SVTK_ViewManager.h>
43 #include <SVTK_ViewModel.h>
44 #include <SVTK_ViewWindow.h>
46 #include <VTKViewer_ViewModel.h>
48 #include <vtkActorCollection.h>
49 #include <VTKViewer_Algorithm.h>
50 #include <vtkRenderer.h>
54 #include <SOCC_ViewModel.h>
55 #include <SOCC_ViewWindow.h>
56 #include <OCCViewer_ViewWindow.h>
57 #include <SALOME_Prs.h>
61 // SALOME KERNEL includes
62 #include <SALOMEDS_Study.hxx>
63 #include <SALOMEDSClient_StudyBuilder.hxx>
64 #include <SALOMEDSClient_SComponent.hxx>
65 #include <SALOMEDSClient_ClientFactory.hxx>
66 #include <SALOMEDSClient_IParameters.hxx>
70 #include <SalomeApp_Study.h>
71 #include <SalomeApp_Module.h>
72 #include <SalomeApp_Application.h>
73 #include <SalomeApp_DataModel.h>
76 #include <SALOME_ListIO.hxx>
79 #include <SALOME_LifeCycleCORBA.hxx>
81 #include <LightApp_VTKSelector.h>
83 #include <OCCViewer_ViewManager.h>
85 #include <QtxPopupMgr.h>
87 #include "Resource.hxx"
89 #include "HEXABLOCKGUI.hxx"
90 #include "HEXABLOCKGUI_Export.hxx"
91 #include "HEXABLOCKGUI_Trace.hxx"
92 #include "HEXABLOCKGUI_Resource.hxx"
94 #include "HEXABLOCKGUI_DocumentModel.hxx"
95 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
96 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
97 #include "HEXABLOCKGUI_DocumentPanel.hxx"
98 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
99 #include "HEXABLOCKGUI_OccGraphicView.hxx"
100 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
102 #include "HEXABLOCK_version.h"
104 #include "MyBasicGUI_PointDlg.hxx"
106 // #include "HEXABLOCK.hxx" del Hexa6
107 // #include "HexDocument_impl.hxx" del Hexa6
111 #include <Visual3d_ViewManager.hxx>
112 //#include <V3d_PerspectiveView.hxx>
113 #include <V3d_AmbientLight.hxx>
114 #include <V3d_DirectionalLight.hxx>
115 #include <Xw_Window.hxx>
116 #include <V3d_TypeOfShadingModel.hxx>
117 #include <TCollection_ExtendedString.hxx>
119 #include <BRepAlgoAPI_Fuse.hxx>
121 #include <AIS_ListIteratorOfListOfInteractive.hxx>
123 #include <utilities.h>
125 #define DW_MINIMUM_WIDTH 50
126 #define DWINPUT_MINIMUM_HEIGHT 50
127 #define DWINPUT_MINIMUM_WIDTH 50//255
130 using namespace HEXABLOCK::GUI;
132 int HEXABLOCKGUI::_oldStudyId = -1;
134 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
136 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
137 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
138 bool HEXABLOCKGUI::assocInProgress = false;
139 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
141 HEXABLOCKGUI::HEXABLOCKGUI() :
142 SalomeApp_Module( "HEXABLOCK" ),
143 // LightApp_Module( "HEXABLOCK" ),
151 _patternDataTreeView(0),
152 // _patternBuilderTreeView(0),
153 _patternGeomTreeView(0),
156 // _treeViewDelegate(0),
158 moduleActivatedOnce(false),
168 _makeCylinderDiag(0),
170 _makeCylindersDiag(0),
178 _makeTransformationDiag(0),
179 _makeSymmetryDiag(0),
180 _performTransformationDiag(0),
181 _performSymmetryDiag(0),
190 _quadRevolutionDiag(0),
191 _makeHemiSphereDiag(0),
192 _modelInfoDiag(NULL),
194 _vertexInfoDialog(NULL),
195 _edgeInfoDialog(NULL),
196 _quadInfoDialog(NULL),
197 _hexaInfoDialog(NULL),
198 _vectorInfoDialog(NULL),
199 _groupInfoDialog(NULL),
200 _lawInfoDialog(NULL),
201 _propagationInfoDialog(NULL),
204 lastVtkDocGView(NULL)
206 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
208 graphicViewsHandler = new GraphicViewsHandler();
209 loadDocLastPath = new QDir();
210 saveDocLastPath = new QDir();
211 hexa_root = HEXA_NS::Hex::getInstance ();
214 HEXABLOCKGUI::~HEXABLOCKGUI()
219 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
221 SUIT_Application* app = SUIT_Session::session()->activeApplication();
223 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
229 // Gets an reference to the module's engine
230 /****************************************************
231 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
233 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
234 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
235 ASSERT(!CORBA::is_nil(clr));
238 **************************************************** */
240 void HEXABLOCKGUI::initialize( CAM_Application* app )
242 MESSAGE("HEXABLOCKGUI::initialize");
243 DEBTRACE("HEXABLOCKGUI::initialize");
244 SalomeApp_Module::initialize( app );
246 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
248 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
250 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
251 setResource(aResourceMgr);
253 createAndFillDockWidget();
260 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
262 DEBTRACE("HEXABLOCKGUI::viewManagers");
263 // list.append( QxScene_Viewer::Type() );
264 // list.append( OCCViewer_Viewer::Type() );
265 // list.append( SVTK_Viewer::Type() );
269 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
271 DEBTRACE("HEXABLOCKGUI::activateModule");
273 /*HexaBlock can be launched in only one application*/
274 if (myApplication == NULL)
275 //remember the first application
276 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
278 //application verification: if it's not the one known by HexaBlock,
279 //leave without activating
280 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
281 if (myApplication != currentApplication) return false;
283 bool bOk = SalomeApp_Module::activateModule( theStudy );
284 if ( !bOk ) return false;
286 showDockWidgets(true);
288 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
289 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
290 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
291 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
293 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
295 SUIT_ViewManager* vm;
296 ViewManagerList OCCViewManagers, VTKViewManagers;
298 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
299 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
300 while ( itOCC.hasNext() && (vm = itOCC.next()) )
301 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
303 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
304 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
305 while ( itVTK.hasNext() && (vm = itVTK.next()) )
306 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
309 SALOME_ListIO selected;
310 sm->selectedObjects( selected );
313 // disable OCC selectors
314 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
315 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
316 while ( itOCCSel.hasNext() )
317 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
318 sr->setEnabled(true);
320 // disable VTK selectors
321 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
322 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
323 while ( itVTKSel.hasNext() )
324 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
325 sr->setEnabled(true);
327 sm->setSelectedObjects( selected, true ); //NPAL 19674
329 //connect close signal to vtk view manager
330 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
333 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
334 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
337 //connect close signal to occ view manager
338 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
341 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
342 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
345 /* ************************************ TODO Hexa6
346 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
347 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
348 if ( _PTR(Study) aStudy = s->studyDS()) {
349 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
350 updateObjBrowser(); // objects can be removed
352 ************************************ */
354 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
355 currentOccGView->getViewWindow()->installEventFilter(this);
357 if (currentDocGView != NULL)
359 switchModel(currentDocGView);
362 if (currentDocGView->getViewWindow() != NULL)
363 currentDocGView->getViewWindow()->installEventFilter(this);
375 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
377 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
378 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
379 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
380 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
382 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
383 if ( vtkView != NULL)
385 //default selectionMode in VTKView
386 vtkView->SetSelectionMode( ActorSelection );
387 vtkView->removeEventFilter(this);
391 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
394 //defaut selectionMode in OccView
395 selectionMgr()->clearSelected();
396 currentOccGView->globalSelection();
397 occView->removeEventFilter(this);
401 qDeleteAll(myOCCSelectors);
402 myOCCSelectors.clear();
403 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
405 qDeleteAll(myVTKSelectors);
406 myVTKSelectors.clear();
407 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
409 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
411 //switch off current document graphic view
412 switchOffGraphicView(currentDocGView);
415 setMenuShown( false );
416 setToolShown( false );
417 showDockWidgets( false );
419 _dwInputPanel->close();
426 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
428 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
429 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
430 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
431 int aStudyID = theStudy->StudyId();
432 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
433 return aDSStudy._retn();
436 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
437 QMap<QString, QString>& docShapesEntry,
438 QMap<QString, QString>& docShapesName)
440 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
441 return; //there's nothing to publish in this case
443 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
444 if(!appStudy) return;
445 _PTR(Study) aStudy = appStudy->studyDS();
446 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
447 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
448 QString entry = currentDocGView->getDocumentModel()->documentEntry();
449 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
450 if (aFatherSO->_is_nil())
453 // * get a presentation
454 bool isNewPrs = false;
455 SOCC_Prs* prs = getOccPrs(currentDocGView);
458 prs = new SOCC_Prs(0);
462 // * init the presentation with the given shapes
463 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
464 while (i != topo_shapes.constEnd())
466 QString shapeName = i.key();
467 TopoDS_Shape shapeValue = i.value();
468 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
469 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
470 QString objStudyEntry = aSO->GetID(); //the entry of the published object
471 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
472 "HEXABLOCK", shapeName.toStdString().c_str());
473 ais_shape->SetOwner(io);
474 prs->AddObject(ais_shape);
475 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
476 docShapesEntry[shapeName] = objStudyEntry;
477 docShapesName[objStudyEntry] = shapeName;
478 currentOccGView->addShape(objStudyEntry, ais_shape);
479 i++; //handle next shape
483 prs->AddObject(currentOccGView->getPreviewShape());
485 occPrs[currentDocGView] = prs;
486 getApp()->updateObjectBrowser();
491 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
493 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
494 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
495 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
497 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
501 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
505 // Pas de renommage des shapes pour le moment, juste les documents
506 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
507 if (dgview == NULL || dgview->getDocumentModel() == NULL)
510 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
511 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
516 _PTR(Study) aStudy = appStudy->studyDS();
521 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
522 _PTR(GenericAttribute) anAttr;
524 if ( obj->FindAttribute(anAttr, "AttributeName") ){
525 _PTR(AttributeName) aName (anAttr);
526 DocumentModel* docModel = dgview->getDocumentModel();
527 docModel->setName( name );
528 aName->SetValue( name.toLatin1().data() );
529 getApp()->updateObjectBrowser();
530 // _dwPattern->setWindowTitle( name );
537 // --- Default windows
538 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
540 DEBTRACE("HEXABLOCKGUI::windows");
542 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
543 #ifndef DISABLE_PYCONSOLE
544 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
548 QString HEXABLOCKGUI::engineIOR() const
550 DEBTRACE("HEXABLOCKGUI::engineIOR");
552 /* ************************************ TODO Hexa6
553 CORBA::ORB_var anORB = getApp()->orb();
554 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
555 return QString( anIOR.in() );
556 ************************************ */
560 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
562 if (docs.count(studyObject->entry()) == 0)
564 //Object's document not acquired yet
565 VtkDocumentGraphicView* dgview;
566 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
567 if (directory == NULL)
568 return NULL; //No working director found
570 //------------------ Load the document -----------------
571 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
572 if (document == NULL)
573 return NULL; //No document found
575 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
577 MESSAGE("Doc model creation failed!");
580 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
581 if (dgview == NULL) return NULL;
583 //update the data tree
584 docs[studyObject->entry()] = dgview;
587 return docs[studyObject->entry()];
590 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
592 // ** we want to switch automatically to the right view windows
594 //first, find selected item
596 DataObjectList dol = getApp()->objectBrowser()->getSelected();
597 if (dol.isEmpty()) return;
598 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
599 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
600 item->entry().isEmpty())
603 // find the document corresponding to it
604 VtkDocumentGraphicView* docGView = NULL;
605 if (docs.contains(item->entry()))
606 docGView = docs[item->entry()];
608 docGView = getOrCreateDocument(item);
610 //Init OCC if necessary
611 if (currentOccGView == NULL)
613 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
614 currentOccGView->getViewWindow()->installEventFilter(this);
616 else if (currentOccGView->getViewWindow() == NULL)
618 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
619 currentOccGView->getViewWindow()->installEventFilter(this);
622 //Init the vtk view if necessary
623 if (docGView->getViewWindow() == NULL)
625 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
627 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
628 docGView->getViewWindow()->installEventFilter(this);
631 setAllMenusEnabled(true);
634 docGView->setViewWindow(currentDocGView->getViewWindow());
636 if (docGView->getDocumentActor() == NULL)
640 if (docGView == NULL || docGView == currentDocGView)
646 //update the current document
647 switchModel(docGView);
651 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
653 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
656 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
658 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
660 //Decharger le model correspondant (VTK)
661 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
665 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
666 { //HexaBlock Vtk Window has been closed
668 if (currentDialog != NULL) currentDialog->close();
669 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
670 if (currentDocGView != NULL)
671 currentDocGView->setViewWindow(NULL);
674 setAllMenusEnabled(false);
675 enableDocumentMenus(true);
681 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
682 if (dgview == NULL) return; //The window has no document to close
684 //Save the document? (Ask only if the document is not empty
685 int answerCode = SUIT_MessageBox::question(
688 tr("Save the document ?"),
689 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
690 SUIT_MessageBox::Cancel);
691 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
692 else if (answerCode == SUIT_MessageBox::Yes)
693 saveDocument(); //Save the document
695 // switchOffGraphicView(window); //disconnect all connected signals
696 // currentVtkView = NULL;
697 // graphicViewsHandler->closeDocumentGraphicView(window);
699 //create a new one (empty document)
701 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
705 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
707 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
708 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
709 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
710 if (currentDialog != NULL) currentDialog->close();
711 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
713 currentOccGView->getViewWindow()->removeEventFilter(this);
714 currentOccGView->setViewWindow(NULL);
718 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
720 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
722 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
723 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
725 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
727 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
728 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
729 // disable OCC selectors
730 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
731 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
732 while ( itOCCSel.hasNext() )
733 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
734 sr->setEnabled(true);
736 else if ( vm->getType() == SVTK_Viewer::Type() )
738 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
739 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
741 // disable VTK selectors
742 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
743 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
744 while ( itVTKSel.hasNext() )
745 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
746 sr->setEnabled(true);
750 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
752 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
754 SUIT_ViewModel* viewer = vm->getViewModel();
755 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
757 //VTK View Manager removed
758 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
760 //Process only if it's our view manager
761 SUIT_ViewManager* myVm = NULL;
762 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
763 myVm = currentDocGView->getViewWindow()->getViewManager();
767 //close opened dialog
768 if (currentDialog != NULL) currentDialog->close();
769 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
775 //remove its selector
776 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
777 while ( itVTKSel.hasNext() )
778 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
779 if ( sr->viewer() == viewer )
781 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
788 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
790 //OCC View removed: remove its selector
791 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
792 while ( itOCCSel.hasNext() )
793 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
794 if ( sr->viewer() == viewer )
796 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
802 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
804 QModelIndexList l = selected.indexes();
805 if ( l.count() == 0 ) return;
806 if ( !l[0].isValid() ) return;
807 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
808 if ( currentGraphicView == NULL) return;
810 QTreeView* theTree = NULL;
811 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
812 theTree = _patternDataTreeView;
814 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
815 theTree = _patternBuilderTreeView;
817 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
818 theTree = _patternGeomTreeView;
820 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
821 theTree = _groupsTreeView;
822 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
823 theTree = _meshTreeView;
826 theTree->scrollTo ( l[0] );
830 bool HEXABLOCKGUI::createSComponent() //addComponent
832 DEBTRACE("HEXABLOCKGUI::createSComponent");
833 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
835 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
836 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
837 _PTR(GenericAttribute) anAttr;
838 _PTR(AttributeName) aName;
839 _PTR(AttributeGraphic) aGraphic;
841 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
842 if ( !aComponent ){ //Create hexablock component if there's not one yet
843 aComponent = aBuilder->NewComponent("HEXABLOCK");
844 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
845 aName = _PTR(AttributeName) (anAttr);
846 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
848 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
849 _PTR(AttributePixMap) aPixmap(anAttr);
850 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
852 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
853 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
859 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
861 DEBTRACE("HEXABLOCKGUI::setResource");
862 _myresource = new HEXABLOCKGUI_Resource(r);
863 _myresource->preferencesChanged();
866 void HEXABLOCKGUI::createPreferences()
868 DEBTRACE("HEXABLOCKGUI::createPreferences");
869 _myresource->createPreferences(this);
872 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
874 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
875 _myresource->preferencesChanged(sect, name);
876 // if(name=="userCatalog")
877 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
880 void HEXABLOCKGUI::studyActivated() //CS_TODO
882 int newStudyId = getApp()->activeStudy()->id();
883 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
884 // if (_oldStudyId != -1)
886 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
887 // if (_studyContextMap.count(newStudyId))
889 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
890 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
894 // DEBTRACE("no switch to null context");
897 _oldStudyId = newStudyId;
900 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
902 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
903 QVariant currentAssocVariant;
904 QString currentAssocEntry;
906 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
907 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
908 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
909 QMenu menu( _patternDataTreeView );
911 QAction *clearAct = menu.addAction( "Remove association(s)" );
912 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
913 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
917 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
918 if (currentVtkGraphicView == NULL) return;
919 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
921 //We don't do anything for single items
922 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
923 item->type() == QUADITEM || item->type() == HEXAITEM)
926 //No associations for HEXA
927 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
928 if ( !treeVariant.isValid() ) return;
929 int eltType = treeVariant.toInt();
930 if (eltType == HEXA_DIR_TREE) return;
931 QMenu menu( _patternDataTreeView );
933 //Show association(s)
934 QAction *showAssocAct = menu.addAction( "Show associations" );
935 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
937 //Clear all associations
938 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
939 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
941 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
946 void HEXABLOCKGUI::createAndFillDockWidget()
949 QMainWindow *aParent = application()->desktop();
951 // Create dock widget (3 dock)
953 //1) *********** user input panel ( contain user's edit dialog box )
954 _dwInputPanel = new QDockWidget(aParent);
955 _dwInputPanel->setVisible(false);
956 _dwInputPanel->setWindowTitle("Input Panel");
957 _dwInputPanel->setObjectName("hexablockInputPanelDock");
958 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
960 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
962 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
964 _dwPattern = new QDockWidget(aParent);
965 _dwPattern->setVisible(false);
966 _dwPattern->setWindowTitle("Model");
967 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
968 _dwPattern->setObjectName("hexablockModelDock");
970 QFrame* patternFrame = new QFrame(_dwPattern);
971 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
972 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
973 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
974 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
975 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
976 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
977 _patternGeomTreeView = new QTreeView(patternFrame);
978 splitter->addWidget(_patternDataTreeView);
979 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
980 splitter->addWidget(_patternGeomTreeView);
981 patternLayout->addWidget(splitter);
983 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
984 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
985 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
988 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
989 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
991 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
992 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
994 _dwPattern->setWidget(patternFrame);
995 patternFrame->show();
998 _dwGroups = new QDockWidget(aParent);
1000 _dwGroups->setVisible(false);
1001 _dwGroups->setWindowTitle("Groups");
1002 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1003 _dwGroups->setObjectName("hexablockGroupsDock");
1004 _groupsTreeView = new QTreeView(_dwGroups);
1005 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1006 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
1007 _dwGroups->setWidget(_groupsTreeView);
1008 _groupsTreeView->show();
1011 _dwMesh = new QDockWidget(aParent);
1012 _dwMesh->setVisible(false);
1013 _dwMesh->setWindowTitle("Mesh");
1014 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1015 _dwMesh->setObjectName("hexablockMeshDock");
1016 _meshTreeView = new QTreeView(_dwMesh);
1017 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1018 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1019 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1020 _dwMesh->setWidget(_meshTreeView);
1021 _meshTreeView->show();
1023 // QDockWidget *_dwObjectBrowser = 0;
1024 QWidget* wid = getApp()->objectBrowser()->treeView();
1025 QWidget *w = wid->parentWidget();
1026 while ( w && !_dwObjectBrowser ) {
1027 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1028 w = w->parentWidget();
1030 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1031 _dwObjectBrowser->setWindowTitle("Study");
1033 // dock widget position
1034 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1035 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1037 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1038 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1039 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1041 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1042 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1043 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1045 #if QT_VERSION >= 0x040500
1046 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1049 // popup menu on data tree view
1050 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1051 connect(_patternDataTreeView,
1052 SIGNAL(customContextMenuRequested(const QPoint &)),
1054 SLOT(treeContextMenu(const QPoint &)),
1055 Qt::UniqueConnection );
1058 void HEXABLOCKGUI::createActions()
1060 QMainWindow *aParent = application()->desktop();
1061 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1064 _newAct = createAction(_menuId++,
1065 tr("Create a new document"),
1066 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1068 tr("Create a new document"),
1069 0, aParent, false, this, SLOT(newDocument()));
1070 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1072 _importAct = createAction(_menuId++,
1073 tr("Load a document"),
1074 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1075 tr("Load Document"),
1076 tr("Load a document"),
1077 0, aParent, false, this, SLOT(loadDocument()));
1078 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1080 _saveAct = createAction(_menuId++,
1081 tr("Save the document"),
1082 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1083 tr("Save Document"),
1084 tr("Save the document"),
1085 0, aParent, false, this, SLOT(saveDocument()));
1087 // Pattern Data creation
1088 _addVertex = createAction(_menuId++,
1089 tr("Create a vertex"),
1090 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1092 tr("Create a new vertex"),
1093 0, aParent, false, this, SLOT(addVertex()));
1095 _addEdge = createAction(_menuId++,
1096 tr("Create an edge"),
1097 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1099 tr("Create a new edge"),
1100 0, aParent, false, this, SLOT(addEdge()));
1102 _addQuad = createAction(_menuId++,
1103 tr("Create a quadrangle"),
1104 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1105 tr("Add Quadrangle"),
1106 tr("Create a new quadrangle"),
1107 0, aParent, false, this, SLOT(addQuad()));
1109 _addHexa = createAction(_menuId++,
1110 tr("Create an hexahedron"),
1111 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1112 tr("Add Hexahedron"),
1113 tr("Create a new hexahedron"),
1114 0, aParent, false, this, SLOT(addHexa()));
1116 // Builder Data creation
1117 _addVector = createAction(_menuId++,
1118 tr("Create a vector"),
1119 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1121 tr("Create a new vector"),
1122 0, aParent, false, this, SLOT(addVector()));
1124 // _addCylinder = createAction(_menuId++,
1125 // tr("Create a cylinder"),
1126 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1127 // tr("Add Cylinder"),
1128 // tr("Create a new cylinder"),
1129 // 0, aParent, false, this, SLOT(addCylinder()));
1131 // _addPipe = createAction(_menuId++,
1132 // tr("Create a pipe"),
1133 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1135 // tr("Create a new pipe"),
1136 // 0, aParent, false, this, SLOT(addPipe()));
1138 _makeGrid = createAction(_menuId++,
1140 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1143 0, aParent, false, this, SLOT(makeGrid()));
1145 _makeCylinder = createAction(_menuId++,
1146 tr("Make a cylinder"),
1147 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1148 tr("Make Cylinder"),
1149 tr("Make a cylinder"),
1150 0, aParent, false, this, SLOT(makeCylinder()));
1152 _makePipe = createAction(_menuId++,
1154 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1157 0, aParent, false, this, SLOT(makePipe()));
1159 _makeCylinders = createAction(_menuId++,
1160 tr("Make cylinders"),
1161 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1162 tr("Make Cylinders"),
1163 tr("Make cylinders"),
1164 0, aParent, false, this, SLOT(makeCylinders()));
1166 _makePipes = createAction(_menuId++,
1168 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1171 0, aParent, false, this, SLOT(makePipes()));
1173 _makeHemiSphere = createAction(_menuId++,
1174 tr("Make an hemisphere"),
1175 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1176 tr("Make Hemisphere"),
1177 tr("Make an hemisphere"),
1178 0, aParent, false, this, SLOT(makeHemiSphere()));
1180 // Pattern Data edition
1181 _removeHexa = createAction(_menuId++,
1182 tr("Remove hexahedra"),
1183 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1184 tr("Remove Hexahedra"),
1185 tr("Remove hexahedra"),
1186 0, aParent, false, this, SLOT(removeHexa()));
1188 _prismQuad = createAction(_menuId++,
1189 tr("Prism quadrangles"),
1190 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1191 tr("Prism Quadrangles"),
1192 tr("Prism quadrangles"),
1193 0, aParent, false, this, SLOT(prismQuad()));
1195 _joinQuad = createAction(_menuId++,
1196 tr("Join quadrangles"),
1197 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1198 tr("Join Quadrangles"),
1199 tr("Join quadrangles with hexahedra"),
1200 0, aParent, false, this, SLOT(joinQuad()));
1202 _merge = createAction(_menuId++,
1204 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1207 0, aParent, false, this, SLOT(merge()));
1209 _disconnect = createAction(_menuId++,
1211 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1213 tr("Disconnect edges, vertexes or quadrangles"),
1214 0, aParent, false, this, SLOT(disconnectElts()));
1216 _cutEdge = createAction(_menuId++,
1218 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1221 0, aParent, false, this, SLOT(cutEdge()));
1223 _makeTransformation = createAction(_menuId++,
1224 tr("Make transformation"),
1225 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1226 tr("Make Transformation"),
1227 tr("Make transformation"),
1228 0, aParent, false, this, SLOT(makeTransformation()));
1230 _makeSymmetry = createAction(_menuId++,
1231 tr("Make symmetry"),
1232 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1233 tr("Make Symmetry"),
1234 tr("Make symmetry"),
1235 0, aParent, false, this, SLOT(makeSymmetry()));
1237 _performTransformation = createAction(_menuId++,
1238 tr("Perform transformation"),
1239 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1240 tr("Perform Transformation"),
1241 tr("Perform transformation"),
1242 0, aParent, false, this, SLOT(performTransformation()));
1244 _performSymmetry = createAction(_menuId++,
1245 tr("Perform symmetry"),
1246 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1247 tr("Perform Symmetry"),
1248 tr("Perform symmetry"),
1249 0, aParent, false, this, SLOT(performSymmetry()));
1251 _replaceHexa = createAction(_menuId++,
1252 tr("Replace hexahedron"),
1253 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1254 tr("Replace Hexahedron"),
1255 tr("Replace hexahedron"),
1256 0, aParent, false, this, SLOT(replaceHexa()));
1258 _quadRevolution = createAction(_menuId++,
1259 tr("Quad revolution"),
1260 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1261 tr("Quad Revolution"),
1262 tr("Quad revolution"),
1263 0, aParent, false, this, SLOT(quadRevolution()));
1266 _assocVertex = createAction(_menuId++,
1267 tr("Make vertex association"),
1268 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1269 tr("Make Vertex association"),
1270 tr("Make vertex association"),
1271 0, aParent, false, this, SLOT(assocVertex()));
1273 _assocEdge = createAction(_menuId++,
1274 tr("Make edge association"),
1275 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1276 tr("Make Edge Association"),
1277 tr("Make edge association"),
1278 0, aParent, false, this, SLOT(assocEdge()));
1280 _assocQuad = createAction(_menuId++,
1281 tr("Make quad association"),
1282 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1283 tr("Make Quad Association"),
1284 tr("Make quad association"),
1285 0, aParent, false, this, SLOT(assocQuad()));
1288 _addGroup = createAction(_menuId++,
1290 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1293 0, aParent, false, this, SLOT(addGroup()));
1295 _removeGroup = createAction(_menuId++,
1296 tr("Remove a group"),
1297 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1299 tr("Remove a group"),
1300 0, aParent, false, this, SLOT(removeGroup()));
1303 _addLaw = createAction(_menuId++,
1305 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1308 0, aParent, false, this, SLOT(addLaw()));
1310 _removeLaw = createAction(_menuId++,
1312 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1315 0, aParent, false, this, SLOT(removeLaw()));
1317 _setPropagation = createAction(_menuId++,
1318 tr("Set propagation"),
1319 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1320 tr("Set Propagation"),
1321 tr("Set propagation"),
1322 0, aParent, false, this, SLOT(setPropagation()));
1324 _computeMesh = createAction(_menuId++,
1326 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1329 0, aParent, false, this, SLOT(computeMesh()));
1331 _showModelInfoAct = createAction(_menuId++,
1332 tr("Show Model Info"),
1333 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1336 0, aParent, false, this, SLOT(showModelInfo()));
1338 _addShapeAct = createAction(_menuId++,
1340 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1343 0, aParent, false, this, SLOT(addShape()));
1345 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1346 // QAction* createAction(const int id,
1347 // const QString& toolTip,
1348 // const QIcon& icon,
1349 // const QString& menu,
1350 // const QString& status,
1351 // const int shortCut,
1352 // QObject* parent =0,
1353 // bool checkable = false,
1354 // QObject* receiver =0,
1355 // const char* member =0);
1357 _sep1 = separator();
1358 _sep2 = separator();
1359 _sep3 = separator();
1360 _sep4 = separator();
1364 void HEXABLOCKGUI::createMenus()
1366 int aMenuId, subMenuId,aMenuIdMain;
1368 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1370 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1371 createMenu( actionId(_newAct), aMenuId );
1372 createMenu( actionId(_importAct), aMenuId );
1373 createMenu( _saveAct, aMenuId );
1376 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1377 createMenu( _newAct, aMenuDocId );//, 10
1378 createMenu( _importAct, aMenuDocId );
1379 createMenu( _saveAct, aMenuDocId );
1381 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1382 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1383 createMenu( _addVertex, subMenuId );
1384 createMenu( _addEdge, subMenuId );
1385 createMenu( _addQuad, subMenuId );
1386 createMenu( _addHexa, subMenuId );
1387 createMenu( _sep1, subMenuId);
1390 createMenu( _addVector, subMenuId );
1391 // createMenu( _addCylinder, subMenuId );
1392 // createMenu( _addPipe, subMenuId );
1394 createMenu( _sep2, subMenuId);
1396 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1397 createMenu( _makeHemiSphere,subMenuId );
1399 createMenu( _sep3, subMenuId);
1401 createMenu( _makeCylinder, subMenuId );
1402 createMenu( _makePipe, subMenuId );
1403 createMenu( _makeCylinders,subMenuId );
1404 createMenu( _makePipes, subMenuId );
1406 // Pattern Data Edition
1407 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1408 createMenu( _removeHexa, subMenuId );
1409 createMenu( _prismQuad, subMenuId );
1410 createMenu( _joinQuad, subMenuId );
1411 createMenu( _merge, subMenuId );
1412 createMenu( _disconnect, subMenuId );
1413 createMenu( _cutEdge, subMenuId );
1414 createMenu( _makeTransformation, subMenuId );
1415 createMenu( _makeSymmetry, subMenuId );
1416 createMenu( _performTransformation, subMenuId );
1417 createMenu( _performSymmetry, subMenuId );
1418 createMenu( _replaceHexa, subMenuId );
1419 createMenu( _quadRevolution, subMenuId );
1420 createMenu( _sep4, aMenuId );
1421 createMenu( _showModelInfoAct, aMenuId );
1424 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1425 createMenu( _addShapeAct, aMenuId );
1426 createMenu( _assocVertex, aMenuId );
1427 createMenu( _assocEdge, aMenuId );
1428 createMenu( _assocQuad, aMenuId );
1431 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1432 createMenu( _addGroup, aMenuId );
1433 createMenu( _removeGroup, aMenuId ); //CS_TODO
1436 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1437 createMenu( _addLaw, aMenuId );
1438 createMenu( _removeLaw, aMenuId );
1439 createMenu( _setPropagation, aMenuId );
1440 createMenu( _computeMesh, aMenuId );
1442 //show model infomation menu
1443 QString aRule = "$component={'HEXABLOCK'}";
1444 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1445 popupMgr()->setRule( _showModelInfoAct, aRule);
1447 //associate shape to a document menu
1448 popupMgr()->insert( _addShapeAct, -1, -1 );
1449 popupMgr()->setRule( _addShapeAct, aRule );
1451 //-------------------------------------------------
1453 //-------------------------------------------------
1454 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1455 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1456 // QString isNotEmpty("numberOfNodes <> 0");
1457 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1458 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1459 //// aType = aType.arg( mesh_part );
1461 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1462 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1463 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1465 // popupMgr()->insert( separator(), -1, -1 );
1466 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1467 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1468 // // MESSAGE("aClient = " << aClient.toStdString());
1469 // // MESSAGE("aType = " << aType.toStdString());
1470 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1471 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1472 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1473 // // MESSAGE("aRule = " << aRule.toStdString());
1474 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1475 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1477 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1478 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1480 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1481 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1483 // popupMgr()->insert( separator(), -1, -1 );
1487 void HEXABLOCKGUI::createTools()
1491 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1492 createTool( _newAct, aToolId );
1493 createTool( _importAct, aToolId );
1494 createTool( _saveAct, aToolId );
1495 createTool( _showModelInfoAct, aToolId );
1496 // createTool( _testAct, aToolId );
1497 //createTool( separator(), aToolId );
1500 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1501 createTool( _addVertex, aToolId );
1502 createTool( _addEdge, aToolId );
1503 createTool( _addQuad, aToolId );
1504 createTool( _addHexa, aToolId );
1506 createTool( _sep1, aToolId );
1509 createTool( _addVector, aToolId );
1510 // createTool( _addCylinder, aToolId );
1511 // createTool( _addPipe, aToolId );
1513 createTool( _sep2, aToolId );
1515 createTool( _makeGrid, aToolId );
1516 createTool( _makeHemiSphere, aToolId );
1518 createTool( _sep3, aToolId );
1520 createTool( _makeCylinder, aToolId );
1521 createTool( _makePipe, aToolId );
1522 createTool( _makeCylinders,aToolId );
1523 createTool( _makePipes, aToolId );
1525 // Pattern Data Edition
1526 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1527 createTool( _removeHexa, aToolId );
1528 createTool( _prismQuad, aToolId );
1529 createTool( _joinQuad, aToolId );
1530 createTool( _merge, aToolId );
1531 createTool( _disconnect, aToolId );
1532 createTool( _cutEdge, aToolId );
1533 createTool( _makeTransformation, aToolId );
1534 createTool( _makeSymmetry, aToolId );
1535 createTool( _performTransformation, aToolId );
1536 createTool( _performSymmetry, aToolId );
1537 createTool( _replaceHexa, aToolId );
1538 createTool( _quadRevolution, aToolId );
1541 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1542 createTool( _assocVertex, aToolId );
1543 createTool( _assocEdge, aToolId );
1544 createTool( _assocQuad, aToolId );
1545 createTool( _addShapeAct, aToolId );
1548 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1549 createTool( _addGroup, aToolId );
1550 createTool( _removeGroup, aToolId ); //CS_TODO
1553 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1554 createTool( _addLaw, aToolId );
1555 createTool( _removeLaw, aToolId );
1556 createTool( _setPropagation, aToolId );
1557 createTool( _computeMesh, aToolId );
1561 void HEXABLOCKGUI::initialMenus()
1563 showDocumentMenus( true );
1564 showPatternMenus( false );
1565 showAssociationMenus( false );
1566 showGroupsMenus( false );
1567 showMeshMenus( false );
1570 void HEXABLOCKGUI::showAllMenus()
1572 showDocumentMenus( true );
1573 showPatternMenus( true );
1574 showAssociationMenus( true );
1575 showGroupsMenus( true );
1576 showMeshMenus( true );
1579 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1581 enableDocumentMenus( enable );
1582 enablePatternMenus( enable );
1583 enableAssociationMenus( enable );
1584 enableGroupsMenus( enable );
1585 enableMeshMenus( enable );
1587 menusEnabled = enable;
1590 void HEXABLOCKGUI::showDocumentMenus(bool show)
1592 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1594 setMenuShown(_newAct, show);
1595 setToolShown(_newAct, show);
1596 setMenuShown(_importAct, show);
1597 setToolShown(_importAct, show);
1598 setMenuShown(_showModelInfoAct, show);
1599 setToolShown(_showModelInfoAct, show);
1600 setMenuShown(_saveAct, show);
1601 setToolShown(_saveAct, show);
1604 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1606 _newAct->setEnabled(enable);
1607 // setToolShown(_newAct, enable);
1609 _importAct->setEnabled(enable);
1610 // setToolShown(_importAct, enable);
1612 _showModelInfoAct->setEnabled(enable);
1613 // setToolShown(_showModelInfoAct, enable);
1615 _saveAct->setEnabled(enable);
1616 // setToolShown(_saveAct, enable);
1620 void HEXABLOCKGUI::showPatternMenus(bool show)
1622 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1623 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1624 if ( show && !getCurrentModel() ) return;
1626 setMenuShown(_addVertex, show );
1627 setToolShown(_addVertex, show);
1628 setMenuShown(_addEdge, show );
1629 setToolShown(_addEdge, show);
1630 setMenuShown(_addQuad, show );
1631 setToolShown(_addQuad, show);
1632 setMenuShown(_addHexa, show );
1633 setToolShown(_addHexa, show);
1635 setMenuShown(_sep1, show );
1636 setToolShown(_sep1, show);
1638 setMenuShown( _addVector, show );
1639 setToolShown( _addVector, show);
1640 // setMenuShown( _addCylinder, show );
1641 // setToolShown( _addCylinder, show);
1642 // setMenuShown( _addPipe, show );
1643 // setToolShown( _addPipe, show);
1645 setMenuShown(_sep2, show );
1646 setToolShown(_sep2, show);
1648 setMenuShown( _makeGrid, show );
1649 setToolShown( _makeGrid, show);
1650 setMenuShown( _makePipe, show );
1651 setToolShown( _makePipe, show);
1653 setMenuShown(_sep3, show );
1654 setToolShown(_sep3, show);
1656 setMenuShown( _makeCylinder, show );
1657 setToolShown( _makeCylinder, show);
1658 setMenuShown( _makeCylinders, show );
1659 setToolShown( _makeCylinders, show);
1660 setMenuShown( _makePipes, show );
1661 setToolShown( _makePipes, show);
1662 setMenuShown( _makeHemiSphere, show );
1663 setToolShown( _makeHemiSphere, show);
1665 // Pattern Data Edition
1666 setMenuShown( _removeHexa, show );
1667 setToolShown( _removeHexa, show);
1668 setMenuShown( _prismQuad, show );
1669 setToolShown( _prismQuad, show);
1670 setMenuShown( _joinQuad, show );
1671 setToolShown( _joinQuad, show);
1672 setMenuShown( _merge, show );
1673 setToolShown( _merge, show);
1674 setMenuShown( _disconnect, show );
1675 setToolShown( _disconnect, show);
1676 setMenuShown( _cutEdge, show );
1677 setToolShown( _cutEdge, show);
1678 setMenuShown( _makeTransformation, show );
1679 setToolShown( _makeTransformation, show);
1680 setMenuShown( _makeSymmetry, show );
1681 setToolShown( _makeSymmetry, show);
1682 setMenuShown( _performTransformation, show );
1683 setToolShown( _performTransformation, show);
1684 setMenuShown( _performSymmetry, show );
1685 setToolShown( _performSymmetry, show);
1686 setMenuShown( _replaceHexa, show );
1687 setToolShown( _replaceHexa, show);
1688 setMenuShown( _quadRevolution, show );
1689 setToolShown( _quadRevolution, show);
1691 setMenuShown( _sep4, show );
1692 setMenuShown( _showModelInfoAct, show );
1695 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1697 if ( enable && !getCurrentModel() ) return;
1699 _addVertex->setEnabled(enable);
1700 // setToolShown(_addVertex, enable);
1702 _addEdge->setEnabled(enable);
1703 // setToolShown(_addEdge, enable);
1705 _addQuad->setEnabled(enable);
1706 // setToolShown(_addQuad, enable);
1708 _addHexa->setEnabled(enable);
1709 // setToolShown(_addHexa, enable);
1711 // setMenuShown(_sep1, enable );
1712 // setToolShown(_sep1, enable);
1714 _addVector->setEnabled(enable);
1715 // setToolShown( _addVector, enable);
1717 // setMenuShown(_sep2, enable );
1718 // setToolShown(_sep2, enable);
1720 _makeGrid->setEnabled(enable);
1721 // setToolShown( _makeGrid, enable);
1723 _makePipe->setEnabled(enable);
1724 // setToolShown( _makePipe, enable);
1726 // setMenuShown(_sep3, enable );
1727 // setToolShown(_sep3, enable);
1729 _makeCylinder->setEnabled(enable);
1730 // setToolShown( _makeCylinder, enable);
1732 _makeCylinders->setEnabled(enable);
1733 // setToolShown( _makeCylinders, enable);
1735 _makePipes->setEnabled(enable);
1736 // setToolShown( _makePipes, enable);
1738 _makeHemiSphere->setEnabled(enable);
1739 // setToolShown( _makeHemiSphere, enable);
1741 // Pattern Data Edition
1742 _removeHexa->setEnabled(enable);
1743 // setToolShown( _removeHexa, enable);
1745 _prismQuad->setEnabled(enable);
1746 // setToolShown( _prismQuad, enable);
1748 _joinQuad->setEnabled(enable);
1749 // setToolShown( _joinQuad, enable);
1751 _merge->setEnabled(enable);
1752 // setToolShown( _merge, enable);
1754 _disconnect->setEnabled(enable);
1755 // setToolShown( _disconnect, enable);
1757 _cutEdge->setEnabled(enable);
1758 // setToolShown( _cutEdge, enable);
1760 _makeTransformation->setEnabled(enable);
1761 // setToolShown( _makeTransformation, enable);
1763 _makeSymmetry->setEnabled(enable);
1764 // setToolShown( _makeSymmetry, enable);
1766 _performTransformation->setEnabled(enable);
1767 // setToolShown( _performTransformation, enable);
1769 _performSymmetry->setEnabled(enable);
1770 // setToolShown( _performSymmetry, enable);
1772 _replaceHexa->setEnabled(enable);
1773 // setToolShown( _replaceHexa, enable);
1775 _quadRevolution->setEnabled(enable);
1776 // setToolShown( _quadRevolution, enable);
1778 // setMenuShown( _sep4, enable );
1779 _showModelInfoAct->setEnabled(enable);
1783 void HEXABLOCKGUI::showAssociationMenus(bool show)
1785 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1786 if ( show && !getCurrentModel() ) return;
1788 // Association Edition
1789 setMenuShown( _assocVertex, show );
1790 setToolShown( _assocVertex, show );
1792 setMenuShown( _assocEdge, show );
1793 setToolShown( _assocEdge, show );
1795 setMenuShown( _assocQuad, show );
1796 setToolShown( _assocQuad, show );
1798 setMenuShown( _addShapeAct, show );
1799 setToolShown( _addShapeAct, show );
1802 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1804 if ( enable && !getCurrentModel() )
1807 // Association Edition
1808 _assocVertex->setEnabled(enable);
1809 // setToolShown( _assocVertex, enable );
1811 _assocEdge->setEnabled(enable);
1812 // setToolShown( _assocEdge, enable );
1814 _assocQuad->setEnabled(enable);
1815 // setToolShown( _assocQuad, enable );
1817 _addShapeAct->setEnabled(enable);
1818 // setToolShown( _addShapeAct, enable );
1821 void HEXABLOCKGUI::showGroupsMenus(bool show)
1823 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1824 if ( show && !getCurrentModel() ) return;
1825 setMenuShown( _addGroup, show );
1826 setToolShown( _addGroup, show);
1827 setMenuShown( _removeGroup , show );
1828 setToolShown( _removeGroup , show);
1831 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1833 if ( enable && !getCurrentModel() )
1836 _addGroup->setEnabled(enable);
1837 // setToolShown( _addGroup, enable);
1839 _removeGroup->setEnabled(enable);
1840 // setToolShown( _removeGroup , enable);
1843 void HEXABLOCKGUI::showMeshMenus(bool show)
1845 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1846 if ( show && !getCurrentModel() ) return;
1847 setMenuShown( _addLaw, show );
1848 setToolShown( _addLaw, show);
1849 setMenuShown( _removeLaw, show );
1850 setToolShown( _removeLaw, show);;
1851 setMenuShown( _setPropagation, show );
1852 setToolShown( _setPropagation, show);
1853 setMenuShown( _computeMesh, show);
1854 setToolShown( _computeMesh, show);
1857 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1859 if ( enable && !getCurrentModel() )
1862 _addLaw->setEnabled(enable);
1863 // setToolShown( _addLaw, enable);
1865 _removeLaw->setEnabled(enable);
1866 // setToolShown( _removeLaw, enable);
1868 _setPropagation->setEnabled(enable);
1869 // setToolShown( _setPropagation, enable);
1871 _computeMesh->setEnabled(enable);
1872 // setToolShown( _computeMesh, enable);
1875 void HEXABLOCKGUI::showVtkActor()
1877 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1878 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1879 currentVtkGView->getDocumentActor() == NULL)
1882 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1883 if (vtkView == NULL)
1886 SUIT_ViewManager* vman = vtkView->getViewManager();
1887 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1889 //show only the current actor -----------------
1890 vtkView->setFocus();
1891 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1892 Document_Actor *lastDocActor;
1893 if (lastVtkDocGView != NULL)
1895 lastDocActor = lastVtkDocGView->getDocumentActor();
1896 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1897 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1899 vtkView->Erase(lastActorIO);
1900 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1901 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1904 currentVtkGView->update();
1905 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1906 if (!anIO.IsNull() && anIO->hasEntry())
1908 vtkView->Display(anIO);
1909 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1910 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1912 vtkView->onFitAll();
1915 void HEXABLOCKGUI::showOccActor()
1917 if (currentOccGView == NULL)
1919 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1920 if (occView == NULL)
1922 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1926 if (lastOccPrs != NULL)
1927 vf->Erase(lastOccPrs);
1928 currentOccGView->globalSelection();
1929 SOCC_Prs* prs = getOccPrs(currentDocGView);
1930 currentOccGView->setPrs(prs);
1933 occView->onFitAll();
1936 void HEXABLOCKGUI::hideVtkActor()
1938 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1939 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1940 currentVtkGView->getViewWindow() == NULL ||
1941 currentVtkGView->getDocumentActor() == NULL) return;
1943 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1944 currentVtkGView->getViewWindow()->onResetView();
1946 //update the visibility state now
1947 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1948 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1949 if (aStudy == NULL || vman == NULL) return;
1951 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1952 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1953 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1956 void HEXABLOCKGUI::hideOccActor()
1958 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1959 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1960 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1961 if (occView == NULL || docModel == NULL)
1963 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1967 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1968 if (currentOccPrs != NULL)
1969 vf->Erase(currentOccPrs);
1971 occView->onResetView();
1974 void HEXABLOCKGUI::showOnlyActor()
1980 void HEXABLOCKGUI::hideActor()
1987 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1989 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1991 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1992 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1994 if (_dwPattern) _dwPattern->setVisible(isVisible);
1995 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1997 if (_dwMesh) _dwMesh->setVisible(isVisible);
1998 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
2000 if (_dwGroups) _dwGroups->setVisible(isVisible);
2001 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
2005 //clear all used dialogs by the current model
2006 void HEXABLOCKGUI::clearDialogs()
2008 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
2009 fin (currentModelDialogs.end());
2010 for(;debut!=fin;++debut) (*debut)->clear();
2012 currentModelDialogs.clear(); //empty the used dialogs list
2015 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
2017 if (!gViewDlgBox.contains(dgview)) return NULL;
2018 return gViewDlgBox[dgview];
2021 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
2023 if (dgview == NULL) return;
2025 switchOffGraphicView(dgview, false); //to avoid double connect
2028 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2029 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
2030 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2031 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2032 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2033 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2034 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2035 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2036 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2037 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2038 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2039 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2044 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2046 if (dgview == NULL) return;
2048 //disconnect signals
2049 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2050 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2051 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2052 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2053 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2054 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2055 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2056 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2057 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2058 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2059 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2060 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2063 gViewDlgBox[dgview] = currentDialog;
2065 //close opened dialog
2066 if (currentDialog != NULL) currentDialog->close();
2067 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2073 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2075 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2079 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2083 //switch off the current document graphic view (disconnect signals...)
2084 if (currentDocGView != NULL)
2086 //Hide current actor
2088 switchOffGraphicView(currentDocGView);
2091 //clear the dialogs used by the current model so they can be used by the new model
2092 if (currentDocGView != dgview) clearDialogs();
2094 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2095 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2096 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2097 _groupsTreeView->setModel(dgview->getGroupsModel());
2098 _meshTreeView->setModel(dgview->getMeshModel());
2100 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2101 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2103 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2104 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2106 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2107 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2109 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2110 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2112 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2113 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2116 // = * init occ view * =
2117 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2119 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2120 currentOccGView->getViewWindow()->installEventFilter(this);
2125 // = * init vtk view * =
2126 if (currentDocGView != NULL)
2128 if (currentDocGView->getViewWindow() != NULL)
2129 dgview->setViewWindow(currentDocGView->getViewWindow());
2132 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2133 dgview->getViewWindow()->installEventFilter(this);
2139 switchOnGraphicView(dgview);
2141 if (currentDocGView != NULL)
2143 lastVtkDocGView = currentDocGView;
2144 lastOccPrs = getOccPrs(currentDocGView);
2148 lastVtkDocGView = dgview;
2149 lastOccPrs = getOccPrs(dgview);
2152 currentDocGView = dgview;
2154 currentDocGView->getDocumentModel()->refresh();
2155 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2158 setAllMenusEnabled(true);
2161 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2163 if (currentDocGView == NULL) return NULL;
2164 return currentDocGView->getDocumentModel();
2168 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2170 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2171 if (anApp == NULL) return UNKNOWN;
2172 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2173 if (activeVm == NULL) return UNKNOWN;
2175 QString vmType = activeVm->getType();
2176 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2178 else if ( vmType == OCCViewer_Viewer::Type() )
2184 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2186 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2190 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2193 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2195 // Create Document from HEXABLOCK ENGINE
2196 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2197 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2199 // looking doc impl ( c++ )
2200 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2201 // ^Hexa6 ASSERT( dServant );
2202 // ^Hexa6 if ( dServant)
2203 // ^Hexa6 doc = dServant->GetImpl();
2205 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2206 QString docEntry = addDocInStudy (doc);
2208 // looking for docEntry
2209 /* ****************************************************************
2210 if ( !CORBA::is_nil(docIn) ){
2211 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2212 QString docIOR = anIOR.in();
2213 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2214 if ( !docIOR.isEmpty() ) {
2215 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2217 docEntry = SO->GetID().c_str();
2220 **************************************************************** */
2221 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2223 return make_pair (docEntry, doc);
2227 void HEXABLOCKGUI::newDocument()
2229 DEBTRACE("HEXABLOCKGUI::newDocument");
2232 QMainWindow *aParent = application()->desktop();
2233 QWidget *central = aParent->centralWidget();
2235 central->setFocus();
2237 DEBTRACE("No Central Widget");
2240 if (currentOccGView == NULL)
2242 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2243 application()->desktop());
2244 currentOccGView->getViewWindow()->installEventFilter(this);
2246 else if (currentOccGView->getViewWindow() == NULL)
2248 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2249 currentOccGView->getViewWindow()->installEventFilter(this);
2253 // Create Document from HEXABLOCK ENGINE
2254 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2256 VtkDocumentGraphicView* newGraphicView = NULL;
2257 //One document at a time
2258 if (currentDocGView != NULL)
2260 if (currentDocGView->getViewWindow() == NULL)
2262 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2263 currentDocGView->getViewWindow()->installEventFilter(this);
2266 // Create a new document with the current window
2267 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2268 new DocumentModel( docEntry_Doc.second,
2269 docEntry_Doc.first, this ),
2270 currentDocGView->getViewWindow(),
2271 application()->desktop() );
2275 // Create the new Document Graphic View with a new window
2276 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2277 new DocumentModel( docEntry_Doc.second,
2278 docEntry_Doc.first, this ),
2279 graphicViewsHandler->createVtkWindow(),
2280 application()->desktop() );
2281 newGraphicView->getViewWindow()->installEventFilter(this);
2284 if (newGraphicView == NULL)
2285 //We couldn't create a new document graphic view
2286 //we'd better show a dialog box info to inform the user
2289 docs[docEntry_Doc.first] = newGraphicView;
2290 switchModel(newGraphicView); //select the corresponding document in the browser instead
2292 getApp()->updateObjectBrowser();
2297 //Loads the model from the xmlFile in the current graphic view
2298 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2300 DEBTRACE("HEXABLOCKGUI::loadDocument");
2303 QMainWindow *aParent = application()->desktop();
2304 QString selectedFile;
2306 if ( inFile.isNull() ){
2307 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2308 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2309 dialog.setHistory( getQuickDirList() );
2311 //use the last path as default
2312 if (!(loadDocLastPath->absolutePath()).isEmpty())
2313 dialog.setDirectory(*loadDocLastPath);
2316 QStringList selectedFiles = dialog.selectedFiles();
2317 if (!selectedFiles.isEmpty())
2318 selectedFile = selectedFiles.first();
2320 //remember the selected path
2321 *loadDocLastPath = dialog.directory();
2324 selectedFile = inFile;
2326 if (selectedFile.isEmpty())
2329 //we create a new document if necessary
2330 if (currentDocGView == NULL)
2331 //Need a new document
2333 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2335 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2336 currentDocGView->getViewWindow()->installEventFilter(this);
2339 if (!currentDocGView->isEmpty())
2340 //we can only have one document for a graphic view
2343 //we load the selected file in the current graphic view
2344 currentDocGView->loadDocument(selectedFile);
2345 DocumentModel* currentModel = getCurrentModel();
2346 renameObject( currentModel->documentEntry(), currentModel->getName() );
2351 void HEXABLOCKGUI::saveDocument()
2353 QMainWindow *aParent = application()->desktop();
2355 QString aDocName = "document", aFilename;
2357 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2358 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2360 //use the last selected directory as default path for file selection
2361 aFilename = saveDocLastPath->absolutePath();
2362 if (!aFilename.isEmpty())
2363 aFilename += QString("/") + aDocName;
2365 //show the dialog for file selection
2366 aFilename = SUIT_FileDlg::getFileName( aParent,
2369 tr( "Save HexaBlock Document" ),
2372 //save the document in the selected file
2373 if ( !aFilename.isEmpty() ) {
2374 getCurrentVtkGraphicView()->saveDocument( aFilename );
2376 //Remember the path for next save
2377 QFileInfo fileInfo(aFilename);
2378 *saveDocLastPath = fileInfo.dir();
2384 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2386 _patternDataTreeView->openPersistentEditor( topLeft );
2389 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2391 if (diag == NULL || _dwInputPanel == NULL ||
2392 getCurrentVtkGraphicView() == NULL) return;
2394 //mark this dialog as used by the current model
2395 currentModelDialogs.insert(diag);
2397 //close the current dialog box info
2398 // if (_treeViewDelegate != NULL)
2399 // _treeViewDelegate->closeDialog();
2401 // if (_dwInputPanel->widget())
2402 // _dwInputPanel->widget()->close();
2404 //Temporary for debugging EdgeAssoc Faked InfoDialog
2405 if (diag == _edgeAssocDiag)
2406 diag->debugEdgeAssoc = true;
2408 diag->debugEdgeAssoc = false;
2410 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2411 diag == _quadAssocDiag || diag == _addShapeDiag)
2412 assocInProgress = true;
2414 assocInProgress = false;
2416 //show the dialog box in the dockwidget
2417 diag->resetSizeAndShow(_dwInputPanel);
2419 //clear the current selections
2420 selectionMgr()->clearSelected();
2422 currentDialog = diag;
2425 if (currentDocGView != NULL)
2426 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2429 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2431 if (vertex == NULL || _dwInputPanel == NULL)
2434 if (_vertexInfoDialog == NULL)
2435 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2437 _vertexInfoDialog->setValue(vertex);
2438 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2439 currentDialog = _vertexInfoDialog;
2442 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2444 if (edge == NULL || _dwInputPanel == NULL)
2447 if (_edgeInfoDialog == NULL)
2448 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2450 _edgeInfoDialog->setValue(edge);
2451 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2452 currentDialog = _edgeInfoDialog;
2455 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2457 if (quad == NULL || _dwInputPanel == NULL)
2460 if (_quadInfoDialog == NULL)
2461 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2463 _quadInfoDialog->setValue(quad);
2464 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2465 currentDialog = _quadInfoDialog;
2468 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2470 if (hexa == NULL || _dwInputPanel == NULL)
2473 if (_hexaInfoDialog == NULL)
2474 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2476 _hexaInfoDialog->setValue(hexa);
2477 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2478 currentDialog = _hexaInfoDialog;
2481 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2483 if (vector == NULL || _dwInputPanel == NULL)
2486 if (_vectorInfoDialog == NULL)
2487 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2489 _vectorInfoDialog->setValue(vector);
2490 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2491 currentDialog = _vectorInfoDialog;
2494 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2496 if (group == NULL || _dwInputPanel == NULL)
2499 if (_groupInfoDialog == NULL)
2500 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2502 _groupInfoDialog->setValue(group);
2503 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2504 currentDialog = _groupInfoDialog;
2507 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2509 if (law == NULL || _dwInputPanel == NULL)
2512 if (_lawInfoDialog == NULL)
2513 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2515 _lawInfoDialog->setValue(law);
2516 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2517 currentDialog = _lawInfoDialog;
2520 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2522 if (propagation == NULL || _dwInputPanel == NULL)
2525 if (_propagationInfoDialog == NULL)
2526 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2528 _propagationInfoDialog->setValue(propagation);
2529 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2530 currentDialog = _propagationInfoDialog;
2533 void HEXABLOCKGUI::addVertex()
2535 if ( !_vertexDiag ){
2536 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2538 _showDialogBox( _vertexDiag );
2541 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2542 if (_vertexDiag != NULL && doc != NULL)
2543 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2546 void HEXABLOCKGUI::addEdge()
2549 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2551 _showDialogBox( _edgeDiag );
2554 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2555 if (_edgeDiag != NULL && doc != NULL)
2556 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2559 void HEXABLOCKGUI::addQuad()
2562 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2565 _showDialogBox( _quadDiag );
2568 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2569 if (_quadDiag != NULL && doc != NULL)
2570 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2573 void HEXABLOCKGUI::addHexa()
2576 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2578 _showDialogBox( _hexaDiag );
2581 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2582 if (_hexaDiag != NULL && doc != NULL)
2583 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2586 void HEXABLOCKGUI::addVector()
2588 if ( !_vectorDiag ){
2589 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2591 _showDialogBox( _vectorDiag );
2594 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2595 if (_vectorDiag != NULL && doc != NULL)
2596 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2599 //void HEXABLOCKGUI::addCylinder()
2601 // if ( !_cylinderDiag ){
2602 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2604 // _showDialogBox( _cylinderDiag );
2606 // //set default name
2607 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2608 // if (_cylinderDiag != NULL && doc != NULL)
2609 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2613 //void HEXABLOCKGUI::addPipe()
2615 // if ( !_pipeDiag){
2616 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2618 // _showDialogBox( _pipeDiag );
2620 // //set default name
2621 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2622 // if (_pipeDiag != NULL && doc != NULL)
2623 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2627 void HEXABLOCKGUI::makeGrid()
2629 if ( !_makeGridDiag ){
2630 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2632 _showDialogBox( _makeGridDiag );
2636 void HEXABLOCKGUI::makeCylinder()
2638 if ( !_makeCylinderDiag ){
2639 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2641 _showDialogBox( _makeCylinderDiag );
2644 void HEXABLOCKGUI::makePipe()
2646 if ( !_makePipeDiag ){
2647 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2649 _showDialogBox( _makePipeDiag );
2652 void HEXABLOCKGUI::makeCylinders()
2654 if ( !_makeCylindersDiag ){
2655 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2657 _showDialogBox( _makeCylindersDiag );
2660 void HEXABLOCKGUI::makePipes()
2662 if ( !_makePipesDiag ){
2663 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2665 _showDialogBox( _makePipesDiag );
2669 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2671 if ( !_makeHemiSphereDiag ){
2672 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2674 _showDialogBox( _makeHemiSphereDiag );
2678 void HEXABLOCKGUI::removeHexa()
2680 if ( !_removeHexaDiag ){
2681 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2683 _showDialogBox( _removeHexaDiag );
2687 void HEXABLOCKGUI::prismQuad()
2689 if ( !_prismQuadDiag ){
2690 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2692 _showDialogBox( _prismQuadDiag );
2696 void HEXABLOCKGUI::joinQuad()
2698 if ( !_joinQuadDiag ){
2699 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2701 _showDialogBox( _joinQuadDiag );
2704 void HEXABLOCKGUI::merge()
2707 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2709 _showDialogBox( _mergeDiag );
2712 void HEXABLOCKGUI::disconnectElts()
2714 if ( !_disconnectDiag ){
2715 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2717 _showDialogBox( _disconnectDiag );
2720 void HEXABLOCKGUI::cutEdge()
2722 if ( !_cutEdgeDiag ){
2723 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2725 _showDialogBox( _cutEdgeDiag );
2728 void HEXABLOCKGUI::makeTransformation()
2730 if ( !_makeTransformationDiag ){
2731 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2733 _showDialogBox( _makeTransformationDiag );
2737 void HEXABLOCKGUI::makeSymmetry()
2739 if ( !_makeSymmetryDiag ){
2740 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2742 _showDialogBox( _makeSymmetryDiag );
2746 void HEXABLOCKGUI::performTransformation()
2748 if ( !_performTransformationDiag ){
2749 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2751 _showDialogBox( _performTransformationDiag );
2755 void HEXABLOCKGUI::performSymmetry()
2757 if ( !_performSymmetryDiag ){
2758 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2760 _showDialogBox( _performSymmetryDiag );
2764 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2766 if ( !_replaceHexaDiag ){
2767 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2769 _showDialogBox( _replaceHexaDiag );
2773 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2775 if ( !_quadRevolutionDiag ){
2776 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2778 _showDialogBox( _quadRevolutionDiag );
2782 void HEXABLOCKGUI::assocVertex()
2784 if (!_dwInputPanel) return;
2785 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2786 if ( !_vertexAssocDiag )
2787 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2788 _showDialogBox( _vertexAssocDiag );
2792 void HEXABLOCKGUI::assocEdge()
2794 if ( !_edgeAssocDiag )
2795 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2796 _showDialogBox( _edgeAssocDiag );
2799 void HEXABLOCKGUI::assocQuad()
2801 if ( !_quadAssocDiag )
2802 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2803 _showDialogBox( _quadAssocDiag );
2807 void HEXABLOCKGUI::addGroup()
2810 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2812 _showDialogBox( _groupDiag );
2813 if (_groupDiag != NULL && getCurrentModel() != NULL)
2815 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2816 if (doc == NULL) return;
2817 char defaultName[16];
2818 sprintf (defaultName, "g%04d", doc->countGroup());
2819 _groupDiag->name_le->setText(defaultName);
2823 void HEXABLOCKGUI::removeGroup()
2825 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2826 if (currentDGView == NULL) return;
2828 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2829 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2830 int nbGroupsRemoved = 0;
2833 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2834 tr( "No group selected!" ) );
2838 foreach( QModelIndex selected, l ){
2839 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2840 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2841 Q_ASSERT(selected.isValid());
2843 //Confirm the deletion of the group
2844 if (SUIT_MessageBox::question(
2847 tr("Remove group : %1 ?").arg(selected.data().toString()),
2848 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2849 SUIT_MessageBox::Cancel
2850 ) == SUIT_MessageBox::Cancel) return;
2852 bool removed = getCurrentModel()->removeGroup( selected );
2854 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2855 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2861 if (!nbGroupsRemoved)
2862 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2863 tr( "No group selected!" ) );
2866 void HEXABLOCKGUI::addLaw()
2869 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2871 _showDialogBox( _lawDiag );
2872 if (_lawDiag != NULL && getCurrentModel() != NULL)
2874 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2875 if (doc == NULL) return;
2876 char defaultName[16];
2877 sprintf (defaultName, "l%04d", doc->countLaw());
2878 _lawDiag->name_le->setText(defaultName);
2882 void HEXABLOCKGUI::removeLaw()
2884 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2885 if (currentDGView == NULL) return;
2887 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2888 int nbLawsRemoved = 0;
2891 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2892 tr( "No law selected!" ) );
2896 foreach( QModelIndex selected, l ){
2897 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2898 selected = currentDGView->getMeshModel()->mapToSource( selected );
2899 Q_ASSERT(selected.isValid());
2901 //Confirm the deletion of the law
2902 if (SUIT_MessageBox::question(
2905 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2906 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2907 SUIT_MessageBox::Cancel
2908 ) == SUIT_MessageBox::Cancel) return;
2910 bool removed = getCurrentModel()->removeLaw(selected);
2912 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2913 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2920 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2921 tr( "No law selected!" ) );
2926 void HEXABLOCKGUI::setPropagation()
2928 if ( !_propagationDiag )
2929 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2931 _showDialogBox( _propagationDiag );
2934 // Dialog box to compute a mesh from a document
2935 // --------------------------------------------
2936 void HEXABLOCKGUI::computeMesh()
2938 if ( !_computeMeshDiag )
2939 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2941 _showDialogBox( _computeMeshDiag );
2944 void HEXABLOCKGUI::clearAssociations()
2946 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2947 if (currentDGView == NULL) return;
2949 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2950 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2951 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2953 getCurrentModel()->clearEltAssociations(iModel);
2955 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2958 void HEXABLOCKGUI::showModelInfo()
2960 //create the info dialog if not yet
2961 if (_modelInfoDiag == NULL)
2962 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2964 //show the model informations dialog
2965 _showDialogBox( _modelInfoDiag );
2968 void HEXABLOCKGUI::addShape()
2970 //create the info dialog if not yet
2971 if (_addShapeDiag == NULL)
2972 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2974 //show the model informations dialog
2975 _showDialogBox( _addShapeDiag );
2978 void HEXABLOCKGUI::clearAllAssociations()
2980 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2981 if (currentDGView == NULL) return;
2983 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2984 if (!currentIndex.isValid()) return;
2985 QVariant currentAssocVariant;
2986 QString currentAssocEntry;
2988 //Confirm the deletion of the associations
2989 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2990 if ( !treeVariant.isValid() ) return;
2991 int eltType = treeVariant.toInt();
2992 QString typeStr = "";
2993 HEXA_NS::EnumElt hexaType;
2994 if (eltType == VERTEX_DIR_TREE)
2996 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2997 hexaType = HEXA_NS::EL_VERTEX;
2999 else if (eltType == EDGE_DIR_TREE)
3001 typeStr = tr("TREE_ITEM_EDGE").toUpper();
3002 hexaType = HEXA_NS::EL_EDGE;
3004 else if (eltType == QUAD_DIR_TREE)
3006 typeStr = tr("TREE_ITEM_QUAD").toUpper();
3007 hexaType = HEXA_NS::EL_QUAD;
3010 if (SUIT_MessageBox::question(
3012 tr("CLEAR_ASSOCIATIONS"),
3013 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
3014 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
3015 SUIT_MessageBox::Cancel
3016 ) == SUIT_MessageBox::Cancel) return;
3019 DocumentModel* docModel = getCurrentModel();
3020 if (docModel == NULL) return;
3021 docModel->clearAssociation(hexaType);
3024 void HEXABLOCKGUI::showAssociations()
3026 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3027 if (currentDGView == NULL) return;
3029 QModelIndexList elts;
3030 int currentChildIndex = 0;
3031 QVariant currentAssocVariant;
3032 QString currentAssocEntry;
3033 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
3034 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
3036 while( currentChild.isValid() ) {
3038 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3039 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3040 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3041 elts << currentChild;
3043 currentChild = currentChild.sibling(currentChildIndex++, 0);
3045 currentDocGView->highlight(elts);
3046 currentOccGView->highlight(elts, false);
3050 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3052 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3054 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3059 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3061 if ( event->type() == QEvent::Enter )
3062 { // *** ENTER EVENT
3064 if (currentDialog == NULL || !currentDialog->isVisible())
3065 return QObject::eventFilter(obj, event);
3067 // ** The window acquire the focus when the cursor enter
3069 //OCC - window enter
3070 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3071 if ( occWindow != NULL)
3072 currentDialog->onWindowActivated(occWindow->getViewManager());
3074 //VTK - window enter
3076 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3077 if ( vtkWindow != NULL)
3078 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3082 //standard event processing
3083 return QObject::eventFilter(obj, event);
3086 QStringList HEXABLOCKGUI::getQuickDirList()
3088 QStringList dirList;
3089 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3091 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3097 // --- Export the module
3101 HEXABLOCK_EXPORT CAM_Module* createModule()
3103 return new HEXABLOCKGUI();
3106 HEXABLOCK_EXPORT char* getModuleVersion()
3108 return (char*)HEXABLOCK_VERSION_STR;
3114 // ******************** TESTS ***************************************************
3116 void HEXABLOCKGUI::testDocument()
3120 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3121 // QStandardItem *myItem = new QStandardItem("MyItem");
3122 // parentItem->appendRow(myItem);
3124 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3125 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3126 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3127 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3128 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3129 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3130 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3131 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3134 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3135 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3136 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3137 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3138 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3139 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3141 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3142 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3143 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3144 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3149 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3150 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3151 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3152 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3160 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3161 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3163 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3164 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3168 // newMesh( "toto", 3, "FactoryServer");
3172 void HEXABLOCKGUI::test_make_cart_grid()
3174 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3175 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3176 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3177 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3178 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3179 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3181 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3182 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3189 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3190 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3191 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3192 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3193 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3194 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3199 void HEXABLOCKGUI::test_make_elmts_transform()
3206 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3207 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3210 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3211 // orig.setScalar(2);
3213 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3214 // getCurrentModel()->saveVtk(file_name)
3216 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3217 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3219 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3220 // getCurrentModel()->saveVtk(file_name)
3222 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3225 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3226 // getCurrentModel()->saveVtk(file_name);
3229 // print "...test make elements by transforming elements OK"
3231 // =============================================================== addDocInSudy
3232 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3236 if (document == NULL)
3239 QString docName = document->getName ();
3241 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3242 if (app_study == NULL)
3245 _PTR(Study) study = app_study->studyDS();
3246 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3247 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3248 QString entry = app_study->centry("HEXABLOCK");
3249 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3250 if (aFatherSO->_is_nil())
3253 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3256 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3257 docEntry = aSO->GetID(); //the entry of the published object
3262 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3264 void HEXABLOCKGUI::test()
3266 DEBTRACE("HEXABLOCKGUI::test");
3267 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3268 if (currentDGView == NULL) return;
3269 currentDGView->update();
3273 void HEXABLOCKGUI::test_association()
3275 DEBTRACE("HEXABLOCKGUI::test_association");
3278 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3280 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3281 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3282 DocumentModel::GeomObj q0AssocA, q0AssocB;
3284 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3285 QList<DocumentModel::GeomObj> e1Assocs_test;
3286 DocumentModel::GeomObj q0Assoc_test;
3288 v0 = getCurrentModel()->addVertex(0, 0, 0);
3289 v1 = getCurrentModel()->addVertex(1, 0, 0);
3290 v2 = getCurrentModel()->addVertex(1, 1, 0);
3291 v3 = getCurrentModel()->addVertex(0, 1, 0);
3292 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3293 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3294 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3297 // >>> face3.GetEntry()'0:1:4'
3298 // >>> e1.GetEntry()'0:1:8'
3299 // >>> e2.GetEntry()'0:1:9'
3300 // >>> e3.GetEntry()'0:1:10'
3301 // >>> e4.GetEntry()'0:1:11'
3302 // >>> v1.GetEntry()'0:1:12'
3303 // >>> v2.GetEntry()'0:1:13'
3304 // >>> v3.GetEntry()'0:1:14'
3305 // >>> v4.GetEntry()'0:1:15'
3308 // v0Assoc.name = "geomV0";
3309 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3310 // v0Assoc.brep = "brepV0";
3311 // v1Assoc.name = "geomV1";
3312 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3313 // v1Assoc.brep = "brepV1";
3314 // v2Assoc.name = "geomV2";
3315 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3316 // v2Assoc.brep = "brepV2";
3317 // v3Assoc.name = "geomV3";
3318 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3319 // v3Assoc.brep = "brepV3";
3323 // e0AssocA.name = "geomE0a";
3324 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3325 // e0AssocA.brep = "brepE0a";
3326 // e0AssocA.start = 0.10;
3327 // e0AssocA.end = 0.95;
3331 // e1AssocA.name = "geomE1a";
3332 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3333 // e1AssocA.brep = "brepE1a";
3334 // e1AssocA.start = 0.12;
3335 // e1AssocA.end = 0.89;
3336 // e1AssocB.name = "geomE1b";
3337 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3338 // e1AssocB.brep = "brepE1b";
3339 // e1AssocB.start = 0.20;
3340 // e1AssocB.end = 0.80;
3341 // e1AssocC.name = "geomE1c";
3342 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3343 // e1AssocC.brep = "brepE1c";
3344 // e1AssocC.start = 0.16;
3345 // e1AssocC.end = 0.96;
3347 // q0AssocA.name = "geomQuad";
3348 // q0AssocA.entry = "0:1:1:1:3";
3349 // q0AssocA.brep = "brepq0";
3351 // q0AssocB.name = "geomQuad";
3352 // q0AssocB.entry = "0:1:1:1:4";
3353 // q0AssocB.brep = "brepq0";
3355 // getCurrentModel()->addAssociation( v0, v0Assoc );
3356 // getCurrentModel()->addAssociation( v1, v1Assoc );
3357 // getCurrentModel()->addAssociation( v2, v2Assoc );
3358 // getCurrentModel()->addAssociation( v3, v3Assoc );
3361 // getCurrentModel()->addAssociation( e0, e0AssocA );
3363 // getCurrentModel()->addAssociation( e1, e1AssocA );
3364 // getCurrentModel()->addAssociation( e1, e1AssocB );
3365 // getCurrentModel()->addAssociation( e1, e1AssocC );
3367 // getCurrentModel()->addAssociation( q0, q0AssocA );
3368 // getCurrentModel()->addAssociation( q0, q0AssocB );
3374 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3375 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3376 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3377 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3378 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3379 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3380 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3381 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3382 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3383 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3384 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3385 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3388 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3389 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3390 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3391 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3392 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3393 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3394 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3395 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3396 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3397 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3398 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3399 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3400 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3402 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3403 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3404 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3407 DEBTRACE("HEXABLOCKGUI::test_association fin");