]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Display invalid profiles names in OB in red color.
authormzn <mzn@opencascade.com>
Fri, 29 Nov 2013 14:48:18 +0000 (14:48 +0000)
committermzn <mzn@opencascade.com>
Fri, 29 Nov 2013 14:48:18 +0000 (14:48 +0000)
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataObject.cxx
src/HYDROGUI/HYDROGUI_DataObject.h

index 675d2f4898ef2f59c4fdaaf9f72131c11840ee63..ef8a9065d3da6c647a2f9b3216b381218e530d55 100644 (file)
@@ -744,6 +744,13 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
         createZone( aGuiObj, aRegionZone, "", true );
     }
   }
+  else if ( anObjectKind == KIND_PROFILE )
+  {
+    Handle(HYDROData_Profile) aProfileObj =
+      Handle(HYDROData_Profile)::DownCast( aDataObj );
+
+    aGuiObj->setIsValid( aProfileObj->IsValid() );
+  }
 }
 
 void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )
index bab5e03975076149e87011eed432c43cba875f6a..c35afa88d6f5bd148351adeed4d8934185efdcda 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "HYDROGUI_DataObject.h"
 
-#include <HYDROData_Image.h>
 #include <SUIT_DataObject.h>
 #include <TDF_Tool.hxx>
 
@@ -32,7 +31,8 @@ HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
 : CAM_DataObject( theParent ),
   LightApp_DataObject( theParent ),
   myData( theData ),
-  myParentEntry( theParentEntry )
+  myParentEntry( theParentEntry ),
+  myIsValid( true )
 {
 }
 
@@ -70,6 +70,35 @@ QFont HYDROGUI_DataObject::font( const int theId ) const
   return aFont;
 }
 
+QColor HYDROGUI_DataObject::color( const ColorRole theRole, const int theId ) const
+{
+  QColor aColor;
+
+  if ( !isValid() ) {
+    switch ( theRole )
+    {
+      case Text:
+      case Foreground:
+      case Highlight:
+        aColor = QColor( 255, 0, 0 ); // red
+      break;
+      case HighlightedText:
+        // text color for the highlighted item
+        aColor = QColor( 255, 255, 255 );   // white
+      break;
+
+      default:
+        break;
+    }
+  }
+
+  if ( !aColor.isValid() ) {
+    aColor = LightApp_DataObject::color( theRole, theId );
+  }
+
+  return aColor;
+}
+
 QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
                                               const bool theWithPrefix )
 {
@@ -85,6 +114,16 @@ QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& th
   return aEntryStr;
 }
 
+void HYDROGUI_DataObject::setIsValid( const bool theIsValid )
+{
+  myIsValid = theIsValid;
+}
+
+bool HYDROGUI_DataObject::isValid() const
+{
+  return myIsValid;
+}
+
 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
                                             const QString&   theName,
                                             const QString&   theParentEntry  )
index 41a7bca4a72f7e525434afece793dd1b2a2090e3..72f31ed52780cec3a6202fcb5f0412f4bfadcffd 100644 (file)
@@ -80,6 +80,11 @@ public:
    */
   virtual QFont font( const int = SUIT_DataObject::NameId ) const;
 
+  /**
+   * Returns the object color.
+   */
+  virtual QColor color( const ColorRole, const int = NameId ) const;
+
   /**
    * Returns the model data object.
    */
@@ -100,10 +105,22 @@ public:
    */
   static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
                                   const bool theWithPrefix = true );
+  /**
+   * Sets the validity flag: if object is valid or not.
+   * \param theIsValid is true for valid objects, false for invalid
+   */
+  void setIsValid( const bool theIsValid );
+
+  /**
+   * Returns the validity flag: is object valid or not
+   * \returns false if object is not valid
+   */
+  bool isValid() const;
 
 protected:
   Handle(HYDROData_Entity) myData; ///< object from data model
   QString myParentEntry;
+  bool myIsValid; ///< indicates if the object is valid
 };
 
 /**