]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPRGUI/MULTIPR_GUI.cxx
Salome HOME
*** empty log message ***
[modules/multipr.git] / src / MULTIPRGUI / MULTIPR_GUI.cxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_GUI.cxx
6  *
7  * \brief   see MULTIPR_GUI.h
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13   
14 //*****************************************************************************
15 // Includes section
16 //*****************************************************************************
17
18 // MULTIPR Includes
19 #include "MULTIPR_GUI.h"
20 #include "MULTIPR_GUI_Dlg.h"
21
22 // Salome Includes
23 #include <SUIT_MessageBox.h>
24 #include <SUIT_ResourceMgr.h>
25 #include <SUIT_Session.h>
26 #include <SalomeApp_Application.h>
27 #include <SalomeApp_DataModel.h>
28 #include <SalomeApp_Study.h>
29 #include <SalomeApp_CheckFileDlg.h>
30 #include <LightApp_Study.h>
31 #include <LightApp_DataModel.h>
32 #include <LightApp_DataOwner.h>
33 #include <LightApp_SelectionMgr.h>
34 #include <CAM_DataModel.h>
35 #include <CAM_Module.h>
36
37 #include <SALOME_LifeCycleCORBA.hxx>
38
39 #include <QtxPopupMgr.h>
40
41 // QT Includes
42 #include <qapplication.h>
43 #include <qinputdialog.h>
44 #include <qlayout.h>
45 #include <qpushbutton.h>
46 #include <qgroupbox.h>
47 #include <qvbox.h>
48 #include <qbuttongroup.h>
49 #include <qlabel.h>
50 #include <qcombobox.h>
51 #include <qvariant.h>
52 #include <qlineedit.h>
53 #include <qspinbox.h>
54 #include <qtooltip.h>
55 #include <qwhatsthis.h>
56 #include <qimage.h>
57 #include <qpixmap.h>
58 #include <qmessagebox.h>
59
60
61 using namespace std;
62
63
64 //*****************************************************************************
65 // Global variable
66 //*****************************************************************************
67
68 namespace multipr
69 {
70         // progress callback used by the MULTIPR library
71         extern MULTIPR_ProgressCallback* gProgressCallback;
72 }
73
74
75 //*****************************************************************************
76 // Class MULTIPR_GUI implementation
77 //*****************************************************************************
78
79 MULTIPR_GUI::MULTIPR_GUI() : SalomeApp_Module("MULTIPR")
80 {
81         mMEDFileName = "";
82         mMULTIPRObj = NULL;
83 }
84
85
86 MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_GUI::getMULTIPRObj()
87 {
88         return mMULTIPRObj;
89 }
90
91
92 SalomeApp_Application* MULTIPR_GUI::getAppli() const
93 {
94         return getApp();
95 }
96
97
98 MULTIPR_ORB::MULTIPR_Gen_ptr MULTIPR_GUI::InitMULTIPRGen(SalomeApp_Application* app)
99 {
100         Engines::Component_var comp = app->lcc()->FindOrLoad_Component("FactoryServer", "MULTIPR");
101         MULTIPR_ORB::MULTIPR_Gen_ptr clr = MULTIPR_ORB::MULTIPR_Gen::_narrow(comp);
102         ASSERT(!CORBA::is_nil(clr));
103         return clr;
104 }
105
106
107 void MULTIPR_GUI::initialize(CAM_Application* app)
108 {
109         SalomeApp_Module::initialize(app);
110         
111         InitMULTIPRGen(dynamic_cast<SalomeApp_Application*>(app));
112         
113         QWidget* aParent = app->desktop();
114         SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
115         
116         //-------------------------------------------------------------------------
117         // create actions
118         //-------------------------------------------------------------------------     
119         QPixmap aPixmapImportFromMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("ICON_IMPORT_MED"));
120         
121         createAction( 
122                 ACTION_IMPORT_MED, 
123                 tr("TLT_IMPORT_FROM_MED_FILE"), 
124                 QIconSet(aPixmapImportFromMEDFile), 
125                 tr("MEN_IMPORT_FROM_MED_FILE"), 
126                 tr("STS_IMPORT_FROM_MED_FILE"), 
127                 (CTRL + Key_I),
128                 aParent, 
129                 false,
130                 this, 
131                 SLOT(OnImportFromMEDFile()));
132                 
133         createAction( 
134                 ACTION_SPLIT, 
135                 tr("TLT_SPLIT"), 
136                 QIconSet(), 
137                 tr("MEN_SPLIT"), 
138                 tr("STS_SPLIT"), 
139                 0,
140                 aParent, 
141                 false,
142                 this, 
143                 SLOT(OnPartition2()));
144         
145         createAction( 
146                 ACTION_DECIMATE, 
147                 tr("TLT_DECIMATE"), 
148                 QIconSet(), 
149                 tr("MEN_DECIMATE"), 
150                 tr("STS_DECIMATE"), 
151                 0,
152                 aParent, 
153                 false,
154                 this, 
155                 SLOT(OnDecimate()));
156         
157         createAction( 
158                 ACTION_REMOVE, 
159                 tr("TLT_REMOVE"), 
160                 QIconSet(), 
161                 tr("MEN_REMOVE"), 
162                 tr("STS_REMOVE"), 
163                 0,
164                 aParent, 
165                 false,
166                 this, 
167                 SLOT(OnRemove()));
168                 
169         QPixmap aPixmapSaveMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("ICON_SAVE_MED"));
170         
171         createAction( 
172                 ACTION_SAVE, 
173                 tr("TLT_SAVE"), 
174                 QIconSet(aPixmapSaveMEDFile), 
175                 tr("MEN_SAVE"), 
176                 tr("STS_SAVE"), 
177                 0,
178                 aParent, 
179                 false,
180                 this, 
181                 SLOT(OnSave()));
182         
183         //-------------------------------------------------------------------------
184         // create menus
185         //-------------------------------------------------------------------------
186         int aMenuId;
187         aMenuId = createMenu(tr("MEN_FILE"), -1, -1);
188         createMenu(separator(), aMenuId, -1, 10);
189         aMenuId = createMenu(tr("MEN_FILE_MULTIPR"), aMenuId, -1, 10);
190         createMenu(ACTION_IMPORT_MED, aMenuId);
191         
192         aMenuId = createMenu(tr("MEN_MULTIPR"), -1, -1, 30);
193         createMenu(ACTION_IMPORT_MED, aMenuId, 10);
194         createMenu(ACTION_SAVE, aMenuId, 10);
195         createMenu(ACTION_SPLIT, aMenuId, 10);
196         createMenu(ACTION_DECIMATE, aMenuId, 10);
197         createMenu(ACTION_REMOVE, aMenuId, 10);
198         
199         //-------------------------------------------------------------------------
200         // create toolbars
201         //-------------------------------------------------------------------------
202         int aToolId = createTool(tr("TOOL_MULTIPR"));
203         createTool(ACTION_IMPORT_MED, aToolId);
204         createTool(ACTION_SAVE, aToolId);
205         
206         //-------------------------------------------------------------------------
207         // create popup menus
208         //-------------------------------------------------------------------------
209         QtxPopupMgr* mgr = popupMgr();
210         mgr->insert( action(ACTION_SPLIT), -1, -1, -1 );
211         mgr->insert( action(ACTION_DECIMATE), -1, -1, -1 );
212         mgr->insert( action(ACTION_REMOVE), -1, -1, -1 );
213         mgr->insert( action(ACTION_SAVE), -1, -1, -1 );
214         
215         QString aRule = "client='ObjectBrowser' and selcount>=1"; // $type in {'VISU::TMESH'}";
216         mgr->setRule(action(ACTION_SPLIT), aRule, true);
217         mgr->setRule(action(ACTION_DECIMATE), aRule, true);
218         mgr->setRule(action(ACTION_REMOVE), aRule, true);
219         mgr->setRule(action(ACTION_SAVE), aRule, true);
220         
221         //-------------------------------------------------------------------------
222         // set progress dialog
223         //-------------------------------------------------------------------------
224         MULTIPR_GUI_ProgressCallbackDlg* progressDlg = new MULTIPR_GUI_ProgressCallbackDlg(application()->desktop());
225         multipr::gProgressCallback = progressDlg;
226 }
227
228
229 CAM_DataModel* MULTIPR_GUI::createDataModel()
230 {
231         return new MULTIPR_GUI_DataModel(this);
232 }
233
234
235 QString MULTIPR_GUI::engineIOR() const
236 {
237         CORBA::String_var anIOR = getApp()->orb()->object_to_string(InitMULTIPRGen(getApp()));
238         return QString(anIOR.in());
239 }
240
241
242 bool MULTIPR_GUI::activateModule(SUIT_Study* theStudy)
243 {
244         bool bOk = SalomeApp_Module::activateModule(theStudy);
245         
246         setMenuShown(true);
247         setToolShown(true);
248         
249         return bOk;
250 }
251
252
253 bool MULTIPR_GUI::deactivateModule(SUIT_Study* theStudy)
254 {
255         setMenuShown(false);
256         setToolShown(false);
257         
258         return SalomeApp_Module::deactivateModule(theStudy);
259 }
260
261
262 void MULTIPR_GUI::windows(QMap<int, int>& theMap) const
263 {
264         theMap.clear();
265         theMap.insert(SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft);
266         theMap.insert(SalomeApp_Application::WT_PyConsole,     Qt::DockBottom);
267 }
268
269
270 void MULTIPR_GUI::selected(QStringList& entries, const bool multiple)
271 {
272         LightApp_SelectionMgr* mgr = getApp()->selectionMgr();
273         
274         if(!mgr) return;
275         
276         SUIT_DataOwnerPtrList anOwnersList;
277         mgr->selected(anOwnersList);
278         
279         for (int i = 0 ; i < anOwnersList.size() ; i++)
280         {
281                 const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>(anOwnersList[i].get());
282                 
283                 if (!entries.contains(owner->entry()))
284                 {
285                         entries.append(owner->entry());
286                 }
287                         
288                 if (!multiple)
289                         break;
290         }
291 }
292
293
294 void MULTIPR_GUI::OnImportFromMEDFile()
295 {
296         // Get file name
297         QStringList aFilter;
298         aFilter.append(tr("FLT_MED_FILES"));
299         aFilter.append(tr("FLT_ALL_FILES"));
300         
301         SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg(
302                 this->application()->desktop(), 
303                 true, 
304                 tr("USE_BUILD_PROGRESS") );
305         fd->setCaption(tr("MEN_IMPORT_FROM_MED_FILE"));
306         fd->setFilters(aFilter);
307         fd->exec();
308         QFileInfo aFileInfo(fd->selectedFile());
309         delete fd;
310         
311         // Check the file name
312         if (!aFileInfo.exists())
313                 return;
314                 
315         mMEDFileName = aFileInfo.filePath();
316         
317         QApplication::setOverrideCursor(Qt::waitCursor);
318         
319         try
320         {
321                 MULTIPR_ORB::MULTIPR_Gen_ptr multiprgen = MULTIPR_GUI::InitMULTIPRGen(getApp());
322                 mMULTIPRObj = multiprgen->getObject(mMEDFileName.latin1());
323         }
324         catch(...)
325         {
326                 SUIT_MessageBox::error1( 
327                         getApp()->desktop(),
328                         "Import MED file error", 
329                         "Invalid MED file (not recognized by MULTIPR)", 
330                         tr("OK") );
331         }
332         QApplication::restoreOverrideCursor();
333         
334         try
335         {
336                 if (mMULTIPRObj->isValidSequentialMEDFile())
337                 {
338                         OnPartition1();
339                 }
340         }
341         catch (...)
342         {
343         }
344         
345         getApp()->updateObjectBrowser();
346 }
347
348
349 void MULTIPR_GUI::OnPartition1()
350 {
351         MULTIPR_GUI_Partition1Dlg* dialog = new MULTIPR_GUI_Partition1Dlg(this);
352         dialog->exec();
353         delete dialog;
354 }
355
356
357 void MULTIPR_GUI::OnPartition2()
358 {
359         retrieveSelectedParts();
360         
361         if (mSelectedParts.count() == 0)
362         {
363                 SUIT_MessageBox::warn1( 
364                         getApp()->desktop(),
365                         "Split warning", 
366                         "No parts selected", 
367                         tr("OK") );
368                 return;
369         }
370         
371         MULTIPR_GUI_Partition2Dlg* dialog = new MULTIPR_GUI_Partition2Dlg(this);
372         dialog->exec();
373         delete dialog;
374         getApp()->updateObjectBrowser();
375 }
376
377
378 void MULTIPR_GUI::OnDecimate()
379 {
380         retrieveSelectedParts();
381         
382         if (mSelectedParts.count() == 0)
383         {
384                 SUIT_MessageBox::warn1( 
385                         getApp()->desktop(),
386                         "Decimation warning", 
387                         "No parts selected", 
388                         tr("OK") );
389                 return;
390         }
391         
392         // for each selected part, check if there are lower resolution
393         // and then propose to remove them before processing new decimation
394         QStringList partNameLowerResolution;
395         for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
396         {
397                 const QString& partName = (*it);
398                 QString partNameLow = partName + "_LOW";
399                 QString partNameMed = partName + "_MED";
400                 const char* strPartNameLow = partNameLow.latin1();
401                 const char* strPartNameMed = partNameMed.latin1();
402                 
403                 if (isPartExist(strPartNameLow))
404                 {
405                         partNameLowerResolution.push_back(partNameLow);
406                         cout << "Part to be removed: " << partNameLow << endl;
407                 }
408                 
409                 if (isPartExist(strPartNameMed))
410                 {
411                         partNameLowerResolution.push_back(partNameMed);
412                         cout << "Part to be removed: " << partNameMed << endl;
413                 }
414         }
415          
416         if (partNameLowerResolution.count() > 0)
417         {
418                 if (QMessageBox::question(
419                                 getApp()->desktop(),
420                                 tr("Decimation: remove previous results"),
421                                 tr("Do you want to remove previous results?"),
422                                 tr("&Yes"), tr("&No"),
423                                 QString::null, 0, 1 ) )
424                 {
425                         return;
426                 }
427         
428                 QApplication::setOverrideCursor(Qt::waitCursor);
429                 
430                 try
431                 {
432                         for (QStringList::const_iterator it = partNameLowerResolution.begin(), last = partNameLowerResolution.end(); it != last; it++)
433                         {
434                                 const QString& partName = (*it);
435                                 cout << "Remove " << partName.latin1() << endl;
436                                 mMULTIPRObj->removePart(partName.latin1());
437                         }
438                         
439                 }
440                 catch(...)
441                 {
442                         SUIT_MessageBox::error1( 
443                                 getApp()->desktop(),
444                                 "Remove error", 
445                                 "Error while removing previous results", 
446                                 tr("OK") );
447                 }
448                 
449                 QApplication::restoreOverrideCursor();
450                 
451                 getApp()->updateObjectBrowser();
452         }
453         
454         MULTIPR_GUI_DecimateDlg* dialog = new MULTIPR_GUI_DecimateDlg(this);
455         dialog->exec();
456         delete dialog;
457         getApp()->updateObjectBrowser();
458 }
459
460
461 void MULTIPR_GUI::OnRemove()
462 {
463         retrieveSelectedParts();
464         
465         if (mSelectedParts.count() == 0)
466         {
467                 SUIT_MessageBox::warn1( 
468                         getApp()->desktop(),
469                         "Remove warning", 
470                         "No parts selected", 
471                         tr("OK") );
472                 return;
473         }
474         
475         if (QMessageBox::question(
476             getApp()->desktop(),
477             tr("Remove selected part(s)"),
478             tr("Do you want to remove selected part(s)?"),
479             tr("&Yes"), tr("&No"),
480             QString::null, 0, 1 ) )
481         {
482                 return;
483         }
484
485         QApplication::setOverrideCursor(Qt::waitCursor);
486         
487         try
488         {
489                 for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
490                 {
491                         const QString& partName = (*it);
492                         cout << "Remove " << partName.latin1() << endl;
493                         mMULTIPRObj->removePart(partName.latin1());
494                 }
495                 
496         }
497         catch(...)
498         {
499                 SUIT_MessageBox::error1( 
500                         getApp()->desktop(),
501                         "Remove error", 
502                         "Error while removing selected part(s)", 
503                         tr("OK") );
504         }
505         
506         QApplication::restoreOverrideCursor();
507         
508         getApp()->updateObjectBrowser();
509 }
510
511
512 void MULTIPR_GUI::OnSave()
513 {
514         QApplication::setOverrideCursor(Qt::waitCursor);
515         
516         try
517         {
518                 mMULTIPRObj->save();
519                 getApp()->updateObjectBrowser();
520         }
521         catch(...)
522         {
523                 SUIT_MessageBox::error1( 
524                         getApp()->desktop(),
525                         "Save distributed MED file error", 
526                         "Error while writing distributed MED file", 
527                         tr("OK") );
528         }
529         
530         QApplication::restoreOverrideCursor();
531 }
532
533
534
535 void MULTIPR_GUI::retrieveSelectedParts()
536 {
537         mSelectedParts.clear();
538
539         QStringList userSelection;      
540         selected(userSelection, true);
541         for (QStringList::const_iterator it = userSelection.begin(), last = userSelection.end(); it != last; it++)
542         {
543                 const QString& str = (*it);
544                 QStringList words = QStringList::split(":", str);
545                 if (words.count() == 2)
546                 {
547                         if (words[0] == "MULTIPR_PART")
548                         {
549                                 mSelectedParts.push_back(words[1]);
550                         }
551                 }
552     }
553 }
554
555
556 bool MULTIPR_GUI::isPartExist(const char* partName)
557 {
558         if (mMULTIPRObj == NULL) return false;
559         
560         MULTIPR_ORB::string_array* listParts = mMULTIPRObj->getParts();
561         for (int i=0 ; i<listParts->length() ; i++)
562         {
563                 const char* strItem = (*listParts)[i];
564                 if (strcmp(strItem, partName) == 0) 
565                 {
566                         return true;
567                 }
568         }
569         return false;
570 }
571
572
573 //*****************************************************************************
574 // Super class Data Object implementation
575 //*****************************************************************************
576
577 MULTIPR_GUI_DataObject::MULTIPR_GUI_DataObject(SUIT_DataObject* parent, const char* name) : 
578         LightApp_DataObject(parent),
579         CAM_DataObject(parent)
580 {
581         mName = name;
582 }
583
584
585 MULTIPR_GUI_DataObject::~MULTIPR_GUI_DataObject()
586 {
587         // do nothing!
588 }
589
590
591 QString MULTIPR_GUI_DataObject::entry() const
592 {
593         return QString("MULTIPR_OBJECT");
594 }
595
596
597 QString MULTIPR_GUI_DataObject::name() const
598 {
599   return mName;
600 }
601
602
603 QPixmap MULTIPR_GUI_DataObject::icon() const
604 {
605         //static QPixmap icon = SUIT_Session::session()->resourceMgr()->loadPixmap("MULTIPR", QObject::tr("ICON_IMPORT_MED"), false);
606         return QPixmap();
607         
608 }
609
610
611 QString MULTIPR_GUI_DataObject::toolTip() const
612 {
613         // default behaviour: return an empty string
614         return "";
615 }
616
617
618 //*****************************************************************************
619 // Class Data Object Module implementation
620 //*****************************************************************************
621
622 MULTIPR_GUI_DataObject_Module::MULTIPR_GUI_DataObject_Module(CAM_DataModel* dm, SUIT_DataObject* parent, const char* name) : 
623         MULTIPR_GUI_DataObject(parent, name),
624         LightApp_ModuleObject(dm, parent),
625         CAM_DataObject(parent)
626 {
627         // do nothing!
628 }
629
630
631 MULTIPR_GUI_DataObject_Module::~MULTIPR_GUI_DataObject_Module()
632 {
633         // do nothing!
634 }
635
636
637 QString MULTIPR_GUI_DataObject_Module::entry() const
638 {
639         return QString("MULTIPR_MODULE:" + mName);
640 }
641
642
643 QString MULTIPR_GUI_DataObject_Module::name() const
644 {
645   return CAM_RootObject::name();
646 }
647
648
649 QPixmap MULTIPR_GUI_DataObject_Module::icon() const
650 {
651         return QPixmap();
652 }
653
654
655 QString MULTIPR_GUI_DataObject_Module::toolTip() const
656 {
657         return QString("Module MULTIPR");
658 }
659
660
661 //*****************************************************************************
662 // Class Data Object Mesh implementation
663 //*****************************************************************************
664
665 MULTIPR_GUI_DataObject_Mesh::MULTIPR_GUI_DataObject_Mesh(SUIT_DataObject* parent, const char* name) : 
666         MULTIPR_GUI_DataObject(parent, name),
667         CAM_DataObject(parent)
668 {
669         // do nothing!
670 }
671
672
673 MULTIPR_GUI_DataObject_Mesh::~MULTIPR_GUI_DataObject_Mesh()
674 {
675         // do nothing!
676 }
677
678
679 QString MULTIPR_GUI_DataObject_Mesh::entry() const
680 {
681         return QString("MULTIPR_MESH:") + mName;
682 }
683
684
685 QPixmap MULTIPR_GUI_DataObject_Mesh::icon() const
686 {
687         return QPixmap();
688 }
689
690
691 QString MULTIPR_GUI_DataObject_Mesh::toolTip() const
692 {
693         return QString("Original mesh");
694 }
695
696
697 //*****************************************************************************
698 // Class Data Object Part implementation
699 //*****************************************************************************
700
701 MULTIPR_GUI_DataObject_Part::MULTIPR_GUI_DataObject_Part(SUIT_DataObject* parent, const char* name, const char* info) : 
702         MULTIPR_GUI_DataObject(parent, name),
703         CAM_DataObject(parent)
704 {
705         mMeshName    = "";
706         mId          = 0;
707         mPath        = "";
708         mMEDFileName = "";
709         
710         mTooltip = info;
711         
712         // parse info to retrieve all the fields
713         char   lMeshName[256];
714         int    lId;
715         char   lPartName[256];
716         char   lPath[256];
717         char   lMEDFileName[256];
718         
719         int ret = sscanf(info, "%s %d %s %s %s", 
720                                 lMeshName,
721                                 &lId,
722                                 lPartName,
723                                 lPath,
724                                 lMEDFileName);
725                                 
726         // number of read parameters should be 5
727         if (ret != 5) return;
728         
729         mMeshName    = lMeshName;
730         mId          = lId;
731         mPath        = lPath;
732         mMEDFileName = lMEDFileName;
733 }
734
735
736 MULTIPR_GUI_DataObject_Part::~MULTIPR_GUI_DataObject_Part()
737 {
738         // do nothing!
739 }
740
741
742 QString MULTIPR_GUI_DataObject_Part::entry() const
743 {
744         return QString("MULTIPR_PART:") + mName;
745 }
746
747
748 QPixmap MULTIPR_GUI_DataObject_Part::icon() const
749 {
750         return QPixmap();
751 }
752
753
754 QString MULTIPR_GUI_DataObject_Part::toolTip() const
755 {
756         return mTooltip;
757 }
758
759
760 //*****************************************************************************
761 // Class Data Object Resolution implementation
762 //*****************************************************************************
763
764 MULTIPR_GUI_DataObject_Resolution::MULTIPR_GUI_DataObject_Resolution(SUIT_DataObject* parent, const char* name, const char* info) : 
765         MULTIPR_GUI_DataObject_Part(parent, name, info),
766         CAM_DataObject(parent)
767 {
768         // do nothing!
769 }
770
771
772 MULTIPR_GUI_DataObject_Resolution::~MULTIPR_GUI_DataObject_Resolution()
773 {
774         // do nothing!
775 }
776
777
778 QString MULTIPR_GUI_DataObject_Resolution::entry() const
779 {
780         return QString("MULTIPR_RESOLUTION:") + mName;
781 }
782
783
784 QPixmap MULTIPR_GUI_DataObject_Resolution::icon() const
785 {
786         return QPixmap();
787 }
788
789
790 QString MULTIPR_GUI_DataObject_Resolution::toolTip() const
791 {
792         return mTooltip;
793 }
794
795
796 //*****************************************************************************
797 // Data Model
798 //*****************************************************************************
799
800 MULTIPR_GUI_DataModel::MULTIPR_GUI_DataModel(CAM_Module* module) : 
801         LightApp_DataModel(module)
802 {
803         mMULTIPR_GUI = dynamic_cast<MULTIPR_GUI*>(module);
804 }
805
806
807 MULTIPR_GUI_DataModel::~MULTIPR_GUI_DataModel()
808 {
809         // do nothing!
810 }
811
812
813 void MULTIPR_GUI_DataModel::build()
814 {
815         MULTIPR_GUI_DataObject_Module* modelRoot = dynamic_cast<MULTIPR_GUI_DataObject_Module*>(root());
816         
817         if (!modelRoot)  
818         {  
819                 // root is not set yet
820                 modelRoot = new MULTIPR_GUI_DataObject_Module(this, NULL, "MULTIPR");
821                 setRoot(modelRoot);
822         }
823         
824         MULTIPR_ORB::MULTIPR_Obj_ptr obj = mMULTIPR_GUI->getMULTIPRObj();
825         
826         if (obj != NULL)
827         {
828                 MULTIPR_ORB::string_array* listParts = obj->getParts();
829                 
830                 if (listParts->length() >= 1)
831                 {
832                         const char* strPartName0 = (*listParts)[0];
833                         char* strPartInfo0 = obj->getPartInfo(strPartName0);
834                         
835                         char   lMeshName[256];
836                         int    lId;
837                         char   lPartName[256];
838                         char   lPath[256];
839                         char   lMEDFileName[256];       
840                         
841                         // parse infos
842                         int ret = sscanf(strPartInfo0, "%s %d %s %s %s", 
843                                 lMeshName,
844                                 &lId,
845                                 lPartName,
846                                 lPath,
847                                 lMEDFileName);
848                                 
849                         if (ret != 5) return;
850                         
851                         MULTIPR_GUI_DataObject_Mesh* dataObjectMesh = new MULTIPR_GUI_DataObject_Mesh(modelRoot, lMeshName);
852                         
853                         MULTIPR_GUI_DataObject_Part* dataObjectPart_prev = NULL;
854                         
855                         for (int i = 0 ; i < listParts->length() ; i++)
856                         {
857                                 const char* strItem = (*listParts)[i];
858                                 char* strPartInfo = obj->getPartInfo(strItem);
859                                 
860                                 // parse infos
861                                 int ret = sscanf(strPartInfo, "%s %d %s %s %s", 
862                                         lMeshName,
863                                         &lId,
864                                         lPartName,
865                                         lPath,
866                                         lMEDFileName);
867                                 
868                                 if (ret != 5) return;
869                         
870                                 //cout << "Part : " << lPartName << endl;
871                                 if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
872                                 {
873                                         //cout << "Found MED/LOW" << endl;
874                                         new MULTIPR_GUI_DataObject_Resolution(dataObjectPart_prev, strItem, strPartInfo);
875                                 }
876                                 else
877                                 {
878                                         dataObjectPart_prev = new MULTIPR_GUI_DataObject_Part(dataObjectMesh, strItem, strPartInfo);
879                                 }
880                         }
881                 }
882         }
883 }
884
885
886 extern "C" 
887 {
888         CAM_Module* createModule()
889         {
890                 return new MULTIPR_GUI();
891         }
892 }
893
894
895 // EOF