2013-04-01 18:25:01 +06:00
|
|
|
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-06-17 18:19:23 +06:00
|
|
|
#include "GEOM_Object.hxx"
|
2013-09-30 17:45:32 +06:00
|
|
|
|
2013-06-17 18:19:23 +06:00
|
|
|
#include <TDataStd_Integer.hxx>
|
|
|
|
#include <TDataStd_Real.hxx>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <TDataStd_RealArray.hxx>
|
2013-06-17 18:19:23 +06:00
|
|
|
|
|
|
|
#include "utilities.h"
|
|
|
|
|
2013-09-30 17:45:32 +06:00
|
|
|
// #define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb)))
|
|
|
|
// #define TYPE_LABEL 2 -- Labels used by GEOM_BaseObject
|
|
|
|
// #define FREE_LABEL 3
|
|
|
|
// #define TIC_LABEL 4
|
2008-03-07 12:45:34 +05:00
|
|
|
#define COLOR_LABEL 5
|
|
|
|
#define AUTO_COLOR_LABEL 6
|
2012-08-09 13:58:02 +06:00
|
|
|
#define MARKER_LABEL 7
|
|
|
|
|
|
|
|
#define MARKER_LABEL_TYPE 1
|
|
|
|
#define MARKER_LABEL_SIZE 2
|
|
|
|
#define MARKER_LABEL_ID 3
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetObject
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-09-30 17:45:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel)
|
|
|
|
{
|
2013-09-30 17:45:32 +06:00
|
|
|
Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetObject(theLabel);
|
|
|
|
return Handle(GEOM_Object)::DownCast( base );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetReferencedObject
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-09-30 17:45:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel)
|
|
|
|
{
|
2013-09-30 17:45:32 +06:00
|
|
|
Handle(GEOM_BaseObject) base = GEOM_BaseObject::GetReferencedObject(theLabel);
|
|
|
|
return Handle(GEOM_Object)::DownCast( base );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Constructor: private
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-09-30 17:45:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM_Object::GEOM_Object(TDF_Label& theEntry)
|
2013-09-30 17:45:32 +06:00
|
|
|
: GEOM_BaseObject(theEntry)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Constructor: public
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2013-09-30 17:45:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
|
2013-09-30 17:45:32 +06:00
|
|
|
: GEOM_BaseObject( theEntry, theType )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOM_Object::~GEOM_Object()
|
|
|
|
{
|
|
|
|
MESSAGE("GEOM_Object::~GEOM_Object()");
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetValue
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
TopoDS_Shape GEOM_Object::GetValue()
|
|
|
|
{
|
|
|
|
TopoDS_Shape aShape;
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = GetLastFunction();
|
|
|
|
|
|
|
|
if (!aFunction.IsNull())
|
|
|
|
aShape = aFunction->GetValue();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
return aShape;
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* SetColor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GEOM_Object::SetColor(const GEOM_Object::Color& theColor)
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
|
|
|
Handle(TDataStd_RealArray) anArray = new TDataStd_RealArray();
|
|
|
|
anArray->Init( 1, 3 );
|
|
|
|
anArray->SetValue( 1, theColor.R );
|
|
|
|
anArray->SetValue( 2, theColor.G );
|
|
|
|
anArray->SetValue( 3, theColor.B );
|
|
|
|
|
|
|
|
Handle(TDataStd_RealArray) anAttr =
|
|
|
|
TDataStd_RealArray::Set(_label.FindChild(COLOR_LABEL), anArray->Lower(), anArray->Upper());
|
|
|
|
anAttr->ChangeArray(anArray->Array());
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetColor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM_Object::Color GEOM_Object::GetColor()
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
|
|
|
Handle(TDataStd_RealArray) anArray;
|
|
|
|
bool isFound = _label.FindChild(COLOR_LABEL).FindAttribute(TDataStd_RealArray::GetID(), anArray);
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM_Object::Color aColor;
|
|
|
|
aColor.R = isFound ? anArray->Value( 1 ) : -1;
|
|
|
|
aColor.G = isFound ? anArray->Value( 2 ) : -1;
|
|
|
|
aColor.B = isFound ? anArray->Value( 3 ) : -1;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
return aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* SetAutoColor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GEOM_Object::SetAutoColor(bool theAutoColor)
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
|
|
|
TDataStd_Integer::Set(_label.FindChild(AUTO_COLOR_LABEL), (int)theAutoColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetAutoColor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
bool GEOM_Object::GetAutoColor()
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
|
|
|
Handle(TDataStd_Integer) anAutoColor;
|
|
|
|
if(!_label.FindChild(AUTO_COLOR_LABEL).FindAttribute(TDataStd_Integer::GetID(), anAutoColor)) return false;
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
return bool(anAutoColor->Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* SetMarkerStd
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOM_Object::SetMarkerStd(const Aspect_TypeOfMarker theType, double theSize)
|
|
|
|
{
|
|
|
|
TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL);
|
|
|
|
TDataStd_Integer::Set(aMarkerLabel.FindChild(MARKER_LABEL_TYPE), (int)theType);
|
|
|
|
TDataStd_Real::Set(aMarkerLabel.FindChild(MARKER_LABEL_SIZE), theSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* SetMarkerTexture
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOM_Object::SetMarkerTexture(int theTextureId)
|
|
|
|
{
|
|
|
|
TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL);
|
|
|
|
TDataStd_Integer::Set(aMarkerLabel.FindChild(MARKER_LABEL_TYPE), (int)Aspect_TOM_USERDEFINED);
|
|
|
|
TDataStd_Integer::Set(aMarkerLabel.FindChild(MARKER_LABEL_ID), theTextureId);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetMarkerType
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Aspect_TypeOfMarker GEOM_Object::GetMarkerType()
|
|
|
|
{
|
|
|
|
Standard_Integer aType = -1;
|
|
|
|
TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL, Standard_False);
|
|
|
|
if(!aMarkerLabel.IsNull()) {
|
|
|
|
TDF_Label aTypeLabel = aMarkerLabel.FindChild(MARKER_LABEL_TYPE, Standard_False);
|
|
|
|
Handle(TDataStd_Integer) aTypeAttr;
|
|
|
|
if (!aTypeLabel.IsNull() && aTypeLabel.FindAttribute(TDataStd_Integer::GetID(), aTypeAttr))
|
|
|
|
aType = aTypeAttr->Get();
|
|
|
|
}
|
|
|
|
return (Aspect_TypeOfMarker)aType;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetMarkerSize
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
double GEOM_Object::GetMarkerSize()
|
|
|
|
{
|
|
|
|
Standard_Real aSize = 0.;
|
|
|
|
TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL, Standard_False);
|
|
|
|
if(!aMarkerLabel.IsNull()) {
|
|
|
|
TDF_Label aSizeLabel = aMarkerLabel.FindChild(MARKER_LABEL_SIZE, Standard_False);
|
|
|
|
Handle(TDataStd_Real) aSizeAttr;
|
|
|
|
if (!aSizeLabel.IsNull() && aSizeLabel.FindAttribute(TDataStd_Real::GetID(), aSizeAttr))
|
|
|
|
aSize = aSizeAttr->Get();
|
|
|
|
}
|
|
|
|
return aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetMarkerTexture
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
int GEOM_Object::GetMarkerTexture()
|
|
|
|
{
|
|
|
|
Standard_Integer anId = 0;
|
|
|
|
if ( GetMarkerType() == Aspect_TOM_USERDEFINED) {
|
|
|
|
TDF_Label aMarkerLabel = _label.FindChild(MARKER_LABEL, Standard_False);
|
|
|
|
if(!aMarkerLabel.IsNull()) {
|
|
|
|
TDF_Label aTypeLabel = aMarkerLabel.FindChild(MARKER_LABEL_ID, Standard_False);
|
|
|
|
Handle(TDataStd_Integer) anIdAttr;
|
|
|
|
if (!aTypeLabel.IsNull() && aTypeLabel.FindAttribute(TDataStd_Integer::GetID(), anIdAttr))
|
|
|
|
anId = anIdAttr->Get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return anId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* SetAuxData
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOM_Object::UnsetMarker()
|
|
|
|
{
|
|
|
|
SetMarkerStd((Aspect_TypeOfMarker)-1, 0.);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* IsSubShape
|
|
|
|
*/
|
2008-03-07 12:45:34 +05:00
|
|
|
//=============================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
bool GEOM_Object::IsMainShape()
|
|
|
|
{
|
|
|
|
Handle(GEOM_Function) aFunction = GetFunction(1);
|
2013-09-30 17:45:32 +06:00
|
|
|
if(aFunction.IsNull() || aFunction->GetDriverGUID() != GetSubShapeID())
|
|
|
|
return true; // mkr : IPAL9921
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-30 17:45:32 +06:00
|
|
|
IMPLEMENT_STANDARD_HANDLE (GEOM_Object, GEOM_BaseObject );
|
|
|
|
IMPLEMENT_STANDARD_RTTIEXT(GEOM_Object, GEOM_BaseObject );
|