X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Object.cxx;h=25b9e2625187447f1a6a2ad224eb99c530b2da13;hb=c0d628b2e1f42a693a91c1054f42dcfd36a054e5;hp=242a09748a610faad504e8a0ee08bc3395731667;hpb=74c188e3a6b35d44424c694c6188b82273812be7;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 242a0974..25b9e262 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "HYDROData_Object.h" @@ -11,6 +28,7 @@ #include #include +#include #include @@ -132,6 +150,38 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetGroups() const return GetReferenceObjects( DataTag_EdgesGroup ); } +Handle(HYDROData_ShapesGroup) HYDROData_Object::GetGroup( const int theGroupId ) const +{ + Handle(HYDROData_ShapesGroup) aResGroup; + + HYDROData_SequenceOfObjects aGroups = GetGroups(); + if ( theGroupId < 0 || theGroupId >= aGroups.Length() ) + return aResGroup; + + aResGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( theGroupId + 1 ) ); + + return aResGroup; +} + +int HYDROData_Object::GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup ) const +{ + int aRes = -1; + + HYDROData_SequenceOfObjects aGroups = GetGroups(); + for ( int i = 1, n = aGroups.Length(); i <= n; ++i ) + { + Handle(HYDROData_ShapesGroup) aGroup = + Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( i ) ); + if ( IsEqual( theGroup, aGroup ) ) + { + aRes = i - 1; + break; + } + } + + return aRes; +} + bool HYDROData_Object::SetAltitudeObject( const Handle(HYDROData_IAltitudeObject)& theAltitude ) { @@ -188,24 +238,37 @@ QColor HYDROData_Object::GetBorderColor() const return GetColor( getDefaultBorderColor(), DataTag_BorderColor ); } -QColor HYDROData_Object::DefaultFillingColor() +QColor HYDROData_Object::getDefaultFillingColor() const { return QColor( Qt::yellow ); } -QColor HYDROData_Object::DefaultBorderColor() +QColor HYDROData_Object::getDefaultBorderColor() const { return QColor( Qt::transparent ); } -QColor HYDROData_Object::getDefaultFillingColor() const +QStringList HYDROData_Object::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const { - return DefaultFillingColor(); -} + QStringList aResList = HYDROData_Entity::dumpObjectCreation( theTreatedObjects ); + if ( aResList.isEmpty() ) + return aResList; //Object was not created -QColor HYDROData_Object::getDefaultBorderColor() const -{ - return DefaultBorderColor(); + QStringList aColorsDef; + + QColor aFillingColor = GetFillingColor(); + setPythonObjectColor( aColorsDef, aFillingColor, getDefaultFillingColor(), "SetFillingColor" ); + + QColor aBorderColor = GetBorderColor(); + setPythonObjectColor( aColorsDef, aBorderColor, getDefaultBorderColor(), "SetBorderColor" ); + + if ( !aColorsDef.isEmpty() ) + { + aResList << aColorsDef; + aResList << QString( "" ); + } + + return aResList; } ObjectKind HYDROData_Object::getAltitudeObjectType() const @@ -267,10 +330,6 @@ Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject() return aNewGroup; } -void HYDROData_Object::createGroupObjects() -{ -} - void HYDROData_Object::removeGroupObjects() { TDF_Label aLabel = myLab.FindChild( DataTag_EdgesGroup, false ); @@ -318,3 +377,20 @@ void HYDROData_Object::removeShape3D() aLabel.ForgetAllAttributes(); } +bool HYDROData_Object::IsSubmersible() const +{ + Handle(TDataStd_Integer) aSubMersibleAttr; + + bool isSubmersible = true; //default + if( myLab.FindAttribute(TDataStd_Integer::GetID(), aSubMersibleAttr ) ) + { + int aValue = aSubMersibleAttr->Get(); + isSubmersible = ( aValue != 0 ); + } + return isSubmersible; +} + +void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const +{ + TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 ); +}