1 // Copyright (C) 2009-2015 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>
29 #include <QtxTreeView.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_ViewManager.h>
35 #include <SUIT_ViewWindow.h>
36 #include <SUIT_DataObject.h>
37 #include <SUIT_DataBrowser.h>
38 #include <SUIT_FileDlg.h>
40 #include <SVTK_ViewManager.h>
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewWindow.h>
44 #include <VTKViewer_ViewModel.h>
46 #include <vtkActorCollection.h>
47 #include <VTKViewer_Algorithm.h>
48 #include <vtkRenderer.h>
52 #include <SOCC_ViewModel.h>
53 #include <SOCC_ViewWindow.h>
54 #include <OCCViewer_ViewWindow.h>
55 #include <SALOME_Prs.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_Study.hxx>
61 #include <SALOMEDSClient_StudyBuilder.hxx>
62 #include <SALOMEDSClient_SComponent.hxx>
63 #include <SALOMEDSClient_ClientFactory.hxx>
64 #include <SALOMEDSClient_IParameters.hxx>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Module.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataModel.h>
74 #include <SALOME_ListIO.hxx>
77 #include <SALOME_LifeCycleCORBA.hxx>
79 #include <LightApp_VTKSelector.h>
81 #include <OCCViewer_ViewManager.h>
83 #include <QtxPopupMgr.h>
85 #include "Resource.hxx"
87 #include "HEXABLOCKGUI.hxx"
88 #include "HEXABLOCKGUI_Export.hxx"
89 #include "HEXABLOCKGUI_Trace.hxx"
90 #include "HEXABLOCKGUI_Resource.hxx"
92 #include "HEXABLOCKGUI_DocumentModel.hxx"
93 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
94 //#include "HEXABLOCKGUI_DocumentDelegate.hxx"
95 #include "HEXABLOCKGUI_DocumentPanel.hxx"
96 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
97 #include "HEXABLOCKGUI_OccGraphicView.hxx"
98 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
100 #include "HEXABLOCK_version.h"
102 #include "MyBasicGUI_PointDlg.hxx"
104 // #include "HEXABLOCK.hxx" del Hexa6
105 // #include "HexDocument_impl.hxx" del Hexa6
109 #include <Visual3d_ViewManager.hxx>
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 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
289 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
291 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
293 SUIT_ViewManager* vm;
294 ViewManagerList OCCViewManagers, VTKViewManagers;
296 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
297 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
298 while ( itOCC.hasNext() && (vm = itOCC.next()) )
299 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
301 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
302 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
303 while ( itVTK.hasNext() && (vm = itVTK.next()) )
304 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
307 SALOME_ListIO selected;
308 sm->selectedObjects( selected );
311 // disable OCC selectors
312 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
313 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
314 while ( itOCCSel.hasNext() )
315 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
316 sr->setEnabled(true);
318 // disable VTK selectors
319 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
320 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
321 while ( itVTKSel.hasNext() )
322 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
323 sr->setEnabled(true);
325 sm->setSelectedObjects( selected, true ); //NPAL 19674
327 //connect close signal to vtk view manager
328 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
331 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
332 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
335 //connect close signal to occ view manager
336 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
339 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
340 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
343 /* ************************************ TODO Hexa6
344 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
345 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
346 if ( _PTR(Study) aStudy = s->studyDS()) {
347 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
348 updateObjBrowser(); // objects can be removed
350 ************************************ */
352 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
353 currentOccGView->getViewWindow()->installEventFilter(this);
355 if (currentDocGView != NULL)
357 switchModel(currentDocGView);
360 if (currentDocGView->getViewWindow() != NULL)
361 currentDocGView->getViewWindow()->installEventFilter(this);
373 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
375 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
376 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
377 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
378 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
380 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
381 if ( vtkView != NULL)
383 //default selectionMode in VTKView
384 vtkView->SetSelectionMode( ActorSelection );
385 vtkView->removeEventFilter(this);
389 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
392 //defaut selectionMode in OccView
393 selectionMgr()->clearSelected();
394 currentOccGView->globalSelection();
395 occView->removeEventFilter(this);
399 qDeleteAll(myOCCSelectors);
400 myOCCSelectors.clear();
401 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
403 qDeleteAll(myVTKSelectors);
404 myVTKSelectors.clear();
405 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
407 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
409 //switch off current document graphic view
410 switchOffGraphicView(currentDocGView);
413 setMenuShown( false );
414 setToolShown( false );
415 showDockWidgets( false );
417 _dwInputPanel->close();
424 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
426 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
427 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
428 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
429 int aStudyID = theStudy->StudyId();
430 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
431 return aDSStudy._retn();
434 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
435 QMap<QString, QString>& docShapesEntry,
436 QMap<QString, QString>& docShapesName)
438 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
439 return; //there's nothing to publish in this case
441 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
442 if(!appStudy) return;
443 _PTR(Study) aStudy = appStudy->studyDS();
444 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
445 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
446 QString entry = currentDocGView->getDocumentModel()->documentEntry();
447 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
448 if (aFatherSO->_is_nil())
451 // * get a presentation
452 bool isNewPrs = false;
453 SOCC_Prs* prs = getOccPrs(currentDocGView);
456 prs = new SOCC_Prs(0);
460 // * init the presentation with the given shapes
461 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
462 while (i != topo_shapes.constEnd())
464 QString shapeName = i.key();
465 TopoDS_Shape shapeValue = i.value();
466 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
467 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
468 QString objStudyEntry = aSO->GetID(); //the entry of the published object
469 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
470 "HEXABLOCK", shapeName.toStdString().c_str());
471 ais_shape->SetOwner(io);
472 prs->AddObject(ais_shape);
473 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
474 docShapesEntry[shapeName] = objStudyEntry;
475 docShapesName[objStudyEntry] = shapeName;
476 currentOccGView->addShape(objStudyEntry, ais_shape);
477 i++; //handle next shape
481 prs->AddObject(currentOccGView->getPreviewShape());
483 occPrs[currentDocGView] = prs;
484 getApp()->updateObjectBrowser();
489 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
491 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
492 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
493 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
495 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
499 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
503 // Pas de renommage des shapes pour le moment, juste les documents
504 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
505 if (dgview == NULL || dgview->getDocumentModel() == NULL)
508 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
509 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
514 _PTR(Study) aStudy = appStudy->studyDS();
519 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
520 _PTR(GenericAttribute) anAttr;
522 if ( obj->FindAttribute(anAttr, "AttributeName") ){
523 _PTR(AttributeName) aName (anAttr);
524 DocumentModel* docModel = dgview->getDocumentModel();
525 docModel->setName( name );
526 aName->SetValue( name.toLatin1().data() );
527 getApp()->updateObjectBrowser();
528 // _dwPattern->setWindowTitle( name );
535 // --- Default windows
536 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
538 DEBTRACE("HEXABLOCKGUI::windows");
540 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
541 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
544 QString HEXABLOCKGUI::engineIOR() const
546 DEBTRACE("HEXABLOCKGUI::engineIOR");
548 /* ************************************ TODO Hexa6
549 CORBA::ORB_var anORB = getApp()->orb();
550 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
551 return QString( anIOR.in() );
552 ************************************ */
556 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
558 if (docs.count(studyObject->entry()) == 0)
560 //Object's document not acquired yet
561 VtkDocumentGraphicView* dgview;
562 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
563 if (directory == NULL)
564 return NULL; //No working director found
566 //------------------ Load the document -----------------
567 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
568 if (document == NULL)
569 return NULL; //No document found
571 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
573 MESSAGE("Doc model creation failed!");
576 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
577 if (dgview == NULL) return NULL;
579 //update the data tree
580 docs[studyObject->entry()] = dgview;
583 return docs[studyObject->entry()];
586 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
588 // ** we want to switch automatically to the right view windows
590 //first, find selected item
592 DataObjectList dol = getApp()->objectBrowser()->getSelected();
593 if (dol.isEmpty()) return;
594 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
595 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
596 item->entry().isEmpty())
599 // find the document corresponding to it
600 VtkDocumentGraphicView* docGView = NULL;
601 if (docs.contains(item->entry()))
602 docGView = docs[item->entry()];
604 docGView = getOrCreateDocument(item);
606 //Init OCC if necessary
607 if (currentOccGView == NULL)
609 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
610 currentOccGView->getViewWindow()->installEventFilter(this);
612 else if (currentOccGView->getViewWindow() == NULL)
614 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
615 currentOccGView->getViewWindow()->installEventFilter(this);
618 //Init the vtk view if necessary
619 if (docGView->getViewWindow() == NULL)
621 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
623 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
624 docGView->getViewWindow()->installEventFilter(this);
627 setAllMenusEnabled(true);
630 docGView->setViewWindow(currentDocGView->getViewWindow());
632 if (docGView->getDocumentActor() == NULL)
636 if (docGView == NULL || docGView == currentDocGView)
642 //update the current document
643 switchModel(docGView);
647 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
649 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
652 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
654 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
656 //Decharger le model correspondant (VTK)
657 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
661 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
662 { //HexaBlock Vtk Window has been closed
664 if (currentDialog != NULL) currentDialog->close();
665 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
666 if (currentDocGView != NULL)
667 currentDocGView->setViewWindow(NULL);
670 setAllMenusEnabled(false);
671 enableDocumentMenus(true);
677 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
678 if (dgview == NULL) return; //The window has no document to close
680 //Save the document? (Ask only if the document is not empty
681 int answerCode = SUIT_MessageBox::question(
684 tr("Save the document ?"),
685 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
686 SUIT_MessageBox::Cancel);
687 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
688 else if (answerCode == SUIT_MessageBox::Yes)
689 saveDocument(); //Save the document
691 // switchOffGraphicView(window); //disconnect all connected signals
692 // currentVtkView = NULL;
693 // graphicViewsHandler->closeDocumentGraphicView(window);
695 //create a new one (empty document)
697 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
701 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
703 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
704 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
705 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
706 if (currentDialog != NULL) currentDialog->close();
707 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
709 currentOccGView->getViewWindow()->removeEventFilter(this);
710 currentOccGView->setViewWindow(NULL);
714 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
716 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
718 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
719 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
721 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
723 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
724 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
725 // disable OCC selectors
726 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
727 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
728 while ( itOCCSel.hasNext() )
729 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
730 sr->setEnabled(true);
732 else if ( vm->getType() == SVTK_Viewer::Type() )
734 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
735 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
737 // disable VTK selectors
738 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
739 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
740 while ( itVTKSel.hasNext() )
741 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
742 sr->setEnabled(true);
746 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
748 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
750 SUIT_ViewModel* viewer = vm->getViewModel();
751 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
753 //VTK View Manager removed
754 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
756 //Process only if it's our view manager
757 SUIT_ViewManager* myVm = NULL;
758 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
759 myVm = currentDocGView->getViewWindow()->getViewManager();
763 //close opened dialog
764 if (currentDialog != NULL) currentDialog->close();
765 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
771 //remove its selector
772 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
773 while ( itVTKSel.hasNext() )
774 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
775 if ( sr->viewer() == viewer )
777 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
784 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
786 //OCC View removed: remove its selector
787 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
788 while ( itOCCSel.hasNext() )
789 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
790 if ( sr->viewer() == viewer )
792 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
798 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
800 QModelIndexList l = selected.indexes();
801 if ( l.count() == 0 ) return;
802 if ( !l[0].isValid() ) return;
803 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
804 if ( currentGraphicView == NULL) return;
806 QTreeView* theTree = NULL;
807 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
808 theTree = _patternDataTreeView;
810 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
811 theTree = _patternBuilderTreeView;
813 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
814 theTree = _patternGeomTreeView;
816 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
817 theTree = _groupsTreeView;
818 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
819 theTree = _meshTreeView;
822 theTree->scrollTo ( l[0] );
826 bool HEXABLOCKGUI::createSComponent() //addComponent
828 DEBTRACE("HEXABLOCKGUI::createSComponent");
829 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
831 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
832 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
833 _PTR(GenericAttribute) anAttr;
834 _PTR(AttributeName) aName;
835 _PTR(AttributeGraphic) aGraphic;
837 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
838 if ( !aComponent ){ //Create hexablock component if there's not one yet
839 aComponent = aBuilder->NewComponent("HEXABLOCK");
840 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
841 aName = _PTR(AttributeName) (anAttr);
842 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
844 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
845 _PTR(AttributePixMap) aPixmap(anAttr);
846 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
848 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
849 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
855 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
857 DEBTRACE("HEXABLOCKGUI::setResource");
858 _myresource = new HEXABLOCKGUI_Resource(r);
859 _myresource->preferencesChanged();
862 void HEXABLOCKGUI::createPreferences()
864 DEBTRACE("HEXABLOCKGUI::createPreferences");
865 _myresource->createPreferences(this);
868 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
870 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
871 _myresource->preferencesChanged(sect, name);
872 // if(name=="userCatalog")
873 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
876 void HEXABLOCKGUI::studyActivated() //CS_TODO
878 int newStudyId = getApp()->activeStudy()->id();
879 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
880 // if (_oldStudyId != -1)
882 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
883 // if (_studyContextMap.count(newStudyId))
885 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
886 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
890 // DEBTRACE("no switch to null context");
893 _oldStudyId = newStudyId;
896 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
898 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
899 QVariant currentAssocVariant;
900 QString currentAssocEntry;
902 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
903 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
904 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
905 QMenu menu( _patternDataTreeView );
907 QAction *clearAct = menu.addAction( "Remove association(s)" );
908 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
909 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
913 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
914 if (currentVtkGraphicView == NULL) return;
915 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
917 //We don't do anything for single items
918 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
919 item->type() == QUADITEM || item->type() == HEXAITEM)
922 //No associations for HEXA
923 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
924 if ( !treeVariant.isValid() ) return;
925 int eltType = treeVariant.toInt();
926 if (eltType == HEXA_DIR_TREE) return;
927 QMenu menu( _patternDataTreeView );
929 //Show association(s)
930 QAction *showAssocAct = menu.addAction( "Show associations" );
931 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
933 //Clear all associations
934 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
935 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
937 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
942 void HEXABLOCKGUI::createAndFillDockWidget()
945 QMainWindow *aParent = application()->desktop();
947 // Create dock widget (3 dock)
949 //1) *********** user input panel ( contain user's edit dialog box )
950 _dwInputPanel = new QDockWidget(aParent);
951 _dwInputPanel->setVisible(false);
952 _dwInputPanel->setWindowTitle("Input Panel");
953 _dwInputPanel->setObjectName("hexablockInputPanelDock");
954 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
956 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
958 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
960 _dwPattern = new QDockWidget(aParent);
961 _dwPattern->setVisible(false);
962 _dwPattern->setWindowTitle("Model");
963 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
964 _dwPattern->setObjectName("hexablockModelDock");
966 QFrame* patternFrame = new QFrame(_dwPattern);
967 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
968 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
969 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
970 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
971 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
972 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
973 _patternGeomTreeView = new QTreeView(patternFrame);
974 splitter->addWidget(_patternDataTreeView);
975 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
976 splitter->addWidget(_patternGeomTreeView);
977 patternLayout->addWidget(splitter);
979 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
980 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
981 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
984 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
985 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
987 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
988 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
990 _dwPattern->setWidget(patternFrame);
991 patternFrame->show();
994 _dwGroups = new QDockWidget(aParent);
996 _dwGroups->setVisible(false);
997 _dwGroups->setWindowTitle("Groups");
998 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
999 _dwGroups->setObjectName("hexablockGroupsDock");
1000 _groupsTreeView = new QTreeView(_dwGroups);
1001 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1002 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
1003 _dwGroups->setWidget(_groupsTreeView);
1004 _groupsTreeView->show();
1007 _dwMesh = new QDockWidget(aParent);
1008 _dwMesh->setVisible(false);
1009 _dwMesh->setWindowTitle("Mesh");
1010 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1011 _dwMesh->setObjectName("hexablockMeshDock");
1012 _meshTreeView = new QTreeView(_dwMesh);
1013 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1014 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1015 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1016 _dwMesh->setWidget(_meshTreeView);
1017 _meshTreeView->show();
1019 // QDockWidget *_dwObjectBrowser = 0;
1020 QWidget* wid = getApp()->objectBrowser()->treeView();
1021 QWidget *w = wid->parentWidget();
1022 while ( w && !_dwObjectBrowser ) {
1023 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1024 w = w->parentWidget();
1026 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1027 _dwObjectBrowser->setWindowTitle("Study");
1029 // dock widget position
1030 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1031 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1033 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1034 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1035 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1037 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1038 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1039 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1041 #if QT_VERSION >= 0x040500
1042 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1045 // popup menu on data tree view
1046 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1047 connect(_patternDataTreeView,
1048 SIGNAL(customContextMenuRequested(const QPoint &)),
1050 SLOT(treeContextMenu(const QPoint &)),
1051 Qt::UniqueConnection );
1054 void HEXABLOCKGUI::createActions()
1056 QMainWindow *aParent = application()->desktop();
1057 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1060 _newAct = createAction(_menuId++,
1061 tr("Create a new document"),
1062 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1064 tr("Create a new document"),
1065 0, aParent, false, this, SLOT(newDocument()));
1066 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1068 _importAct = createAction(_menuId++,
1069 tr("Load a document"),
1070 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1071 tr("Load Document"),
1072 tr("Load a document"),
1073 0, aParent, false, this, SLOT(loadDocument()));
1074 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1076 _saveAct = createAction(_menuId++,
1077 tr("Save the document"),
1078 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1079 tr("Save Document"),
1080 tr("Save the document"),
1081 0, aParent, false, this, SLOT(saveDocument()));
1083 // Pattern Data creation
1084 _addVertex = createAction(_menuId++,
1085 tr("Create a vertex"),
1086 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1088 tr("Create a new vertex"),
1089 0, aParent, false, this, SLOT(addVertex()));
1091 _addEdge = createAction(_menuId++,
1092 tr("Create an edge"),
1093 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1095 tr("Create a new edge"),
1096 0, aParent, false, this, SLOT(addEdge()));
1098 _addQuad = createAction(_menuId++,
1099 tr("Create a quadrangle"),
1100 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1101 tr("Add Quadrangle"),
1102 tr("Create a new quadrangle"),
1103 0, aParent, false, this, SLOT(addQuad()));
1105 _addHexa = createAction(_menuId++,
1106 tr("Create an hexahedron"),
1107 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1108 tr("Add Hexahedron"),
1109 tr("Create a new hexahedron"),
1110 0, aParent, false, this, SLOT(addHexa()));
1112 // Builder Data creation
1113 _addVector = createAction(_menuId++,
1114 tr("Create a vector"),
1115 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1117 tr("Create a new vector"),
1118 0, aParent, false, this, SLOT(addVector()));
1120 // _addCylinder = createAction(_menuId++,
1121 // tr("Create a cylinder"),
1122 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1123 // tr("Add Cylinder"),
1124 // tr("Create a new cylinder"),
1125 // 0, aParent, false, this, SLOT(addCylinder()));
1127 // _addPipe = createAction(_menuId++,
1128 // tr("Create a pipe"),
1129 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1131 // tr("Create a new pipe"),
1132 // 0, aParent, false, this, SLOT(addPipe()));
1134 _makeGrid = createAction(_menuId++,
1136 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1139 0, aParent, false, this, SLOT(makeGrid()));
1141 _makeCylinder = createAction(_menuId++,
1142 tr("Make a cylinder"),
1143 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1144 tr("Make Cylinder"),
1145 tr("Make a cylinder"),
1146 0, aParent, false, this, SLOT(makeCylinder()));
1148 _makePipe = createAction(_menuId++,
1150 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1153 0, aParent, false, this, SLOT(makePipe()));
1155 _makeCylinders = createAction(_menuId++,
1156 tr("Make cylinders"),
1157 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1158 tr("Make Cylinders"),
1159 tr("Make cylinders"),
1160 0, aParent, false, this, SLOT(makeCylinders()));
1162 _makePipes = createAction(_menuId++,
1164 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1167 0, aParent, false, this, SLOT(makePipes()));
1169 _makeHemiSphere = createAction(_menuId++,
1170 tr("Make an hemisphere"),
1171 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1172 tr("Make Hemisphere"),
1173 tr("Make an hemisphere"),
1174 0, aParent, false, this, SLOT(makeHemiSphere()));
1176 // Pattern Data edition
1177 _removeHexa = createAction(_menuId++,
1178 tr("Remove hexahedra"),
1179 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1180 tr("Remove Hexahedra"),
1181 tr("Remove hexahedra"),
1182 0, aParent, false, this, SLOT(removeHexa()));
1184 _prismQuad = createAction(_menuId++,
1185 tr("Prism quadrangles"),
1186 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1187 tr("Prism Quadrangles"),
1188 tr("Prism quadrangles"),
1189 0, aParent, false, this, SLOT(prismQuad()));
1191 _joinQuad = createAction(_menuId++,
1192 tr("Join quadrangles"),
1193 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1194 tr("Join Quadrangles"),
1195 tr("Join quadrangles with hexahedra"),
1196 0, aParent, false, this, SLOT(joinQuad()));
1198 _merge = createAction(_menuId++,
1200 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1203 0, aParent, false, this, SLOT(merge()));
1205 _disconnect = createAction(_menuId++,
1207 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1209 tr("Disconnect edges, vertexes or quadrangles"),
1210 0, aParent, false, this, SLOT(disconnectElts()));
1212 _cutEdge = createAction(_menuId++,
1214 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1217 0, aParent, false, this, SLOT(cutEdge()));
1219 _makeTransformation = createAction(_menuId++,
1220 tr("Make transformation"),
1221 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1222 tr("Make Transformation"),
1223 tr("Make transformation"),
1224 0, aParent, false, this, SLOT(makeTransformation()));
1226 _makeSymmetry = createAction(_menuId++,
1227 tr("Make symmetry"),
1228 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1229 tr("Make Symmetry"),
1230 tr("Make symmetry"),
1231 0, aParent, false, this, SLOT(makeSymmetry()));
1233 _performTransformation = createAction(_menuId++,
1234 tr("Perform transformation"),
1235 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1236 tr("Perform Transformation"),
1237 tr("Perform transformation"),
1238 0, aParent, false, this, SLOT(performTransformation()));
1240 _performSymmetry = createAction(_menuId++,
1241 tr("Perform symmetry"),
1242 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1243 tr("Perform Symmetry"),
1244 tr("Perform symmetry"),
1245 0, aParent, false, this, SLOT(performSymmetry()));
1247 _replaceHexa = createAction(_menuId++,
1248 tr("Replace hexahedron"),
1249 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1250 tr("Replace Hexahedron"),
1251 tr("Replace hexahedron"),
1252 0, aParent, false, this, SLOT(replaceHexa()));
1254 _quadRevolution = createAction(_menuId++,
1255 tr("Quad revolution"),
1256 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1257 tr("Quad Revolution"),
1258 tr("Quad revolution"),
1259 0, aParent, false, this, SLOT(quadRevolution()));
1262 _assocVertex = createAction(_menuId++,
1263 tr("Make vertex association"),
1264 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1265 tr("Make Vertex association"),
1266 tr("Make vertex association"),
1267 0, aParent, false, this, SLOT(assocVertex()));
1269 _assocEdge = createAction(_menuId++,
1270 tr("Make edge association"),
1271 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1272 tr("Make Edge Association"),
1273 tr("Make edge association"),
1274 0, aParent, false, this, SLOT(assocEdge()));
1276 _assocQuad = createAction(_menuId++,
1277 tr("Make quad association"),
1278 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1279 tr("Make Quad Association"),
1280 tr("Make quad association"),
1281 0, aParent, false, this, SLOT(assocQuad()));
1284 _addGroup = createAction(_menuId++,
1286 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1289 0, aParent, false, this, SLOT(addGroup()));
1291 _removeGroup = createAction(_menuId++,
1292 tr("Remove a group"),
1293 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1295 tr("Remove a group"),
1296 0, aParent, false, this, SLOT(removeGroup()));
1299 _addLaw = createAction(_menuId++,
1301 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1304 0, aParent, false, this, SLOT(addLaw()));
1306 _removeLaw = createAction(_menuId++,
1308 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1311 0, aParent, false, this, SLOT(removeLaw()));
1313 _setPropagation = createAction(_menuId++,
1314 tr("Set propagation"),
1315 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1316 tr("Set Propagation"),
1317 tr("Set propagation"),
1318 0, aParent, false, this, SLOT(setPropagation()));
1320 _computeMesh = createAction(_menuId++,
1322 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1325 0, aParent, false, this, SLOT(computeMesh()));
1327 _showModelInfoAct = createAction(_menuId++,
1328 tr("Show Model Info"),
1329 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1332 0, aParent, false, this, SLOT(showModelInfo()));
1334 _addShapeAct = createAction(_menuId++,
1336 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1339 0, aParent, false, this, SLOT(addShape()));
1341 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1342 // QAction* createAction(const int id,
1343 // const QString& toolTip,
1344 // const QIcon& icon,
1345 // const QString& menu,
1346 // const QString& status,
1347 // const int shortCut,
1348 // QObject* parent =0,
1349 // bool checkable = false,
1350 // QObject* receiver =0,
1351 // const char* member =0);
1353 _sep1 = separator();
1354 _sep2 = separator();
1355 _sep3 = separator();
1356 _sep4 = separator();
1360 void HEXABLOCKGUI::createMenus()
1362 int aMenuId, subMenuId,aMenuIdMain;
1364 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1366 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1367 createMenu( actionId(_newAct), aMenuId );
1368 createMenu( actionId(_importAct), aMenuId );
1369 createMenu( _saveAct, aMenuId );
1372 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1373 createMenu( _newAct, aMenuDocId );//, 10
1374 createMenu( _importAct, aMenuDocId );
1375 createMenu( _saveAct, aMenuDocId );
1377 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1378 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1379 createMenu( _addVertex, subMenuId );
1380 createMenu( _addEdge, subMenuId );
1381 createMenu( _addQuad, subMenuId );
1382 createMenu( _addHexa, subMenuId );
1383 createMenu( _sep1, subMenuId);
1386 createMenu( _addVector, subMenuId );
1387 // createMenu( _addCylinder, subMenuId );
1388 // createMenu( _addPipe, subMenuId );
1390 createMenu( _sep2, subMenuId);
1392 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1393 createMenu( _makeHemiSphere,subMenuId );
1395 createMenu( _sep3, subMenuId);
1397 createMenu( _makeCylinder, subMenuId );
1398 createMenu( _makePipe, subMenuId );
1399 createMenu( _makeCylinders,subMenuId );
1400 createMenu( _makePipes, subMenuId );
1402 // Pattern Data Edition
1403 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1404 createMenu( _removeHexa, subMenuId );
1405 createMenu( _prismQuad, subMenuId );
1406 createMenu( _joinQuad, subMenuId );
1407 createMenu( _merge, subMenuId );
1408 createMenu( _disconnect, subMenuId );
1409 createMenu( _cutEdge, subMenuId );
1410 createMenu( _makeTransformation, subMenuId );
1411 createMenu( _makeSymmetry, subMenuId );
1412 createMenu( _performTransformation, subMenuId );
1413 createMenu( _performSymmetry, subMenuId );
1414 createMenu( _replaceHexa, subMenuId );
1415 createMenu( _quadRevolution, subMenuId );
1416 createMenu( _sep4, aMenuId );
1417 createMenu( _showModelInfoAct, aMenuId );
1420 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1421 createMenu( _addShapeAct, aMenuId );
1422 createMenu( _assocVertex, aMenuId );
1423 createMenu( _assocEdge, aMenuId );
1424 createMenu( _assocQuad, aMenuId );
1427 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1428 createMenu( _addGroup, aMenuId );
1429 createMenu( _removeGroup, aMenuId ); //CS_TODO
1432 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1433 createMenu( _addLaw, aMenuId );
1434 createMenu( _removeLaw, aMenuId );
1435 createMenu( _setPropagation, aMenuId );
1436 createMenu( _computeMesh, aMenuId );
1438 //show model infomation menu
1439 QString aRule = "$component={'HEXABLOCK'}";
1440 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1441 popupMgr()->setRule( _showModelInfoAct, aRule);
1443 //associate shape to a document menu
1444 popupMgr()->insert( _addShapeAct, -1, -1 );
1445 popupMgr()->setRule( _addShapeAct, aRule );
1447 //-------------------------------------------------
1449 //-------------------------------------------------
1450 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1451 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1452 // QString isNotEmpty("numberOfNodes <> 0");
1453 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1454 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1455 //// aType = aType.arg( mesh_part );
1457 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1458 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1459 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1461 // popupMgr()->insert( separator(), -1, -1 );
1462 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1463 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1464 // // MESSAGE("aClient = " << aClient.toStdString());
1465 // // MESSAGE("aType = " << aType.toStdString());
1466 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1467 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1468 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1469 // // MESSAGE("aRule = " << aRule.toStdString());
1470 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1471 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1473 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1474 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1476 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1477 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1479 // popupMgr()->insert( separator(), -1, -1 );
1483 void HEXABLOCKGUI::createTools()
1487 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1488 createTool( _newAct, aToolId );
1489 createTool( _importAct, aToolId );
1490 createTool( _saveAct, aToolId );
1491 createTool( _showModelInfoAct, aToolId );
1492 // createTool( _testAct, aToolId );
1493 //createTool( separator(), aToolId );
1496 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1497 createTool( _addVertex, aToolId );
1498 createTool( _addEdge, aToolId );
1499 createTool( _addQuad, aToolId );
1500 createTool( _addHexa, aToolId );
1502 createTool( _sep1, aToolId );
1505 createTool( _addVector, aToolId );
1506 // createTool( _addCylinder, aToolId );
1507 // createTool( _addPipe, aToolId );
1509 createTool( _sep2, aToolId );
1511 createTool( _makeGrid, aToolId );
1512 createTool( _makeHemiSphere, aToolId );
1514 createTool( _sep3, aToolId );
1516 createTool( _makeCylinder, aToolId );
1517 createTool( _makePipe, aToolId );
1518 createTool( _makeCylinders,aToolId );
1519 createTool( _makePipes, aToolId );
1521 // Pattern Data Edition
1522 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1523 createTool( _removeHexa, aToolId );
1524 createTool( _prismQuad, aToolId );
1525 createTool( _joinQuad, aToolId );
1526 createTool( _merge, aToolId );
1527 createTool( _disconnect, aToolId );
1528 createTool( _cutEdge, aToolId );
1529 createTool( _makeTransformation, aToolId );
1530 createTool( _makeSymmetry, aToolId );
1531 createTool( _performTransformation, aToolId );
1532 createTool( _performSymmetry, aToolId );
1533 createTool( _replaceHexa, aToolId );
1534 createTool( _quadRevolution, aToolId );
1537 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1538 createTool( _assocVertex, aToolId );
1539 createTool( _assocEdge, aToolId );
1540 createTool( _assocQuad, aToolId );
1541 createTool( _addShapeAct, aToolId );
1544 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1545 createTool( _addGroup, aToolId );
1546 createTool( _removeGroup, aToolId ); //CS_TODO
1549 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1550 createTool( _addLaw, aToolId );
1551 createTool( _removeLaw, aToolId );
1552 createTool( _setPropagation, aToolId );
1553 createTool( _computeMesh, aToolId );
1557 void HEXABLOCKGUI::initialMenus()
1559 showDocumentMenus( true );
1560 showPatternMenus( false );
1561 showAssociationMenus( false );
1562 showGroupsMenus( false );
1563 showMeshMenus( false );
1566 void HEXABLOCKGUI::showAllMenus()
1568 showDocumentMenus( true );
1569 showPatternMenus( true );
1570 showAssociationMenus( true );
1571 showGroupsMenus( true );
1572 showMeshMenus( true );
1575 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1577 enableDocumentMenus( enable );
1578 enablePatternMenus( enable );
1579 enableAssociationMenus( enable );
1580 enableGroupsMenus( enable );
1581 enableMeshMenus( enable );
1583 menusEnabled = enable;
1586 void HEXABLOCKGUI::showDocumentMenus(bool show)
1588 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1590 setMenuShown(_newAct, show);
1591 setToolShown(_newAct, show);
1592 setMenuShown(_importAct, show);
1593 setToolShown(_importAct, show);
1594 setMenuShown(_showModelInfoAct, show);
1595 setToolShown(_showModelInfoAct, show);
1596 setMenuShown(_saveAct, show);
1597 setToolShown(_saveAct, show);
1600 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1602 _newAct->setEnabled(enable);
1603 // setToolShown(_newAct, enable);
1605 _importAct->setEnabled(enable);
1606 // setToolShown(_importAct, enable);
1608 _showModelInfoAct->setEnabled(enable);
1609 // setToolShown(_showModelInfoAct, enable);
1611 _saveAct->setEnabled(enable);
1612 // setToolShown(_saveAct, enable);
1616 void HEXABLOCKGUI::showPatternMenus(bool show)
1618 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1619 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1620 if ( show && !getCurrentModel() ) return;
1622 setMenuShown(_addVertex, show );
1623 setToolShown(_addVertex, show);
1624 setMenuShown(_addEdge, show );
1625 setToolShown(_addEdge, show);
1626 setMenuShown(_addQuad, show );
1627 setToolShown(_addQuad, show);
1628 setMenuShown(_addHexa, show );
1629 setToolShown(_addHexa, show);
1631 setMenuShown(_sep1, show );
1632 setToolShown(_sep1, show);
1634 setMenuShown( _addVector, show );
1635 setToolShown( _addVector, show);
1636 // setMenuShown( _addCylinder, show );
1637 // setToolShown( _addCylinder, show);
1638 // setMenuShown( _addPipe, show );
1639 // setToolShown( _addPipe, show);
1641 setMenuShown(_sep2, show );
1642 setToolShown(_sep2, show);
1644 setMenuShown( _makeGrid, show );
1645 setToolShown( _makeGrid, show);
1646 setMenuShown( _makePipe, show );
1647 setToolShown( _makePipe, show);
1649 setMenuShown(_sep3, show );
1650 setToolShown(_sep3, show);
1652 setMenuShown( _makeCylinder, show );
1653 setToolShown( _makeCylinder, show);
1654 setMenuShown( _makeCylinders, show );
1655 setToolShown( _makeCylinders, show);
1656 setMenuShown( _makePipes, show );
1657 setToolShown( _makePipes, show);
1658 setMenuShown( _makeHemiSphere, show );
1659 setToolShown( _makeHemiSphere, show);
1661 // Pattern Data Edition
1662 setMenuShown( _removeHexa, show );
1663 setToolShown( _removeHexa, show);
1664 setMenuShown( _prismQuad, show );
1665 setToolShown( _prismQuad, show);
1666 setMenuShown( _joinQuad, show );
1667 setToolShown( _joinQuad, show);
1668 setMenuShown( _merge, show );
1669 setToolShown( _merge, show);
1670 setMenuShown( _disconnect, show );
1671 setToolShown( _disconnect, show);
1672 setMenuShown( _cutEdge, show );
1673 setToolShown( _cutEdge, show);
1674 setMenuShown( _makeTransformation, show );
1675 setToolShown( _makeTransformation, show);
1676 setMenuShown( _makeSymmetry, show );
1677 setToolShown( _makeSymmetry, show);
1678 setMenuShown( _performTransformation, show );
1679 setToolShown( _performTransformation, show);
1680 setMenuShown( _performSymmetry, show );
1681 setToolShown( _performSymmetry, show);
1682 setMenuShown( _replaceHexa, show );
1683 setToolShown( _replaceHexa, show);
1684 setMenuShown( _quadRevolution, show );
1685 setToolShown( _quadRevolution, show);
1687 setMenuShown( _sep4, show );
1688 setMenuShown( _showModelInfoAct, show );
1691 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1693 if ( enable && !getCurrentModel() ) return;
1695 _addVertex->setEnabled(enable);
1696 // setToolShown(_addVertex, enable);
1698 _addEdge->setEnabled(enable);
1699 // setToolShown(_addEdge, enable);
1701 _addQuad->setEnabled(enable);
1702 // setToolShown(_addQuad, enable);
1704 _addHexa->setEnabled(enable);
1705 // setToolShown(_addHexa, enable);
1707 // setMenuShown(_sep1, enable );
1708 // setToolShown(_sep1, enable);
1710 _addVector->setEnabled(enable);
1711 // setToolShown( _addVector, enable);
1713 // setMenuShown(_sep2, enable );
1714 // setToolShown(_sep2, enable);
1716 _makeGrid->setEnabled(enable);
1717 // setToolShown( _makeGrid, enable);
1719 _makePipe->setEnabled(enable);
1720 // setToolShown( _makePipe, enable);
1722 // setMenuShown(_sep3, enable );
1723 // setToolShown(_sep3, enable);
1725 _makeCylinder->setEnabled(enable);
1726 // setToolShown( _makeCylinder, enable);
1728 _makeCylinders->setEnabled(enable);
1729 // setToolShown( _makeCylinders, enable);
1731 _makePipes->setEnabled(enable);
1732 // setToolShown( _makePipes, enable);
1734 _makeHemiSphere->setEnabled(enable);
1735 // setToolShown( _makeHemiSphere, enable);
1737 // Pattern Data Edition
1738 _removeHexa->setEnabled(enable);
1739 // setToolShown( _removeHexa, enable);
1741 _prismQuad->setEnabled(enable);
1742 // setToolShown( _prismQuad, enable);
1744 _joinQuad->setEnabled(enable);
1745 // setToolShown( _joinQuad, enable);
1747 _merge->setEnabled(enable);
1748 // setToolShown( _merge, enable);
1750 _disconnect->setEnabled(enable);
1751 // setToolShown( _disconnect, enable);
1753 _cutEdge->setEnabled(enable);
1754 // setToolShown( _cutEdge, enable);
1756 _makeTransformation->setEnabled(enable);
1757 // setToolShown( _makeTransformation, enable);
1759 _makeSymmetry->setEnabled(enable);
1760 // setToolShown( _makeSymmetry, enable);
1762 _performTransformation->setEnabled(enable);
1763 // setToolShown( _performTransformation, enable);
1765 _performSymmetry->setEnabled(enable);
1766 // setToolShown( _performSymmetry, enable);
1768 _replaceHexa->setEnabled(enable);
1769 // setToolShown( _replaceHexa, enable);
1771 _quadRevolution->setEnabled(enable);
1772 // setToolShown( _quadRevolution, enable);
1774 // setMenuShown( _sep4, enable );
1775 _showModelInfoAct->setEnabled(enable);
1779 void HEXABLOCKGUI::showAssociationMenus(bool show)
1781 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1782 if ( show && !getCurrentModel() ) return;
1784 // Association Edition
1785 setMenuShown( _assocVertex, show );
1786 setToolShown( _assocVertex, show );
1788 setMenuShown( _assocEdge, show );
1789 setToolShown( _assocEdge, show );
1791 setMenuShown( _assocQuad, show );
1792 setToolShown( _assocQuad, show );
1794 setMenuShown( _addShapeAct, show );
1795 setToolShown( _addShapeAct, show );
1798 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1800 if ( enable && !getCurrentModel() )
1803 // Association Edition
1804 _assocVertex->setEnabled(enable);
1805 // setToolShown( _assocVertex, enable );
1807 _assocEdge->setEnabled(enable);
1808 // setToolShown( _assocEdge, enable );
1810 _assocQuad->setEnabled(enable);
1811 // setToolShown( _assocQuad, enable );
1813 _addShapeAct->setEnabled(enable);
1814 // setToolShown( _addShapeAct, enable );
1817 void HEXABLOCKGUI::showGroupsMenus(bool show)
1819 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1820 if ( show && !getCurrentModel() ) return;
1821 setMenuShown( _addGroup, show );
1822 setToolShown( _addGroup, show);
1823 setMenuShown( _removeGroup , show );
1824 setToolShown( _removeGroup , show);
1827 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1829 if ( enable && !getCurrentModel() )
1832 _addGroup->setEnabled(enable);
1833 // setToolShown( _addGroup, enable);
1835 _removeGroup->setEnabled(enable);
1836 // setToolShown( _removeGroup , enable);
1839 void HEXABLOCKGUI::showMeshMenus(bool show)
1841 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1842 if ( show && !getCurrentModel() ) return;
1843 setMenuShown( _addLaw, show );
1844 setToolShown( _addLaw, show);
1845 setMenuShown( _removeLaw, show );
1846 setToolShown( _removeLaw, show);;
1847 setMenuShown( _setPropagation, show );
1848 setToolShown( _setPropagation, show);
1849 setMenuShown( _computeMesh, show);
1850 setToolShown( _computeMesh, show);
1853 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1855 if ( enable && !getCurrentModel() )
1858 _addLaw->setEnabled(enable);
1859 // setToolShown( _addLaw, enable);
1861 _removeLaw->setEnabled(enable);
1862 // setToolShown( _removeLaw, enable);
1864 _setPropagation->setEnabled(enable);
1865 // setToolShown( _setPropagation, enable);
1867 _computeMesh->setEnabled(enable);
1868 // setToolShown( _computeMesh, enable);
1871 void HEXABLOCKGUI::showVtkActor()
1873 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1874 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1875 currentVtkGView->getDocumentActor() == NULL)
1878 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1879 if (vtkView == NULL)
1882 SUIT_ViewManager* vman = vtkView->getViewManager();
1883 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1885 //show only the current actor -----------------
1886 vtkView->setFocus();
1887 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1888 Document_Actor *lastDocActor;
1889 if (lastVtkDocGView != NULL)
1891 lastDocActor = lastVtkDocGView->getDocumentActor();
1892 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1893 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1895 vtkView->Erase(lastActorIO);
1896 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1897 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1900 currentVtkGView->update();
1901 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1902 if (!anIO.IsNull() && anIO->hasEntry())
1904 vtkView->Display(anIO);
1905 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1906 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1908 vtkView->onFitAll();
1911 void HEXABLOCKGUI::showOccActor()
1913 if (currentOccGView == NULL)
1915 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1916 if (occView == NULL)
1918 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1922 if (lastOccPrs != NULL)
1923 vf->Erase(lastOccPrs);
1924 currentOccGView->globalSelection();
1925 SOCC_Prs* prs = getOccPrs(currentDocGView);
1926 currentOccGView->setPrs(prs);
1929 occView->onFitAll();
1932 void HEXABLOCKGUI::hideVtkActor()
1934 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1935 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1936 currentVtkGView->getViewWindow() == NULL ||
1937 currentVtkGView->getDocumentActor() == NULL) return;
1939 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1940 currentVtkGView->getViewWindow()->onResetView();
1942 //update the visibility state now
1943 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1944 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1945 if (aStudy == NULL || vman == NULL) return;
1947 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1948 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1949 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1952 void HEXABLOCKGUI::hideOccActor()
1954 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1955 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1956 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1957 if (occView == NULL || docModel == NULL)
1959 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1963 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1964 if (currentOccPrs != NULL)
1965 vf->Erase(currentOccPrs);
1967 occView->onResetView();
1970 void HEXABLOCKGUI::showOnlyActor()
1976 void HEXABLOCKGUI::hideActor()
1983 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1985 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1987 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1988 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1990 if (_dwPattern) _dwPattern->setVisible(isVisible);
1991 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1993 if (_dwMesh) _dwMesh->setVisible(isVisible);
1994 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1996 if (_dwGroups) _dwGroups->setVisible(isVisible);
1997 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
2001 //clear all used dialogs by the current model
2002 void HEXABLOCKGUI::clearDialogs()
2004 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
2005 fin (currentModelDialogs.end());
2006 for(;debut!=fin;++debut) (*debut)->clear();
2008 currentModelDialogs.clear(); //empty the used dialogs list
2011 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
2013 if (!gViewDlgBox.contains(dgview)) return NULL;
2014 return gViewDlgBox[dgview];
2017 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
2019 if (dgview == NULL) return;
2021 switchOffGraphicView(dgview, false); //to avoid double connect
2024 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2025 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
2026 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2027 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2028 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2029 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2030 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2031 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2032 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2033 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2034 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2035 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2040 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2042 if (dgview == NULL) return;
2044 //disconnect signals
2045 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2046 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2047 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2048 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2049 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2050 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2051 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2052 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2053 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2054 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2055 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2056 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2059 gViewDlgBox[dgview] = currentDialog;
2061 //close opened dialog
2062 if (currentDialog != NULL) currentDialog->close();
2063 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2069 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2071 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2075 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2079 //switch off the current document graphic view (disconnect signals...)
2080 if (currentDocGView != NULL)
2082 //Hide current actor
2084 switchOffGraphicView(currentDocGView);
2087 //clear the dialogs used by the current model so they can be used by the new model
2088 if (currentDocGView != dgview) clearDialogs();
2090 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2091 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2092 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2093 _groupsTreeView->setModel(dgview->getGroupsModel());
2094 _meshTreeView->setModel(dgview->getMeshModel());
2096 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2097 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2099 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2100 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2102 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2103 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2105 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2106 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2108 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2109 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2112 // = * init occ view * =
2113 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2115 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2116 currentOccGView->getViewWindow()->installEventFilter(this);
2121 // = * init vtk view * =
2122 if (currentDocGView != NULL)
2124 if (currentDocGView->getViewWindow() != NULL)
2125 dgview->setViewWindow(currentDocGView->getViewWindow());
2128 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2129 dgview->getViewWindow()->installEventFilter(this);
2135 switchOnGraphicView(dgview);
2137 if (currentDocGView != NULL)
2139 lastVtkDocGView = currentDocGView;
2140 lastOccPrs = getOccPrs(currentDocGView);
2144 lastVtkDocGView = dgview;
2145 lastOccPrs = getOccPrs(dgview);
2148 currentDocGView = dgview;
2150 currentDocGView->getDocumentModel()->refresh();
2151 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2154 setAllMenusEnabled(true);
2157 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2159 if (currentDocGView == NULL) return NULL;
2160 return currentDocGView->getDocumentModel();
2164 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2166 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2167 if (anApp == NULL) return UNKNOWN;
2168 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2169 if (activeVm == NULL) return UNKNOWN;
2171 QString vmType = activeVm->getType();
2172 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2174 else if ( vmType == OCCViewer_Viewer::Type() )
2180 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2182 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2186 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2189 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2191 // Create Document from HEXABLOCK ENGINE
2192 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2193 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2195 // looking doc impl ( c++ )
2196 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2197 // ^Hexa6 ASSERT( dServant );
2198 // ^Hexa6 if ( dServant)
2199 // ^Hexa6 doc = dServant->GetImpl();
2201 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2202 QString docEntry = addDocInStudy (doc);
2204 // looking for docEntry
2205 /* ****************************************************************
2206 if ( !CORBA::is_nil(docIn) ){
2207 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2208 QString docIOR = anIOR.in();
2209 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2210 if ( !docIOR.isEmpty() ) {
2211 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2213 docEntry = SO->GetID().c_str();
2216 **************************************************************** */
2217 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2219 return make_pair (docEntry, doc);
2223 void HEXABLOCKGUI::newDocument()
2225 DEBTRACE("HEXABLOCKGUI::newDocument");
2228 QMainWindow *aParent = application()->desktop();
2229 QWidget *central = aParent->centralWidget();
2231 central->setFocus();
2233 DEBTRACE("No Central Widget");
2236 if (currentOccGView == NULL)
2238 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2239 application()->desktop());
2240 currentOccGView->getViewWindow()->installEventFilter(this);
2242 else if (currentOccGView->getViewWindow() == NULL)
2244 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2245 currentOccGView->getViewWindow()->installEventFilter(this);
2249 // Create Document from HEXABLOCK ENGINE
2250 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2252 VtkDocumentGraphicView* newGraphicView = NULL;
2253 //One document at a time
2254 if (currentDocGView != NULL)
2256 if (currentDocGView->getViewWindow() == NULL)
2258 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2259 currentDocGView->getViewWindow()->installEventFilter(this);
2262 // Create a new document with the current window
2263 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2264 new DocumentModel( docEntry_Doc.second,
2265 docEntry_Doc.first, this ),
2266 currentDocGView->getViewWindow(),
2267 application()->desktop() );
2271 // Create the new Document Graphic View with a new window
2272 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2273 new DocumentModel( docEntry_Doc.second,
2274 docEntry_Doc.first, this ),
2275 graphicViewsHandler->createVtkWindow(),
2276 application()->desktop() );
2277 newGraphicView->getViewWindow()->installEventFilter(this);
2280 if (newGraphicView == NULL)
2281 //We couldn't create a new document graphic view
2282 //we'd better show a dialog box info to inform the user
2285 docs[docEntry_Doc.first] = newGraphicView;
2286 switchModel(newGraphicView); //select the corresponding document in the browser instead
2288 getApp()->updateObjectBrowser();
2293 //Loads the model from the xmlFile in the current graphic view
2294 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2296 DEBTRACE("HEXABLOCKGUI::loadDocument");
2299 QMainWindow *aParent = application()->desktop();
2300 QString selectedFile;
2302 if ( inFile.isNull() ){
2303 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2304 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2305 dialog.setHistory( getQuickDirList() );
2307 //use the last path as default
2308 if (!(loadDocLastPath->absolutePath()).isEmpty())
2309 dialog.setDirectory(*loadDocLastPath);
2312 QStringList selectedFiles = dialog.selectedFiles();
2313 if (!selectedFiles.isEmpty())
2314 selectedFile = selectedFiles.first();
2316 //remember the selected path
2317 *loadDocLastPath = dialog.directory();
2320 selectedFile = inFile;
2322 if (selectedFile.isEmpty())
2325 //we create a new document if necessary
2326 if (currentDocGView == NULL)
2327 //Need a new document
2329 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2331 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2332 currentDocGView->getViewWindow()->installEventFilter(this);
2335 if (!currentDocGView->isEmpty())
2336 //we can only have one document for a graphic view
2339 //we load the selected file in the current graphic view
2340 currentDocGView->loadDocument(selectedFile);
2341 DocumentModel* currentModel = getCurrentModel();
2342 renameObject( currentModel->documentEntry(), currentModel->getName() );
2347 void HEXABLOCKGUI::saveDocument()
2349 QMainWindow *aParent = application()->desktop();
2351 QString aDocName = "document", aFilename;
2353 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2354 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2356 //use the last selected directory as default path for file selection
2357 aFilename = saveDocLastPath->absolutePath();
2358 if (!aFilename.isEmpty())
2359 aFilename += QString("/") + aDocName;
2361 //show the dialog for file selection
2362 aFilename = SUIT_FileDlg::getFileName( aParent,
2365 tr( "Save HexaBlock Document" ),
2368 //save the document in the selected file
2369 if ( !aFilename.isEmpty() ) {
2370 getCurrentVtkGraphicView()->saveDocument( aFilename );
2372 //Remember the path for next save
2373 QFileInfo fileInfo(aFilename);
2374 *saveDocLastPath = fileInfo.dir();
2380 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2382 _patternDataTreeView->openPersistentEditor( topLeft );
2385 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2387 if (diag == NULL || _dwInputPanel == NULL ||
2388 getCurrentVtkGraphicView() == NULL) return;
2390 //mark this dialog as used by the current model
2391 currentModelDialogs.insert(diag);
2393 //close the current dialog box info
2394 // if (_treeViewDelegate != NULL)
2395 // _treeViewDelegate->closeDialog();
2397 // if (_dwInputPanel->widget())
2398 // _dwInputPanel->widget()->close();
2400 //Temporary for debugging EdgeAssoc Faked InfoDialog
2401 if (diag == _edgeAssocDiag)
2402 diag->debugEdgeAssoc = true;
2404 diag->debugEdgeAssoc = false;
2406 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2407 diag == _quadAssocDiag || diag == _addShapeDiag)
2408 assocInProgress = true;
2410 assocInProgress = false;
2412 //show the dialog box in the dockwidget
2413 diag->resetSizeAndShow(_dwInputPanel);
2415 //clear the current selections
2416 selectionMgr()->clearSelected();
2418 currentDialog = diag;
2421 if (currentDocGView != NULL)
2422 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2425 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2427 if (vertex == NULL || _dwInputPanel == NULL)
2430 if (_vertexInfoDialog == NULL)
2431 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2433 _vertexInfoDialog->setValue(vertex);
2434 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2435 currentDialog = _vertexInfoDialog;
2438 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2440 if (edge == NULL || _dwInputPanel == NULL)
2443 if (_edgeInfoDialog == NULL)
2444 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2446 _edgeInfoDialog->setValue(edge);
2447 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2448 currentDialog = _edgeInfoDialog;
2451 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2453 if (quad == NULL || _dwInputPanel == NULL)
2456 if (_quadInfoDialog == NULL)
2457 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2459 _quadInfoDialog->setValue(quad);
2460 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2461 currentDialog = _quadInfoDialog;
2464 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2466 if (hexa == NULL || _dwInputPanel == NULL)
2469 if (_hexaInfoDialog == NULL)
2470 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2472 _hexaInfoDialog->setValue(hexa);
2473 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2474 currentDialog = _hexaInfoDialog;
2477 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2479 if (vector == NULL || _dwInputPanel == NULL)
2482 if (_vectorInfoDialog == NULL)
2483 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2485 _vectorInfoDialog->setValue(vector);
2486 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2487 currentDialog = _vectorInfoDialog;
2490 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2492 if (group == NULL || _dwInputPanel == NULL)
2495 if (_groupInfoDialog == NULL)
2496 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2498 _groupInfoDialog->setValue(group);
2499 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2500 currentDialog = _groupInfoDialog;
2503 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2505 if (law == NULL || _dwInputPanel == NULL)
2508 if (_lawInfoDialog == NULL)
2509 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2511 _lawInfoDialog->setValue(law);
2512 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2513 currentDialog = _lawInfoDialog;
2516 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2518 if (propagation == NULL || _dwInputPanel == NULL)
2521 if (_propagationInfoDialog == NULL)
2522 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2524 _propagationInfoDialog->setValue(propagation);
2525 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2526 currentDialog = _propagationInfoDialog;
2529 void HEXABLOCKGUI::addVertex()
2531 if ( !_vertexDiag ){
2532 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2534 _showDialogBox( _vertexDiag );
2537 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2538 if (_vertexDiag != NULL && doc != NULL)
2539 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2542 void HEXABLOCKGUI::addEdge()
2545 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2547 _showDialogBox( _edgeDiag );
2550 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2551 if (_edgeDiag != NULL && doc != NULL)
2552 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2555 void HEXABLOCKGUI::addQuad()
2558 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2561 _showDialogBox( _quadDiag );
2564 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2565 if (_quadDiag != NULL && doc != NULL)
2566 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2569 void HEXABLOCKGUI::addHexa()
2572 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2574 _showDialogBox( _hexaDiag );
2577 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2578 if (_hexaDiag != NULL && doc != NULL)
2579 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2582 void HEXABLOCKGUI::addVector()
2584 if ( !_vectorDiag ){
2585 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2587 _showDialogBox( _vectorDiag );
2590 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2591 if (_vectorDiag != NULL && doc != NULL)
2592 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2595 //void HEXABLOCKGUI::addCylinder()
2597 // if ( !_cylinderDiag ){
2598 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2600 // _showDialogBox( _cylinderDiag );
2602 // //set default name
2603 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2604 // if (_cylinderDiag != NULL && doc != NULL)
2605 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2609 //void HEXABLOCKGUI::addPipe()
2611 // if ( !_pipeDiag){
2612 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2614 // _showDialogBox( _pipeDiag );
2616 // //set default name
2617 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2618 // if (_pipeDiag != NULL && doc != NULL)
2619 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2623 void HEXABLOCKGUI::makeGrid()
2625 if ( !_makeGridDiag ){
2626 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2628 _showDialogBox( _makeGridDiag );
2632 void HEXABLOCKGUI::makeCylinder()
2634 if ( !_makeCylinderDiag ){
2635 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2637 _showDialogBox( _makeCylinderDiag );
2640 void HEXABLOCKGUI::makePipe()
2642 if ( !_makePipeDiag ){
2643 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2645 _showDialogBox( _makePipeDiag );
2648 void HEXABLOCKGUI::makeCylinders()
2650 if ( !_makeCylindersDiag ){
2651 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2653 _showDialogBox( _makeCylindersDiag );
2656 void HEXABLOCKGUI::makePipes()
2658 if ( !_makePipesDiag ){
2659 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2661 _showDialogBox( _makePipesDiag );
2665 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2667 if ( !_makeHemiSphereDiag ){
2668 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2670 _showDialogBox( _makeHemiSphereDiag );
2674 void HEXABLOCKGUI::removeHexa()
2676 if ( !_removeHexaDiag ){
2677 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2679 _showDialogBox( _removeHexaDiag );
2683 void HEXABLOCKGUI::prismQuad()
2685 if ( !_prismQuadDiag ){
2686 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2688 _showDialogBox( _prismQuadDiag );
2692 void HEXABLOCKGUI::joinQuad()
2694 if ( !_joinQuadDiag ){
2695 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2697 _showDialogBox( _joinQuadDiag );
2700 void HEXABLOCKGUI::merge()
2703 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2705 _showDialogBox( _mergeDiag );
2708 void HEXABLOCKGUI::disconnectElts()
2710 if ( !_disconnectDiag ){
2711 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2713 _showDialogBox( _disconnectDiag );
2716 void HEXABLOCKGUI::cutEdge()
2718 if ( !_cutEdgeDiag ){
2719 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2721 _showDialogBox( _cutEdgeDiag );
2724 void HEXABLOCKGUI::makeTransformation()
2726 if ( !_makeTransformationDiag ){
2727 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2729 _showDialogBox( _makeTransformationDiag );
2733 void HEXABLOCKGUI::makeSymmetry()
2735 if ( !_makeSymmetryDiag ){
2736 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2738 _showDialogBox( _makeSymmetryDiag );
2742 void HEXABLOCKGUI::performTransformation()
2744 if ( !_performTransformationDiag ){
2745 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2747 _showDialogBox( _performTransformationDiag );
2751 void HEXABLOCKGUI::performSymmetry()
2753 if ( !_performSymmetryDiag ){
2754 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2756 _showDialogBox( _performSymmetryDiag );
2760 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2762 if ( !_replaceHexaDiag ){
2763 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2765 _showDialogBox( _replaceHexaDiag );
2769 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2771 if ( !_quadRevolutionDiag ){
2772 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2774 _showDialogBox( _quadRevolutionDiag );
2778 void HEXABLOCKGUI::assocVertex()
2780 if (!_dwInputPanel) return;
2781 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2782 if ( !_vertexAssocDiag )
2783 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2784 _showDialogBox( _vertexAssocDiag );
2788 void HEXABLOCKGUI::assocEdge()
2790 if ( !_edgeAssocDiag )
2791 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2792 _showDialogBox( _edgeAssocDiag );
2795 void HEXABLOCKGUI::assocQuad()
2797 if ( !_quadAssocDiag )
2798 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2799 _showDialogBox( _quadAssocDiag );
2803 void HEXABLOCKGUI::addGroup()
2806 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2808 _showDialogBox( _groupDiag );
2809 if (_groupDiag != NULL && getCurrentModel() != NULL)
2811 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2812 if (doc == NULL) return;
2813 char defaultName[16];
2814 sprintf (defaultName, "g%04d", doc->countGroup());
2815 _groupDiag->name_le->setText(defaultName);
2819 void HEXABLOCKGUI::removeGroup()
2821 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2822 if (currentDGView == NULL) return;
2824 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2825 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2826 int nbGroupsRemoved = 0;
2829 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2830 tr( "No group selected!" ) );
2834 foreach( QModelIndex selected, l ){
2835 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2836 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2837 Q_ASSERT(selected.isValid());
2839 //Confirm the deletion of the group
2840 if (SUIT_MessageBox::question(
2843 tr("Remove group : %1 ?").arg(selected.data().toString()),
2844 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2845 SUIT_MessageBox::Cancel
2846 ) == SUIT_MessageBox::Cancel) return;
2848 bool removed = getCurrentModel()->removeGroup( selected );
2850 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2851 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2857 if (!nbGroupsRemoved)
2858 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2859 tr( "No group selected!" ) );
2862 void HEXABLOCKGUI::addLaw()
2865 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2867 _showDialogBox( _lawDiag );
2868 if (_lawDiag != NULL && getCurrentModel() != NULL)
2870 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2871 if (doc == NULL) return;
2872 char defaultName[16];
2873 sprintf (defaultName, "l%04d", doc->countLaw());
2874 _lawDiag->name_le->setText(defaultName);
2878 void HEXABLOCKGUI::removeLaw()
2880 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2881 if (currentDGView == NULL) return;
2883 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2884 int nbLawsRemoved = 0;
2887 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2888 tr( "No law selected!" ) );
2892 foreach( QModelIndex selected, l ){
2893 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2894 selected = currentDGView->getMeshModel()->mapToSource( selected );
2895 Q_ASSERT(selected.isValid());
2897 //Confirm the deletion of the law
2898 if (SUIT_MessageBox::question(
2901 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2902 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2903 SUIT_MessageBox::Cancel
2904 ) == SUIT_MessageBox::Cancel) return;
2906 bool removed = getCurrentModel()->removeLaw(selected);
2908 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2909 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2916 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2917 tr( "No law selected!" ) );
2922 void HEXABLOCKGUI::setPropagation()
2924 if ( !_propagationDiag )
2925 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2927 _showDialogBox( _propagationDiag );
2930 // Dialog box to compute a mesh from a document
2931 // --------------------------------------------
2932 void HEXABLOCKGUI::computeMesh()
2934 if ( !_computeMeshDiag )
2935 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2937 _showDialogBox( _computeMeshDiag );
2940 void HEXABLOCKGUI::clearAssociations()
2942 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2943 if (currentDGView == NULL) return;
2945 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2946 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2947 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2949 getCurrentModel()->clearEltAssociations(iModel);
2951 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2954 void HEXABLOCKGUI::showModelInfo()
2956 //create the info dialog if not yet
2957 if (_modelInfoDiag == NULL)
2958 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2960 //show the model informations dialog
2961 _showDialogBox( _modelInfoDiag );
2964 void HEXABLOCKGUI::addShape()
2966 //create the info dialog if not yet
2967 if (_addShapeDiag == NULL)
2968 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2970 //show the model informations dialog
2971 _showDialogBox( _addShapeDiag );
2974 void HEXABLOCKGUI::clearAllAssociations()
2976 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2977 if (currentDGView == NULL) return;
2979 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2980 if (!currentIndex.isValid()) return;
2981 QVariant currentAssocVariant;
2982 QString currentAssocEntry;
2984 //Confirm the deletion of the associations
2985 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2986 if ( !treeVariant.isValid() ) return;
2987 int eltType = treeVariant.toInt();
2988 QString typeStr = "";
2989 HEXA_NS::EnumElt hexaType;
2990 if (eltType == VERTEX_DIR_TREE)
2992 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2993 hexaType = HEXA_NS::EL_VERTEX;
2995 else if (eltType == EDGE_DIR_TREE)
2997 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2998 hexaType = HEXA_NS::EL_EDGE;
3000 else if (eltType == QUAD_DIR_TREE)
3002 typeStr = tr("TREE_ITEM_QUAD").toUpper();
3003 hexaType = HEXA_NS::EL_QUAD;
3006 if (SUIT_MessageBox::question(
3008 tr("CLEAR_ASSOCIATIONS"),
3009 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
3010 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
3011 SUIT_MessageBox::Cancel
3012 ) == SUIT_MessageBox::Cancel) return;
3015 DocumentModel* docModel = getCurrentModel();
3016 if (docModel == NULL) return;
3017 docModel->clearAssociation(hexaType);
3020 void HEXABLOCKGUI::showAssociations()
3022 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3023 if (currentDGView == NULL) return;
3025 QModelIndexList elts;
3026 int currentChildIndex = 0;
3027 QVariant currentAssocVariant;
3028 QString currentAssocEntry;
3029 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
3030 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
3032 while( currentChild.isValid() ) {
3034 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3035 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3036 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3037 elts << currentChild;
3039 currentChild = currentChild.sibling(currentChildIndex++, 0);
3041 currentDocGView->highlight(elts);
3042 currentOccGView->highlight(elts, false);
3046 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3048 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3050 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3055 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3057 if ( event->type() == QEvent::Enter )
3058 { // *** ENTER EVENT
3060 if (currentDialog == NULL || !currentDialog->isVisible())
3061 return QObject::eventFilter(obj, event);
3063 // ** The window acquire the focus when the cursor enter
3065 //OCC - window enter
3066 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3067 if ( occWindow != NULL)
3068 currentDialog->onWindowActivated(occWindow->getViewManager());
3070 //VTK - window enter
3072 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3073 if ( vtkWindow != NULL)
3074 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3078 //standard event processing
3079 return QObject::eventFilter(obj, event);
3082 QStringList HEXABLOCKGUI::getQuickDirList()
3084 QStringList dirList;
3085 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3087 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3093 // --- Export the module
3097 HEXABLOCK_EXPORT CAM_Module* createModule()
3099 return new HEXABLOCKGUI();
3102 HEXABLOCK_EXPORT char* getModuleVersion()
3104 return (char*)HEXABLOCK_VERSION_STR;
3110 // ******************** TESTS ***************************************************
3112 void HEXABLOCKGUI::testDocument()
3116 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3117 // QStandardItem *myItem = new QStandardItem("MyItem");
3118 // parentItem->appendRow(myItem);
3120 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3121 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3122 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3123 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3124 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3125 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3126 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3127 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3130 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3131 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3132 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3133 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3134 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3135 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3137 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3138 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3139 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3140 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3145 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3146 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3147 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3148 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3156 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3157 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3159 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3160 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3164 // newMesh( "toto", 3, "FactoryServer");
3168 void HEXABLOCKGUI::test_make_cart_grid()
3170 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3171 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3172 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3173 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3174 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3175 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3177 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3178 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3185 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3186 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3187 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3188 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3189 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3190 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3195 void HEXABLOCKGUI::test_make_elmts_transform()
3202 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3203 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3206 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3207 // orig.setScalar(2);
3209 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3210 // getCurrentModel()->saveVtk(file_name)
3212 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3213 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3215 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3216 // getCurrentModel()->saveVtk(file_name)
3218 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3221 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3222 // getCurrentModel()->saveVtk(file_name);
3225 // print "...test make elements by transforming elements OK"
3227 // =============================================================== addDocInSudy
3228 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3232 if (document == NULL)
3235 QString docName = document->getName ();
3237 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3238 if (app_study == NULL)
3241 _PTR(Study) study = app_study->studyDS();
3242 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3243 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3244 QString entry = app_study->centry("HEXABLOCK");
3245 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3246 if (aFatherSO->_is_nil())
3249 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3252 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3253 docEntry = aSO->GetID(); //the entry of the published object
3258 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3260 void HEXABLOCKGUI::test()
3262 DEBTRACE("HEXABLOCKGUI::test");
3263 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3264 if (currentDGView == NULL) return;
3265 currentDGView->update();
3269 void HEXABLOCKGUI::test_association()
3271 DEBTRACE("HEXABLOCKGUI::test_association");
3274 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3276 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3277 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3278 DocumentModel::GeomObj q0AssocA, q0AssocB;
3280 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3281 QList<DocumentModel::GeomObj> e1Assocs_test;
3282 DocumentModel::GeomObj q0Assoc_test;
3284 v0 = getCurrentModel()->addVertex(0, 0, 0);
3285 v1 = getCurrentModel()->addVertex(1, 0, 0);
3286 v2 = getCurrentModel()->addVertex(1, 1, 0);
3287 v3 = getCurrentModel()->addVertex(0, 1, 0);
3288 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3289 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3290 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3293 // >>> face3.GetEntry()'0:1:4'
3294 // >>> e1.GetEntry()'0:1:8'
3295 // >>> e2.GetEntry()'0:1:9'
3296 // >>> e3.GetEntry()'0:1:10'
3297 // >>> e4.GetEntry()'0:1:11'
3298 // >>> v1.GetEntry()'0:1:12'
3299 // >>> v2.GetEntry()'0:1:13'
3300 // >>> v3.GetEntry()'0:1:14'
3301 // >>> v4.GetEntry()'0:1:15'
3304 // v0Assoc.name = "geomV0";
3305 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3306 // v0Assoc.brep = "brepV0";
3307 // v1Assoc.name = "geomV1";
3308 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3309 // v1Assoc.brep = "brepV1";
3310 // v2Assoc.name = "geomV2";
3311 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3312 // v2Assoc.brep = "brepV2";
3313 // v3Assoc.name = "geomV3";
3314 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3315 // v3Assoc.brep = "brepV3";
3319 // e0AssocA.name = "geomE0a";
3320 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3321 // e0AssocA.brep = "brepE0a";
3322 // e0AssocA.start = 0.10;
3323 // e0AssocA.end = 0.95;
3327 // e1AssocA.name = "geomE1a";
3328 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3329 // e1AssocA.brep = "brepE1a";
3330 // e1AssocA.start = 0.12;
3331 // e1AssocA.end = 0.89;
3332 // e1AssocB.name = "geomE1b";
3333 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3334 // e1AssocB.brep = "brepE1b";
3335 // e1AssocB.start = 0.20;
3336 // e1AssocB.end = 0.80;
3337 // e1AssocC.name = "geomE1c";
3338 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3339 // e1AssocC.brep = "brepE1c";
3340 // e1AssocC.start = 0.16;
3341 // e1AssocC.end = 0.96;
3343 // q0AssocA.name = "geomQuad";
3344 // q0AssocA.entry = "0:1:1:1:3";
3345 // q0AssocA.brep = "brepq0";
3347 // q0AssocB.name = "geomQuad";
3348 // q0AssocB.entry = "0:1:1:1:4";
3349 // q0AssocB.brep = "brepq0";
3351 // getCurrentModel()->addAssociation( v0, v0Assoc );
3352 // getCurrentModel()->addAssociation( v1, v1Assoc );
3353 // getCurrentModel()->addAssociation( v2, v2Assoc );
3354 // getCurrentModel()->addAssociation( v3, v3Assoc );
3357 // getCurrentModel()->addAssociation( e0, e0AssocA );
3359 // getCurrentModel()->addAssociation( e1, e1AssocA );
3360 // getCurrentModel()->addAssociation( e1, e1AssocB );
3361 // getCurrentModel()->addAssociation( e1, e1AssocC );
3363 // getCurrentModel()->addAssociation( q0, q0AssocA );
3364 // getCurrentModel()->addAssociation( q0, q0AssocB );
3370 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3371 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3372 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3373 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3374 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3375 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3376 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3377 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3378 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3379 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3380 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3381 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3384 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3385 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3386 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3387 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3388 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3389 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3390 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3391 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3392 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3393 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3394 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3395 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3396 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3398 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3399 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3400 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3403 DEBTRACE("HEXABLOCKGUI::test_association fin");