Salome HOME
Copyright update 2021
[modules/gui.git] / src / SalomeApp / SalomeApp_DataObject.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : SalomeApp_DataObject.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24
25 #include "SalomeApp_DataObject.h"
26 #include "SalomeApp_Study.h"
27 #include "SalomeApp_Application.h"
28
29 #include <CAM_DataObject.h>
30
31 #include <SUIT_Session.h>
32 #include <SUIT_Application.h>
33 #include <SUIT_ResourceMgr.h>
34
35 #include <SALOME_LifeCycleCORBA.hxx>
36 #include <Basics_Utils.hxx>
37
38 #include <QObject>
39 #include <QVariant>
40
41 //VSR: uncomment below macro to support unicode text properly in SALOME
42 //     current commented out due to regressions
43 //#define PAL22528_UNICODE
44
45 namespace
46 {
47   QString fromUtf8( const char* txt )
48   {
49 #ifdef PAL22528_UNICODE
50     return QString::fromUtf8( txt );
51 #else
52     return QString( txt );
53 #endif
54   }
55
56   QString fromUtf8( const std::string& txt )
57   {
58     return fromUtf8( txt.c_str() );
59   }
60 }
61
62 /*!
63   \class SalomeApp_DataObject
64   \brief Implementation of the data object for use in CORBA-based
65   SALOME modules.
66 */
67
68 /*!
69   \brief Constructor. 
70   \param parent parent data object
71 */
72 SalomeApp_DataObject::SalomeApp_DataObject( SUIT_DataObject* parent )
73 : CAM_DataObject( parent ),
74   LightApp_DataObject( parent )
75 {
76 }
77
78 /*!
79   \brief Constructor. 
80   \param sobj SALOMEDS object
81   \param parent parent data object
82 */
83 SalomeApp_DataObject::SalomeApp_DataObject( const _PTR(SObject)& sobj, 
84                                             SUIT_DataObject* parent )
85 : CAM_DataObject( parent ),
86   LightApp_DataObject( parent )
87 {
88   myObject = sobj;
89 }
90
91 /*!
92   \brief Destructor.
93 */
94 SalomeApp_DataObject::~SalomeApp_DataObject()
95 {
96 }
97
98 /*!
99   \brief Get data object name.
100   \return object name
101 */
102 QString SalomeApp_DataObject::name() const
103 {
104   QString str;
105   if ( myObject )
106     str = fromUtf8( myObject->GetName() );
107   
108   if ( str.isEmpty() ) {
109     _PTR(SObject) refObj = referencedObject();
110     if ( refObj )
111       str = fromUtf8( refObj->GetName() );
112   }
113   
114   if ( isReference() ) {
115     if ( !(QString(referencedObject()->GetName().c_str()).isEmpty()) )
116       str = QString( "* " ) + str;
117     else
118       str = QString( "<Invalid Reference>" );
119   }
120   return str;
121 }
122
123 /*!
124   \brief Get object string identifier.
125   \return object ID
126 */
127 QString SalomeApp_DataObject::entry() const
128 {
129   return entry( myObject );
130 }
131
132 /*!
133   \brief Get object text data for the specified column.
134
135   This method returns the data according to the specufied column \a id:
136   - NameId     : object name (by calling name() method)
137   - EntryId    : object entry (by calling entry() method)
138   - ValueId    : object value
139   - IORId      : object IOR
140   - RefEntryId : object reference entry
141
142   \param id column id
143   \return object text data
144 */
145 QString SalomeApp_DataObject::text( const int id ) const
146 {
147   QString txt;
148
149   // Text for "Value" and "IOR" columns
150   switch ( id )
151   {
152   case ValueId:
153     if ( componentObject() != (SUIT_DataObject*)this )
154       txt = value( object() );
155     if ( txt.isEmpty() )
156       txt = value( referencedObject() );
157     break;
158   case IORId:
159     txt = ior( referencedObject() );
160     break;
161   default:
162     // Issue 21379: LightApp_DataObject::text() treats "Entry"
163     // and "Reference Entry" columns
164     txt = LightApp_DataObject::text( id );
165     break;
166   }
167   return txt;
168 }
169
170 /*!
171   \brief Get data object icon for the specified column.
172   \param id column id
173   \return object icon for the specified column
174 */
175 QPixmap SalomeApp_DataObject::icon( const int id ) const
176 {
177   // we display icon only for the first (NameId ) column
178   if ( id == NameId ) {
179     _PTR(GenericAttribute) anAttr;
180     if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){
181       _PTR(AttributePixMap) aPixAttr ( anAttr );
182       if ( aPixAttr->HasPixMap() ) {
183         QString componentType = componentDataType();
184         QString pixmapID      = fromUtf8( aPixAttr->GetPixMap() );
185         // select a plugin within a component
186         QStringList plugin_pixmap = pixmapID.split( "::", QString::KeepEmptyParts );
187         if ( plugin_pixmap.size() == 2 ) {
188           componentType = plugin_pixmap.front();
189           pixmapID      = plugin_pixmap.back();
190         }
191         QString pixmapName = QObject::tr( pixmapID.toLatin1().constData() );
192         LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
193         if ( aRoot && aRoot->study() ) {
194           SUIT_ResourceMgr* mgr = aRoot->study()->application()->resourceMgr();
195           return mgr->loadPixmap( componentType, pixmapName, false ); 
196         }
197       }
198     }
199   }
200   return LightApp_DataObject::icon( id );
201 }
202
203 /*!
204   \brief Get data object color for the specified column.
205   \param role color role
206   \param id column id (not used)
207   \return object color for the specified column
208 */
209 QColor SalomeApp_DataObject::color( const ColorRole role, const int id ) const
210 {
211   // we ignore parameter <id> in order to use the same colors for 
212   // all columns
213   QColor c;
214   switch ( role )
215   {
216   case Text:
217   case Foreground:
218     // text color (not selected item)
219     if ( isReference() ) {
220       if ( QString(referencedObject()->GetName().c_str()).isEmpty() )
221         c = QColor( 200, 200, 200 );  // invalid reference (grayed)
222     }
223     else if ( myObject ) {
224       // get color atrtribute value
225       _PTR(GenericAttribute) anAttr;
226       if ( myObject->FindAttribute( anAttr, "AttributeTextColor" ) ) {
227         _PTR(AttributeTextColor) aColAttr = anAttr;
228         c = QColor( (int)aColAttr->TextColor().R, (int)aColAttr->TextColor().G, (int)aColAttr->TextColor().B );
229       }
230     }
231     break;
232
233   case Highlight:
234     // background color for the highlighted item
235     if ( isReference() ) {
236       if ( QString(referencedObject()->GetName().c_str()).isEmpty() )
237         c = QColor( 200, 200, 200 );  // invalid reference (grayed)
238     }
239     else if ( myObject ) {
240       // get color atrtribute value
241       _PTR(GenericAttribute) anAttr;
242       if( myObject->FindAttribute ( anAttr, "AttributeTextHighlightColor") ) {
243         _PTR(AttributeTextHighlightColor) aHighColAttr = anAttr;
244         c = QColor( (int)(aHighColAttr->TextHighlightColor().R), 
245                     (int)(aHighColAttr->TextHighlightColor().G), 
246                     (int)(aHighColAttr->TextHighlightColor().B));
247       }
248     }
249     break;
250   default:
251     break;
252   }
253
254   // Issue 21379: LightApp_DataObject::color() defines colors for valid references
255   if ( !c.isValid() )
256     c = LightApp_DataObject::color( role, id );
257
258   return c;
259 }
260
261 /*!
262   \brief Get data object tooltip for the specified column.
263   \param id column id (not used)
264   \return object tooltip for the specified column
265 */
266 QString SalomeApp_DataObject::toolTip( const int /*id*/ ) const
267 {
268   // we ignore parameter <id> in order to use the same tooltip for 
269   // all columns
270   
271   // Get customized tooltip in case of it exists
272   const SalomeApp_DataObject* compObj = dynamic_cast<SalomeApp_DataObject*>( componentObject() );
273   // Check if the component has been loaded.
274   // In order to avoid loading the component only for getting a custom tooltip.
275   if ( compObj && compObj != this && !ior(compObj->object()).isEmpty() ) {
276     SalomeApp_Application* app = 
277       dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
278     if ( app ) {
279       // --- try to find (and not load) the component instance, like GEOM instance,
280       //     registered in naming service under Containers/<hostname>/...
281       //     with any container name, on every machine available
282       Engines::ContainerParameters params;
283       app->lcc()->preSet(params); // --- any container name, anywhere
284       Engines::EngineComponent_var aComponent =
285         app->lcc()->FindComponent(params, componentDataType().toLatin1().constData() );
286       
287       if ( !CORBA::is_nil(aComponent) && aComponent->hasObjectInfo() ) {
288         LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
289         if ( aRoot && aRoot->study() ) {
290           CORBA::String_var data = aComponent->getObjectInfo( entry().toUtf8().constData());
291           QString objInfo = data.in();
292           QStringList l;
293           l << name();
294           if ( !objInfo.isEmpty() )
295             l << objInfo;
296           return l.join("\n");
297         }
298       }
299     }
300   }
301   
302   return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() );
303 }
304
305 /*!
306   \brief Get font to be used for data object rendering in the item views
307   \param id column id
308   \return font to be used for the item rendering
309 */
310 QFont SalomeApp_DataObject::font( const int id ) const
311 {
312   QFont f = LightApp_DataObject::font( id );
313   if ( id == NameId ) {
314     if ( !expandable() && hasChildren() ) {
315       // set bold font to highlight the item which is non-expandable but has children
316       f.setBold( true );
317     }
318   }
319   return f;
320 }
321
322 /*!
323   \brief Get component type.
324   \return component type
325 */
326 QString SalomeApp_DataObject::componentDataType() const
327 {
328   //  if ( myCompDataType.isEmpty() ) {
329     const SalomeApp_DataObject* compObj = dynamic_cast<SalomeApp_DataObject*>( componentObject() );
330     if ( compObj && compObj->object() )
331     {
332       _PTR(SComponent) aComp( compObj->object() );
333       if ( aComp ) {
334         SalomeApp_DataObject* that = (SalomeApp_DataObject*)this;
335         that->myCompDataType = aComp->ComponentDataType().c_str();
336       }
337     }
338     //  }
339   return myCompDataType;
340 }
341
342 /*!
343   \brief Get SALOMEDS object.
344   \return SALOMEDS object
345 */
346 _PTR(SObject) SalomeApp_DataObject::object() const
347 {
348   return myObject;
349 }
350
351 /*!
352   \brief Returns the string identifier of the data objects referenced by this one.
353
354   Re-implemented from LightApp_DataObject using SALOMEDS API.
355
356   \return ID string of the referenced SObject
357 */
358 QString SalomeApp_DataObject::refEntry() const
359 {
360   return entry( referencedObject() );
361 }
362
363 /*!
364   \brief Check if the data object is a reference.
365
366   Re-implemented from LightApp_DataObject using SALOMEDS API.
367
368   \return \c true if this data object actually refers to another one
369 */
370 bool SalomeApp_DataObject::isReference() const
371 {
372   bool isRef = false;
373   if ( myObject )
374   {
375     _PTR(SObject) refObj;
376     isRef = myObject->ReferencedObject( refObj );
377   }
378   return isRef;
379 }
380
381 /*!
382   \brief Get the object referenced by this one.
383   \return referenced object
384 */
385 _PTR(SObject) SalomeApp_DataObject::referencedObject() const
386 {
387   _PTR(SObject) refObj;
388   _PTR(SObject) obj = myObject;
389   while ( obj && obj->ReferencedObject( refObj ) )
390     obj = refObj;
391
392   return obj;
393 }
394
395 /*!
396   \brief Check if object has children
397   \return \c true if object has at least one child sub-object and \c false otherwise
398 */
399 bool SalomeApp_DataObject::hasChildren() const
400 {
401   bool ok = false;
402
403   // tmp??
404   _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder();
405   if (aUseCaseBuilder->IsUseCaseNode(myObject)) {
406     ok = aUseCaseBuilder->HasChildren(myObject);
407     // TODO: check name as below?
408   }
409   else {
410     _PTR(ChildIterator) it ( SalomeApp_Application::getStudy()->NewChildIterator( myObject ) );
411     for ( ; it->More() && !ok; it->Next() ) {
412       _PTR(SObject) obj = it->Value();
413       if ( obj ) {
414         _PTR(SObject) refObj;
415         //if ( obj->ReferencedObject( refObj ) ) continue; // omit references
416         if ( obj->GetName() != "" ) ok = true;
417       }
418     }
419   }
420   return ok;
421 }
422
423 /*!
424   \brief Check if the object is expandable (e.g. in the data tree view)
425   \return \c true if object is expandable and \c false otherwise
426 */
427 bool SalomeApp_DataObject::expandable() const
428 {
429   bool exp = true;
430   _PTR(GenericAttribute) anAttr;
431   if ( myObject && myObject->FindAttribute( anAttr, "AttributeExpandable" ) ) {
432     _PTR(AttributeExpandable) aAttrExp = anAttr;
433     exp = aAttrExp->IsExpandable();
434   }
435   return exp;
436 }
437
438 /*!
439   \brief Check if the object is visible.
440   \return \c true if this object is displayable or \c false otherwise
441 */
442 bool SalomeApp_DataObject::isVisible() const
443 {
444   bool isDraw = true;
445   _PTR(GenericAttribute) anAttr;
446   if ( myObject && myObject->FindAttribute(anAttr, "AttributeDrawable") ) 
447   {
448     _PTR(AttributeDrawable) aAttrDraw = anAttr;
449     isDraw = aAttrDraw->IsDrawable(); 
450   }
451   return isDraw && LightApp_DataObject::isVisible() && ( !name().isEmpty() || isReference() );
452 }
453
454 /*!
455   \brief Check if the specified column supports custom sorting.
456   \param id column id
457   \return \c true if column sorting should be customized
458   \sa compare()
459 */
460 bool SalomeApp_DataObject::customSorting( const int id ) const
461 {
462   // perform custom sorting for the "Entry" and "Reference Entry" columns
463   return id == EntryId  || id == RefEntryId  ? true 
464     : LightApp_DataObject::customSorting( id );
465 }
466
467 /*!
468   \brief Compares data from two items for sorting purposes.
469
470   This method is called only for those columns for which customSorting()
471   method returns \c true.
472
473   \param left first data to compare
474   \param right second data to compare
475   \param id column id
476   \return result of the comparison
477   \sa customSorting()
478 */
479 bool SalomeApp_DataObject::compare( const QVariant& left, const QVariant& right, const int id ) const
480 {
481   // use the same custom sorting for the "Reference Entry" column as for the
482   // "Entry" column (call base implementation)
483   return LightApp_DataObject::compare( left, right, id == RefEntryId ? EntryId : id );
484 }
485
486 /*!
487   \brief Get data object IOR.
488   \param obj data object
489   \return data object IOR or null string if IOR is empty
490 */
491 QString SalomeApp_DataObject::ior( const _PTR(SObject)& obj ) const
492 {
493   QString txt;
494   if ( obj )
495   {
496     _PTR(GenericAttribute) attr;
497     if ( obj->FindAttribute( attr, "AttributeIOR" ) )
498     {
499       _PTR(AttributeIOR) iorAttr = attr;
500       if ( iorAttr )
501       {
502         std::string str = iorAttr->Value();
503         txt = QString( str.c_str() );
504       }
505     }
506   }
507   return txt;
508 }
509
510 /*!
511   \brief Get data object entry identifier.
512   \param obj data object
513   \return data object entry identifier or empty object does not have entry
514 */
515 QString SalomeApp_DataObject::entry( const _PTR(SObject)& obj ) const
516 {
517   QString txt;
518   if ( obj )
519   {
520     std::string str = obj->GetID();
521     txt = QString( str.c_str() );
522   }
523   return txt;
524 }
525
526 /*!
527   \brief Get data object value.
528   \param obj data object
529   \return data object value or empty string if there is no 
530   value associated to the object
531 */
532 QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const
533 {
534   if ( !obj )
535     return QString();
536
537   QString val;
538   _PTR(GenericAttribute) attr;
539
540   if ( obj->FindAttribute( attr, "AttributeString" ) )
541   {
542     _PTR(AttributeString) strAttr = attr;
543     std::string str = strAttr->Value();
544     QString aStrings = fromUtf8( str );
545     
546     //Special case to show NoteBook variables in the "Value" column of the OB 
547     bool ok = false;
548     QStringList aSectionList = aStrings.split( "|" );
549     if ( !aSectionList.isEmpty() )
550     {
551       QString aLastSection = aSectionList.last();
552       QStringList aStringList = aLastSection.split( ":" );
553       if ( !aStringList.isEmpty() )
554       {
555         ok = true;
556         for ( int i = 0, n = aStringList.size(); i < n; i++ )
557         {
558           QString aStr = aStringList[i];
559           if ( SalomeApp_Application::getStudy()->IsVariable( aStr.toStdString() ) )
560             val.append( aStr + ", " );
561         }
562
563         if ( !val.isEmpty() )
564           val.remove( val.length() - 2, 2 );
565       }
566     }
567     if( !ok )
568       val = aStrings;
569   }
570   else if ( obj->FindAttribute( attr, "AttributeInteger" ) )
571   {
572     _PTR(AttributeInteger) intAttr = attr;
573     if ( intAttr )
574       val = QString::number( intAttr->Value() );
575   }
576   else if ( obj->FindAttribute( attr, "AttributeReal" ) )
577   {
578     _PTR(AttributeReal) realAttr = attr;
579     if ( realAttr )
580       val = QString::number( realAttr->Value() );
581   }
582   else if ( obj->FindAttribute( attr, "AttributeTableOfInteger" ) )
583   {
584     _PTR(AttributeTableOfInteger) tableAttr = attr;
585     std::string title = tableAttr->GetTitle();
586     val = QString( title.c_str() );
587     if ( !val.isEmpty() )
588       val += QString( " " );
589     val += QString( "[%1,%2]" ).arg( tableAttr->GetNbRows() ).arg( tableAttr->GetNbColumns() );
590   }
591   else if ( obj->FindAttribute( attr, "AttributeTableOfReal" ) )
592   {
593     _PTR(AttributeTableOfReal) tableAttr = attr;
594     std::string title = tableAttr->GetTitle();
595     val = QString( title.c_str() );
596     if ( !val.isEmpty() )
597       val += QString( " " );
598     val += QString( "[%1,%2]" ).arg( tableAttr->GetNbRows() ).arg( tableAttr->GetNbColumns() );
599   }
600   else if ( obj->FindAttribute( attr, "AttributeComment" ) )
601   {
602     _PTR(AttributeComment) comm = attr;
603     std::string str = comm->Value();
604     val = fromUtf8( str );
605   }
606
607   return val;
608 }
609
610 void SalomeApp_DataObject::insertChildAtTag( SalomeApp_DataObject* obj, int tag )
611 {
612   int pos = 0;
613   int npos = qMin( tag-1,childCount() );
614   for ( int i = npos; i > 0; i-- )
615   {
616     if ( (dynamic_cast<SalomeApp_DataObject*>( childObject( i-1 ) ) )->object()->Tag() < tag )
617     {
618       pos = i;
619       break;
620     }
621   }
622   insertChildAtPos( obj, pos );
623 }
624
625 void SalomeApp_DataObject::updateItem()
626 {
627   if ( modified() ) return;
628   setModified( true );
629 }
630
631 /*!
632   \class SalomeApp_ModuleObject
633   \brief This class is used for optimized access to the SALOMEDS-based 
634   data model from SalomeApp_DataObject class instances.
635   \sa CAM_ModuleObject class
636 */
637
638 /*!
639   \brief Constructor.
640   \param parent parent data object
641 */
642 SalomeApp_ModuleObject::SalomeApp_ModuleObject( SUIT_DataObject* parent )
643 : CAM_DataObject( parent ),
644   LightApp_DataObject( parent ),
645   SalomeApp_DataObject( parent ),
646   CAM_ModuleObject( parent )
647 {
648 }
649
650 /*!
651   \brief Constructor.
652   \param sobj SALOMEDS object
653   \param parent parent data object
654 */
655 SalomeApp_ModuleObject::SalomeApp_ModuleObject( const _PTR(SObject)& sobj, 
656                                                 SUIT_DataObject* parent )
657 : CAM_DataObject( parent ),
658   LightApp_DataObject( parent ),
659   SalomeApp_DataObject( sobj, parent ),
660   CAM_ModuleObject( parent )
661 {
662 }
663
664 /*!
665   \brief Constructor.
666   \param dm data model
667   \param sobj SALOMEDS object
668   \param parent parent data object
669 */
670 SalomeApp_ModuleObject::SalomeApp_ModuleObject( CAM_DataModel* dm, 
671                                                 const _PTR(SObject)& sobj, 
672                                                 SUIT_DataObject* parent )
673 : CAM_DataObject( parent ),
674   LightApp_DataObject( parent ),
675   SalomeApp_DataObject( sobj, parent ),
676   CAM_ModuleObject( dm, parent )
677 {
678 }
679
680 /*!
681   \brief Destructor.
682 */
683 SalomeApp_ModuleObject::~SalomeApp_ModuleObject()
684 {
685 }
686
687 /*!
688   \brief Get module name.
689   \return module name
690 */
691 QString SalomeApp_ModuleObject::name() const
692 {
693   return SalomeApp_DataObject::name();
694 }
695
696 /*!
697   \brief Get data object icon for the specified column.
698   \param id column id
699   \return object icon for the specified column
700   \sa CAM_ModuleObject class
701 */
702 QPixmap SalomeApp_ModuleObject::icon( const int id ) const
703 {
704   QPixmap p = SalomeApp_DataObject::icon( id );
705   // The module might not provide a separate small icon
706   // for Obj. Browser representation -> always try to scale it
707   // See CAM_ModuleObject::icon()
708   if ( !p.isNull() )
709     p = Qtx::scaleIcon( p, 16 );
710   return p;
711 }
712
713 /*!
714   \brief Get data object tooltip for the specified column.
715   \param id column id
716   \return object tooltip for the specified column
717 */
718 QString SalomeApp_ModuleObject::toolTip( const int id ) const
719 {
720   return SalomeApp_DataObject::toolTip( id );
721 }
722
723 /*!
724   \class SalomeApp_RootObject
725   \brief Root data object for the CORBA-based SALOME application.
726
727   This class is to be instanciated by only one object - the root object
728   of the SalomeApp data object tree. This object is not shown in the object browser.
729   The goal of this class is to provide a unified access to SalomeApp_Study
730   object from SalomeApp_DataObject instances.
731 */
732
733 /*!
734   \brief Constructor.
735   \param study pointer to the study
736 */
737 SalomeApp_RootObject::SalomeApp_RootObject( LightApp_Study* study )
738 : CAM_DataObject( 0 ),
739   LightApp_DataObject( 0 ),
740   SalomeApp_DataObject( 0 ),
741   LightApp_RootObject( study ),
742   _toSynchronize(true)
743 {
744 }
745
746 /*!
747   \brief Destructor.
748 */
749 SalomeApp_RootObject::~SalomeApp_RootObject()
750 {
751 }
752
753 /*!
754   \brief Get data object name.
755   \return object name
756 */
757 QString SalomeApp_RootObject::name() const
758 {
759   return LightApp_RootObject::name();
760 }
761  
762 /*!
763   \brief Get object string identifier.
764   \return object ID
765 */
766 QString SalomeApp_RootObject::entry() const
767 {
768   return LightApp_RootObject::entry();
769 }
770
771 /*!
772   \brief Get object text data for the specified column.
773   \param id column id
774   \return object text data
775 */
776 QString SalomeApp_RootObject::text( const int id ) const
777 {
778   return LightApp_RootObject::text( id );
779 }
780
781 /*!
782   \brief Get data object icon for the specified column.
783   \param id column id
784   \return object icon for the specified column
785 */
786 QPixmap SalomeApp_RootObject::icon( const int id ) const
787 {
788   return LightApp_RootObject::icon( id );
789 }
790
791 /*!
792   \brief Get data object color for the specified column.
793   \param role color role
794   \param id column id (not used)
795   \return object color for the specified column
796 */
797 QColor SalomeApp_RootObject::color( const ColorRole role, const int id ) const
798 {
799   return LightApp_RootObject::color( role, id );
800 }
801
802 /*!
803   \brief Get data object tooltip for the specified column.
804   \param id column id (not used)
805   \return object tooltip for the specified column
806 */
807 QString SalomeApp_RootObject::toolTip( const int id ) const
808 {
809   return LightApp_RootObject::toolTip( id );
810 }
811
812 /*!
813   \class SalomeApp_SavePointObject
814   \brief Represents persistent visual_state object.
815
816   Save point objects are stored in the data model, but NOT in SObjects
817   structure, so they are handled separately using this special class
818 */
819
820 /*!
821   \brief Constructor.
822   \param parent parent data object
823   \param id save point ID
824   \param study study
825 */
826 SalomeApp_SavePointObject::SalomeApp_SavePointObject( SUIT_DataObject* parent,
827                                                       const int id,
828                                                       SalomeApp_Study* study )
829   : CAM_DataObject( parent ),
830     LightApp_DataObject( parent ),
831     myId( id ),
832     myStudy( study )
833 {
834 }
835
836 /*!
837   \brief Destructor.
838 */
839 SalomeApp_SavePointObject::~SalomeApp_SavePointObject()
840 {
841 }
842
843 /*!
844   \brief Get save point unique identifier.
845   \return save point ID
846 */
847 int SalomeApp_SavePointObject::getId() const
848 {
849   return myId;
850 }
851
852 /*!
853   \brief Get object string identifier.
854   \return object ID
855 */
856 QString SalomeApp_SavePointObject::entry() const
857 {
858   return QObject::tr( "SAVE_POINT_DEF_NAME" ) + QString::number( myId );
859 }
860
861 /*!
862   \brief Get data object name.
863   \return object name
864 */
865 QString SalomeApp_SavePointObject::name() const
866 {
867   return myStudy->getNameOfSavePoint( myId );
868 }
869
870 /*!
871   \brief Get data object icon for the specified column.
872   \param id column id
873   \return object icon for the specified column
874 */
875 QPixmap SalomeApp_SavePointObject::icon( const int /*id*/ ) const
876 {
877   return QPixmap();
878 }
879
880 /*!
881   \brief Get data object tooltip for the specified column.
882   \param id column id (not used)
883   \return object tooltip for the specified column
884 */
885 QString SalomeApp_SavePointObject::toolTip( const int /*id*/ ) const
886 {
887   return QObject::tr( "SAVE_POINT_OBJECT_TOOLTIP" ).arg( name() );
888 }
889
890 /*!
891   \class SalomeApp_SavePointRootObject
892   \brief Represents parent object for visual_state objects.
893 */
894
895 /*!
896   \brief Constructor.
897   \param parent parent object
898 */
899 SalomeApp_SavePointRootObject::SalomeApp_SavePointRootObject( SUIT_DataObject* parent )
900 : SUIT_DataObject( parent )
901 {
902 }
903
904 /*!
905   \brief Get data object name.
906   \return object name
907 */
908 QString SalomeApp_SavePointRootObject::name() const
909 {
910   return QObject::tr( "SAVE_POINT_ROOT_NAME" ); 
911 }
912
913 /*!
914   \brief Get data object tooltip for the specified column.
915   \param id column id (not used)
916   \return object tooltip for the specified column
917 */
918 QString SalomeApp_SavePointRootObject::toolTip( const int /*id*/ ) const
919 {
920   return QObject::tr( "SAVE_POINT_ROOT_TOOLTIP" ); 
921 }