]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPRGUI/MULTIPR_GUI.cxx
Salome HOME
a9d83b0ac218a6001e13287557b234bce5b75232
[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("MULTIPR_ICON_IMPORT_MED"));
120         
121         createAction( 
122                 ACTION_IMPORT_MED, 
123                 tr("MULTIPR_TLT_IMPORT_FROM_MED_FILE"), 
124                 QIconSet(aPixmapImportFromMEDFile), 
125                 tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE"), 
126                 tr("MULTIPR_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("MULTIPR_TLT_SPLIT"), 
136                 QIconSet(), 
137                 tr("MULTIPR_MEN_SPLIT"), 
138                 tr("MULTIPR_STS_SPLIT"), 
139                 0,
140                 aParent, 
141                 false,
142                 this, 
143                 SLOT(OnPartition2()));
144         
145         createAction( 
146                 ACTION_DECIMATE, 
147                 tr("MULTIPR_TLT_DECIMATE"), 
148                 QIconSet(), 
149                 tr("MULTIPR_MEN_DECIMATE"), 
150                 tr("MULTIPR_STS_DECIMATE"), 
151                 0,
152                 aParent, 
153                 false,
154                 this, 
155                 SLOT(OnDecimate()));
156         
157         createAction( 
158                 ACTION_REMOVE, 
159                 tr("MULTIPR_TLT_REMOVE"), 
160                 QIconSet(), 
161                 tr("MULTIPR_MEN_REMOVE"), 
162                 tr("MULTIPR_STS_REMOVE"), 
163                 0,
164                 aParent, 
165                 false,
166                 this, 
167                 SLOT(OnRemove()));
168                 
169         QPixmap aPixmapSaveMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("MULTIPR_ICON_SAVE_MED"));
170         
171         createAction( 
172                 ACTION_SAVE, 
173                 tr("MULTIPR_TLT_SAVE"), 
174                 QIconSet(aPixmapSaveMEDFile), 
175                 tr("MULTIPR_MEN_SAVE"), 
176                 tr("MULTIPR_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("MULTIPR_MEN_FILE"), -1, -1);
188         createMenu(separator(), aMenuId, -1, 10);
189         aMenuId = createMenu(tr("MULTIPR_MEN_FILE_MULTIPR"), aMenuId, -1, 10);
190         createMenu(ACTION_IMPORT_MED, aMenuId);
191         
192         aMenuId = createMenu(tr("MULTIPR_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("MULTIPR_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("MULTIPR_FLT_MED_FILES"));
299         aFilter.append(tr("MULTIPR_FLT_ALL_FILES"));
300         
301         SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg(
302                 this->application()->desktop(), 
303                 true, 
304                 tr("MULTIPR_USE_BUILD_PROGRESS") );
305                 
306         fd->setCaption(tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE"));
307         fd->setFilters(aFilter);
308         fd->exec();
309         QFileInfo aFileInfo(fd->selectedFile());
310         delete fd;
311         
312         // Check the file name
313         if (!aFileInfo.exists())
314                 return;
315                 
316         mMEDFileName = aFileInfo.filePath();
317         
318         QApplication::setOverrideCursor(Qt::waitCursor);
319         
320         try
321         {
322                 MULTIPR_ORB::MULTIPR_Gen_ptr multiprgen = MULTIPR_GUI::InitMULTIPRGen(getApp());
323                 mMULTIPRObj = multiprgen->getObject(mMEDFileName.latin1());
324         }
325         catch(...)
326         {
327                 SUIT_MessageBox::error1( 
328                         getApp()->desktop(),
329                         "Import MED file error", 
330                         "Invalid MED file (not recognized by MULTIPR)", 
331                         tr("MULTIPR_OK") );
332         }
333         QApplication::restoreOverrideCursor();
334         
335         if (mMULTIPRObj != NULL)
336         {
337                 try
338                 {
339                         if (mMULTIPRObj->isValidSequentialMEDFile())
340                         {
341                                 OnPartition1();
342                         }
343                 }
344                 catch (...)
345                 {
346                 }
347                 
348                 getApp()->updateObjectBrowser();
349         }
350 }
351
352
353 void MULTIPR_GUI::OnPartition1()
354 {
355         // check if MULTIPRObj exists
356         if (mMULTIPRObj == NULL)
357         {
358                 return;
359         }
360         
361         MULTIPR_GUI_Partition1Dlg* dialog = new MULTIPR_GUI_Partition1Dlg(this);
362         dialog->exec();
363         delete dialog;
364 }
365
366
367 void MULTIPR_GUI::OnPartition2()
368 {
369         // check if MULTIPRObj exists
370         if (mMULTIPRObj == NULL)
371         {
372                 return;
373         }
374         
375         retrieveSelectedParts();
376         
377         if (mSelectedParts.count() == 0)
378         {
379                 SUIT_MessageBox::warn1( 
380                         getApp()->desktop(),
381                         "Split warning", 
382                         "No parts selected", 
383                         tr("MULTIPR_OK") );
384                 return;
385         }
386         
387         if (!removeLowerResolution())
388         {
389                 return;
390         }
391         
392         MULTIPR_GUI_Partition2Dlg* dialog = new MULTIPR_GUI_Partition2Dlg(this);
393         dialog->exec();
394         delete dialog;
395         getApp()->updateObjectBrowser();
396 }
397
398
399 void MULTIPR_GUI::OnDecimate()
400 {
401         // check if MULTIPRObj exists
402         if (mMULTIPRObj == NULL)
403         {
404                 return;
405         }
406         
407         retrieveSelectedParts();
408         
409         if (mSelectedParts.count() == 0)
410         {
411                 SUIT_MessageBox::warn1( 
412                         getApp()->desktop(),
413                         "Decimation warning", 
414                         "No parts selected", 
415                         tr("MULTIPR_OK") );
416                 return;
417         }
418         
419         if (!removeLowerResolution())
420         {
421                 return;
422         }
423         
424         MULTIPR_GUI_DecimateDlg* dialog = new MULTIPR_GUI_DecimateDlg(this);
425         dialog->exec();
426         delete dialog;
427         getApp()->updateObjectBrowser();
428 }
429
430
431 void MULTIPR_GUI::OnRemove()
432 {
433         // check if MULTIPRObj exists
434         if (mMULTIPRObj == NULL)
435         {
436                 return;
437         }
438         
439         retrieveSelectedParts();
440         
441         if (mSelectedParts.count() == 0)
442         {
443                 SUIT_MessageBox::warn1( 
444                         getApp()->desktop(),
445                         "Remove warning", 
446                         "No parts selected", 
447                         tr("MULTIPR_OK") );
448                 return;
449         }
450         
451         if (QMessageBox::question(
452             getApp()->desktop(),
453             tr("Remove selected part(s)"),
454             tr("Do you want to remove selected part(s)?"),
455             tr("&Yes"), tr("&No"),
456             QString::null, 0, 1 ) )
457         {
458                 return;
459         }
460
461         QApplication::setOverrideCursor(Qt::waitCursor);
462         
463         try
464         {
465                 for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
466                 {
467                         const QString& partName = (*it);
468                         cout << "Remove " << partName.latin1() << endl;
469                         mMULTIPRObj->removeParts(partName.latin1());
470                 }
471                 
472         }
473         catch(...)
474         {
475                 SUIT_MessageBox::error1( 
476                         getApp()->desktop(),
477                         "Remove error", 
478                         "Error while removing selected part(s)", 
479                         tr("MULTIPR_OK") );
480         }
481         
482         QApplication::restoreOverrideCursor();
483         
484         getApp()->updateObjectBrowser();
485 }
486
487
488 void MULTIPR_GUI::OnSave()
489 {
490         // check if MULTIPRObj exists
491         if (mMULTIPRObj == NULL)
492         {
493                 return;
494         }
495
496         QApplication::setOverrideCursor(Qt::waitCursor);
497         
498         try
499         {
500                 mMULTIPRObj->save();
501                 getApp()->updateObjectBrowser();
502         }
503         catch(...)
504         {
505                 SUIT_MessageBox::error1( 
506                         getApp()->desktop(),
507                         "Save distributed MED file error", 
508                         "Error while writing distributed MED file", 
509                         tr("MULTIPR_OK") );
510         }
511         
512         QApplication::restoreOverrideCursor();
513 }
514
515
516
517 void MULTIPR_GUI::retrieveSelectedParts()
518 {
519         mSelectedParts.clear();
520
521         QStringList userSelection;      
522         selected(userSelection, true);
523         for (QStringList::const_iterator it = userSelection.begin(), last = userSelection.end(); it != last; it++)
524         {
525                 const QString& str = (*it);
526                 QStringList words = QStringList::split(":", str);
527                 if (words.count() == 2)
528                 {
529                         if (words[0] == "MULTIPR_PART")
530                         {
531                                 mSelectedParts.push_back(words[1]);
532                         }
533                 }
534     }
535 }
536
537
538 bool MULTIPR_GUI::isPartExist(const char* partName)
539 {
540         if (mMULTIPRObj == NULL) return false;
541         
542         MULTIPR_ORB::string_array* listParts = mMULTIPRObj->getParts();
543         for (int i=0 ; i<listParts->length() ; i++)
544         {
545                 const char* strItem = (*listParts)[i];
546                 if (strcmp(strItem, partName) == 0) 
547                 {
548                         return true;
549                 }
550         }
551         return false;
552 }
553
554
555 bool MULTIPR_GUI::removeLowerResolution()
556 {
557         // for each selected part, check if there are lower resolution
558         // and then propose to remove them before performing new process
559         QStringList partNameLowerResolution;
560         for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
561         {
562                 const QString& partName = (*it);
563                 QString partNameLow = partName + "_LOW";
564                 QString partNameMed = partName + "_MED";
565                 const char* strPartNameLow = partNameLow.latin1();
566                 const char* strPartNameMed = partNameMed.latin1();
567                 
568                 if (isPartExist(strPartNameLow))
569                 {
570                         partNameLowerResolution.push_back(partNameLow);
571                         cout << "Part to be removed: " << partNameLow << endl;
572                 }
573                 
574                 if (isPartExist(strPartNameMed))
575                 {
576                         partNameLowerResolution.push_back(partNameMed);
577                         cout << "Part to be removed: " << partNameMed << endl;
578                 }
579         }
580          
581         if (partNameLowerResolution.count() > 0)
582         {
583                 if (QMessageBox::question(
584                                 getApp()->desktop(),
585                                 tr("Remove previous results"),
586                                 tr("Do you want to remove previous results?"),
587                                 tr("&Yes"), tr("&No"),
588                                 QString::null, 0, 1 ) )
589                 {
590                         return false;
591                 }
592         
593                 QApplication::setOverrideCursor(Qt::waitCursor);
594                 
595                 try
596                 {
597                         for (QStringList::const_iterator it = partNameLowerResolution.begin(), last = partNameLowerResolution.end(); it != last; it++)
598                         {
599                                 const QString& partName = (*it);
600                                 cout << "Remove " << partName.latin1() << endl;
601                                 mMULTIPRObj->removeParts(partName.latin1());
602                         }
603                         
604                 }
605                 catch(...)
606                 {
607                         SUIT_MessageBox::error1( 
608                                 getApp()->desktop(),
609                                 "Remove error", 
610                                 "Error while removing previous results", 
611                                 tr("OK") );
612                 }
613                 
614                 QApplication::restoreOverrideCursor();
615                 
616                 getApp()->updateObjectBrowser();
617         }
618         
619         return true;
620 }
621
622
623 //*****************************************************************************
624 // Super class Data Object implementation
625 //*****************************************************************************
626
627 MULTIPR_GUI_DataObject::MULTIPR_GUI_DataObject(SUIT_DataObject* parent, const char* name) : 
628         LightApp_DataObject(parent),
629         CAM_DataObject(parent)
630 {
631         mName = name;
632 }
633
634
635 MULTIPR_GUI_DataObject::~MULTIPR_GUI_DataObject()
636 {
637         // do nothing!
638 }
639
640
641 QString MULTIPR_GUI_DataObject::entry() const
642 {
643         return QString("MULTIPR_OBJECT");
644 }
645
646
647 QString MULTIPR_GUI_DataObject::name() const
648 {
649   return mName;
650 }
651
652
653 QPixmap MULTIPR_GUI_DataObject::icon() const
654 {
655         //static QPixmap icon = SUIT_Session::session()->resourceMgr()->loadPixmap("MULTIPR", QObject::tr("ICON_IMPORT_MED"), false);
656         return QPixmap();
657         
658 }
659
660
661 QString MULTIPR_GUI_DataObject::toolTip() const
662 {
663         // default behaviour: return an empty string
664         return "";
665 }
666
667
668 //*****************************************************************************
669 // Class Data Object Module implementation
670 //*****************************************************************************
671
672 MULTIPR_GUI_DataObject_Module::MULTIPR_GUI_DataObject_Module(CAM_DataModel* dm, SUIT_DataObject* parent, const char* name) : 
673         MULTIPR_GUI_DataObject(parent, name),
674         LightApp_ModuleObject(dm, parent),
675         CAM_DataObject(parent)
676 {
677         // do nothing!
678 }
679
680
681 MULTIPR_GUI_DataObject_Module::~MULTIPR_GUI_DataObject_Module()
682 {
683         // do nothing!
684 }
685
686
687 QString MULTIPR_GUI_DataObject_Module::entry() const
688 {
689         return QString("MULTIPR_MODULE:" + mName);
690 }
691
692
693 QString MULTIPR_GUI_DataObject_Module::name() const
694 {
695   return CAM_RootObject::name();
696 }
697
698
699 QPixmap MULTIPR_GUI_DataObject_Module::icon() const
700 {
701         return QPixmap();
702 }
703
704
705 QString MULTIPR_GUI_DataObject_Module::toolTip() const
706 {
707         return QString("Module MULTIPR");
708 }
709
710
711 //*****************************************************************************
712 // Class Data Object Mesh implementation
713 //*****************************************************************************
714
715 MULTIPR_GUI_DataObject_Mesh::MULTIPR_GUI_DataObject_Mesh(SUIT_DataObject* parent, const char* name) : 
716         MULTIPR_GUI_DataObject(parent, name),
717         CAM_DataObject(parent)
718 {
719         // do nothing!
720 }
721
722
723 MULTIPR_GUI_DataObject_Mesh::~MULTIPR_GUI_DataObject_Mesh()
724 {
725         // do nothing!
726 }
727
728
729 QString MULTIPR_GUI_DataObject_Mesh::entry() const
730 {
731         return QString("MULTIPR_MESH:") + mName;
732 }
733
734
735 QPixmap MULTIPR_GUI_DataObject_Mesh::icon() const
736 {
737         return QPixmap();
738 }
739
740
741 QString MULTIPR_GUI_DataObject_Mesh::toolTip() const
742 {
743         return QString("Original mesh");
744 }
745
746
747 //*****************************************************************************
748 // Class Data Object Part implementation
749 //*****************************************************************************
750
751 MULTIPR_GUI_DataObject_Part::MULTIPR_GUI_DataObject_Part(SUIT_DataObject* parent, const char* name, const char* info) : 
752         MULTIPR_GUI_DataObject(parent, name),
753         CAM_DataObject(parent)
754 {
755         mMeshName    = "";
756         mId          = 0;
757         mPath        = "";
758         mMEDFileName = "";
759         
760         mTooltip = info;
761         
762         // parse info to retrieve all the fields
763         char   lMeshName[256];
764         int    lId;
765         char   lPartName[256];
766         char   lPath[256];
767         char   lMEDFileName[256];
768         
769         int ret = sscanf(info, "%s %d %s %s %s", 
770                                 lMeshName,
771                                 &lId,
772                                 lPartName,
773                                 lPath,
774                                 lMEDFileName);
775                                 
776         // number of read parameters should be 5
777         if (ret != 5) return;
778         
779         mMeshName    = lMeshName;
780         mId          = lId;
781         mPath        = lPath;
782         mMEDFileName = lMEDFileName;
783 }
784
785
786 MULTIPR_GUI_DataObject_Part::~MULTIPR_GUI_DataObject_Part()
787 {
788         // do nothing!
789 }
790
791
792 QString MULTIPR_GUI_DataObject_Part::entry() const
793 {
794         return QString("MULTIPR_PART:") + mName;
795 }
796
797
798 QPixmap MULTIPR_GUI_DataObject_Part::icon() const
799 {
800         return QPixmap();
801 }
802
803
804 QString MULTIPR_GUI_DataObject_Part::toolTip() const
805 {
806         return mTooltip;
807 }
808
809
810 //*****************************************************************************
811 // Class Data Object Resolution implementation
812 //*****************************************************************************
813
814 MULTIPR_GUI_DataObject_Resolution::MULTIPR_GUI_DataObject_Resolution(SUIT_DataObject* parent, const char* name, const char* info) : 
815         MULTIPR_GUI_DataObject_Part(parent, name, info),
816         CAM_DataObject(parent)
817 {
818         // do nothing!
819 }
820
821
822 MULTIPR_GUI_DataObject_Resolution::~MULTIPR_GUI_DataObject_Resolution()
823 {
824         // do nothing!
825 }
826
827
828 QString MULTIPR_GUI_DataObject_Resolution::entry() const
829 {
830         return QString("MULTIPR_RESOLUTION:") + mName;
831 }
832
833
834 QPixmap MULTIPR_GUI_DataObject_Resolution::icon() const
835 {
836         return QPixmap();
837 }
838
839
840 QString MULTIPR_GUI_DataObject_Resolution::toolTip() const
841 {
842         return mTooltip;
843 }
844
845
846 //*****************************************************************************
847 // Data Model
848 //*****************************************************************************
849
850 MULTIPR_GUI_DataModel::MULTIPR_GUI_DataModel(CAM_Module* module) : 
851         LightApp_DataModel(module)
852 {
853         mMULTIPR_GUI = dynamic_cast<MULTIPR_GUI*>(module);
854 }
855
856
857 MULTIPR_GUI_DataModel::~MULTIPR_GUI_DataModel()
858 {
859         // do nothing!
860 }
861
862
863 void MULTIPR_GUI_DataModel::build()
864 {
865         try
866         {
867                 MULTIPR_GUI_DataObject_Module* modelRoot = dynamic_cast<MULTIPR_GUI_DataObject_Module*>(root());
868                 
869                 if (!modelRoot)  
870                 {  
871                         // root is not set yet
872                         modelRoot = new MULTIPR_GUI_DataObject_Module(this, NULL, "MULTIPR");
873                         setRoot(modelRoot);
874                 }
875                 
876                 MULTIPR_ORB::MULTIPR_Obj_ptr obj = mMULTIPR_GUI->getMULTIPRObj();
877                 
878                 if (obj != NULL)
879                 {
880                         MULTIPR_ORB::string_array* listParts = obj->getParts();
881                         
882                         if (listParts->length() >= 1)
883                         {
884                                 const char* strPartName0 = (*listParts)[0];
885                                 char* strPartInfo0 = obj->getPartInfo(strPartName0);
886                                 
887                                 char   lMeshName[256];
888                                 int    lId;
889                                 char   lPartName[256];
890                                 char   lPath[256];
891                                 char   lMEDFileName[256];       
892                                 
893                                 // parse infos
894                                 int ret = sscanf(strPartInfo0, "%s %d %s %s %s", 
895                                         lMeshName,
896                                         &lId,
897                                         lPartName,
898                                         lPath,
899                                         lMEDFileName);
900                                         
901                                 if (ret != 5) return;
902                                 
903                                 MULTIPR_GUI_DataObject_Mesh* dataObjectMesh = new MULTIPR_GUI_DataObject_Mesh(modelRoot, lMeshName);
904                                 
905                                 MULTIPR_GUI_DataObject_Part* dataObjectPart_prev = NULL;
906                                 
907                                 for (int i = 0 ; i < listParts->length() ; i++)
908                                 {
909                                         const char* strItem = (*listParts)[i];
910                                         char* strPartInfo = obj->getPartInfo(strItem);
911                                         
912                                         // parse infos
913                                         int ret = sscanf(strPartInfo, "%s %d %s %s %s", 
914                                                 lMeshName,
915                                                 &lId,
916                                                 lPartName,
917                                                 lPath,
918                                                 lMEDFileName);
919                                         
920                                         if (ret != 5) return;
921                                 
922                                         //cout << "Part : " << lPartName << endl;
923                                         if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
924                                         {
925                                                 //cout << "Found MED/LOW" << endl;
926                                                 new MULTIPR_GUI_DataObject_Resolution(dataObjectPart_prev, strItem, strPartInfo);
927                                         }
928                                         else
929                                         {
930                                                 dataObjectPart_prev = new MULTIPR_GUI_DataObject_Part(dataObjectMesh, strItem, strPartInfo);
931                                         }
932                                 }
933                         }
934                 }
935         }
936         catch (...)
937         {
938         }
939 }
940
941
942 extern "C" 
943 {
944         CAM_Module* createModule()
945         {
946                 return new MULTIPR_GUI();
947         }
948 }
949
950
951 // EOF