2016-09-27 13:54:16 +03:00
|
|
|
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
|
|
|
|
// File : GEOMGUI_ShapeAnnotations.h
|
|
|
|
// Author : Anton POLETAEV, Open CASCADE S.A.S.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef GEOMGUI_SHAPEANNOTATIONS_H
|
|
|
|
#define GEOMGUI_SHAPEANNOTATIONS_H
|
|
|
|
|
2016-10-11 17:44:18 +03:00
|
|
|
#include <GEOMGUI_VisualProperties.h>
|
|
|
|
|
2016-09-27 13:54:16 +03:00
|
|
|
// OCCT includes
|
|
|
|
#include <gp_Ax3.hxx>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
class SalomeApp_Study;
|
2016-09-29 17:36:19 +03:00
|
|
|
class GEOM_Annotation;
|
2016-09-27 13:54:16 +03:00
|
|
|
|
2016-10-11 17:44:18 +03:00
|
|
|
class GEOMGUI_ShapeAnnotations;
|
|
|
|
typedef QSharedPointer<GEOMGUI_ShapeAnnotations> ShapeAnnotationsPtr;
|
|
|
|
|
2016-09-27 13:54:16 +03:00
|
|
|
/*!
|
|
|
|
* \brief Algorithms to translate and manitain list of shape annotation properties.
|
|
|
|
*
|
|
|
|
* Shape annotation presentations are store in relative coordinate system (LCS).
|
|
|
|
* To ensure that dimension is bound to the equal shape irrespectively of its location
|
|
|
|
* transformation.
|
|
|
|
*/
|
2016-10-11 17:44:18 +03:00
|
|
|
class Standard_EXPORT GEOMGUI_ShapeAnnotations : public GEOMGUI_VisualProperties
|
2016-09-27 13:54:16 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \ brief Structure representing properties of the shape annotation entry.
|
|
|
|
*/
|
|
|
|
struct ShapeAnnotation
|
|
|
|
{
|
2016-10-12 11:08:05 +03:00
|
|
|
QString Name; // annotation name label
|
2016-09-29 17:36:19 +03:00
|
|
|
QString Text; // annotation text label
|
|
|
|
bool IsVisible; // visibility of annotation
|
|
|
|
bool IsScreenFixed; // fixed screen mode flag
|
|
|
|
gp_Pnt Position; // position of the annotation
|
|
|
|
gp_Pnt Attach; // attachment point of the annotation
|
|
|
|
int ShapeIndex; // index of the annotated subshape
|
|
|
|
int ShapeType; // type of the annotated subshape
|
2016-09-30 12:01:23 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Update presentation properties using the annotation record definition.
|
|
|
|
* \param theShapeAnnotation [in] the explicit definition of the annotation.
|
|
|
|
*/
|
|
|
|
void ToPresentation( const Handle(GEOM_Annotation)& theShapeAnnotation,
|
|
|
|
const gp_Ax3& theLCS ) const;
|
2016-09-29 17:36:19 +03:00
|
|
|
|
|
|
|
bool operator == (const ShapeAnnotation& theOther) const
|
|
|
|
{
|
2016-10-12 11:08:05 +03:00
|
|
|
return Name == theOther.Name
|
|
|
|
&& Text == theOther.Text
|
2016-09-29 17:36:19 +03:00
|
|
|
&& IsVisible == theOther.IsVisible
|
|
|
|
&& IsScreenFixed == theOther.IsScreenFixed
|
|
|
|
&& Position.IsEqual (theOther.Position, 0.0)
|
|
|
|
&& Attach.IsEqual (theOther.Attach, 0.0)
|
|
|
|
&& ShapeIndex == theOther.ShapeIndex
|
|
|
|
&& ShapeType == theOther.ShapeType;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator != (const ShapeAnnotation& theOther) const
|
|
|
|
{
|
|
|
|
return !(operator == (theOther));
|
|
|
|
}
|
2016-09-27 13:54:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructor. Inits empty property.
|
|
|
|
*/
|
|
|
|
GEOMGUI_ShapeAnnotations();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Copy constructor.
|
|
|
|
*/
|
|
|
|
GEOMGUI_ShapeAnnotations( const GEOMGUI_ShapeAnnotations& theOther );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructor. Inits property from attribute.
|
|
|
|
*/
|
|
|
|
GEOMGUI_ShapeAnnotations( SalomeApp_Study* theStudy, const std::string& theEntry );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructor. Inits property from formatted QString.
|
|
|
|
*/
|
|
|
|
GEOMGUI_ShapeAnnotations( const QString& theProperty );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Destructor.
|
|
|
|
*/
|
|
|
|
~GEOMGUI_ShapeAnnotations();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Overload QVariant cast operator.
|
|
|
|
*/
|
|
|
|
operator QVariant() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Overload QString cast operator.
|
|
|
|
*/
|
|
|
|
operator QString() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Overload comparsion.
|
|
|
|
*/
|
|
|
|
bool operator == (const GEOMGUI_ShapeAnnotations &theOther) const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Overload comparsion.
|
|
|
|
*/
|
|
|
|
bool operator != (const GEOMGUI_ShapeAnnotations &theOther) const
|
|
|
|
{
|
|
|
|
return !(operator == (theOther));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Adds new shape annotation entry using explicit definition.
|
|
|
|
* \param theShapeAnnotation [in] the explicit definition of the annotation.
|
2016-10-11 17:44:18 +03:00
|
|
|
* \param theLCS [in] the local coordinate system of parent object.
|
2016-09-27 13:54:16 +03:00
|
|
|
*/
|
|
|
|
void Add( const ShapeAnnotation& theShapeAnnotation )
|
|
|
|
{
|
|
|
|
myAnnotations.append( theShapeAnnotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Update entry data using the explicit definition.
|
|
|
|
* \param theIndex [in] the index of the dimension record.
|
|
|
|
* \param theShapeAnnotation [in] the explicit definition of the annotation.
|
|
|
|
*/
|
|
|
|
void SetValues( const int theIndex, const ShapeAnnotation& theShapeAnnotation )
|
|
|
|
{
|
|
|
|
myAnnotations[theIndex] = theShapeAnnotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets annotation's entry data using the properties of interactive presentation.
|
|
|
|
* \param theIndex [in] the index of the record.
|
|
|
|
* \param theShapeAnnotation [in] the interactive presnetation.
|
|
|
|
* \param theLCS [in] the local coordinate system of parent object.
|
|
|
|
*/
|
|
|
|
void FromPresentation( const int theIndex,
|
|
|
|
const Handle(GEOM_Annotation)& theShapeAnnotation,
|
|
|
|
const gp_Ax3& theLCS );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Update presentation properties using the annotation record definition.
|
|
|
|
* \param theIndex [in] the index of the dimension record.
|
|
|
|
* \param theShapeAnnotation [in] the explicit definition of the annotation.
|
|
|
|
*/
|
|
|
|
void ToPresentation( const int theIndex,
|
|
|
|
const Handle(GEOM_Annotation)& theShapeAnnotation,
|
|
|
|
const gp_Ax3& theLCS );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Get explicit definition of an annotation by index.
|
|
|
|
* \param theIndex [in] the index of the entry.
|
|
|
|
*/
|
|
|
|
const ShapeAnnotation& Get( const int theIndex ) const { return myAnnotations[theIndex]; }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns mutable reference on the annotation entry.
|
|
|
|
* \param theIndex [in] the index of annotation entry.
|
|
|
|
*/
|
|
|
|
ShapeAnnotation& Change( const int theIndex ) { return myAnnotations[theIndex]; }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Removes entry by its index.
|
|
|
|
* \param theIndex [in] the index of annotation entry.
|
|
|
|
*/
|
|
|
|
void Remove( const int theIndex ) { myAnnotations.remove( theIndex ); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Clears property data.
|
|
|
|
*/
|
|
|
|
void Clear() { myAnnotations.clear(); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns number of shape annotation records.
|
|
|
|
*/
|
2016-10-11 17:44:18 +03:00
|
|
|
virtual int GetNumber() const { return myAnnotations.size(); };
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns visibility state of dimension record by its index.
|
|
|
|
*
|
|
|
|
* \param theIndex [in] the index of the dimension record.
|
|
|
|
*/
|
2016-10-12 11:08:05 +03:00
|
|
|
virtual bool IsVisible( const int theIndex ) const
|
|
|
|
{
|
|
|
|
return myAnnotations[theIndex].IsVisible;
|
|
|
|
}
|
2016-10-11 17:44:18 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Changes visibility state of the dimension record.
|
|
|
|
*
|
|
|
|
* \param theIndex [in] the index of the dimension record.
|
|
|
|
* \param theIsVisible [in] the new visibility state.
|
|
|
|
*/
|
2016-10-12 11:08:05 +03:00
|
|
|
virtual void SetVisible( const int theIndex, const bool theIsVisible )
|
|
|
|
{
|
|
|
|
myAnnotations[theIndex].IsVisible = theIsVisible;
|
|
|
|
}
|
2016-10-11 17:44:18 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns name of dimension record by its index.
|
|
|
|
*
|
|
|
|
* \param theIndex [in] the index of the dimension record.
|
|
|
|
*/
|
2016-10-12 11:08:05 +03:00
|
|
|
virtual QString GetName( const int theIndex ) const
|
|
|
|
{
|
|
|
|
return myAnnotations[theIndex].Name;
|
|
|
|
}
|
2016-10-11 17:44:18 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Changes name of dimension record.
|
|
|
|
*
|
|
|
|
* \param theIndex [in] the index of the dimension record.
|
|
|
|
* \param theName [in] the new name.
|
|
|
|
*/
|
2016-10-12 11:08:05 +03:00
|
|
|
virtual void SetName( const int theIndex, const QString& theName )
|
|
|
|
{
|
|
|
|
myAnnotations[theIndex].Name = theName;
|
|
|
|
}
|
2016-09-27 13:54:16 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Loads properties data from attribute.
|
|
|
|
* \param theStudy [in] the study.
|
|
|
|
* \param theEntry [in] the entry of GEOM object to operate with.
|
|
|
|
*/
|
2016-10-11 17:44:18 +03:00
|
|
|
virtual void LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
|
2016-09-27 13:54:16 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Saves properties data to attribute.
|
|
|
|
* \param theStudy [in] the study.
|
|
|
|
* \param theEntry [in] the entry of GEOM object to operate with.
|
|
|
|
*/
|
2016-10-11 17:44:18 +03:00
|
|
|
virtual void SaveToAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
|
2016-09-27 13:54:16 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QVector<ShapeAnnotation> myAnnotations;
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(GEOMGUI_ShapeAnnotations);
|
|
|
|
|
|
|
|
#endif
|