+QColor HYDROGUI_DataObject::color( const ColorRole theRole, const int theId ) const
+{
+ QColor aColor;
+
+ if ( !isValid() ) {
+ switch ( theRole )
+ {
+ case Text:
+ case Foreground:
+ case Highlight:
+ aColor = Qt::red; // red
+ break;
+ case HighlightedText:
+ // text color for the highlighted item
+ aColor = Qt::white; // white
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if ( !aColor.isValid() )
+ {
+ Handle(HYDROData_Entity) aDataObject = modelObject();
+ if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
+ {
+ switch ( theRole )
+ {
+ case Text:
+ case Foreground:
+ case Highlight:
+ aColor = Qt::blue; // color for objects which need updating
+ break;
+ case HighlightedText:
+ // text color for the highlighted item
+ aColor = Qt::white; // white
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ if ( !aColor.isValid() ) {
+ aColor = PARENT::color( theRole, theId );
+ }
+
+ return aColor;
+}
+
+QPixmap HYDROGUI_DataObject::icon( const int theId ) const
+{
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ if ( theId == NameId )
+ {
+ QString anIcon;
+ Handle(HYDROData_Entity) aDataObject = modelObject();
+ Handle(HYDROData_Object) anObject;
+ Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aDataObject);
+ Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aDataObject);
+
+ if (!anAObject.IsNull())
+ anObject = anAObject;
+ if (!aNObject.IsNull())
+ anObject = aNObject;
+
+ if( aDataObject.IsNull() )
+ {
+ anIcon = QObject::tr( "HYDRO_TYPE0_ICO" ); // KIND_UNKNOWN
+ }
+ else
+ {
+ QString aNeedUpdate( aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ? "M_" : "" );
+
+ int anObjectKind = (int)aDataObject->GetKind();
+ bool IsUnsImmZone = false;
+ if ( anObjectKind == KIND_DUMMY_3D )
+ {
+ Handle(HYDROData_DummyObject3D) anObject3D =
+ Handle(HYDROData_DummyObject3D)::DownCast( aDataObject );
+
+ Handle(HYDROData_Object) aFatherObj = anObject3D->GetObject();
+ if ( !aFatherObj.IsNull() )
+ anObjectKind = aFatherObj->GetKind();
+ anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() );
+ }
+ else if ( !anObject.IsNull() )
+ {
+ bool IsSubm = anObject->IsSubmersible();
+ QString anIcon1 = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() );
+ QString anIcon2;
+ if (IsSubm)
+ anIcon2 = QObject::tr( QString("HYDRO_SUBMERSIBLE16_ICO").toLatin1());
+ else
+ anIcon2 = QObject::tr( QString("HYDRO_UNSUBMERSIBLE16_ICO").toLatin1());
+
+ QPixmap qpm1 = aResMgr->loadPixmap( "HYDRO", anIcon1 );
+ QPixmap qpm2 = aResMgr->loadPixmap( "HYDRO", anIcon2 );
+ QPixmap qpmD(32,16);
+ qpmD.fill(QColor(0,0,0));
+ QPainter painter;
+ painter.begin(&qpmD);
+ painter.drawPixmap(0, 0, qpm1);
+ painter.drawPixmap(16, 0, qpm2);
+ painter.end();
+ return qpmD;
+ }
+ else if (anObjectKind == KIND_BC_POLYGON)
+ {
+ Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( aDataObject );
+ int aBT = aBCObj->GetBoundaryType();
+ if (aBT == 1)
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1());
+ else if (aBT == 2)
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1());
+ else if (aBT == 3)
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+ else
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE_UNDEF_ICO").toLatin1());
+ }
+ else
+ anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() );
+ }
+
+ return aResMgr->loadPixmap( "HYDRO", anIcon );
+ }
+ return PARENT::icon( theId );
+}
+