X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Object.cxx;h=fff074adebd0d85ed9f4dbb78b5ae42b49b1de85;hb=981b9eb91e769d90dd63a0288cc3af6841bcb15e;hp=719c105bf908f79ae3ddb090f11af3ce03be4671;hpb=efb8a93b758b3a8ca6b277de19e8f9eb5d21b14a;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 719c105b..fff074ad 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,14 +28,15 @@ #include #include +#include #include IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity) -HYDROData_Object::HYDROData_Object() -: HYDROData_Entity() +HYDROData_Object::HYDROData_Object( Geometry theGeometry ) + : HYDROData_Entity( theGeometry ) { } @@ -57,9 +75,14 @@ void HYDROData_Object::SetName( const QString& theName ) void HYDROData_Object::Update() { - removeTopShape(); - removeShape3D(); - removeGroupObjects(); + if( IsMustBeUpdated2d() ) + { + removeTopShape(); + removeGroupObjects(); + } + if( IsMustBeUpdated3d() ) + removeShape3D(); + checkAndSetAltitudeObject(); HYDROData_Entity::Update(); } @@ -75,13 +98,13 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const return aResSeq; } -void HYDROData_Object::SetToUpdate( bool theFlag ) +void HYDROData_Object::Changed( Geometry theChangedGeometry ) { - HYDROData_Entity::SetToUpdate( theFlag ); + HYDROData_Entity::Changed( theChangedGeometry ); Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D(); if ( !anObject3D.IsNull() ) - anObject3D->SetToUpdate( theFlag ); + anObject3D->Changed( theChangedGeometry ); } void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape ) @@ -132,6 +155,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 ) { @@ -144,8 +199,9 @@ bool HYDROData_Object::SetAltitudeObject( SetReferenceObject( theAltitude, DataTag_AltitudeObject ); - // Indicate model of the need to update object - SetToUpdate( true ); + // #636: In the case of the altitude object change the geometry of the main object is not changed, + // to the object should not be marked as updated + //SetToUpdate( true ); return true; } @@ -164,8 +220,9 @@ void HYDROData_Object::RemoveAltitudeObject() ClearReferenceObjects( DataTag_AltitudeObject ); - // Indicate model of the need to update object - SetToUpdate( true ); + // #636: In the case of the altitude object change the geometry of the main object is not changed, + // to the object should not be marked as updated + //SetToUpdate( true ); } void HYDROData_Object::SetFillingColor( const QColor& theColor ) @@ -198,6 +255,29 @@ QColor HYDROData_Object::getDefaultBorderColor() const return QColor( Qt::transparent ); } +QStringList HYDROData_Object::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList = HYDROData_Entity::dumpObjectCreation( theTreatedObjects ); + if ( aResList.isEmpty() ) + return aResList; //Object was not created + + 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 { return KIND_UNKNOWN; @@ -304,3 +384,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 ); +}