+// 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"
#include <TNaming_NamedShape.hxx>
#include <TopoDS_Shape.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Real.hxx>
#include <QColor>
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
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 )
{
}
void HYDROData_Object::Update()
{
- removeTopShape();
- removeShape3D();
- removeGroupObjects();
+ if( IsMustBeUpdated( Geom_2d ) )
+ {
+ removeTopShape();
+ removeGroupObjects();
+ }
+ if( IsMustBeUpdated( Geom_3d ) )
+ removeShape3D();
+
checkAndSetAltitudeObject();
HYDROData_Entity::Update();
}
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 )
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 )
{
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;
}
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 )
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;
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
ObjectKind anAltitudeObjectType = getAltitudeObjectType();
+ DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType);
if ( anAltitudeObjectType == KIND_UNKNOWN )
return; // No need to create altitude object
HYDROData_Iterator::CreateObject( aChildLabel, anAltitudeObjectType ) );
QString anAltitudePref = GetName() + "_Altitude";
+ DEBTRACE("anAltitudePref " << anAltitudePref.toStdString());
QString anAltitudeName = HYDROData_Tool::GenerateObjectName( aDocument, anAltitudePref );
anAltitudeObject->SetName( anAltitudeName );
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 );
+}