1 // Copyright (C) 2009-2014 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>
122 #define DW_MINIMUM_WIDTH 50
123 #define DWINPUT_MINIMUM_HEIGHT 50
124 #define DWINPUT_MINIMUM_WIDTH 50//255
127 using namespace HEXABLOCK::GUI;
129 int HEXABLOCKGUI::_oldStudyId = -1;
131 // HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
133 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
134 OccGraphicView* HEXABLOCKGUI::currentOccGView = NULL;
135 bool HEXABLOCKGUI::assocInProgress = false;
136 SalomeApp_Application* HEXABLOCKGUI::myApplication = NULL;
138 HEXABLOCKGUI::HEXABLOCKGUI() :
139 SalomeApp_Module( "HEXABLOCK" ),
140 // LightApp_Module( "HEXABLOCK" ),
148 _patternDataTreeView(0),
149 // _patternBuilderTreeView(0),
150 _patternGeomTreeView(0),
153 // _treeViewDelegate(0),
155 moduleActivatedOnce(false),
165 _makeCylinderDiag(0),
167 _makeCylindersDiag(0),
175 _makeTransformationDiag(0),
176 _makeSymmetryDiag(0),
177 _performTransformationDiag(0),
178 _performSymmetryDiag(0),
187 _quadRevolutionDiag(0),
188 _makeHemiSphereDiag(0),
189 _modelInfoDiag(NULL),
191 _vertexInfoDialog(NULL),
192 _edgeInfoDialog(NULL),
193 _quadInfoDialog(NULL),
194 _hexaInfoDialog(NULL),
195 _vectorInfoDialog(NULL),
196 _groupInfoDialog(NULL),
197 _lawInfoDialog(NULL),
198 _propagationInfoDialog(NULL),
201 lastVtkDocGView(NULL)
203 DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
205 graphicViewsHandler = new GraphicViewsHandler();
206 loadDocLastPath = new QDir();
207 saveDocLastPath = new QDir();
208 hexa_root = HEXA_NS::Hex::getInstance ();
211 HEXABLOCKGUI::~HEXABLOCKGUI()
216 SalomeApp_Study* HEXABLOCKGUI::activeStudy()
218 SUIT_Application* app = SUIT_Session::session()->activeApplication();
220 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
226 // Gets an reference to the module's engine
227 /****************************************************
228 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
230 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
231 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr clr = HEXABLOCK_ORB::HEXABLOCK_Gen::_narrow(comp);
232 ASSERT(!CORBA::is_nil(clr));
235 **************************************************** */
237 void HEXABLOCKGUI::initialize( CAM_Application* app )
239 MESSAGE("HEXABLOCKGUI::initialize");
240 DEBTRACE("HEXABLOCKGUI::initialize");
241 SalomeApp_Module::initialize( app );
243 // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
245 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
247 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
248 setResource(aResourceMgr);
250 createAndFillDockWidget();
257 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
259 DEBTRACE("HEXABLOCKGUI::viewManagers");
260 // list.append( QxScene_Viewer::Type() );
261 // list.append( OCCViewer_Viewer::Type() );
262 // list.append( SVTK_Viewer::Type() );
266 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
268 DEBTRACE("HEXABLOCKGUI::activateModule");
270 /*HexaBlock can be launched in only one application*/
271 if (myApplication == NULL)
272 //remember the first application
273 myApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
275 //application verification: if it's not the one known by HexaBlock,
276 //leave without activating
277 SalomeApp_Application* currentApplication = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
278 if (myApplication != currentApplication) return false;
280 bool bOk = SalomeApp_Module::activateModule( theStudy );
281 if ( !bOk ) return false;
283 showDockWidgets(true);
285 connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
286 this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
287 connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
288 this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
290 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
292 SUIT_ViewManager* vm;
293 ViewManagerList OCCViewManagers, VTKViewManagers;
295 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
296 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
297 while ( itOCC.hasNext() && (vm = itOCC.next()) )
298 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
300 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
301 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
302 while ( itVTK.hasNext() && (vm = itVTK.next()) )
303 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
306 SALOME_ListIO selected;
307 sm->selectedObjects( selected );
310 // disable OCC selectors
311 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
312 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
313 while ( itOCCSel.hasNext() )
314 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
315 sr->setEnabled(true);
317 // disable VTK selectors
318 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
319 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
320 while ( itVTKSel.hasNext() )
321 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
322 sr->setEnabled(true);
324 sm->setSelectedObjects( selected, true ); //NPAL 19674
326 //connect close signal to vtk view manager
327 vm = getApp()->getViewManager(SVTK_Viewer::Type(), false);
330 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
331 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
334 //connect close signal to occ view manager
335 vm = getApp()->getViewManager(OCCViewer_Viewer::Type(), false);
338 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
339 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
342 /* ************************************ TODO Hexa6
343 _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
344 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
345 if ( _PTR(Study) aStudy = s->studyDS()) {
346 _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
347 updateObjBrowser(); // objects can be removed
349 ************************************ */
351 if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
352 currentOccGView->getViewWindow()->installEventFilter(this);
354 if (currentDocGView != NULL)
356 switchModel(currentDocGView);
359 if (currentDocGView->getViewWindow() != NULL)
360 currentDocGView->getViewWindow()->installEventFilter(this);
372 bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
374 disconnect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
375 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
376 disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
377 this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
379 SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
380 if ( vtkView != NULL)
382 //default selectionMode in VTKView
383 vtkView->SetSelectionMode( ActorSelection );
384 vtkView->removeEventFilter(this);
388 OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
391 //defaut selectionMode in OccView
392 selectionMgr()->clearSelected();
393 currentOccGView->globalSelection();
394 occView->removeEventFilter(this);
398 qDeleteAll(myOCCSelectors);
399 myOCCSelectors.clear();
400 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
402 qDeleteAll(myVTKSelectors);
403 myVTKSelectors.clear();
404 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
406 bool bOk = SalomeApp_Module::deactivateModule( theStudy );
408 //switch off current document graphic view
409 switchOffGraphicView(currentDocGView);
412 setMenuShown( false );
413 setToolShown( false );
414 showDockWidgets( false );
416 _dwInputPanel->close();
423 SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
425 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
426 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
427 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
428 int aStudyID = theStudy->StudyId();
429 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
430 return aDSStudy._retn();
433 void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
434 QMap<QString, QString>& docShapesEntry,
435 QMap<QString, QString>& docShapesName)
437 if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
438 return; //there's nothing to publish in this case
440 SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
441 if(!appStudy) return;
442 _PTR(Study) aStudy = appStudy->studyDS();
443 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
444 SALOMEDS::StudyBuilder_var aBuilder (aDSStudy->NewBuilder());
445 QString entry = currentDocGView->getDocumentModel()->documentEntry();
446 SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
447 if (aFatherSO->_is_nil())
450 // * get a presentation
451 bool isNewPrs = false;
452 SOCC_Prs* prs = getOccPrs(currentDocGView);
455 prs = new SOCC_Prs();
459 // * init the presentation with the given shapes
460 QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
461 while (i != topo_shapes.constEnd())
463 QString shapeName = i.key();
464 TopoDS_Shape shapeValue = i.value();
465 Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
466 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
467 QString objStudyEntry = aSO->GetID(); //the entry of the published object
468 Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
469 "HEXABLOCK", shapeName.toStdString().c_str());
470 ais_shape->SetOwner(io);
471 prs->AddObject(ais_shape);
472 aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
473 docShapesEntry[shapeName] = objStudyEntry;
474 docShapesName[objStudyEntry] = shapeName;
475 currentOccGView->addShape(objStudyEntry, ais_shape);
476 i++; //handle next shape
480 prs->AddObject(currentOccGView->getPreviewShape());
482 occPrs[currentDocGView] = prs;
483 getApp()->updateObjectBrowser();
488 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
490 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
491 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
492 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
494 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
498 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
502 // Pas de renommage des shapes pour le moment, juste les documents
503 VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
504 if (dgview == NULL || dgview->getDocumentModel() == NULL)
507 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
508 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
513 _PTR(Study) aStudy = appStudy->studyDS();
518 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
519 _PTR(GenericAttribute) anAttr;
521 if ( obj->FindAttribute(anAttr, "AttributeName") ){
522 _PTR(AttributeName) aName (anAttr);
523 DocumentModel* docModel = dgview->getDocumentModel();
524 docModel->setName( name );
525 aName->SetValue( name.toLatin1().data() );
526 getApp()->updateObjectBrowser();
527 // _dwPattern->setWindowTitle( name );
534 // --- Default windows
535 void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
537 DEBTRACE("HEXABLOCKGUI::windows");
539 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
540 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
543 QString HEXABLOCKGUI::engineIOR() const
545 DEBTRACE("HEXABLOCKGUI::engineIOR");
547 /* ************************************ TODO Hexa6
548 CORBA::ORB_var anORB = getApp()->orb();
549 CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
550 return QString( anIOR.in() );
551 ************************************ */
555 VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
557 if (docs.count(studyObject->entry()) == 0)
559 //Object's document not acquired yet
560 VtkDocumentGraphicView* dgview;
561 HEXA_NS::Hex* directory = HEXA_NS::Hex::getInstance();
562 if (directory == NULL)
563 return NULL; //No working director found
565 //------------------ Load the document -----------------
566 HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
567 if (document == NULL)
568 return NULL; //No document found
570 DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
572 MESSAGE("Doc model creation failed!");
575 dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
576 if (dgview == NULL) return NULL;
578 //update the data tree
579 docs[studyObject->entry()] = dgview;
582 return docs[studyObject->entry()];
585 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
587 // ** we want to switch automatically to the right view windows
589 //first, find selected item
591 DataObjectList dol = getApp()->objectBrowser()->getSelected();
592 if (dol.isEmpty()) return;
593 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
594 if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
595 item->entry().isEmpty())
598 // find the document corresponding to it
599 VtkDocumentGraphicView* docGView = NULL;
600 if (docs.contains(item->entry()))
601 docGView = docs[item->entry()];
603 docGView = getOrCreateDocument(item);
605 //Init OCC if necessary
606 if (currentOccGView == NULL)
608 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
609 currentOccGView->getViewWindow()->installEventFilter(this);
611 else if (currentOccGView->getViewWindow() == NULL)
613 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
614 currentOccGView->getViewWindow()->installEventFilter(this);
617 //Init the vtk view if necessary
618 if (docGView->getViewWindow() == NULL)
620 if (currentDocGView == NULL || currentDocGView->getViewWindow() == NULL)
622 docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
623 docGView->getViewWindow()->installEventFilter(this);
626 setAllMenusEnabled(true);
629 docGView->setViewWindow(currentDocGView->getViewWindow());
631 if (docGView->getDocumentActor() == NULL)
635 if (docGView == NULL || docGView == currentDocGView)
641 //update the current document
642 switchModel(docGView);
646 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
648 DEBTRACE("HEXABLOCKGUI::onWindowActivated");
651 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
653 DEBTRACE("HEXABLOCKGUI::onWindowClosed");
655 //Decharger le model correspondant (VTK)
656 SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
660 if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
661 { //HexaBlock Vtk Window has been closed
663 if (currentDialog != NULL) currentDialog->close();
664 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
665 if (currentDocGView != NULL)
666 currentDocGView->setViewWindow(NULL);
669 setAllMenusEnabled(false);
670 enableDocumentMenus(true);
676 /*VtkDocumentGraphicView* dgview = graphicViewsHandler->getDocumentGraphicView(window);
677 if (dgview == NULL) return; //The window has no document to close
679 //Save the document? (Ask only if the document is not empty
680 int answerCode = SUIT_MessageBox::question(
683 tr("Save the document ?"),
684 SUIT_MessageBox::Yes | SUIT_MessageBox::Cancel,
685 SUIT_MessageBox::Cancel);
686 if ( answerCode == SUIT_MessageBox::Cancel) return; //abort closing
687 else if (answerCode == SUIT_MessageBox::Yes)
688 saveDocument(); //Save the document
690 // switchOffGraphicView(window); //disconnect all connected signals
691 // currentVtkView = NULL;
692 // graphicViewsHandler->closeDocumentGraphicView(window);
694 //create a new one (empty document)
696 // currentVtkView->setWindowTitle(tr("HEXABLOCK") + " : " + currentVtkView->windowTitle());
700 if (currentOccGView != NULL && svw == currentOccGView->getViewWindow())
702 if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear();
703 if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
704 if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
705 if (currentDialog != NULL) currentDialog->close();
706 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
708 currentOccGView->getViewWindow()->removeEventFilter(this);
709 currentOccGView->setViewWindow(NULL);
713 void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager* vm)
715 DEBTRACE("HEXABLOCKGUI::onViewManagerAdded");
717 connect( vm, SIGNAL( tryCloseView( SUIT_ViewWindow * ) ),
718 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
720 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
722 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
723 myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
724 // disable OCC selectors
725 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
726 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
727 while ( itOCCSel.hasNext() )
728 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
729 sr->setEnabled(true);
731 else if ( vm->getType() == SVTK_Viewer::Type() )
733 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
734 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
736 // disable VTK selectors
737 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
738 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
739 while ( itVTKSel.hasNext() )
740 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
741 sr->setEnabled(true);
745 void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
747 DEBTRACE("HEXABLOCKGUI::::onViewManagerRemoved");
749 SUIT_ViewModel* viewer = vm->getViewModel();
750 if (vm != NULL && vm->getType() == SVTK_Viewer::Type())
752 //VTK View Manager removed
753 if (getApp()->activeModule()->moduleName().compare("HEXABLOCK") == 0)
755 //Process only if it's our view manager
756 SUIT_ViewManager* myVm = NULL;
757 if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
758 myVm = currentDocGView->getViewWindow()->getViewManager();
762 //close opened dialog
763 if (currentDialog != NULL) currentDialog->close();
764 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
770 //remove its selector
771 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
772 while ( itVTKSel.hasNext() )
773 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
774 if ( sr->viewer() == viewer )
776 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
783 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
785 //OCC View removed: remove its selector
786 QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
787 while ( itOCCSel.hasNext() )
788 if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
789 if ( sr->viewer() == viewer )
791 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
797 void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
799 QModelIndexList l = selected.indexes();
800 if ( l.count() == 0 ) return;
801 if ( !l[0].isValid() ) return;
802 VtkDocumentGraphicView* currentGraphicView = getCurrentVtkGraphicView();
803 if ( currentGraphicView == NULL) return;
805 QTreeView* theTree = NULL;
806 if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
807 theTree = _patternDataTreeView;
809 /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
810 theTree = _patternBuilderTreeView;
812 else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
813 theTree = _patternGeomTreeView;
815 else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
816 theTree = _groupsTreeView;
817 } else if ( sender() == currentGraphicView->getMeshSelectionModel() ){
818 theTree = _meshTreeView;
821 theTree->scrollTo ( l[0] );
825 bool HEXABLOCKGUI::createSComponent() //addComponent
827 DEBTRACE("HEXABLOCKGUI::createSComponent");
828 // --- Find or create (if not done yet) "HEXABLOCK" SComponent in the study
830 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
831 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
832 _PTR(GenericAttribute) anAttr;
833 _PTR(AttributeName) aName;
834 _PTR(AttributeGraphic) aGraphic;
836 _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
837 if ( !aComponent ){ //Create hexablock component if there's not one yet
838 aComponent = aBuilder->NewComponent("HEXABLOCK");
839 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
840 aName = _PTR(AttributeName) (anAttr);
841 aName->SetValue(getApp()->moduleTitle("HEXABLOCK").toStdString());
843 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
844 _PTR(AttributePixMap) aPixmap(anAttr);
845 aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
847 aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
848 DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
854 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
856 DEBTRACE("HEXABLOCKGUI::setResource");
857 _myresource = new HEXABLOCKGUI_Resource(r);
858 _myresource->preferencesChanged();
861 void HEXABLOCKGUI::createPreferences()
863 DEBTRACE("HEXABLOCKGUI::createPreferences");
864 _myresource->createPreferences(this);
867 void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name )
869 DEBTRACE("HEXABLOCKGUI::preferencesChanged");
870 _myresource->preferencesChanged(sect, name);
871 // if(name=="userCatalog")
872 // _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
875 void HEXABLOCKGUI::studyActivated() //CS_TODO
877 int newStudyId = getApp()->activeStudy()->id();
878 DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
879 // if (_oldStudyId != -1)
881 // _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
882 // if (_studyContextMap.count(newStudyId))
884 // DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
885 // QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
889 // DEBTRACE("no switch to null context");
892 _oldStudyId = newStudyId;
895 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
897 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
898 QVariant currentAssocVariant;
899 QString currentAssocEntry;
901 currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
902 currentAssocEntry = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
903 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
904 QMenu menu( _patternDataTreeView );
906 QAction *clearAct = menu.addAction( "Remove association(s)" );
907 connect( clearAct, SIGNAL(triggered()), this, SLOT(clearAssociations()), Qt::UniqueConnection );
908 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
912 VtkDocumentGraphicView* currentVtkGraphicView = getCurrentVtkGraphicView();
913 if (currentVtkGraphicView == NULL) return;
914 QStandardItem *item = currentVtkGraphicView->getPatternDataModel()->itemFromIndex(currentIndex);
916 //We don't do anything for single items
917 if ( item->type() == VERTEXITEM || item->type() == EDGEITEM ||
918 item->type() == QUADITEM || item->type() == HEXAITEM)
921 //No associations for HEXA
922 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
923 if ( !treeVariant.isValid() ) return;
924 int eltType = treeVariant.toInt();
925 if (eltType == HEXA_DIR_TREE) return;
926 QMenu menu( _patternDataTreeView );
928 //Show association(s)
929 QAction *showAssocAct = menu.addAction( "Show associations" );
930 connect( showAssocAct, SIGNAL(triggered()), this, SLOT(showAssociations()), Qt::UniqueConnection );
932 //Clear all associations
933 QAction *clearAllAssocAct = menu.addAction( "Remove all associations" );
934 connect( clearAllAssocAct, SIGNAL(triggered()), this, SLOT(clearAllAssociations()), Qt::UniqueConnection );
936 menu.exec( _patternDataTreeView->mapToGlobal( aPosition) );
941 void HEXABLOCKGUI::createAndFillDockWidget()
944 QMainWindow *aParent = application()->desktop();
946 // Create dock widget (3 dock)
948 //1) *********** user input panel ( contain user's edit dialog box )
949 _dwInputPanel = new QDockWidget(aParent);
950 _dwInputPanel->setVisible(false);
951 _dwInputPanel->setWindowTitle("Input Panel");
952 _dwInputPanel->setObjectName("hexablockInputPanelDock");
953 // _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
955 // _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
957 //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
959 _dwPattern = new QDockWidget(aParent);
960 _dwPattern->setVisible(false);
961 _dwPattern->setWindowTitle("Model");
962 _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
963 _dwPattern->setObjectName("hexablockModelDock");
965 QFrame* patternFrame = new QFrame(_dwPattern);
966 patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
967 QVBoxLayout* patternLayout = new QVBoxLayout(patternFrame);
968 patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
969 QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
970 _patternDataTreeView = new QTreeView(patternFrame);//_dwPattern);
971 // _patternBuilderTreeView = new QTreeView(patternFrame); // ---> TO REMOVE
972 _patternGeomTreeView = new QTreeView(patternFrame);
973 splitter->addWidget(_patternDataTreeView);
974 // splitter->addWidget(_patternBuilderTreeView); // ---> TO REMOVE
975 splitter->addWidget(_patternGeomTreeView);
976 patternLayout->addWidget(splitter);
978 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
979 _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
980 // _patternDataTreeView->setItemDelegate(_treeViewDelegate);
983 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
984 // _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
986 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
987 _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
989 _dwPattern->setWidget(patternFrame);
990 patternFrame->show();
993 _dwGroups = new QDockWidget(aParent);
995 _dwGroups->setVisible(false);
996 _dwGroups->setWindowTitle("Groups");
997 _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
998 _dwGroups->setObjectName("hexablockGroupsDock");
999 _groupsTreeView = new QTreeView(_dwGroups);
1000 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1001 // _groupsTreeView->setItemDelegate(_treeViewDelegate);
1002 _dwGroups->setWidget(_groupsTreeView);
1003 _groupsTreeView->show();
1006 _dwMesh = new QDockWidget(aParent);
1007 _dwMesh->setVisible(false);
1008 _dwMesh->setWindowTitle("Mesh");
1009 _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1010 _dwMesh->setObjectName("hexablockMeshDock");
1011 _meshTreeView = new QTreeView(_dwMesh);
1012 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
1013 _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
1014 // _meshTreeView->setItemDelegate(_treeViewDelegate);
1015 _dwMesh->setWidget(_meshTreeView);
1016 _meshTreeView->show();
1018 // QDockWidget *_dwObjectBrowser = 0;
1019 QWidget* wid = getApp()->objectBrowser()->treeView();
1020 QWidget *w = wid->parentWidget();
1021 while ( w && !_dwObjectBrowser ) {
1022 _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
1023 w = w->parentWidget();
1025 _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
1026 _dwObjectBrowser->setWindowTitle("Study");
1028 // dock widget position
1029 aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
1030 aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
1032 // aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
1033 // aParent->tabifyDockWidget( _dwGroups, _dwPattern );
1034 // aParent->tabifyDockWidget( _dwMesh, _dwGroups );
1036 aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
1037 aParent->tabifyDockWidget( _dwPattern, _dwGroups );
1038 aParent->tabifyDockWidget( _dwGroups, _dwMesh );
1040 #if QT_VERSION >= 0x040500
1041 aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
1044 // popup menu on data tree view
1045 _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
1046 connect(_patternDataTreeView,
1047 SIGNAL(customContextMenuRequested(const QPoint &)),
1049 SLOT(treeContextMenu(const QPoint &)),
1050 Qt::UniqueConnection );
1053 void HEXABLOCKGUI::createActions()
1055 QMainWindow *aParent = application()->desktop();
1056 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1059 _newAct = createAction(_menuId++,
1060 tr("Create a new document"),
1061 resMgr->loadPixmap("HEXABLOCK", tr("ICON_NEW_DOCUMENT")),
1063 tr("Create a new document"),
1064 0, aParent, false, this, SLOT(newDocument()));
1065 _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1067 _importAct = createAction(_menuId++,
1068 tr("Load a document"),
1069 resMgr->loadPixmap("HEXABLOCK", tr("ICON_LOAD_DOCUMENT")),
1070 tr("Load Document"),
1071 tr("Load a document"),
1072 0, aParent, false, this, SLOT(loadDocument()));
1073 _importAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O); // --- QKeySequence::Open ambiguous in SALOME
1075 _saveAct = createAction(_menuId++,
1076 tr("Save the document"),
1077 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SAVE_DOCUMENT")),
1078 tr("Save Document"),
1079 tr("Save the document"),
1080 0, aParent, false, this, SLOT(saveDocument()));
1082 // Pattern Data creation
1083 _addVertex = createAction(_menuId++,
1084 tr("Create a vertex"),
1085 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_VERTEX")),
1087 tr("Create a new vertex"),
1088 0, aParent, false, this, SLOT(addVertex()));
1090 _addEdge = createAction(_menuId++,
1091 tr("Create an edge"),
1092 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_EDGE")),
1094 tr("Create a new edge"),
1095 0, aParent, false, this, SLOT(addEdge()));
1097 _addQuad = createAction(_menuId++,
1098 tr("Create a quadrangle"),
1099 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_QUAD")),
1100 tr("Add Quadrangle"),
1101 tr("Create a new quadrangle"),
1102 0, aParent, false, this, SLOT(addQuad()));
1104 _addHexa = createAction(_menuId++,
1105 tr("Create an hexahedron"),
1106 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_HEXA")),
1107 tr("Add Hexahedron"),
1108 tr("Create a new hexahedron"),
1109 0, aParent, false, this, SLOT(addHexa()));
1111 // Builder Data creation
1112 _addVector = createAction(_menuId++,
1113 tr("Create a vector"),
1114 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_ADD_VECTOR")),
1116 tr("Create a new vector"),
1117 0, aParent, false, this, SLOT(addVector()));
1119 // _addCylinder = createAction(_menuId++,
1120 // tr("Create a cylinder"),
1121 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
1122 // tr("Add Cylinder"),
1123 // tr("Create a new cylinder"),
1124 // 0, aParent, false, this, SLOT(addCylinder()));
1126 // _addPipe = createAction(_menuId++,
1127 // tr("Create a pipe"),
1128 // resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
1130 // tr("Create a new pipe"),
1131 // 0, aParent, false, this, SLOT(addPipe()));
1133 _makeGrid = createAction(_menuId++,
1135 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_GRID")),
1138 0, aParent, false, this, SLOT(makeGrid()));
1140 _makeCylinder = createAction(_menuId++,
1141 tr("Make a cylinder"),
1142 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDER")),
1143 tr("Make Cylinder"),
1144 tr("Make a cylinder"),
1145 0, aParent, false, this, SLOT(makeCylinder()));
1147 _makePipe = createAction(_menuId++,
1149 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPE")),
1152 0, aParent, false, this, SLOT(makePipe()));
1154 _makeCylinders = createAction(_menuId++,
1155 tr("Make cylinders"),
1156 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_CYLINDERS")),
1157 tr("Make Cylinders"),
1158 tr("Make cylinders"),
1159 0, aParent, false, this, SLOT(makeCylinders()));
1161 _makePipes = createAction(_menuId++,
1163 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_PIPES")),
1166 0, aParent, false, this, SLOT(makePipes()));
1168 _makeHemiSphere = createAction(_menuId++,
1169 tr("Make an hemisphere"),
1170 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
1171 tr("Make Hemisphere"),
1172 tr("Make an hemisphere"),
1173 0, aParent, false, this, SLOT(makeHemiSphere()));
1175 // Pattern Data edition
1176 _removeHexa = createAction(_menuId++,
1177 tr("Remove hexahedra"),
1178 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_HEXA")),
1179 tr("Remove Hexahedra"),
1180 tr("Remove hexahedra"),
1181 0, aParent, false, this, SLOT(removeHexa()));
1183 _prismQuad = createAction(_menuId++,
1184 tr("Prism quadrangles"),
1185 resMgr->loadPixmap( "HEXABLOCK", tr("ICON_PRISM_QUAD")),
1186 tr("Prism Quadrangles"),
1187 tr("Prism quadrangles"),
1188 0, aParent, false, this, SLOT(prismQuad()));
1190 _joinQuad = createAction(_menuId++,
1191 tr("Join quadrangles"),
1192 resMgr->loadPixmap("HEXABLOCK", tr("ICON_JOIN_QUAD")),
1193 tr("Join Quadrangles"),
1194 tr("Join quadrangles with hexahedra"),
1195 0, aParent, false, this, SLOT(joinQuad()));
1197 _merge = createAction(_menuId++,
1199 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MERGE")),
1202 0, aParent, false, this, SLOT(merge()));
1204 _disconnect = createAction(_menuId++,
1206 resMgr->loadPixmap("HEXABLOCK", tr("ICON_DISCONNECT")),
1208 tr("Disconnect edges, vertexes or quadrangles"),
1209 0, aParent, false, this, SLOT(disconnectElts()));
1211 _cutEdge = createAction(_menuId++,
1213 resMgr->loadPixmap("HEXABLOCK", tr("ICON_CUT_EDGE")),
1216 0, aParent, false, this, SLOT(cutEdge()));
1218 _makeTransformation = createAction(_menuId++,
1219 tr("Make transformation"),
1220 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_TRANSFORMATION")),
1221 tr("Make Transformation"),
1222 tr("Make transformation"),
1223 0, aParent, false, this, SLOT(makeTransformation()));
1225 _makeSymmetry = createAction(_menuId++,
1226 tr("Make symmetry"),
1227 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_SYMMETRY")),
1228 tr("Make Symmetry"),
1229 tr("Make symmetry"),
1230 0, aParent, false, this, SLOT(makeSymmetry()));
1232 _performTransformation = createAction(_menuId++,
1233 tr("Perform transformation"),
1234 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_TRANSFORMATION")),
1235 tr("Perform Transformation"),
1236 tr("Perform transformation"),
1237 0, aParent, false, this, SLOT(performTransformation()));
1239 _performSymmetry = createAction(_menuId++,
1240 tr("Perform symmetry"),
1241 resMgr->loadPixmap("HEXABLOCK", tr("ICON_PERFORM_SYMMETRY")),
1242 tr("Perform Symmetry"),
1243 tr("Perform symmetry"),
1244 0, aParent, false, this, SLOT(performSymmetry()));
1246 _replaceHexa = createAction(_menuId++,
1247 tr("Replace hexahedron"),
1248 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REPLACE_HEXA")),
1249 tr("Replace Hexahedron"),
1250 tr("Replace hexahedron"),
1251 0, aParent, false, this, SLOT(replaceHexa()));
1253 _quadRevolution = createAction(_menuId++,
1254 tr("Quad revolution"),
1255 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_REVOLUTION")),
1256 tr("Quad Revolution"),
1257 tr("Quad revolution"),
1258 0, aParent, false, this, SLOT(quadRevolution()));
1261 _assocVertex = createAction(_menuId++,
1262 tr("Make vertex association"),
1263 resMgr->loadPixmap("HEXABLOCK", tr("ICON_VERTEX_ASSOCIATION")),
1264 tr("Make Vertex association"),
1265 tr("Make vertex association"),
1266 0, aParent, false, this, SLOT(assocVertex()));
1268 _assocEdge = createAction(_menuId++,
1269 tr("Make edge association"),
1270 resMgr->loadPixmap("HEXABLOCK", tr("ICON_EDGE_ASSOCIATION")),
1271 tr("Make Edge Association"),
1272 tr("Make edge association"),
1273 0, aParent, false, this, SLOT(assocEdge()));
1275 _assocQuad = createAction(_menuId++,
1276 tr("Make quad association"),
1277 resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
1278 tr("Make Quad Association"),
1279 tr("Make quad association"),
1280 0, aParent, false, this, SLOT(assocQuad()));
1283 _addGroup = createAction(_menuId++,
1285 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_GROUP")),
1288 0, aParent, false, this, SLOT(addGroup()));
1290 _removeGroup = createAction(_menuId++,
1291 tr("Remove a group"),
1292 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_GROUP")),
1294 tr("Remove a group"),
1295 0, aParent, false, this, SLOT(removeGroup()));
1298 _addLaw = createAction(_menuId++,
1300 resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_LAW")),
1303 0, aParent, false, this, SLOT(addLaw()));
1305 _removeLaw = createAction(_menuId++,
1307 resMgr->loadPixmap("HEXABLOCK", tr("ICON_REMOVE_LAW")),
1310 0, aParent, false, this, SLOT(removeLaw()));
1312 _setPropagation = createAction(_menuId++,
1313 tr("Set propagation"),
1314 resMgr->loadPixmap("HEXABLOCK", tr("ICON_SET_PROPAGATION")),
1315 tr("Set Propagation"),
1316 tr("Set propagation"),
1317 0, aParent, false, this, SLOT(setPropagation()));
1319 _computeMesh = createAction(_menuId++,
1321 resMgr->loadPixmap("HEXABLOCK", tr("ICON_COMPUTE_MESH")),
1324 0, aParent, false, this, SLOT(computeMesh()));
1326 _showModelInfoAct = createAction(_menuId++,
1327 tr("Show Model Info"),
1328 resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
1331 0, aParent, false, this, SLOT(showModelInfo()));
1333 _addShapeAct = createAction(_menuId++,
1335 resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
1338 0, aParent, false, this, SLOT(addShape()));
1340 // _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
1341 // QAction* createAction(const int id,
1342 // const QString& toolTip,
1343 // const QIcon& icon,
1344 // const QString& menu,
1345 // const QString& status,
1346 // const int shortCut,
1347 // QObject* parent =0,
1348 // bool checkable = false,
1349 // QObject* receiver =0,
1350 // const char* member =0);
1352 _sep1 = separator();
1353 _sep2 = separator();
1354 _sep3 = separator();
1355 _sep4 = separator();
1359 void HEXABLOCKGUI::createMenus()
1361 int aMenuId, subMenuId,aMenuIdMain;
1363 aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
1365 aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
1366 createMenu( actionId(_newAct), aMenuId );
1367 createMenu( actionId(_importAct), aMenuId );
1368 createMenu( _saveAct, aMenuId );
1371 int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
1372 createMenu( _newAct, aMenuDocId );//, 10
1373 createMenu( _importAct, aMenuDocId );
1374 createMenu( _saveAct, aMenuDocId );
1376 aMenuId = createMenu( tr("Model"), -1, -1, 30 );
1377 subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
1378 createMenu( _addVertex, subMenuId );
1379 createMenu( _addEdge, subMenuId );
1380 createMenu( _addQuad, subMenuId );
1381 createMenu( _addHexa, subMenuId );
1382 createMenu( _sep1, subMenuId);
1385 createMenu( _addVector, subMenuId );
1386 // createMenu( _addCylinder, subMenuId );
1387 // createMenu( _addPipe, subMenuId );
1389 createMenu( _sep2, subMenuId);
1391 createMenu( _makeGrid, subMenuId ); //Cartesian, Cylindrical, Spherical
1392 createMenu( _makeHemiSphere,subMenuId );
1394 createMenu( _sep3, subMenuId);
1396 createMenu( _makeCylinder, subMenuId );
1397 createMenu( _makePipe, subMenuId );
1398 createMenu( _makeCylinders,subMenuId );
1399 createMenu( _makePipes, subMenuId );
1401 // Pattern Data Edition
1402 subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
1403 createMenu( _removeHexa, subMenuId );
1404 createMenu( _prismQuad, subMenuId );
1405 createMenu( _joinQuad, subMenuId );
1406 createMenu( _merge, subMenuId );
1407 createMenu( _disconnect, subMenuId );
1408 createMenu( _cutEdge, subMenuId );
1409 createMenu( _makeTransformation, subMenuId );
1410 createMenu( _makeSymmetry, subMenuId );
1411 createMenu( _performTransformation, subMenuId );
1412 createMenu( _performSymmetry, subMenuId );
1413 createMenu( _replaceHexa, subMenuId );
1414 createMenu( _quadRevolution, subMenuId );
1415 createMenu( _sep4, aMenuId );
1416 createMenu( _showModelInfoAct, aMenuId );
1419 aMenuId = createMenu( tr("Association"), -1, -1, 30 );
1420 createMenu( _addShapeAct, aMenuId );
1421 createMenu( _assocVertex, aMenuId );
1422 createMenu( _assocEdge, aMenuId );
1423 createMenu( _assocQuad, aMenuId );
1426 aMenuId = createMenu( tr("Groups"), -1, -1, 30 );
1427 createMenu( _addGroup, aMenuId );
1428 createMenu( _removeGroup, aMenuId ); //CS_TODO
1431 aMenuId = createMenu( tr("Mesh "), -1, -1, 30 );
1432 createMenu( _addLaw, aMenuId );
1433 createMenu( _removeLaw, aMenuId );
1434 createMenu( _setPropagation, aMenuId );
1435 createMenu( _computeMesh, aMenuId );
1437 //show model infomation menu
1438 QString aRule = "$component={'HEXABLOCK'}";
1439 popupMgr()->insert( _showModelInfoAct, -1, -1 );
1440 popupMgr()->setRule( _showModelInfoAct, aRule);
1442 //associate shape to a document menu
1443 popupMgr()->insert( _addShapeAct, -1, -1 );
1444 popupMgr()->setRule( _addShapeAct, aRule );
1446 //-------------------------------------------------
1448 //-------------------------------------------------
1449 // QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
1450 // QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
1451 // QString isNotEmpty("numberOfNodes <> 0");
1452 // QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
1453 // QString aType = QString( "%1type in {%2}" ).arg( lc );
1454 //// aType = aType.arg( mesh_part );
1456 // aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
1457 // QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
1458 // QString aSelCount = QString( "%1 > 0" ).arg( dc );
1460 // popupMgr()->insert( separator(), -1, -1 );
1461 // QString aRule = "$component={'HEXABLOCK'}";/* and ( type='(" + aClient + " and " +
1462 // aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";*/
1463 // // MESSAGE("aClient = " << aClient.toStdString());
1464 // // MESSAGE("aType = " << aType.toStdString());
1465 // // MESSAGE("aSelCount = " << aSelCount.toStdString());
1466 // // MESSAGE("anActiveVTK = " << anActiveVTK.toStdString());
1467 // // MESSAGE("isNotEmpty = " << isNotEmpty.toStdString());
1468 // // MESSAGE("aRule = " << aRule.toStdString());
1469 // popupMgr()->insert( _showAct, -1, -1 ); // DISPLAY
1470 // popupMgr()->setRule( _showAct, aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
1472 // popupMgr()->insert( _hideAct, -1, -1 ); // ERASE
1473 // popupMgr()->setRule( _hideAct, aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
1475 // popupMgr()->insert( _showOnlyAct, -1, -1 ); // DISPLAY_ONLY
1476 // popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
1478 // popupMgr()->insert( separator(), -1, -1 );
1482 void HEXABLOCKGUI::createTools()
1486 aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
1487 createTool( _newAct, aToolId );
1488 createTool( _importAct, aToolId );
1489 createTool( _saveAct, aToolId );
1490 createTool( _showModelInfoAct, aToolId );
1491 // createTool( _testAct, aToolId );
1492 //createTool( separator(), aToolId );
1495 aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
1496 createTool( _addVertex, aToolId );
1497 createTool( _addEdge, aToolId );
1498 createTool( _addQuad, aToolId );
1499 createTool( _addHexa, aToolId );
1501 createTool( _sep1, aToolId );
1504 createTool( _addVector, aToolId );
1505 // createTool( _addCylinder, aToolId );
1506 // createTool( _addPipe, aToolId );
1508 createTool( _sep2, aToolId );
1510 createTool( _makeGrid, aToolId );
1511 createTool( _makeHemiSphere, aToolId );
1513 createTool( _sep3, aToolId );
1515 createTool( _makeCylinder, aToolId );
1516 createTool( _makePipe, aToolId );
1517 createTool( _makeCylinders,aToolId );
1518 createTool( _makePipes, aToolId );
1520 // Pattern Data Edition
1521 aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
1522 createTool( _removeHexa, aToolId );
1523 createTool( _prismQuad, aToolId );
1524 createTool( _joinQuad, aToolId );
1525 createTool( _merge, aToolId );
1526 createTool( _disconnect, aToolId );
1527 createTool( _cutEdge, aToolId );
1528 createTool( _makeTransformation, aToolId );
1529 createTool( _makeSymmetry, aToolId );
1530 createTool( _performTransformation, aToolId );
1531 createTool( _performSymmetry, aToolId );
1532 createTool( _replaceHexa, aToolId );
1533 createTool( _quadRevolution, aToolId );
1536 aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
1537 createTool( _assocVertex, aToolId );
1538 createTool( _assocEdge, aToolId );
1539 createTool( _assocQuad, aToolId );
1540 createTool( _addShapeAct, aToolId );
1543 aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
1544 createTool( _addGroup, aToolId );
1545 createTool( _removeGroup, aToolId ); //CS_TODO
1548 aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
1549 createTool( _addLaw, aToolId );
1550 createTool( _removeLaw, aToolId );
1551 createTool( _setPropagation, aToolId );
1552 createTool( _computeMesh, aToolId );
1556 void HEXABLOCKGUI::initialMenus()
1558 showDocumentMenus( true );
1559 showPatternMenus( false );
1560 showAssociationMenus( false );
1561 showGroupsMenus( false );
1562 showMeshMenus( false );
1565 void HEXABLOCKGUI::showAllMenus()
1567 showDocumentMenus( true );
1568 showPatternMenus( true );
1569 showAssociationMenus( true );
1570 showGroupsMenus( true );
1571 showMeshMenus( true );
1574 void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
1576 enableDocumentMenus( enable );
1577 enablePatternMenus( enable );
1578 enableAssociationMenus( enable );
1579 enableGroupsMenus( enable );
1580 enableMeshMenus( enable );
1582 menusEnabled = enable;
1585 void HEXABLOCKGUI::showDocumentMenus(bool show)
1587 DEBTRACE("HEXABLOCKGUI::showDocumentMenus " << show);
1589 setMenuShown(_newAct, show);
1590 setToolShown(_newAct, show);
1591 setMenuShown(_importAct, show);
1592 setToolShown(_importAct, show);
1593 setMenuShown(_showModelInfoAct, show);
1594 setToolShown(_showModelInfoAct, show);
1595 setMenuShown(_saveAct, show);
1596 setToolShown(_saveAct, show);
1599 void HEXABLOCKGUI::enableDocumentMenus(bool enable)
1601 _newAct->setEnabled(enable);
1602 // setToolShown(_newAct, enable);
1604 _importAct->setEnabled(enable);
1605 // setToolShown(_importAct, enable);
1607 _showModelInfoAct->setEnabled(enable);
1608 // setToolShown(_showModelInfoAct, enable);
1610 _saveAct->setEnabled(enable);
1611 // setToolShown(_saveAct, enable);
1615 void HEXABLOCKGUI::showPatternMenus(bool show)
1617 DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
1618 DEBTRACE("getCurrentModel() " << getCurrentModel() );
1619 if ( show && !getCurrentModel() ) return;
1621 setMenuShown(_addVertex, show );
1622 setToolShown(_addVertex, show);
1623 setMenuShown(_addEdge, show );
1624 setToolShown(_addEdge, show);
1625 setMenuShown(_addQuad, show );
1626 setToolShown(_addQuad, show);
1627 setMenuShown(_addHexa, show );
1628 setToolShown(_addHexa, show);
1630 setMenuShown(_sep1, show );
1631 setToolShown(_sep1, show);
1633 setMenuShown( _addVector, show );
1634 setToolShown( _addVector, show);
1635 // setMenuShown( _addCylinder, show );
1636 // setToolShown( _addCylinder, show);
1637 // setMenuShown( _addPipe, show );
1638 // setToolShown( _addPipe, show);
1640 setMenuShown(_sep2, show );
1641 setToolShown(_sep2, show);
1643 setMenuShown( _makeGrid, show );
1644 setToolShown( _makeGrid, show);
1645 setMenuShown( _makePipe, show );
1646 setToolShown( _makePipe, show);
1648 setMenuShown(_sep3, show );
1649 setToolShown(_sep3, show);
1651 setMenuShown( _makeCylinder, show );
1652 setToolShown( _makeCylinder, show);
1653 setMenuShown( _makeCylinders, show );
1654 setToolShown( _makeCylinders, show);
1655 setMenuShown( _makePipes, show );
1656 setToolShown( _makePipes, show);
1657 setMenuShown( _makeHemiSphere, show );
1658 setToolShown( _makeHemiSphere, show);
1660 // Pattern Data Edition
1661 setMenuShown( _removeHexa, show );
1662 setToolShown( _removeHexa, show);
1663 setMenuShown( _prismQuad, show );
1664 setToolShown( _prismQuad, show);
1665 setMenuShown( _joinQuad, show );
1666 setToolShown( _joinQuad, show);
1667 setMenuShown( _merge, show );
1668 setToolShown( _merge, show);
1669 setMenuShown( _disconnect, show );
1670 setToolShown( _disconnect, show);
1671 setMenuShown( _cutEdge, show );
1672 setToolShown( _cutEdge, show);
1673 setMenuShown( _makeTransformation, show );
1674 setToolShown( _makeTransformation, show);
1675 setMenuShown( _makeSymmetry, show );
1676 setToolShown( _makeSymmetry, show);
1677 setMenuShown( _performTransformation, show );
1678 setToolShown( _performTransformation, show);
1679 setMenuShown( _performSymmetry, show );
1680 setToolShown( _performSymmetry, show);
1681 setMenuShown( _replaceHexa, show );
1682 setToolShown( _replaceHexa, show);
1683 setMenuShown( _quadRevolution, show );
1684 setToolShown( _quadRevolution, show);
1686 setMenuShown( _sep4, show );
1687 setMenuShown( _showModelInfoAct, show );
1690 void HEXABLOCKGUI::enablePatternMenus(bool enable)
1692 if ( enable && !getCurrentModel() ) return;
1694 _addVertex->setEnabled(enable);
1695 // setToolShown(_addVertex, enable);
1697 _addEdge->setEnabled(enable);
1698 // setToolShown(_addEdge, enable);
1700 _addQuad->setEnabled(enable);
1701 // setToolShown(_addQuad, enable);
1703 _addHexa->setEnabled(enable);
1704 // setToolShown(_addHexa, enable);
1706 // setMenuShown(_sep1, enable );
1707 // setToolShown(_sep1, enable);
1709 _addVector->setEnabled(enable);
1710 // setToolShown( _addVector, enable);
1712 // setMenuShown(_sep2, enable );
1713 // setToolShown(_sep2, enable);
1715 _makeGrid->setEnabled(enable);
1716 // setToolShown( _makeGrid, enable);
1718 _makePipe->setEnabled(enable);
1719 // setToolShown( _makePipe, enable);
1721 // setMenuShown(_sep3, enable );
1722 // setToolShown(_sep3, enable);
1724 _makeCylinder->setEnabled(enable);
1725 // setToolShown( _makeCylinder, enable);
1727 _makeCylinders->setEnabled(enable);
1728 // setToolShown( _makeCylinders, enable);
1730 _makePipes->setEnabled(enable);
1731 // setToolShown( _makePipes, enable);
1733 _makeHemiSphere->setEnabled(enable);
1734 // setToolShown( _makeHemiSphere, enable);
1736 // Pattern Data Edition
1737 _removeHexa->setEnabled(enable);
1738 // setToolShown( _removeHexa, enable);
1740 _prismQuad->setEnabled(enable);
1741 // setToolShown( _prismQuad, enable);
1743 _joinQuad->setEnabled(enable);
1744 // setToolShown( _joinQuad, enable);
1746 _merge->setEnabled(enable);
1747 // setToolShown( _merge, enable);
1749 _disconnect->setEnabled(enable);
1750 // setToolShown( _disconnect, enable);
1752 _cutEdge->setEnabled(enable);
1753 // setToolShown( _cutEdge, enable);
1755 _makeTransformation->setEnabled(enable);
1756 // setToolShown( _makeTransformation, enable);
1758 _makeSymmetry->setEnabled(enable);
1759 // setToolShown( _makeSymmetry, enable);
1761 _performTransformation->setEnabled(enable);
1762 // setToolShown( _performTransformation, enable);
1764 _performSymmetry->setEnabled(enable);
1765 // setToolShown( _performSymmetry, enable);
1767 _replaceHexa->setEnabled(enable);
1768 // setToolShown( _replaceHexa, enable);
1770 _quadRevolution->setEnabled(enable);
1771 // setToolShown( _quadRevolution, enable);
1773 // setMenuShown( _sep4, enable );
1774 _showModelInfoAct->setEnabled(enable);
1778 void HEXABLOCKGUI::showAssociationMenus(bool show)
1780 DEBTRACE("HEXABLOCKGUI::showAssociationMenus" << show);
1781 if ( show && !getCurrentModel() ) return;
1783 // Association Edition
1784 setMenuShown( _assocVertex, show );
1785 setToolShown( _assocVertex, show );
1787 setMenuShown( _assocEdge, show );
1788 setToolShown( _assocEdge, show );
1790 setMenuShown( _assocQuad, show );
1791 setToolShown( _assocQuad, show );
1793 setMenuShown( _addShapeAct, show );
1794 setToolShown( _addShapeAct, show );
1797 void HEXABLOCKGUI::enableAssociationMenus(bool enable)
1799 if ( enable && !getCurrentModel() )
1802 // Association Edition
1803 _assocVertex->setEnabled(enable);
1804 // setToolShown( _assocVertex, enable );
1806 _assocEdge->setEnabled(enable);
1807 // setToolShown( _assocEdge, enable );
1809 _assocQuad->setEnabled(enable);
1810 // setToolShown( _assocQuad, enable );
1812 _addShapeAct->setEnabled(enable);
1813 // setToolShown( _addShapeAct, enable );
1816 void HEXABLOCKGUI::showGroupsMenus(bool show)
1818 DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
1819 if ( show && !getCurrentModel() ) return;
1820 setMenuShown( _addGroup, show );
1821 setToolShown( _addGroup, show);
1822 setMenuShown( _removeGroup , show );
1823 setToolShown( _removeGroup , show);
1826 void HEXABLOCKGUI::enableGroupsMenus(bool enable)
1828 if ( enable && !getCurrentModel() )
1831 _addGroup->setEnabled(enable);
1832 // setToolShown( _addGroup, enable);
1834 _removeGroup->setEnabled(enable);
1835 // setToolShown( _removeGroup , enable);
1838 void HEXABLOCKGUI::showMeshMenus(bool show)
1840 DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
1841 if ( show && !getCurrentModel() ) return;
1842 setMenuShown( _addLaw, show );
1843 setToolShown( _addLaw, show);
1844 setMenuShown( _removeLaw, show );
1845 setToolShown( _removeLaw, show);;
1846 setMenuShown( _setPropagation, show );
1847 setToolShown( _setPropagation, show);
1848 setMenuShown( _computeMesh, show);
1849 setToolShown( _computeMesh, show);
1852 void HEXABLOCKGUI::enableMeshMenus(bool enable)
1854 if ( enable && !getCurrentModel() )
1857 _addLaw->setEnabled(enable);
1858 // setToolShown( _addLaw, enable);
1860 _removeLaw->setEnabled(enable);
1861 // setToolShown( _removeLaw, enable);
1863 _setPropagation->setEnabled(enable);
1864 // setToolShown( _setPropagation, enable);
1866 _computeMesh->setEnabled(enable);
1867 // setToolShown( _computeMesh, enable);
1870 void HEXABLOCKGUI::showVtkActor()
1872 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1873 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1874 currentVtkGView->getDocumentActor() == NULL)
1877 SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
1878 if (vtkView == NULL)
1881 SUIT_ViewManager* vman = vtkView->getViewManager();
1882 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1884 //show only the current actor -----------------
1885 vtkView->setFocus();
1886 // vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
1887 Document_Actor *lastDocActor;
1888 if (lastVtkDocGView != NULL)
1890 lastDocActor = lastVtkDocGView->getDocumentActor();
1891 Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
1892 if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
1894 vtkView->Erase(lastActorIO);
1895 aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(), "Visibility", 0 );
1896 displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
1899 currentVtkGView->update();
1900 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1901 if (!anIO.IsNull() && anIO->hasEntry())
1903 vtkView->Display(anIO);
1904 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 1 );
1905 displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
1907 vtkView->onFitAll();
1910 void HEXABLOCKGUI::showOccActor()
1912 if (currentOccGView == NULL)
1914 OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
1915 if (occView == NULL)
1917 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1921 if (lastOccPrs != NULL)
1922 vf->Erase(lastOccPrs);
1923 currentOccGView->globalSelection();
1924 SOCC_Prs* prs = getOccPrs(currentDocGView);
1925 currentOccGView->setPrs(prs);
1928 occView->onFitAll();
1931 void HEXABLOCKGUI::hideVtkActor()
1933 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1934 if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
1935 currentVtkGView->getViewWindow() == NULL ||
1936 currentVtkGView->getDocumentActor() == NULL) return;
1938 currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
1939 currentVtkGView->getViewWindow()->onResetView();
1941 //update the visibility state now
1942 SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
1943 SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
1944 if (aStudy == NULL || vman == NULL) return;
1946 Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
1947 aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), "Visibility", 0 );
1948 displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
1951 void HEXABLOCKGUI::hideOccActor()
1953 OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
1954 VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
1955 DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
1956 if (occView == NULL || docModel == NULL)
1958 SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
1962 SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
1963 if (currentOccPrs != NULL)
1964 vf->Erase(currentOccPrs);
1966 occView->onResetView();
1969 void HEXABLOCKGUI::showOnlyActor()
1975 void HEXABLOCKGUI::hideActor()
1982 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
1984 DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
1986 if (_dwObjectBrowser) _dwObjectBrowser->setVisible(isVisible);
1987 if (_dwObjectBrowser) _dwObjectBrowser->toggleViewAction()->setVisible(isVisible);
1989 if (_dwPattern) _dwPattern->setVisible(isVisible);
1990 if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
1992 if (_dwMesh) _dwMesh->setVisible(isVisible);
1993 if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
1995 if (_dwGroups) _dwGroups->setVisible(isVisible);
1996 if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
2000 //clear all used dialogs by the current model
2001 void HEXABLOCKGUI::clearDialogs()
2003 std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
2004 fin (currentModelDialogs.end());
2005 for(;debut!=fin;++debut) (*debut)->clear();
2007 currentModelDialogs.clear(); //empty the used dialogs list
2010 HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
2012 if (!gViewDlgBox.contains(dgview)) return NULL;
2013 return gViewDlgBox[dgview];
2016 void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
2018 if (dgview == NULL) return;
2020 switchOffGraphicView(dgview, false); //to avoid double connect
2023 connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2024 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
2025 connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2026 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2027 // connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2028 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2029 connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2030 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2031 connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2032 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2033 connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2034 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
2039 void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
2041 if (dgview == NULL) return;
2043 //disconnect signals
2044 disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
2045 dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
2046 disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2047 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2048 // disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2049 // this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2050 disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2051 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2052 disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2053 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2054 disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
2055 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
2058 gViewDlgBox[dgview] = currentDialog;
2060 //close opened dialog
2061 if (currentDialog != NULL) currentDialog->close();
2062 // if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
2068 void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
2070 DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
2074 MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
2078 //switch off the current document graphic view (disconnect signals...)
2079 if (currentDocGView != NULL)
2081 //Hide current actor
2083 switchOffGraphicView(currentDocGView);
2086 //clear the dialogs used by the current model so they can be used by the new model
2087 if (currentDocGView != dgview) clearDialogs();
2089 _patternDataTreeView->setModel(dgview->getPatternDataModel());
2090 // _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
2091 _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
2092 _groupsTreeView->setModel(dgview->getGroupsModel());
2093 _meshTreeView->setModel(dgview->getMeshModel());
2095 _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
2096 _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2098 // _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
2099 // _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
2101 _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
2102 _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2104 _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
2105 _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2107 _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
2108 _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
2111 // = * init occ view * =
2112 if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
2114 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2115 currentOccGView->getViewWindow()->installEventFilter(this);
2120 // = * init vtk view * =
2121 if (currentDocGView != NULL)
2123 if (currentDocGView->getViewWindow() != NULL)
2124 dgview->setViewWindow(currentDocGView->getViewWindow());
2127 dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
2128 dgview->getViewWindow()->installEventFilter(this);
2134 switchOnGraphicView(dgview);
2136 if (currentDocGView != NULL)
2138 lastVtkDocGView = currentDocGView;
2139 lastOccPrs = getOccPrs(currentDocGView);
2143 lastVtkDocGView = dgview;
2144 lastOccPrs = getOccPrs(dgview);
2147 currentDocGView = dgview;
2149 currentDocGView->getDocumentModel()->refresh();
2150 // _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
2153 setAllMenusEnabled(true);
2156 DocumentModel* HEXABLOCKGUI::getCurrentModel()
2158 if (currentDocGView == NULL) return NULL;
2159 return currentDocGView->getDocumentModel();
2163 HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
2165 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2166 if (anApp == NULL) return UNKNOWN;
2167 SUIT_ViewManager* activeVm = anApp->activeViewManager();
2168 if (activeVm == NULL) return UNKNOWN;
2170 QString vmType = activeVm->getType();
2171 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
2173 else if ( vmType == OCCViewer_Viewer::Type() )
2179 HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
2181 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2185 return dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
2188 pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
2190 // Create Document from HEXABLOCK ENGINE
2191 // WARNING : IN HEXABLOCK component, GUI and ENGINE share the same process
2192 // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime Hexa6
2194 // looking doc impl ( c++ )
2195 // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
2196 // ^Hexa6 ASSERT( dServant );
2197 // ^Hexa6 if ( dServant)
2198 // ^Hexa6 doc = dServant->GetImpl();
2200 HEXA_NS::Document* doc = hexa_root->addDocument ("default");
2201 QString docEntry = addDocInStudy (doc);
2203 // looking for docEntry
2204 /* ****************************************************************
2205 if ( !CORBA::is_nil(docIn) ){
2206 CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
2207 QString docIOR = anIOR.in();
2208 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
2209 if ( !docIOR.isEmpty() ) {
2210 _PTR(SObject) SO( study->studyDS()->FindObjectIOR( docIOR.toLatin1().constData() ) );
2212 docEntry = SO->GetID().c_str();
2215 **************************************************************** */
2216 DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
2218 return make_pair (docEntry, doc);
2222 void HEXABLOCKGUI::newDocument()
2224 DEBTRACE("HEXABLOCKGUI::newDocument");
2227 QMainWindow *aParent = application()->desktop();
2228 QWidget *central = aParent->centralWidget();
2230 central->setFocus();
2232 DEBTRACE("No Central Widget");
2235 if (currentOccGView == NULL)
2237 currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
2238 application()->desktop());
2239 currentOccGView->getViewWindow()->installEventFilter(this);
2241 else if (currentOccGView->getViewWindow() == NULL)
2243 currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
2244 currentOccGView->getViewWindow()->installEventFilter(this);
2248 // Create Document from HEXABLOCK ENGINE
2249 pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
2251 VtkDocumentGraphicView* newGraphicView = NULL;
2252 //One document at a time
2253 if (currentDocGView != NULL)
2255 if (currentDocGView->getViewWindow() == NULL)
2257 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2258 currentDocGView->getViewWindow()->installEventFilter(this);
2261 // Create a new document with the current window
2262 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2263 new DocumentModel( docEntry_Doc.second,
2264 docEntry_Doc.first, this ),
2265 currentDocGView->getViewWindow(),
2266 application()->desktop() );
2270 // Create the new Document Graphic View with a new window
2271 newGraphicView = graphicViewsHandler->createDocumentGraphicView(
2272 new DocumentModel( docEntry_Doc.second,
2273 docEntry_Doc.first, this ),
2274 graphicViewsHandler->createVtkWindow(),
2275 application()->desktop() );
2276 newGraphicView->getViewWindow()->installEventFilter(this);
2279 if (newGraphicView == NULL)
2280 //We couldn't create a new document graphic view
2281 //we'd better show a dialog box info to inform the user
2284 docs[docEntry_Doc.first] = newGraphicView;
2285 switchModel(newGraphicView); //select the corresponding document in the browser instead
2287 getApp()->updateObjectBrowser();
2292 //Loads the model from the xmlFile in the current graphic view
2293 void HEXABLOCKGUI::loadDocument( const QString &inFile )
2295 DEBTRACE("HEXABLOCKGUI::loadDocument");
2298 QMainWindow *aParent = application()->desktop();
2299 QString selectedFile;
2301 if ( inFile.isNull() ){
2302 QFileDialog dialog( aParent, tr("Open HexaBlock Document") ,
2303 QString::null, tr( "XML-Files (*.xml);;All Files (*)" ) );
2304 dialog.setHistory( getQuickDirList() );
2306 //use the last path as default
2307 if (!(loadDocLastPath->absolutePath()).isEmpty())
2308 dialog.setDirectory(*loadDocLastPath);
2311 QStringList selectedFiles = dialog.selectedFiles();
2312 if (!selectedFiles.isEmpty())
2313 selectedFile = selectedFiles.first();
2315 //remember the selected path
2316 *loadDocLastPath = dialog.directory();
2319 selectedFile = inFile;
2321 if (selectedFile.isEmpty())
2324 //we create a new document if necessary
2325 if (currentDocGView == NULL)
2326 //Need a new document
2328 else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
2330 currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
2331 currentDocGView->getViewWindow()->installEventFilter(this);
2334 if (!currentDocGView->isEmpty())
2335 //we can only have one document for a graphic view
2338 //we load the selected file in the current graphic view
2339 currentDocGView->loadDocument(selectedFile);
2340 DocumentModel* currentModel = getCurrentModel();
2341 renameObject( currentModel->documentEntry(), currentModel->getName() );
2346 void HEXABLOCKGUI::saveDocument()
2348 QMainWindow *aParent = application()->desktop();
2350 QString aDocName = "document", aFilename;
2352 filter.append( QObject::tr( "XML_FILES_FILTER" ) + " (*.xml)" );
2353 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
2355 //use the last selected directory as default path for file selection
2356 aFilename = saveDocLastPath->absolutePath();
2357 if (!aFilename.isEmpty())
2358 aFilename += QString("/") + aDocName;
2360 //show the dialog for file selection
2361 aFilename = SUIT_FileDlg::getFileName( aParent,
2364 tr( "Save HexaBlock Document" ),
2367 //save the document in the selected file
2368 if ( !aFilename.isEmpty() ) {
2369 getCurrentVtkGraphicView()->saveDocument( aFilename );
2371 //Remember the path for next save
2372 QFileInfo fileInfo(aFilename);
2373 *saveDocLastPath = fileInfo.dir();
2379 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
2381 _patternDataTreeView->openPersistentEditor( topLeft );
2384 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
2386 if (diag == NULL || _dwInputPanel == NULL ||
2387 getCurrentVtkGraphicView() == NULL) return;
2389 //mark this dialog as used by the current model
2390 currentModelDialogs.insert(diag);
2392 //close the current dialog box info
2393 // if (_treeViewDelegate != NULL)
2394 // _treeViewDelegate->closeDialog();
2396 // if (_dwInputPanel->widget())
2397 // _dwInputPanel->widget()->close();
2399 //Temporary for debugging EdgeAssoc Faked InfoDialog
2400 if (diag == _edgeAssocDiag)
2401 diag->debugEdgeAssoc = true;
2403 diag->debugEdgeAssoc = false;
2405 if (diag == _vertexAssocDiag || diag == _edgeAssocDiag ||
2406 diag == _quadAssocDiag || diag == _addShapeDiag)
2407 assocInProgress = true;
2409 assocInProgress = false;
2411 //show the dialog box in the dockwidget
2412 diag->resetSizeAndShow(_dwInputPanel);
2414 //clear the current selections
2415 selectionMgr()->clearSelected();
2417 currentDialog = diag;
2420 if (currentDocGView != NULL)
2421 currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
2424 void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
2426 if (vertex == NULL || _dwInputPanel == NULL)
2429 if (_vertexInfoDialog == NULL)
2430 _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2432 _vertexInfoDialog->setValue(vertex);
2433 _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
2434 currentDialog = _vertexInfoDialog;
2437 void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
2439 if (edge == NULL || _dwInputPanel == NULL)
2442 if (_edgeInfoDialog == NULL)
2443 _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2445 _edgeInfoDialog->setValue(edge);
2446 _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
2447 currentDialog = _edgeInfoDialog;
2450 void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
2452 if (quad == NULL || _dwInputPanel == NULL)
2455 if (_quadInfoDialog == NULL)
2456 _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2458 _quadInfoDialog->setValue(quad);
2459 _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
2460 currentDialog = _quadInfoDialog;
2463 void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
2465 if (hexa == NULL || _dwInputPanel == NULL)
2468 if (_hexaInfoDialog == NULL)
2469 _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2471 _hexaInfoDialog->setValue(hexa);
2472 _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
2473 currentDialog = _hexaInfoDialog;
2476 void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
2478 if (vector == NULL || _dwInputPanel == NULL)
2481 if (_vectorInfoDialog == NULL)
2482 _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2484 _vectorInfoDialog->setValue(vector);
2485 _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
2486 currentDialog = _vectorInfoDialog;
2489 void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
2491 if (group == NULL || _dwInputPanel == NULL)
2494 if (_groupInfoDialog == NULL)
2495 _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2497 _groupInfoDialog->setValue(group);
2498 _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
2499 currentDialog = _groupInfoDialog;
2502 void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
2504 if (law == NULL || _dwInputPanel == NULL)
2507 if (_lawInfoDialog == NULL)
2508 _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2510 _lawInfoDialog->setValue(law);
2511 _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
2512 currentDialog = _lawInfoDialog;
2515 void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
2517 if (propagation == NULL || _dwInputPanel == NULL)
2520 if (_propagationInfoDialog == NULL)
2521 _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
2523 _propagationInfoDialog->setValue(propagation);
2524 _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
2525 currentDialog = _propagationInfoDialog;
2528 void HEXABLOCKGUI::addVertex()
2530 if ( !_vertexDiag ){
2531 _vertexDiag = new VertexDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2533 _showDialogBox( _vertexDiag );
2536 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2537 if (_vertexDiag != NULL && doc != NULL)
2538 _vertexDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VERTEX).c_str());
2541 void HEXABLOCKGUI::addEdge()
2544 _edgeDiag = new EdgeDialog( _dwInputPanel, HexaBaseDialog::NEW_MODE);
2546 _showDialogBox( _edgeDiag );
2549 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2550 if (_edgeDiag != NULL && doc != NULL)
2551 _edgeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_EDGE).c_str());
2554 void HEXABLOCKGUI::addQuad()
2557 _quadDiag = new QuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2560 _showDialogBox( _quadDiag );
2563 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2564 if (_quadDiag != NULL && doc != NULL)
2565 _quadDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_QUAD).c_str());
2568 void HEXABLOCKGUI::addHexa()
2571 _hexaDiag = new HexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2573 _showDialogBox( _hexaDiag );
2576 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2577 if (_hexaDiag != NULL && doc != NULL)
2578 _hexaDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_HEXA).c_str());
2581 void HEXABLOCKGUI::addVector()
2583 if ( !_vectorDiag ){
2584 _vectorDiag = new VectorDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2586 _showDialogBox( _vectorDiag );
2589 HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2590 if (_vectorDiag != NULL && doc != NULL)
2591 _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
2594 //void HEXABLOCKGUI::addCylinder()
2596 // if ( !_cylinderDiag ){
2597 // _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2599 // _showDialogBox( _cylinderDiag );
2601 // //set default name
2602 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2603 // if (_cylinderDiag != NULL && doc != NULL)
2604 // _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2608 //void HEXABLOCKGUI::addPipe()
2610 // if ( !_pipeDiag){
2611 // _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2613 // _showDialogBox( _pipeDiag );
2615 // //set default name
2616 // HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
2617 // if (_pipeDiag != NULL && doc != NULL)
2618 // _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
2622 void HEXABLOCKGUI::makeGrid()
2624 if ( !_makeGridDiag ){
2625 _makeGridDiag = new MakeGridDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2627 _showDialogBox( _makeGridDiag );
2631 void HEXABLOCKGUI::makeCylinder()
2633 if ( !_makeCylinderDiag ){
2634 _makeCylinderDiag = new MakeCylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2636 _showDialogBox( _makeCylinderDiag );
2639 void HEXABLOCKGUI::makePipe()
2641 if ( !_makePipeDiag ){
2642 _makePipeDiag = new MakePipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2644 _showDialogBox( _makePipeDiag );
2647 void HEXABLOCKGUI::makeCylinders()
2649 if ( !_makeCylindersDiag ){
2650 _makeCylindersDiag = new MakeCylindersDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2652 _showDialogBox( _makeCylindersDiag );
2655 void HEXABLOCKGUI::makePipes()
2657 if ( !_makePipesDiag ){
2658 _makePipesDiag = new MakePipesDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2660 _showDialogBox( _makePipesDiag );
2664 void HEXABLOCKGUI::makeHemiSphere() // NEW HEXA3
2666 if ( !_makeHemiSphereDiag ){
2667 _makeHemiSphereDiag = new MakeHemiSphereDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2669 _showDialogBox( _makeHemiSphereDiag );
2673 void HEXABLOCKGUI::removeHexa()
2675 if ( !_removeHexaDiag ){
2676 _removeHexaDiag = new RemoveHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2678 _showDialogBox( _removeHexaDiag );
2682 void HEXABLOCKGUI::prismQuad()
2684 if ( !_prismQuadDiag ){
2685 _prismQuadDiag = new PrismQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2687 _showDialogBox( _prismQuadDiag );
2691 void HEXABLOCKGUI::joinQuad()
2693 if ( !_joinQuadDiag ){
2694 _joinQuadDiag = new JoinQuadDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2696 _showDialogBox( _joinQuadDiag );
2699 void HEXABLOCKGUI::merge()
2702 _mergeDiag = new MergeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2704 _showDialogBox( _mergeDiag );
2707 void HEXABLOCKGUI::disconnectElts()
2709 if ( !_disconnectDiag ){
2710 _disconnectDiag = new DisconnectDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2712 _showDialogBox( _disconnectDiag );
2715 void HEXABLOCKGUI::cutEdge()
2717 if ( !_cutEdgeDiag ){
2718 _cutEdgeDiag = new CutEdgeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2720 _showDialogBox( _cutEdgeDiag );
2723 void HEXABLOCKGUI::makeTransformation()
2725 if ( !_makeTransformationDiag ){
2726 _makeTransformationDiag = new MakeTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2728 _showDialogBox( _makeTransformationDiag );
2732 void HEXABLOCKGUI::makeSymmetry()
2734 if ( !_makeSymmetryDiag ){
2735 _makeSymmetryDiag = new MakeSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2737 _showDialogBox( _makeSymmetryDiag );
2741 void HEXABLOCKGUI::performTransformation()
2743 if ( !_performTransformationDiag ){
2744 _performTransformationDiag = new PerformTransformationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2746 _showDialogBox( _performTransformationDiag );
2750 void HEXABLOCKGUI::performSymmetry()
2752 if ( !_performSymmetryDiag ){
2753 _performSymmetryDiag = new PerformSymmetryDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2755 _showDialogBox( _performSymmetryDiag );
2759 void HEXABLOCKGUI::replaceHexa() // NEW HEXA3
2761 if ( !_replaceHexaDiag ){
2762 _replaceHexaDiag = new ReplaceHexaDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2764 _showDialogBox( _replaceHexaDiag );
2768 void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
2770 if ( !_quadRevolutionDiag ){
2771 _quadRevolutionDiag = new QuadRevolutionDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2773 _showDialogBox( _quadRevolutionDiag );
2777 void HEXABLOCKGUI::assocVertex()
2779 if (!_dwInputPanel) return;
2780 QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
2781 if ( !_vertexAssocDiag )
2782 _vertexAssocDiag = new VertexAssocDialog( d /*_dwInputPanel*/);
2783 _showDialogBox( _vertexAssocDiag );
2787 void HEXABLOCKGUI::assocEdge()
2789 if ( !_edgeAssocDiag )
2790 _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2791 _showDialogBox( _edgeAssocDiag );
2794 void HEXABLOCKGUI::assocQuad()
2796 if ( !_quadAssocDiag )
2797 _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2798 _showDialogBox( _quadAssocDiag );
2802 void HEXABLOCKGUI::addGroup()
2805 _groupDiag = new GroupDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2807 _showDialogBox( _groupDiag );
2808 if (_groupDiag != NULL && getCurrentModel() != NULL)
2810 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2811 if (doc == NULL) return;
2812 char defaultName[16];
2813 sprintf (defaultName, "g%04d", doc->countGroup());
2814 _groupDiag->name_le->setText(defaultName);
2818 void HEXABLOCKGUI::removeGroup()
2820 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2821 if (currentDGView == NULL) return;
2823 QItemSelectionModel *groupsSelectionModel = _groupsTreeView->selectionModel();
2824 QModelIndexList l = groupsSelectionModel->selectedIndexes();
2825 int nbGroupsRemoved = 0;
2828 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2829 tr( "No group selected!" ) );
2833 foreach( QModelIndex selected, l ){
2834 if ( selected.data(HEXA_TREE_ROLE) == GROUP_TREE ){
2835 selected = currentDGView->getGroupsModel()->mapToSource( selected );
2836 Q_ASSERT(selected.isValid());
2838 //Confirm the deletion of the group
2839 if (SUIT_MessageBox::question(
2842 tr("Remove group : %1 ?").arg(selected.data().toString()),
2843 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2844 SUIT_MessageBox::Cancel
2845 ) == SUIT_MessageBox::Cancel) return;
2847 bool removed = getCurrentModel()->removeGroup( selected );
2849 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2850 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2856 if (!nbGroupsRemoved)
2857 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE GROUP" ),
2858 tr( "No group selected!" ) );
2861 void HEXABLOCKGUI::addLaw()
2864 _lawDiag = new LawDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2866 _showDialogBox( _lawDiag );
2867 if (_lawDiag != NULL && getCurrentModel() != NULL)
2869 HEXA_NS::Document* doc = getCurrentModel()->getHexaDocument();
2870 if (doc == NULL) return;
2871 char defaultName[16];
2872 sprintf (defaultName, "l%04d", doc->countLaw());
2873 _lawDiag->name_le->setText(defaultName);
2877 void HEXABLOCKGUI::removeLaw()
2879 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2880 if (currentDGView == NULL) return;
2882 QModelIndexList l = currentDGView->getMeshSelectionModel()->selectedIndexes();
2883 int nbLawsRemoved = 0;
2886 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2887 tr( "No law selected!" ) );
2891 foreach( QModelIndex selected, l ){
2892 if ( selected.data(HEXA_TREE_ROLE) == LAW_TREE ){
2893 selected = currentDGView->getMeshModel()->mapToSource( selected );
2894 Q_ASSERT(selected.isValid());
2896 //Confirm the deletion of the law
2897 if (SUIT_MessageBox::question(
2900 tr("Remove law : %1 ?\nAll propagations having this law will have the default law.").arg(selected.data().toString()),
2901 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
2902 SUIT_MessageBox::Cancel
2903 ) == SUIT_MessageBox::Cancel) return;
2905 bool removed = getCurrentModel()->removeLaw(selected);
2907 SUIT_MessageBox::critical( 0, tr( "ERR_ERROR" ),
2908 tr( "CANNOT REMOVE %1" ).arg(selected.data().toString()) );
2915 SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
2916 tr( "No law selected!" ) );
2921 void HEXABLOCKGUI::setPropagation()
2923 if ( !_propagationDiag )
2924 _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2926 _showDialogBox( _propagationDiag );
2929 // Dialog box to compute a mesh from a document
2930 // --------------------------------------------
2931 void HEXABLOCKGUI::computeMesh()
2933 if ( !_computeMeshDiag )
2934 _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
2936 _showDialogBox( _computeMeshDiag );
2939 void HEXABLOCKGUI::clearAssociations()
2941 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2942 if (currentDGView == NULL) return;
2944 // QMessageBox::warning( 0, "windowTitle()", "clearAssociations" );
2945 QModelIndex iDataModel = _patternDataTreeView->currentIndex();
2946 QModelIndex iModel = currentDGView->getPatternDataModel()->mapToSource(iDataModel);
2948 getCurrentModel()->clearEltAssociations(iModel);
2950 // SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
2953 void HEXABLOCKGUI::showModelInfo()
2955 //create the info dialog if not yet
2956 if (_modelInfoDiag == NULL)
2957 _modelInfoDiag = new ModelInfoDialog(_dwInputPanel);
2959 //show the model informations dialog
2960 _showDialogBox( _modelInfoDiag );
2963 void HEXABLOCKGUI::addShape()
2965 //create the info dialog if not yet
2966 if (_addShapeDiag == NULL)
2967 _addShapeDiag = new AddShapeDialog(_dwInputPanel);
2969 //show the model informations dialog
2970 _showDialogBox( _addShapeDiag );
2973 void HEXABLOCKGUI::clearAllAssociations()
2975 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
2976 if (currentDGView == NULL) return;
2978 QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
2979 if (!currentIndex.isValid()) return;
2980 QVariant currentAssocVariant;
2981 QString currentAssocEntry;
2983 //Confirm the deletion of the associations
2984 QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
2985 if ( !treeVariant.isValid() ) return;
2986 int eltType = treeVariant.toInt();
2987 QString typeStr = "";
2988 HEXA_NS::EnumElt hexaType;
2989 if (eltType == VERTEX_DIR_TREE)
2991 typeStr = tr("TREE_ITEM_VERTEX").toUpper();
2992 hexaType = HEXA_NS::EL_VERTEX;
2994 else if (eltType == EDGE_DIR_TREE)
2996 typeStr = tr("TREE_ITEM_EDGE").toUpper();
2997 hexaType = HEXA_NS::EL_EDGE;
2999 else if (eltType == QUAD_DIR_TREE)
3001 typeStr = tr("TREE_ITEM_QUAD").toUpper();
3002 hexaType = HEXA_NS::EL_QUAD;
3005 if (SUIT_MessageBox::question(
3007 tr("CLEAR_ASSOCIATIONS"),
3008 tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
3009 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
3010 SUIT_MessageBox::Cancel
3011 ) == SUIT_MessageBox::Cancel) return;
3014 DocumentModel* docModel = getCurrentModel();
3015 if (docModel == NULL) return;
3016 docModel->clearAssociation(hexaType);
3019 void HEXABLOCKGUI::showAssociations()
3021 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3022 if (currentDGView == NULL) return;
3024 QModelIndexList elts;
3025 int currentChildIndex = 0;
3026 QVariant currentAssocVariant;
3027 QString currentAssocEntry;
3028 QModelIndex currentIndex = _patternDataTreeView->currentIndex();
3029 QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
3031 while( currentChild.isValid() ) {
3033 currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
3034 currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
3035 if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
3036 elts << currentChild;
3038 currentChild = currentChild.sibling(currentChildIndex++, 0);
3040 currentDocGView->highlight(elts);
3041 currentOccGView->highlight(elts, false);
3045 LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
3047 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3049 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3054 bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
3056 if ( event->type() == QEvent::Enter )
3057 { // *** ENTER EVENT
3059 if (currentDialog == NULL || !currentDialog->isVisible())
3060 return QObject::eventFilter(obj, event);
3062 // ** The window acquire the focus when the cursor enter
3064 //OCC - window enter
3065 OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
3066 if ( occWindow != NULL)
3067 currentDialog->onWindowActivated(occWindow->getViewManager());
3069 //VTK - window enter
3071 SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
3072 if ( vtkWindow != NULL)
3073 currentDialog->onWindowActivated(vtkWindow->getViewManager());
3077 //standard event processing
3078 return QObject::eventFilter(obj, event);
3081 QStringList HEXABLOCKGUI::getQuickDirList()
3083 QStringList dirList;
3084 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
3086 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
3092 // --- Export the module
3096 HEXABLOCK_EXPORT CAM_Module* createModule()
3098 return new HEXABLOCKGUI();
3101 HEXABLOCK_EXPORT char* getModuleVersion()
3103 return (char*)HEXABLOCK_VERSION_STR;
3109 // ******************** TESTS ***************************************************
3111 void HEXABLOCKGUI::testDocument()
3115 // QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
3116 // QStandardItem *myItem = new QStandardItem("MyItem");
3117 // parentItem->appendRow(myItem);
3119 // QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
3120 // QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
3121 // QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
3122 // QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
3123 // QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
3124 // QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
3125 // QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
3126 // QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
3129 // QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3130 // QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
3131 // QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
3132 // QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
3133 // QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
3134 // QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
3136 // QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
3137 // QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
3138 // QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
3139 // QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
3144 // // QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
3145 // // QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
3146 // // QModelIndex vz = getCurrentModel()->addVector (0,0,1);
3147 // // QModelIndex vx = getCurrentModel()->addVector (1,0,0);
3155 // // QModelIndex cyl = getCurrentModel()->addCylinder (orig1, vz, nr, nl);
3156 // // QModelIndex pipe = getCurrentModel()->addPipe (orig2, vz, nri, nre, nl);
3158 // // getCurrentModel()->makeCylinder (cyl, vx, nr, na, nl);
3159 // // getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
3163 // newMesh( "toto", 3, "FactoryServer");
3167 void HEXABLOCKGUI::test_make_cart_grid()
3169 QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
3170 QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
3171 QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
3172 QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
3173 QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
3174 QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
3176 QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
3177 QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
3184 // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
3185 // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
3186 // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
3187 // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
3188 // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
3189 // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
3194 void HEXABLOCKGUI::test_make_elmts_transform()
3201 // QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
3202 // QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
3205 // QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
3206 // orig.setScalar(2);
3208 // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
3209 // getCurrentModel()->saveVtk(file_name)
3211 // QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
3212 // QModelIndex grid2 = getCurrentModel()->makeTranslation(grid, devant);
3214 // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
3215 // getCurrentModel()->saveVtk(file_name)
3217 // QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
3220 // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
3221 // getCurrentModel()->saveVtk(file_name);
3224 // print "...test make elements by transforming elements OK"
3226 // =============================================================== addDocInSudy
3227 QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
3231 if (document == NULL)
3234 QString docName = document->getName ();
3236 SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
3237 if (app_study == NULL)
3240 _PTR(Study) study = app_study->studyDS();
3241 SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
3242 SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
3243 QString entry = app_study->centry("HEXABLOCK");
3244 SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
3245 if (aFatherSO->_is_nil())
3248 SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
3251 aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
3252 docEntry = aSO->GetID(); //the entry of the published object
3257 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
3259 void HEXABLOCKGUI::test()
3261 DEBTRACE("HEXABLOCKGUI::test");
3262 VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
3263 if (currentDGView == NULL) return;
3264 currentDGView->update();
3268 void HEXABLOCKGUI::test_association()
3270 DEBTRACE("HEXABLOCKGUI::test_association");
3273 QModelIndex v0, v1, v2, v3, e0, e1, q0;
3275 DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
3276 DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
3277 DocumentModel::GeomObj q0AssocA, q0AssocB;
3279 DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
3280 QList<DocumentModel::GeomObj> e1Assocs_test;
3281 DocumentModel::GeomObj q0Assoc_test;
3283 v0 = getCurrentModel()->addVertex(0, 0, 0);
3284 v1 = getCurrentModel()->addVertex(1, 0, 0);
3285 v2 = getCurrentModel()->addVertex(1, 1, 0);
3286 v3 = getCurrentModel()->addVertex(0, 1, 0);
3287 e0 = getCurrentModel()->addEdgeVertices(v0, v1);
3288 e1 = getCurrentModel()->addEdgeVertices(v1, v2);
3289 q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
3292 // >>> face3.GetEntry()'0:1:4'
3293 // >>> e1.GetEntry()'0:1:8'
3294 // >>> e2.GetEntry()'0:1:9'
3295 // >>> e3.GetEntry()'0:1:10'
3296 // >>> e4.GetEntry()'0:1:11'
3297 // >>> v1.GetEntry()'0:1:12'
3298 // >>> v2.GetEntry()'0:1:13'
3299 // >>> v3.GetEntry()'0:1:14'
3300 // >>> v4.GetEntry()'0:1:15'
3303 // v0Assoc.name = "geomV0";
3304 // v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
3305 // v0Assoc.brep = "brepV0";
3306 // v1Assoc.name = "geomV1";
3307 // v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
3308 // v1Assoc.brep = "brepV1";
3309 // v2Assoc.name = "geomV2";
3310 // v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
3311 // v2Assoc.brep = "brepV2";
3312 // v3Assoc.name = "geomV3";
3313 // v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
3314 // v3Assoc.brep = "brepV3";
3318 // e0AssocA.name = "geomE0a";
3319 // e0AssocA.entry = "0:1:1:1:3:5";//"0:1:8";
3320 // e0AssocA.brep = "brepE0a";
3321 // e0AssocA.start = 0.10;
3322 // e0AssocA.end = 0.95;
3326 // e1AssocA.name = "geomE1a";
3327 // e1AssocA.entry = "0:1:1:1:3:2";//"0:1:8";
3328 // e1AssocA.brep = "brepE1a";
3329 // e1AssocA.start = 0.12;
3330 // e1AssocA.end = 0.89;
3331 // e1AssocB.name = "geomE1b";
3332 // e1AssocB.entry = "0:1:1:1:3:3";//"0:1:9";
3333 // e1AssocB.brep = "brepE1b";
3334 // e1AssocB.start = 0.20;
3335 // e1AssocB.end = 0.80;
3336 // e1AssocC.name = "geomE1c";
3337 // e1AssocC.entry = "0:1:1:1:3:4";//"0:1:10";
3338 // e1AssocC.brep = "brepE1c";
3339 // e1AssocC.start = 0.16;
3340 // e1AssocC.end = 0.96;
3342 // q0AssocA.name = "geomQuad";
3343 // q0AssocA.entry = "0:1:1:1:3";
3344 // q0AssocA.brep = "brepq0";
3346 // q0AssocB.name = "geomQuad";
3347 // q0AssocB.entry = "0:1:1:1:4";
3348 // q0AssocB.brep = "brepq0";
3350 // getCurrentModel()->addAssociation( v0, v0Assoc );
3351 // getCurrentModel()->addAssociation( v1, v1Assoc );
3352 // getCurrentModel()->addAssociation( v2, v2Assoc );
3353 // getCurrentModel()->addAssociation( v3, v3Assoc );
3356 // getCurrentModel()->addAssociation( e0, e0AssocA );
3358 // getCurrentModel()->addAssociation( e1, e1AssocA );
3359 // getCurrentModel()->addAssociation( e1, e1AssocB );
3360 // getCurrentModel()->addAssociation( e1, e1AssocC );
3362 // getCurrentModel()->addAssociation( q0, q0AssocA );
3363 // getCurrentModel()->addAssociation( q0, q0AssocB );
3369 // v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
3370 // v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
3371 // v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
3372 // v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
3373 // ASSERT( v0Assoc.name == v0Assoc_test.name );
3374 // ASSERT( v1Assoc.name == v1Assoc_test.name );
3375 // ASSERT( v2Assoc.name == v2Assoc_test.name );
3376 // ASSERT( v3Assoc.name == v3Assoc_test.name );
3377 // ASSERT( v0Assoc.entry == v0Assoc_test.entry );
3378 // ASSERT( v1Assoc.entry == v1Assoc_test.entry );
3379 // ASSERT( v2Assoc.entry == v2Assoc_test.entry );
3380 // ASSERT( v3Assoc.entry == v3Assoc_test.entry );
3383 // e1Assocs_test = getCurrentModel()->getAssociations( e1 );
3384 // ASSERT( e1Assocs_test[0].name == e1AssocA.name );
3385 // ASSERT( e1Assocs_test[1].name == e1AssocB.name );
3386 // ASSERT( e1Assocs_test[2].name == e1AssocC.name );
3387 // ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
3388 // ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
3389 // ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
3390 // ASSERT( e1Assocs_test[0].start == e1AssocA.start );
3391 // ASSERT( e1Assocs_test[1].start == e1AssocB.start );
3392 // ASSERT( e1Assocs_test[2].start == e1AssocC.start );
3393 // ASSERT( e1Assocs_test[0].end == e1AssocA.end );
3394 // ASSERT( e1Assocs_test[1].end == e1AssocB.end );
3395 // ASSERT( e1Assocs_test[2].end == e1AssocC.end );
3397 // q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
3398 // ASSERT( q0Assoc_test.name == q0Assoc.name );
3399 // ASSERT( q0Assoc_test.entry == q0Assoc.entry );
3402 DEBTRACE("HEXABLOCKGUI::test_association fin");