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