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
110 //#include <V3d_PerspectiveView.hxx>
111 #include <V3d_AmbientLight.hxx>
112 #include <V3d_DirectionalLight.hxx>
113 #include <Xw_Window.hxx>
114 #include <V3d_TypeOfShadingModel.hxx>
115 #include <TCollection_ExtendedString.hxx>
117 #include <BRepAlgoAPI_Fuse.hxx>
119 #include <AIS_ListIteratorOfListOfInteractive.hxx>
121 #include <utilities.h>
123 #define DW_MINIMUM_WIDTH 50
124 #define DWINPUT_MINIMUM_HEIGHT 50
125 #define DWINPUT_MINIMUM_WIDTH 50//255
128 using namespace HEXABLOCK::GUI;
130 int HEXABLOCKGUI::_oldStudyId = -1;
132 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
134 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
135 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
136 bool HEXABLOCKGUI::assocInProgress = false;
137 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
139 HEXABLOCKGUI::HEXABLOCKGUI() :
140 SalomeApp_Module( "HEXABLOCK" ),
141 // LightApp_Module( "HEXABLOCK" ),
149 _patternDataTreeView(0),
150 // _patternBuilderTreeView(0),
151 _patternGeomTreeView(0),
154 // _treeViewDelegate(0),
156 moduleActivatedOnce(false),
166 _makeCylinderDiag(0),
168 _makeCylindersDiag(0),
176 _makeTransformationDiag(0),
177 _makeSymmetryDiag(0),
178 _performTransformationDiag(0),
179 _performSymmetryDiag(0),
188 _quadRevolutionDiag(0),
189 _makeHemiSphereDiag(0),
190 _modelInfoDiag(NULL),
192 _vertexInfoDialog(NULL),
193 _edgeInfoDialog(NULL),
194 _quadInfoDialog(NULL),
195 _hexaInfoDialog(NULL),
196 _vectorInfoDialog(NULL),
197 _groupInfoDialog(NULL),
198 _lawInfoDialog(NULL),
199 _propagationInfoDialog(NULL),
202 lastVtkDocGView(NULL)
204 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
206 graphicViewsHandler = new GraphicViewsHandler();
207 loadDocLastPath = new QDir();
208 saveDocLastPath = new QDir();
209 hexa_root = HEXA_NS::Hex::getInstance ();
212 HEXABLOCKGUI::~HEXABLOCKGUI()
217 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
219 SUIT_Application* app = SUIT_Session::session()->activeApplication();
221 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
227 // Gets an reference to the module's engine
228 /****************************************************
229 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
231 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
232 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
233 ASSERT(!CORBA::is_nil(clr));
236 **************************************************** */
238 void HEXABLOCKGUI::initialize( CAM_Application* app )
240 MESSAGE("HEXABLOCKGUI::initialize");
241 DEBTRACE("HEXABLOCKGUI::initialize");
242 SalomeApp_Module::initialize( app );
244 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
246 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
248 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
249 setResource(aResourceMgr);
251 createAndFillDockWidget();
258 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
260 DEBTRACE("HEXABLOCKGUI::viewManagers");
261 // list.append( QxScene_Viewer::Type() );
262 // list.append( OCCViewer_Viewer::Type() );
263 // list.append( SVTK_Viewer::Type() );
267 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
269 DEBTRACE("HEXABLOCKGUI::activateModule");
271 /*HexaBlock can be launched in only one application*/
272 if (myApplication == NULL)
273 //remember the first application
274 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
276 //application verification: if it's not the one known by HexaBlock,
277 //leave without activating
278 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
279 if (myApplication != currentApplication) return false;
281 bool bOk = SalomeApp_Module::activateModule( theStudy );
282 if ( !bOk ) return false;
284 showDockWidgets(true);
286 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
287 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
288 if ( getApp()->objectBrowser() ) {
289 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
290 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;
1025 if ( getApp()->objectBrowser() )
1026 wid = getApp()->objectBrowser()->treeView();
1027 while ( wid && !_dwObjectBrowser ) {
1028 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( wid );
1029 wid = wid->parentWidget();
1032 if ( _dwObjectBrowser ) {
1033 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1034 _dwObjectBrowser->setWindowTitle("Study");
1037 // dock widget position
1038 if ( _dwObjectBrowser ) {
1039 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1041 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1043 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1044 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1045 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1047 if ( _dwObjectBrowser ) {
1048 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1050 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1051 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1053 #if QT_VERSION >= 0x040500
1054 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1057 // popup menu on data tree view
1058 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1059 connect(_patternDataTreeView,
1060 SIGNAL(customContextMenuRequested(const QPoint &)),
1062 SLOT(treeContextMenu(const QPoint &)),
1063 Qt::UniqueConnection );
1066 void HEXABLOCKGUI::createActions()
1068 QMainWindow *aParent = application()->desktop();
1069 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1072 _newAct = createAction(_menuId++,
1073 tr("Create a new document"),
1074 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1076 tr("Create a new document"),
1077 0, aParent, false, this, SLOT(newDocument()));
1078 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1080 _importAct = createAction(_menuId++,
1081 tr("Load a document"),
1082 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1083 tr("Load Document"),
1084 tr("Load a document"),
1085 0, aParent, false, this, SLOT(loadDocument()));
1086 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1088 _saveAct = createAction(_menuId++,
1089 tr("Save the document"),
1090 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1091 tr("Save Document"),
1092 tr("Save the document"),
1093 0, aParent, false, this, SLOT(saveDocument()));
1095 // Pattern Data creation
1096 _addVertex = createAction(_menuId++,
1097 tr("Create a vertex"),
1098 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1100 tr("Create a new vertex"),
1101 0, aParent, false, this, SLOT(addVertex()));
1103 _addEdge = createAction(_menuId++,
1104 tr("Create an edge"),
1105 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1107 tr("Create a new edge"),
1108 0, aParent, false, this, SLOT(addEdge()));
1110 _addQuad = createAction(_menuId++,
1111 tr("Create a quadrangle"),
1112 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1113 tr("Add Quadrangle"),
1114 tr("Create a new quadrangle"),
1115 0, aParent, false, this, SLOT(addQuad()));
1117 _addHexa = createAction(_menuId++,
1118 tr("Create an hexahedron"),
1119 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1120 tr("Add Hexahedron"),
1121 tr("Create a new hexahedron"),
1122 0, aParent, false, this, SLOT(addHexa()));
1124 // Builder Data creation
1125 _addVector = createAction(_menuId++,
1126 tr("Create a vector"),
1127 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1129 tr("Create a new vector"),
1130 0, aParent, false, this, SLOT(addVector()));
1132 // _addCylinder = createAction(_menuId++,
1133 // tr("Create a cylinder"),
1134 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1135 // tr("Add Cylinder"),
1136 // tr("Create a new cylinder"),
1137 // 0, aParent, false, this, SLOT(addCylinder()));
1139 // _addPipe = createAction(_menuId++,
1140 // tr("Create a pipe"),
1141 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1143 // tr("Create a new pipe"),
1144 // 0, aParent, false, this, SLOT(addPipe()));
1146 _makeGrid = createAction(_menuId++,
1148 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1151 0, aParent, false, this, SLOT(makeGrid()));
1153 _makeCylinder = createAction(_menuId++,
1154 tr("Make a cylinder"),
1155 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1156 tr("Make Cylinder"),
1157 tr("Make a cylinder"),
1158 0, aParent, false, this, SLOT(makeCylinder()));
1160 _makePipe = createAction(_menuId++,
1162 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1165 0, aParent, false, this, SLOT(makePipe()));
1167 _makeCylinders = createAction(_menuId++,
1168 tr("Make cylinders"),
1169 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1170 tr("Make Cylinders"),
1171 tr("Make cylinders"),
1172 0, aParent, false, this, SLOT(makeCylinders()));
1174 _makePipes = createAction(_menuId++,
1176 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1179 0, aParent, false, this, SLOT(makePipes()));
1181 _makeHemiSphere = createAction(_menuId++,
1182 tr("Make an hemisphere"),
1183 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1184 tr("Make Hemisphere"),
1185 tr("Make an hemisphere"),
1186 0, aParent, false, this, SLOT(makeHemiSphere()));
1188 // Pattern Data edition
1189 _removeHexa = createAction(_menuId++,
1190 tr("Remove hexahedra"),
1191 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1192 tr("Remove Hexahedra"),
1193 tr("Remove hexahedra"),
1194 0, aParent, false, this, SLOT(removeHexa()));
1196 _prismQuad = createAction(_menuId++,
1197 tr("Prism quadrangles"),
1198 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1199 tr("Prism Quadrangles"),
1200 tr("Prism quadrangles"),
1201 0, aParent, false, this, SLOT(prismQuad()));
1203 _joinQuad = createAction(_menuId++,
1204 tr("Join quadrangles"),
1205 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1206 tr("Join Quadrangles"),
1207 tr("Join quadrangles with hexahedra"),
1208 0, aParent, false, this, SLOT(joinQuad()));
1210 _merge = createAction(_menuId++,
1212 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1215 0, aParent, false, this, SLOT(merge()));
1217 _disconnect = createAction(_menuId++,
1219 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1221 tr("Disconnect edges, vertexes or quadrangles"),
1222 0, aParent, false, this, SLOT(disconnectElts()));
1224 _cutEdge = createAction(_menuId++,
1226 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1229 0, aParent, false, this, SLOT(cutEdge()));
1231 _makeTransformation = createAction(_menuId++,
1232 tr("Make transformation"),
1233 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1234 tr("Make Transformation"),
1235 tr("Make transformation"),
1236 0, aParent, false, this, SLOT(makeTransformation()));
1238 _makeSymmetry = createAction(_menuId++,
1239 tr("Make symmetry"),
1240 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1241 tr("Make Symmetry"),
1242 tr("Make symmetry"),
1243 0, aParent, false, this, SLOT(makeSymmetry()));
1245 _performTransformation = createAction(_menuId++,
1246 tr("Perform transformation"),
1247 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1248 tr("Perform Transformation"),
1249 tr("Perform transformation"),
1250 0, aParent, false, this, SLOT(performTransformation()));
1252 _performSymmetry = createAction(_menuId++,
1253 tr("Perform symmetry"),
1254 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1255 tr("Perform Symmetry"),
1256 tr("Perform symmetry"),
1257 0, aParent, false, this, SLOT(performSymmetry()));
1259 _replaceHexa = createAction(_menuId++,
1260 tr("Replace hexahedron"),
1261 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1262 tr("Replace Hexahedron"),
1263 tr("Replace hexahedron"),
1264 0, aParent, false, this, SLOT(replaceHexa()));
1266 _quadRevolution = createAction(_menuId++,
1267 tr("Quad revolution"),
1268 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1269 tr("Quad Revolution"),
1270 tr("Quad revolution"),
1271 0, aParent, false, this, SLOT(quadRevolution()));
1274 _assocVertex = createAction(_menuId++,
1275 tr("Make vertex association"),
1276 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1277 tr("Make Vertex association"),
1278 tr("Make vertex association"),
1279 0, aParent, false, this, SLOT(assocVertex()));
1281 _assocEdge = createAction(_menuId++,
1282 tr("Make edge association"),
1283 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1284 tr("Make Edge Association"),
1285 tr("Make edge association"),
1286 0, aParent, false, this, SLOT(assocEdge()));
1288 _assocQuad = createAction(_menuId++,
1289 tr("Make quad association"),
1290 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1291 tr("Make Quad Association"),
1292 tr("Make quad association"),
1293 0, aParent, false, this, SLOT(assocQuad()));
1296 _addGroup = createAction(_menuId++,
1298 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1301 0, aParent, false, this, SLOT(addGroup()));
1303 _removeGroup = createAction(_menuId++,
1304 tr("Remove a group"),
1305 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1307 tr("Remove a group"),
1308 0, aParent, false, this, SLOT(removeGroup()));
1311 _addLaw = createAction(_menuId++,
1313 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1316 0, aParent, false, this, SLOT(addLaw()));
1318 _removeLaw = createAction(_menuId++,
1320 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1323 0, aParent, false, this, SLOT(removeLaw()));
1325 _setPropagation = createAction(_menuId++,
1326 tr("Set propagation"),
1327 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1328 tr("Set Propagation"),
1329 tr("Set propagation"),
1330 0, aParent, false, this, SLOT(setPropagation()));
1332 _computeMesh = createAction(_menuId++,
1334 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1337 0, aParent, false, this, SLOT(computeMesh()));
1339 _showModelInfoAct = createAction(_menuId++,
1340 tr("Show Model Info"),
1341 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1344 0, aParent, false, this, SLOT(showModelInfo()));
1346 _addShapeAct = createAction(_menuId++,
1348 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1351 0, aParent, false, this, SLOT(addShape()));
1353 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1354 // QAction* createAction(const int id,
1355 // const QString& toolTip,
1356 // const QIcon& icon,
1357 // const QString& menu,
1358 // const QString& status,
1359 // const int shortCut,
1360 // QObject* parent =0,
1361 // bool checkable = false,
1362 // QObject* receiver =0,
1363 // const char* member =0);
1365 _sep1 = separator();
1366 _sep2 = separator();
1367 _sep3 = separator();
1368 _sep4 = separator();
1372 void HEXABLOCKGUI::createMenus()
1374 int aMenuId, subMenuId,aMenuIdMain;
1376 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1378 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1379 createMenu( actionId(_newAct), aMenuId );
1380 createMenu( actionId(_importAct), aMenuId );
1381 createMenu( _saveAct, aMenuId );
1384 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1385 createMenu( _newAct, aMenuDocId );//, 10
1386 createMenu( _importAct, aMenuDocId );
1387 createMenu( _saveAct, aMenuDocId );
1389 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1390 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1391 createMenu( _addVertex, subMenuId );
1392 createMenu( _addEdge, subMenuId );
1393 createMenu( _addQuad, subMenuId );
1394 createMenu( _addHexa, subMenuId );
1395 createMenu( _sep1, subMenuId);
1398 createMenu( _addVector, subMenuId );
1399 // createMenu( _addCylinder, subMenuId );
1400 // createMenu( _addPipe, subMenuId );
1402 createMenu( _sep2, subMenuId);
1404 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1405 createMenu( _makeHemiSphere,subMenuId );
1407 createMenu( _sep3, subMenuId);
1409 createMenu( _makeCylinder, subMenuId );
1410 createMenu( _makePipe, subMenuId );
1411 createMenu( _makeCylinders,subMenuId );
1412 createMenu( _makePipes, subMenuId );
1414 // Pattern Data Edition
1415 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1416 createMenu( _removeHexa, subMenuId );
1417 createMenu( _prismQuad, subMenuId );
1418 createMenu( _joinQuad, subMenuId );
1419 createMenu( _merge, subMenuId );
1420 createMenu( _disconnect, subMenuId );
1421 createMenu( _cutEdge, subMenuId );
1422 createMenu( _makeTransformation, subMenuId );
1423 createMenu( _makeSymmetry, subMenuId );
1424 createMenu( _performTransformation, subMenuId );
1425 createMenu( _performSymmetry, subMenuId );
1426 createMenu( _replaceHexa, subMenuId );
1427 createMenu( _quadRevolution, subMenuId );
1428 createMenu( _sep4, aMenuId );
1429 createMenu( _showModelInfoAct, aMenuId );
1432 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1433 createMenu( _addShapeAct, aMenuId );
1434 createMenu( _assocVertex, aMenuId );
1435 createMenu( _assocEdge, aMenuId );
1436 createMenu( _assocQuad, aMenuId );
1439 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1440 createMenu( _addGroup, aMenuId );
1441 createMenu( _removeGroup, aMenuId ); //CS_TODO
1444 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1445 createMenu( _addLaw, aMenuId );
1446 createMenu( _removeLaw, aMenuId );
1447 createMenu( _setPropagation, aMenuId );
1448 createMenu( _computeMesh, aMenuId );
1450 //show model infomation menu
1451 QString aRule = "$component={'HEXABLOCK'}";
1452 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1453 popupMgr()->setRule( _showModelInfoAct, aRule);
1455 //associate shape to a document menu
1456 popupMgr()->insert( _addShapeAct, -1, -1 );
1457 popupMgr()->setRule( _addShapeAct, aRule );
1459 //-------------------------------------------------
1461 //-------------------------------------------------
1462 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1463 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1464 // QString isNotEmpty("numberOfNodes <> 0");
1465 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1466 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1467 //// aType = aType.arg( mesh_part );
1469 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1470 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1471 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1473 // popupMgr()->insert( separator(), -1, -1 );
1474 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1475 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1476 // // MESSAGE("aClient = " << aClient.toStdString());
1477 // // MESSAGE("aType = " << aType.toStdString());
1478 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1479 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1480 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1481 // // MESSAGE("aRule = " << aRule.toStdString());
1482 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1483 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1485 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1486 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1488 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1489 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1491 // popupMgr()->insert( separator(), -1, -1 );
1495 void HEXABLOCKGUI::createTools()
1499 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1500 createTool( _newAct, aToolId );
1501 createTool( _importAct, aToolId );
1502 createTool( _saveAct, aToolId );
1503 createTool( _showModelInfoAct, aToolId );
1504 // createTool( _testAct, aToolId );
1505 //createTool( separator(), aToolId );
1508 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1509 createTool( _addVertex, aToolId );
1510 createTool( _addEdge, aToolId );
1511 createTool( _addQuad, aToolId );
1512 createTool( _addHexa, aToolId );
1514 createTool( _sep1, aToolId );
1517 createTool( _addVector, aToolId );
1518 // createTool( _addCylinder, aToolId );
1519 // createTool( _addPipe, aToolId );
1521 createTool( _sep2, aToolId );
1523 createTool( _makeGrid, aToolId );
1524 createTool( _makeHemiSphere, aToolId );
1526 createTool( _sep3, aToolId );
1528 createTool( _makeCylinder, aToolId );
1529 createTool( _makePipe, aToolId );
1530 createTool( _makeCylinders,aToolId );
1531 createTool( _makePipes, aToolId );
1533 // Pattern Data Edition
1534 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1535 createTool( _removeHexa, aToolId );
1536 createTool( _prismQuad, aToolId );
1537 createTool( _joinQuad, aToolId );
1538 createTool( _merge, aToolId );
1539 createTool( _disconnect, aToolId );
1540 createTool( _cutEdge, aToolId );
1541 createTool( _makeTransformation, aToolId );
1542 createTool( _makeSymmetry, aToolId );
1543 createTool( _performTransformation, aToolId );
1544 createTool( _performSymmetry, aToolId );
1545 createTool( _replaceHexa, aToolId );
1546 createTool( _quadRevolution, aToolId );
1549 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1550 createTool( _assocVertex, aToolId );
1551 createTool( _assocEdge, aToolId );
1552 createTool( _assocQuad, aToolId );
1553 createTool( _addShapeAct, aToolId );
1556 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1557 createTool( _addGroup, aToolId );
1558 createTool( _removeGroup, aToolId ); //CS_TODO
1561 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1562 createTool( _addLaw, aToolId );
1563 createTool( _removeLaw, aToolId );
1564 createTool( _setPropagation, aToolId );
1565 createTool( _computeMesh, aToolId );
1569 void HEXABLOCKGUI::initialMenus()
1571 showDocumentMenus( true );
1572 showPatternMenus( false );
1573 showAssociationMenus( false );
1574 showGroupsMenus( false );
1575 showMeshMenus( false );
1578 void HEXABLOCKGUI::showAllMenus()
1580 showDocumentMenus( true );
1581 showPatternMenus( true );
1582 showAssociationMenus( true );
1583 showGroupsMenus( true );
1584 showMeshMenus( true );
1587 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1589 enableDocumentMenus( enable );
1590 enablePatternMenus( enable );
1591 enableAssociationMenus( enable );
1592 enableGroupsMenus( enable );
1593 enableMeshMenus( enable );
1595 menusEnabled = enable;
1598 void HEXABLOCKGUI::showDocumentMenus(bool show)
1600 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1602 setMenuShown(_newAct, show);
1603 setToolShown(_newAct, show);
1604 setMenuShown(_importAct, show);
1605 setToolShown(_importAct, show);
1606 setMenuShown(_showModelInfoAct, show);
1607 setToolShown(_showModelInfoAct, show);
1608 setMenuShown(_saveAct, show);
1609 setToolShown(_saveAct, show);
1612 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1614 _newAct->setEnabled(enable);
1615 // setToolShown(_newAct, enable);
1617 _importAct->setEnabled(enable);
1618 // setToolShown(_importAct, enable);
1620 _showModelInfoAct->setEnabled(enable);
1621 // setToolShown(_showModelInfoAct, enable);
1623 _saveAct->setEnabled(enable);
1624 // setToolShown(_saveAct, enable);
1628 void HEXABLOCKGUI::showPatternMenus(bool show)
1630 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1631 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1632 if ( show && !getCurrentModel() ) return;
1634 setMenuShown(_addVertex, show );
1635 setToolShown(_addVertex, show);
1636 setMenuShown(_addEdge, show );
1637 setToolShown(_addEdge, show);
1638 setMenuShown(_addQuad, show );
1639 setToolShown(_addQuad, show);
1640 setMenuShown(_addHexa, show );
1641 setToolShown(_addHexa, show);
1643 setMenuShown(_sep1, show );
1644 setToolShown(_sep1, show);
1646 setMenuShown( _addVector, show );
1647 setToolShown( _addVector, show);
1648 // setMenuShown( _addCylinder, show );
1649 // setToolShown( _addCylinder, show);
1650 // setMenuShown( _addPipe, show );
1651 // setToolShown( _addPipe, show);
1653 setMenuShown(_sep2, show );
1654 setToolShown(_sep2, show);
1656 setMenuShown( _makeGrid, show );
1657 setToolShown( _makeGrid, show);
1658 setMenuShown( _makePipe, show );
1659 setToolShown( _makePipe, show);
1661 setMenuShown(_sep3, show );
1662 setToolShown(_sep3, show);
1664 setMenuShown( _makeCylinder, show );
1665 setToolShown( _makeCylinder, show);
1666 setMenuShown( _makeCylinders, show );
1667 setToolShown( _makeCylinders, show);
1668 setMenuShown( _makePipes, show );
1669 setToolShown( _makePipes, show);
1670 setMenuShown( _makeHemiSphere, show );
1671 setToolShown( _makeHemiSphere, show);
1673 // Pattern Data Edition
1674 setMenuShown( _removeHexa, show );
1675 setToolShown( _removeHexa, show);
1676 setMenuShown( _prismQuad, show );
1677 setToolShown( _prismQuad, show);
1678 setMenuShown( _joinQuad, show );
1679 setToolShown( _joinQuad, show);
1680 setMenuShown( _merge, show );
1681 setToolShown( _merge, show);
1682 setMenuShown( _disconnect, show );
1683 setToolShown( _disconnect, show);
1684 setMenuShown( _cutEdge, show );
1685 setToolShown( _cutEdge, show);
1686 setMenuShown( _makeTransformation, show );
1687 setToolShown( _makeTransformation, show);
1688 setMenuShown( _makeSymmetry, show );
1689 setToolShown( _makeSymmetry, show);
1690 setMenuShown( _performTransformation, show );
1691 setToolShown( _performTransformation, show);
1692 setMenuShown( _performSymmetry, show );
1693 setToolShown( _performSymmetry, show);
1694 setMenuShown( _replaceHexa, show );
1695 setToolShown( _replaceHexa, show);
1696 setMenuShown( _quadRevolution, show );
1697 setToolShown( _quadRevolution, show);
1699 setMenuShown( _sep4, show );
1700 setMenuShown( _showModelInfoAct, show );
1703 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1705 if ( enable && !getCurrentModel() ) return;
1707 _addVertex->setEnabled(enable);
1708 // setToolShown(_addVertex, enable);
1710 _addEdge->setEnabled(enable);
1711 // setToolShown(_addEdge, enable);
1713 _addQuad->setEnabled(enable);
1714 // setToolShown(_addQuad, enable);
1716 _addHexa->setEnabled(enable);
1717 // setToolShown(_addHexa, enable);
1719 // setMenuShown(_sep1, enable );
1720 // setToolShown(_sep1, enable);
1722 _addVector->setEnabled(enable);
1723 // setToolShown( _addVector, enable);
1725 // setMenuShown(_sep2, enable );
1726 // setToolShown(_sep2, enable);
1728 _makeGrid->setEnabled(enable);
1729 // setToolShown( _makeGrid, enable);
1731 _makePipe->setEnabled(enable);
1732 // setToolShown( _makePipe, enable);
1734 // setMenuShown(_sep3, enable );
1735 // setToolShown(_sep3, enable);
1737 _makeCylinder->setEnabled(enable);
1738 // setToolShown( _makeCylinder, enable);
1740 _makeCylinders->setEnabled(enable);
1741 // setToolShown( _makeCylinders, enable);
1743 _makePipes->setEnabled(enable);
1744 // setToolShown( _makePipes, enable);
1746 _makeHemiSphere->setEnabled(enable);
1747 // setToolShown( _makeHemiSphere, enable);
1749 // Pattern Data Edition
1750 _removeHexa->setEnabled(enable);
1751 // setToolShown( _removeHexa, enable);
1753 _prismQuad->setEnabled(enable);
1754 // setToolShown( _prismQuad, enable);
1756 _joinQuad->setEnabled(enable);
1757 // setToolShown( _joinQuad, enable);
1759 _merge->setEnabled(enable);
1760 // setToolShown( _merge, enable);
1762 _disconnect->setEnabled(enable);
1763 // setToolShown( _disconnect, enable);
1765 _cutEdge->setEnabled(enable);
1766 // setToolShown( _cutEdge, enable);
1768 _makeTransformation->setEnabled(enable);
1769 // setToolShown( _makeTransformation, enable);
1771 _makeSymmetry->setEnabled(enable);
1772 // setToolShown( _makeSymmetry, enable);
1774 _performTransformation->setEnabled(enable);
1775 // setToolShown( _performTransformation, enable);
1777 _performSymmetry->setEnabled(enable);
1778 // setToolShown( _performSymmetry, enable);
1780 _replaceHexa->setEnabled(enable);
1781 // setToolShown( _replaceHexa, enable);
1783 _quadRevolution->setEnabled(enable);
1784 // setToolShown( _quadRevolution, enable);
1786 // setMenuShown( _sep4, enable );
1787 _showModelInfoAct->setEnabled(enable);
1791 void HEXABLOCKGUI::showAssociationMenus(bool show)
1793 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1794 if ( show && !getCurrentModel() ) return;
1796 // Association Edition
1797 setMenuShown( _assocVertex, show );
1798 setToolShown( _assocVertex, show );
1800 setMenuShown( _assocEdge, show );
1801 setToolShown( _assocEdge, show );
1803 setMenuShown( _assocQuad, show );
1804 setToolShown( _assocQuad, show );
1806 setMenuShown( _addShapeAct, show );
1807 setToolShown( _addShapeAct, show );
1810 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1812 if ( enable && !getCurrentModel() )
1815 // Association Edition
1816 _assocVertex->setEnabled(enable);
1817 // setToolShown( _assocVertex, enable );
1819 _assocEdge->setEnabled(enable);
1820 // setToolShown( _assocEdge, enable );
1822 _assocQuad->setEnabled(enable);
1823 // setToolShown( _assocQuad, enable );
1825 _addShapeAct->setEnabled(enable);
1826 // setToolShown( _addShapeAct, enable );
1829 void HEXABLOCKGUI::showGroupsMenus(bool show)
1831 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1832 if ( show && !getCurrentModel() ) return;
1833 setMenuShown( _addGroup, show );
1834 setToolShown( _addGroup, show);
1835 setMenuShown( _removeGroup , show );
1836 setToolShown( _removeGroup , show);
1839 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1841 if ( enable && !getCurrentModel() )
1844 _addGroup->setEnabled(enable);
1845 // setToolShown( _addGroup, enable);
1847 _removeGroup->setEnabled(enable);
1848 // setToolShown( _removeGroup , enable);
1851 void HEXABLOCKGUI::showMeshMenus(bool show)
1853 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1854 if ( show && !getCurrentModel() ) return;
1855 setMenuShown( _addLaw, show );
1856 setToolShown( _addLaw, show);
1857 setMenuShown( _removeLaw, show );
1858 setToolShown( _removeLaw, show);;
1859 setMenuShown( _setPropagation, show );
1860 setToolShown( _setPropagation, show);
1861 setMenuShown( _computeMesh, show);
1862 setToolShown( _computeMesh, show);
1865 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1867 if ( enable && !getCurrentModel() )
1870 _addLaw->setEnabled(enable);
1871 // setToolShown( _addLaw, enable);
1873 _removeLaw->setEnabled(enable);
1874 // setToolShown( _removeLaw, enable);
1876 _setPropagation->setEnabled(enable);
1877 // setToolShown( _setPropagation, enable);
1879 _computeMesh->setEnabled(enable);
1880 // setToolShown( _computeMesh, enable);
1883 void HEXABLOCKGUI::showVtkActor()
1885 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1886 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1887 currentVtkGView->getDocumentActor() == NULL)
1890 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1891 if (vtkView == NULL)
1894 SUIT_ViewManager* vman = vtkView->getViewManager();
1895 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1897 //show only the current actor -----------------
1898 vtkView->setFocus();
1899 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1900 Document_Actor *lastDocActor;
1901 if (lastVtkDocGView != NULL)
1903 lastDocActor = lastVtkDocGView->getDocumentActor();
1904 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1905 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1907 vtkView->Erase(lastActorIO);
1908 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1909 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1912 currentVtkGView->update();
1913 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1914 if (!anIO.IsNull() && anIO->hasEntry())
1916 vtkView->Display(anIO);
1917 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1918 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1920 vtkView->onFitAll();
1923 void HEXABLOCKGUI::showOccActor()
1925 if (currentOccGView == NULL)
1927 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1928 if (occView == NULL)
1930 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1934 if (lastOccPrs != NULL)
1935 vf->Erase(lastOccPrs);
1936 currentOccGView->globalSelection();
1937 SOCC_Prs* prs = getOccPrs(currentDocGView);
1938 currentOccGView->setPrs(prs);
1941 occView->onFitAll();
1944 void HEXABLOCKGUI::hideVtkActor()
1946 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1947 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1948 currentVtkGView->getViewWindow() == NULL ||
1949 currentVtkGView->getDocumentActor() == NULL) return;
1951 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1952 currentVtkGView->getViewWindow()->onResetView();
1954 //update the visibility state now
1955 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1956 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1957 if (aStudy == NULL || vman == NULL) return;
1959 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1960 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1961 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1964 void HEXABLOCKGUI::hideOccActor()
1966 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1967 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1968 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1969 if (occView == NULL || docModel == NULL)
1971 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1975 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1976 if (currentOccPrs != NULL)
1977 vf->Erase(currentOccPrs);
1979 occView->onResetView();
1982 void HEXABLOCKGUI::showOnlyActor()
1988 void HEXABLOCKGUI::hideActor()
1995 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1997 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1999 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
2001 if (_dwPattern) _dwPattern->setVisible(isVisible);
2002 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
2004 if (_dwMesh) _dwMesh->setVisible(isVisible);
2005 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
2007 if (_dwGroups) _dwGroups->setVisible(isVisible);
2008 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
2012 //clear all used dialogs by the current model
2013 void HEXABLOCKGUI::clearDialogs()
2015 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
2016 fin (currentModelDialogs.end());
2017 for(;debut!=fin;++debut) (*debut)->clear();
2019 currentModelDialogs.clear(); //empty the used dialogs list
2022 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
2024 if (!gViewDlgBox.contains(dgview)) return NULL;
2025 return gViewDlgBox[dgview];
2028 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
2030 if (dgview == NULL) return;
2032 switchOffGraphicView(dgview, false); //to avoid double connect
2035 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2036 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
2037 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2038 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2039 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2040 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2041 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2042 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2043 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2044 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2045 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2046 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2051 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2053 if (dgview == NULL) return;
2055 //disconnect signals
2056 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2057 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2058 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2059 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2060 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2061 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2062 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2063 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2064 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2065 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2066 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2067 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2070 gViewDlgBox[dgview] = currentDialog;
2072 //close opened dialog
2073 if (currentDialog != NULL) currentDialog->close();
2074 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2080 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2082 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2086 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2090 //switch off the current document graphic view (disconnect signals...)
2091 if (currentDocGView != NULL)
2093 //Hide current actor
2095 switchOffGraphicView(currentDocGView);
2098 //clear the dialogs used by the current model so they can be used by the new model
2099 if (currentDocGView != dgview) clearDialogs();
2101 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2102 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2103 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2104 _groupsTreeView->setModel(dgview->getGroupsModel());
2105 _meshTreeView->setModel(dgview->getMeshModel());
2107 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2108 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2110 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2111 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2113 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2114 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2116 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2117 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2119 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2120 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2123 // = * init occ view * =
2124 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2126 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2127 currentOccGView->getViewWindow()->installEventFilter(this);
2132 // = * init vtk view * =
2133 if (currentDocGView != NULL)
2135 if (currentDocGView->getViewWindow() != NULL)
2136 dgview->setViewWindow(currentDocGView->getViewWindow());
2139 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2140 dgview->getViewWindow()->installEventFilter(this);
2146 switchOnGraphicView(dgview);
2148 if (currentDocGView != NULL)
2150 lastVtkDocGView = currentDocGView;
2151 lastOccPrs = getOccPrs(currentDocGView);
2155 lastVtkDocGView = dgview;
2156 lastOccPrs = getOccPrs(dgview);
2159 currentDocGView = dgview;
2161 currentDocGView->getDocumentModel()->refresh();
2162 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2165 setAllMenusEnabled(true);
2168 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2170 if (currentDocGView == NULL) return NULL;
2171 return currentDocGView->getDocumentModel();
2175 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2177 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2178 if (anApp == NULL) return UNKNOWN;
2179 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2180 if (activeVm == NULL) return UNKNOWN;
2182 QString vmType = activeVm->getType();
2183 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2185 else if ( vmType == OCCViewer_Viewer::Type() )
2191 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2193 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2197 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2200 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2202 // Create Document from HEXABLOCK ENGINE
2203 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2204 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2206 // looking doc impl ( c++ )
2207 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2208 // ^Hexa6 ASSERT( dServant );
2209 // ^Hexa6 if ( dServant)
2210 // ^Hexa6 doc = dServant->GetImpl();
2212 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2213 QString docEntry = addDocInStudy (doc);
2215 // looking for docEntry
2216 /* ****************************************************************
2217 if ( !CORBA::is_nil(docIn) ){
2218 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2219 QString docIOR = anIOR.in();
2220 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2221 if ( !docIOR.isEmpty() ) {
2222 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2224 docEntry = SO->GetID().c_str();
2227 **************************************************************** */
2228 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2230 return make_pair (docEntry, doc);
2234 void HEXABLOCKGUI::newDocument()
2236 DEBTRACE("HEXABLOCKGUI::newDocument");
2239 QMainWindow *aParent = application()->desktop();
2240 QWidget *central = aParent->centralWidget();
2242 central->setFocus();
2244 DEBTRACE("No Central Widget");
2247 if (currentOccGView == NULL)
2249 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2250 application()->desktop());
2251 currentOccGView->getViewWindow()->installEventFilter(this);
2253 else if (currentOccGView->getViewWindow() == NULL)
2255 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2256 currentOccGView->getViewWindow()->installEventFilter(this);
2260 // Create Document from HEXABLOCK ENGINE
2261 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2263 VtkDocumentGraphicView* newGraphicView = NULL;
2264 //One document at a time
2265 if (currentDocGView != NULL)
2267 if (currentDocGView->getViewWindow() == NULL)
2269 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2270 currentDocGView->getViewWindow()->installEventFilter(this);
2273 // Create a new document with the current window
2274 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2275 new DocumentModel( docEntry_Doc.second,
2276 docEntry_Doc.first, this ),
2277 currentDocGView->getViewWindow(),
2278 application()->desktop() );
2282 // Create the new Document Graphic View with a new window
2283 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2284 new DocumentModel( docEntry_Doc.second,
2285 docEntry_Doc.first, this ),
2286 graphicViewsHandler->createVtkWindow(),
2287 application()->desktop() );
2288 newGraphicView->getViewWindow()->installEventFilter(this);
2291 if (newGraphicView == NULL)
2292 //We couldn't create a new document graphic view
2293 //we'd better show a dialog box info to inform the user
2296 docs[docEntry_Doc.first] = newGraphicView;
2297 switchModel(newGraphicView); //select the corresponding document in the browser instead
2299 getApp()->updateObjectBrowser();
2304 //Loads the model from the xmlFile in the current graphic view
2305 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2307 DEBTRACE("HEXABLOCKGUI::loadDocument");
2310 QMainWindow *aParent = application()->desktop();
2311 QString selectedFile;
2313 if ( inFile.isNull() ){
2314 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2315 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2316 dialog.setHistory( getQuickDirList() );
2318 //use the last path as default
2319 if (!(loadDocLastPath->absolutePath()).isEmpty())
2320 dialog.setDirectory(*loadDocLastPath);
2323 QStringList selectedFiles = dialog.selectedFiles();
2324 if (!selectedFiles.isEmpty())
2325 selectedFile = selectedFiles.first();
2327 //remember the selected path
2328 *loadDocLastPath = dialog.directory();
2331 selectedFile = inFile;
2333 if (selectedFile.isEmpty())
2336 //we create a new document if necessary
2337 if (currentDocGView == NULL)
2338 //Need a new document
2340 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2342 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2343 currentDocGView->getViewWindow()->installEventFilter(this);
2346 if (!currentDocGView->isEmpty())
2347 //we can only have one document for a graphic view
2350 //we load the selected file in the current graphic view
2351 currentDocGView->loadDocument(selectedFile);
2352 DocumentModel* currentModel = getCurrentModel();
2353 renameObject( currentModel->documentEntry(), currentModel->getName() );
2358 void HEXABLOCKGUI::saveDocument()
2360 QMainWindow *aParent = application()->desktop();
2362 QString aDocName = "document", aFilename;
2364 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2365 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2367 //use the last selected directory as default path for file selection
2368 aFilename = saveDocLastPath->absolutePath();
2369 if (!aFilename.isEmpty())
2370 aFilename += QString("/") + aDocName;
2372 //show the dialog for file selection
2373 aFilename = SUIT_FileDlg::getFileName( aParent,
2376 tr( "Save HexaBlock Document" ),
2379 //save the document in the selected file
2380 if ( !aFilename.isEmpty() ) {
2381 getCurrentVtkGraphicView()->saveDocument( aFilename );
2383 //Remember the path for next save
2384 QFileInfo fileInfo(aFilename);
2385 *saveDocLastPath = fileInfo.dir();
2391 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2393 _patternDataTreeView->openPersistentEditor( topLeft );
2396 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2398 if (diag == NULL || _dwInputPanel == NULL ||
2399 getCurrentVtkGraphicView() == NULL) return;
2401 //mark this dialog as used by the current model
2402 currentModelDialogs.insert(diag);
2404 //close the current dialog box info
2405 // if (_treeViewDelegate != NULL)
2406 // _treeViewDelegate->closeDialog();
2408 // if (_dwInputPanel->widget())
2409 // _dwInputPanel->widget()->close();
2411 //Temporary for debugging EdgeAssoc Faked InfoDialog
2412 if (diag == _edgeAssocDiag)
2413 diag->debugEdgeAssoc = true;
2415 diag->debugEdgeAssoc = false;
2417 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2418 diag == _quadAssocDiag || diag == _addShapeDiag)
2419 assocInProgress = true;
2421 assocInProgress = false;
2423 //show the dialog box in the dockwidget
2424 diag->resetSizeAndShow(_dwInputPanel);
2426 //clear the current selections
2427 selectionMgr()->clearSelected();
2429 currentDialog = diag;
2432 if (currentDocGView != NULL)
2433 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2436 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2438 if (vertex == NULL || _dwInputPanel == NULL)
2441 if (_vertexInfoDialog == NULL)
2442 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2444 _vertexInfoDialog->setValue(vertex);
2445 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2446 currentDialog = _vertexInfoDialog;
2449 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2451 if (edge == NULL || _dwInputPanel == NULL)
2454 if (_edgeInfoDialog == NULL)
2455 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2457 _edgeInfoDialog->setValue(edge);
2458 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2459 currentDialog = _edgeInfoDialog;
2462 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2464 if (quad == NULL || _dwInputPanel == NULL)
2467 if (_quadInfoDialog == NULL)
2468 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2470 _quadInfoDialog->setValue(quad);
2471 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2472 currentDialog = _quadInfoDialog;
2475 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2477 if (hexa == NULL || _dwInputPanel == NULL)
2480 if (_hexaInfoDialog == NULL)
2481 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2483 _hexaInfoDialog->setValue(hexa);
2484 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2485 currentDialog = _hexaInfoDialog;
2488 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2490 if (vector == NULL || _dwInputPanel == NULL)
2493 if (_vectorInfoDialog == NULL)
2494 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2496 _vectorInfoDialog->setValue(vector);
2497 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2498 currentDialog = _vectorInfoDialog;
2501 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2503 if (group == NULL || _dwInputPanel == NULL)
2506 if (_groupInfoDialog == NULL)
2507 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2509 _groupInfoDialog->setValue(group);
2510 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2511 currentDialog = _groupInfoDialog;
2514 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2516 if (law == NULL || _dwInputPanel == NULL)
2519 if (_lawInfoDialog == NULL)
2520 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2522 _lawInfoDialog->setValue(law);
2523 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2524 currentDialog = _lawInfoDialog;
2527 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2529 if (propagation == NULL || _dwInputPanel == NULL)
2532 if (_propagationInfoDialog == NULL)
2533 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2535 _propagationInfoDialog->setValue(propagation);
2536 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2537 currentDialog = _propagationInfoDialog;
2540 void HEXABLOCKGUI::addVertex()
2542 if ( !_vertexDiag ){
2543 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2545 _showDialogBox( _vertexDiag );
2548 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2549 if (_vertexDiag != NULL && doc != NULL)
2550 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2553 void HEXABLOCKGUI::addEdge()
2556 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2558 _showDialogBox( _edgeDiag );
2561 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2562 if (_edgeDiag != NULL && doc != NULL)
2563 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2566 void HEXABLOCKGUI::addQuad()
2569 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2572 _showDialogBox( _quadDiag );
2575 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2576 if (_quadDiag != NULL && doc != NULL)
2577 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2580 void HEXABLOCKGUI::addHexa()
2583 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2585 _showDialogBox( _hexaDiag );
2588 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2589 if (_hexaDiag != NULL && doc != NULL)
2590 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2593 void HEXABLOCKGUI::addVector()
2595 if ( !_vectorDiag ){
2596 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2598 _showDialogBox( _vectorDiag );
2601 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2602 if (_vectorDiag != NULL && doc != NULL)
2603 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2606 //void HEXABLOCKGUI::addCylinder()
2608 // if ( !_cylinderDiag ){
2609 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2611 // _showDialogBox( _cylinderDiag );
2613 // //set default name
2614 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2615 // if (_cylinderDiag != NULL && doc != NULL)
2616 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2620 //void HEXABLOCKGUI::addPipe()
2622 // if ( !_pipeDiag){
2623 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2625 // _showDialogBox( _pipeDiag );
2627 // //set default name
2628 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2629 // if (_pipeDiag != NULL && doc != NULL)
2630 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2634 void HEXABLOCKGUI::makeGrid()
2636 if ( !_makeGridDiag ){
2637 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2639 _showDialogBox( _makeGridDiag );
2643 void HEXABLOCKGUI::makeCylinder()
2645 if ( !_makeCylinderDiag ){
2646 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2648 _showDialogBox( _makeCylinderDiag );
2651 void HEXABLOCKGUI::makePipe()
2653 if ( !_makePipeDiag ){
2654 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2656 _showDialogBox( _makePipeDiag );
2659 void HEXABLOCKGUI::makeCylinders()
2661 if ( !_makeCylindersDiag ){
2662 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2664 _showDialogBox( _makeCylindersDiag );
2667 void HEXABLOCKGUI::makePipes()
2669 if ( !_makePipesDiag ){
2670 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2672 _showDialogBox( _makePipesDiag );
2676 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2678 if ( !_makeHemiSphereDiag ){
2679 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2681 _showDialogBox( _makeHemiSphereDiag );
2685 void HEXABLOCKGUI::removeHexa()
2687 if ( !_removeHexaDiag ){
2688 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2690 _showDialogBox( _removeHexaDiag );
2694 void HEXABLOCKGUI::prismQuad()
2696 if ( !_prismQuadDiag ){
2697 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2699 _showDialogBox( _prismQuadDiag );
2703 void HEXABLOCKGUI::joinQuad()
2705 if ( !_joinQuadDiag ){
2706 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2708 _showDialogBox( _joinQuadDiag );
2711 void HEXABLOCKGUI::merge()
2714 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2716 _showDialogBox( _mergeDiag );
2719 void HEXABLOCKGUI::disconnectElts()
2721 if ( !_disconnectDiag ){
2722 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2724 _showDialogBox( _disconnectDiag );
2727 void HEXABLOCKGUI::cutEdge()
2729 if ( !_cutEdgeDiag ){
2730 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2732 _showDialogBox( _cutEdgeDiag );
2735 void HEXABLOCKGUI::makeTransformation()
2737 if ( !_makeTransformationDiag ){
2738 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2740 _showDialogBox( _makeTransformationDiag );
2744 void HEXABLOCKGUI::makeSymmetry()
2746 if ( !_makeSymmetryDiag ){
2747 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2749 _showDialogBox( _makeSymmetryDiag );
2753 void HEXABLOCKGUI::performTransformation()
2755 if ( !_performTransformationDiag ){
2756 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2758 _showDialogBox( _performTransformationDiag );
2762 void HEXABLOCKGUI::performSymmetry()
2764 if ( !_performSymmetryDiag ){
2765 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2767 _showDialogBox( _performSymmetryDiag );
2771 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2773 if ( !_replaceHexaDiag ){
2774 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2776 _showDialogBox( _replaceHexaDiag );
2780 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2782 if ( !_quadRevolutionDiag ){
2783 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2785 _showDialogBox( _quadRevolutionDiag );
2789 void HEXABLOCKGUI::assocVertex()
2791 if (!_dwInputPanel) return;
2792 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2793 if ( !_vertexAssocDiag )
2794 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2795 _showDialogBox( _vertexAssocDiag );
2799 void HEXABLOCKGUI::assocEdge()
2801 if ( !_edgeAssocDiag )
2802 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2803 _showDialogBox( _edgeAssocDiag );
2806 void HEXABLOCKGUI::assocQuad()
2808 if ( !_quadAssocDiag )
2809 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2810 _showDialogBox( _quadAssocDiag );
2814 void HEXABLOCKGUI::addGroup()
2817 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2819 _showDialogBox( _groupDiag );
2820 if (_groupDiag != NULL && getCurrentModel() != NULL)
2822 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2823 if (doc == NULL) return;
2824 char defaultName[16];
2825 sprintf (defaultName, "g%04d", doc->countGroup());
2826 _groupDiag->name_le->setText(defaultName);
2830 void HEXABLOCKGUI::removeGroup()
2832 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2833 if (currentDGView == NULL) return;
2835 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2836 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2837 int nbGroupsRemoved = 0;
2840 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2841 tr( "No group selected!" ) );
2845 foreach( QModelIndex selected, l ){
2846 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2847 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2848 Q_ASSERT(selected.isValid());
2850 //Confirm the deletion of the group
2851 if (SUIT_MessageBox::question(
2854 tr("Remove group : %1 ?").arg(selected.data().toString()),
2855 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2856 SUIT_MessageBox::Cancel
2857 ) == SUIT_MessageBox::Cancel) return;
2859 bool removed = getCurrentModel()->removeGroup( selected );
2861 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2862 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2868 if (!nbGroupsRemoved)
2869 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2870 tr( "No group selected!" ) );
2873 void HEXABLOCKGUI::addLaw()
2876 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2878 _showDialogBox( _lawDiag );
2879 if (_lawDiag != NULL && getCurrentModel() != NULL)
2881 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2882 if (doc == NULL) return;
2883 char defaultName[16];
2884 sprintf (defaultName, "l%04d", doc->countLaw());
2885 _lawDiag->name_le->setText(defaultName);
2889 void HEXABLOCKGUI::removeLaw()
2891 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2892 if (currentDGView == NULL) return;
2894 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2895 int nbLawsRemoved = 0;
2898 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2899 tr( "No law selected!" ) );
2903 foreach( QModelIndex selected, l ){
2904 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2905 selected = currentDGView->getMeshModel()->mapToSource( selected );
2906 Q_ASSERT(selected.isValid());
2908 //Confirm the deletion of the law
2909 if (SUIT_MessageBox::question(
2912 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2913 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2914 SUIT_MessageBox::Cancel
2915 ) == SUIT_MessageBox::Cancel) return;
2917 bool removed = getCurrentModel()->removeLaw(selected);
2919 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2920 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2927 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2928 tr( "No law selected!" ) );
2933 void HEXABLOCKGUI::setPropagation()
2935 if ( !_propagationDiag )
2936 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2938 _showDialogBox( _propagationDiag );
2941 // Dialog box to compute a mesh from a document
2942 // --------------------------------------------
2943 void HEXABLOCKGUI::computeMesh()
2945 if ( !_computeMeshDiag )
2946 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2948 _showDialogBox( _computeMeshDiag );
2951 void HEXABLOCKGUI::clearAssociations()
2953 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2954 if (currentDGView == NULL) return;
2956 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2957 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2958 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2960 getCurrentModel()->clearEltAssociations(iModel);
2962 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2965 void HEXABLOCKGUI::showModelInfo()
2967 //create the info dialog if not yet
2968 if (_modelInfoDiag == NULL)
2969 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2971 //show the model informations dialog
2972 _showDialogBox( _modelInfoDiag );
2975 void HEXABLOCKGUI::addShape()
2977 //create the info dialog if not yet
2978 if (_addShapeDiag == NULL)
2979 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2981 //show the model informations dialog
2982 _showDialogBox( _addShapeDiag );
2985 void HEXABLOCKGUI::clearAllAssociations()
2987 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2988 if (currentDGView == NULL) return;
2990 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2991 if (!currentIndex.isValid()) return;
2992 QVariant currentAssocVariant;
2993 QString currentAssocEntry;
2995 //Confirm the deletion of the associations
2996 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2997 if ( !treeVariant.isValid() ) return;
2998 int eltType = treeVariant.toInt();
2999 QString typeStr = "";
3000 HEXA_NS::EnumElt hexaType;
3001 if (eltType == VERTEX_DIR_TREE)
3003 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
3004 hexaType = HEXA_NS::EL_VERTEX;
3006 else if (eltType == EDGE_DIR_TREE)
3008 typeStr = tr("TREE_ITEM_EDGE").toUpper();
3009 hexaType = HEXA_NS::EL_EDGE;
3011 else if (eltType == QUAD_DIR_TREE)
3013 typeStr = tr("TREE_ITEM_QUAD").toUpper();
3014 hexaType = HEXA_NS::EL_QUAD;
3017 if (SUIT_MessageBox::question(
3019 tr("CLEAR_ASSOCIATIONS"),
3020 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
3021 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
3022 SUIT_MessageBox::Cancel
3023 ) == SUIT_MessageBox::Cancel) return;
3026 DocumentModel* docModel = getCurrentModel();
3027 if (docModel == NULL) return;
3028 docModel->clearAssociation(hexaType);
3031 void HEXABLOCKGUI::showAssociations()
3033 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3034 if (currentDGView == NULL) return;
3036 QModelIndexList elts;
3037 int currentChildIndex = 0;
3038 QVariant currentAssocVariant;
3039 QString currentAssocEntry;
3040 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
3041 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
3043 while( currentChild.isValid() ) {
3045 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3046 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3047 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3048 elts << currentChild;
3050 currentChild = currentChild.sibling(currentChildIndex++, 0);
3052 currentDocGView->highlight(elts);
3053 currentOccGView->highlight(elts, false);
3057 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3059 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3061 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3066 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3068 if ( event->type() == QEvent::Enter )
3069 { // *** ENTER EVENT
3071 if (currentDialog == NULL || !currentDialog->isVisible())
3072 return QObject::eventFilter(obj, event);
3074 // ** The window acquire the focus when the cursor enter
3076 //OCC - window enter
3077 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3078 if ( occWindow != NULL)
3079 currentDialog->onWindowActivated(occWindow->getViewManager());
3081 //VTK - window enter
3083 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3084 if ( vtkWindow != NULL)
3085 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3089 //standard event processing
3090 return QObject::eventFilter(obj, event);
3093 QStringList HEXABLOCKGUI::getQuickDirList()
3095 QStringList dirList;
3096 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3098 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3104 // --- Export the module
3108 HEXABLOCK_EXPORT CAM_Module* createModule()
3110 return new HEXABLOCKGUI();
3113 HEXABLOCK_EXPORT char* getModuleVersion()
3115 return (char*)HEXABLOCK_VERSION_STR;
3121 // ******************** TESTS ***************************************************
3123 void HEXABLOCKGUI::testDocument()
3127 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3128 // QStandardItem *myItem = new QStandardItem("MyItem");
3129 // parentItem->appendRow(myItem);
3131 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3132 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3133 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3134 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3135 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3136 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3137 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3138 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3141 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3142 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3143 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3144 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3145 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3146 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3148 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3149 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3150 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3151 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3156 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3157 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3158 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3159 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3167 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3168 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3170 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3171 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3175 // newMesh( "toto", 3, "FactoryServer");
3179 void HEXABLOCKGUI::test_make_cart_grid()
3181 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3182 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3183 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3184 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3185 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3186 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3188 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3189 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3196 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3197 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3198 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3199 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3200 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3201 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3206 void HEXABLOCKGUI::test_make_elmts_transform()
3213 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3214 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3217 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3218 // orig.setScalar(2);
3220 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3221 // getCurrentModel()->saveVtk(file_name)
3223 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3224 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3226 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3227 // getCurrentModel()->saveVtk(file_name)
3229 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3232 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3233 // getCurrentModel()->saveVtk(file_name);
3236 // print "...test make elements by transforming elements OK"
3238 // =============================================================== addDocInSudy
3239 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3243 if (document == NULL)
3246 QString docName = document->getName ();
3248 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3249 if (app_study == NULL)
3252 _PTR(Study) study = app_study->studyDS();
3253 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3254 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3255 QString entry = app_study->centry("HEXABLOCK");
3256 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3257 if (aFatherSO->_is_nil())
3260 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3263 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3264 docEntry = aSO->GetID(); //the entry of the published object
3269 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3271 void HEXABLOCKGUI::test()
3273 DEBTRACE("HEXABLOCKGUI::test");
3274 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3275 if (currentDGView == NULL) return;
3276 currentDGView->update();
3280 void HEXABLOCKGUI::test_association()
3282 DEBTRACE("HEXABLOCKGUI::test_association");
3285 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3287 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3288 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3289 DocumentModel::GeomObj q0AssocA, q0AssocB;
3291 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3292 QList<DocumentModel::GeomObj> e1Assocs_test;
3293 DocumentModel::GeomObj q0Assoc_test;
3295 v0 = getCurrentModel()->addVertex(0, 0, 0);
3296 v1 = getCurrentModel()->addVertex(1, 0, 0);
3297 v2 = getCurrentModel()->addVertex(1, 1, 0);
3298 v3 = getCurrentModel()->addVertex(0, 1, 0);
3299 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3300 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3301 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3304 // >>> face3.GetEntry()'0:1:4'
3305 // >>> e1.GetEntry()'0:1:8'
3306 // >>> e2.GetEntry()'0:1:9'
3307 // >>> e3.GetEntry()'0:1:10'
3308 // >>> e4.GetEntry()'0:1:11'
3309 // >>> v1.GetEntry()'0:1:12'
3310 // >>> v2.GetEntry()'0:1:13'
3311 // >>> v3.GetEntry()'0:1:14'
3312 // >>> v4.GetEntry()'0:1:15'
3315 // v0Assoc.name = "geomV0";
3316 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3317 // v0Assoc.brep = "brepV0";
3318 // v1Assoc.name = "geomV1";
3319 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3320 // v1Assoc.brep = "brepV1";
3321 // v2Assoc.name = "geomV2";
3322 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3323 // v2Assoc.brep = "brepV2";
3324 // v3Assoc.name = "geomV3";
3325 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3326 // v3Assoc.brep = "brepV3";
3330 // e0AssocA.name = "geomE0a";
3331 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3332 // e0AssocA.brep = "brepE0a";
3333 // e0AssocA.start = 0.10;
3334 // e0AssocA.end = 0.95;
3338 // e1AssocA.name = "geomE1a";
3339 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3340 // e1AssocA.brep = "brepE1a";
3341 // e1AssocA.start = 0.12;
3342 // e1AssocA.end = 0.89;
3343 // e1AssocB.name = "geomE1b";
3344 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3345 // e1AssocB.brep = "brepE1b";
3346 // e1AssocB.start = 0.20;
3347 // e1AssocB.end = 0.80;
3348 // e1AssocC.name = "geomE1c";
3349 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3350 // e1AssocC.brep = "brepE1c";
3351 // e1AssocC.start = 0.16;
3352 // e1AssocC.end = 0.96;
3354 // q0AssocA.name = "geomQuad";
3355 // q0AssocA.entry = "0:1:1:1:3";
3356 // q0AssocA.brep = "brepq0";
3358 // q0AssocB.name = "geomQuad";
3359 // q0AssocB.entry = "0:1:1:1:4";
3360 // q0AssocB.brep = "brepq0";
3362 // getCurrentModel()->addAssociation( v0, v0Assoc );
3363 // getCurrentModel()->addAssociation( v1, v1Assoc );
3364 // getCurrentModel()->addAssociation( v2, v2Assoc );
3365 // getCurrentModel()->addAssociation( v3, v3Assoc );
3368 // getCurrentModel()->addAssociation( e0, e0AssocA );
3370 // getCurrentModel()->addAssociation( e1, e1AssocA );
3371 // getCurrentModel()->addAssociation( e1, e1AssocB );
3372 // getCurrentModel()->addAssociation( e1, e1AssocC );
3374 // getCurrentModel()->addAssociation( q0, q0AssocA );
3375 // getCurrentModel()->addAssociation( q0, q0AssocB );
3381 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3382 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3383 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3384 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3385 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3386 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3387 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3388 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3389 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3390 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3391 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3392 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3395 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3396 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3397 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3398 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3399 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3400 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3401 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3402 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3403 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3404 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3405 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3406 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3407 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3409 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3410 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3411 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3414 DEBTRACE("HEXABLOCKGUI::test_association fin");