mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
Implementation '22873: EDF 8651 GEOM: Annotate shapes into the OCC viewer' issue
This commit is contained in:
parent
0f61961349
commit
cec4acc1bc
BIN
doc/salome/gui/GEOM/images/annotation.png
Normal file
BIN
doc/salome/gui/GEOM/images/annotation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
doc/salome/gui/GEOM/images/annotation_preview.png
Normal file
BIN
doc/salome/gui/GEOM/images/annotation_preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
57
doc/salome/gui/GEOM/input/annotation.doc
Normal file
57
doc/salome/gui/GEOM/input/annotation.doc
Normal file
@ -0,0 +1,57 @@
|
||||
/*!
|
||||
|
||||
\page annotation_page Shape annotation
|
||||
|
||||
<b> Annotation </b> functionality allows showing in the viewer special user-defined text label connected to corresponding part of a CAD model with a line.
|
||||
Annotation text is always parallel to the screen and horizontal. It is is not zoomed or rotated when a 3D scene is zoomed or rotated by the user.
|
||||
The annotation text is defined using UTF-8 encoding and thus support any Unicode characters.
|
||||
|
||||
There are several algorithms for the annotation position calculation during the scene manipulations (panning, zooming, rotation):
|
||||
<ul>
|
||||
<li>Algorithm 1: an annotation has fixed position in 2D screen coordinates (fixed screen position mode). In this mode, the annotations are always visible (appear as topmost objects), never hidden by the (annotated) geometry.</li>
|
||||
<li>Algorithm 2: an annotation has fixed position in 3D model space, this position is projected onto the screen just as normal point coordinates. In this mode, some annotations may be invisible depending on the camera (position, orientation, zoom).</li>
|
||||
</ul>
|
||||
|
||||
\image html annotation_preview.png
|
||||
|
||||
It can be accessed from the main menu via <b>Inspection -> Annotation </b>
|
||||
|
||||
\image html annotation.png "Create Annotation dialog"
|
||||
|
||||
In this dialog you can:
|
||||
<ul>
|
||||
<li>Set <b>Text</b> text shown in View 3d and a name of annotation presented in the Text Browser.</li>
|
||||
<li>Select a \b Shape to which the annotation will be assigned.</li>
|
||||
<li>Set <b>Fixed screen position</b> to select alogithm for the annotation position caldulation.</li>
|
||||
<li>Select a <b>Shape Type</b> to which the annotation will be assigned on the shape.
|
||||
It contains "Whole shape", "Vertex", "Edge", "Face" and "Solid" choices.</li>
|
||||
<li>Select a sub shape to assign annotation to. Text control contains information about local selection in the viewer.</li>
|
||||
<li>Move annotation dragging it in 3D view to select an appropriate position.</li>
|
||||
<li>Push \b Apply or <b>Apply and Close</b> button to commit creation of the field.</li>
|
||||
</ul>
|
||||
|
||||
Annotations appear in an Annotations sub-tree in Text Browser.</li>
|
||||
The foolowing context menu commands are provided for annotation object in Text Browser:
|
||||
<ul>
|
||||
<li><b>Edit</b> allows modifying the annotation text, the positioning algorithm and the annotation position.</li>
|
||||
<li><b>Delete</b> deletes selected annotation.</li>
|
||||
<li><b>Show</b>/<b>Hide</b> change visibility of annotation in the active view.</li>
|
||||
</ul>
|
||||
<b>Edit</b> and <b>Delete</b> actions are also available in View 3d for selected annotation object/s.
|
||||
|
||||
All annotations may be shown/hidden in a 3D view. The corresponded popup menu is available in Text Browser.
|
||||
|
||||
All annotations of a shape may be shown/hidden in a 3D view using corresponded popup menu on the shape item in Object Browser.
|
||||
|
||||
Synchronization of selection between 3D view and Text browser is available. It means that selection of annotation in 3D view will select this annotation in Text browser and vice versa.
|
||||
|
||||
Annotation is logically connected to the shape:
|
||||
<ul>
|
||||
<li>Selection of an annotation will highlight corresponding shape/subshape in 3D view.</li>
|
||||
<li>When the shape is deleted, the annotation will be also deleted.</li>
|
||||
</ul>
|
||||
|
||||
The user is able to modify the font, the style, the color and the size of the annotation text and the color, the width and the style of the connection line applied to all annotations.
|
||||
It can be accessed from the main menu via <b>File -> Preferences</b>. The Shape annotations group on Geometry Settings pane contains controls for it.
|
||||
|
||||
*/
|
@ -17,6 +17,7 @@
|
||||
<li>\subpage angle_page "Angle"</li>
|
||||
<li>\subpage tolerance_page "Tolerance"</li>
|
||||
<li>\subpage managing_dimensions_page "Dimensions"</li>
|
||||
<li>\subpage annotation_page "Annotations"</li>
|
||||
<li>\subpage whatis_page "WhatIs"</li>
|
||||
<li>\subpage inspect_object_operation_page "Inspect Object"</li>
|
||||
<li>\subpage shape_statistics_operation_page "Shape Statistics"</li>
|
||||
|
@ -39,6 +39,7 @@ SET( _res_files
|
||||
isoline.png
|
||||
isoline_v.png
|
||||
angle.png
|
||||
annotation.png
|
||||
arc.png
|
||||
arccenter.png
|
||||
arcofellipse.png
|
||||
|
8
resources/SalomeApp.xml.in
Normal file → Executable file
8
resources/SalomeApp.xml.in
Normal file → Executable file
@ -100,6 +100,14 @@
|
||||
<parameter name="dimensions_default_flyout" value="20" />
|
||||
<parameter name="dimensions_use_text3d" value="0" />
|
||||
|
||||
<!-- Shape annotation presentation properties -->
|
||||
<parameter name="shape_annotation_font_color" value="#00007f" />
|
||||
<parameter name="shape_annotation_font" value="Courier 10 Pitch,24" />
|
||||
<parameter name="shape_annotation_line_color" value="#00007f" />
|
||||
<parameter name="shape_annotation_line_width" value="1.0" />
|
||||
<parameter name="shape_annotation_line_style" value="0" />
|
||||
<parameter name="shape_annotation_autohide" value="false" />
|
||||
|
||||
<!-- Scalar bar for field step presentation -->
|
||||
<parameter name="scalar_bar_x_position" value="0.05" />
|
||||
<parameter name="scalar_bar_y_position" value="0.1" />
|
||||
|
BIN
resources/annotation.png
Normal file
BIN
resources/annotation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 355 B |
@ -65,6 +65,8 @@ public:
|
||||
static SUIT_ViewWindow* getActiveView();
|
||||
|
||||
protected:
|
||||
typedef std::list<SALOME_Prs*> PrsList;
|
||||
|
||||
static GEOM::GEOM_Gen_ptr getGeomEngine();
|
||||
|
||||
void display ( const ObjectList&, const bool = true );
|
||||
@ -97,6 +99,8 @@ protected:
|
||||
const bool = true );
|
||||
void erasePreview ( const bool = true );
|
||||
|
||||
const PrsList& getPreview() const { return myPreview; }
|
||||
|
||||
void localSelection( const ObjectList&, const std::list<int> );
|
||||
void localSelection( const ObjectList&, const int );
|
||||
void localSelection( GEOM::GEOM_Object_ptr, const std::list<int> );
|
||||
@ -210,7 +214,6 @@ private:
|
||||
void clearShapeBuffer( GEOM::GEOM_Object_ptr );
|
||||
|
||||
private:
|
||||
typedef std::list<SALOME_Prs*> PrsList;
|
||||
|
||||
PrsList myPreview;
|
||||
GEOM_Displayer* myDisplayer;
|
||||
|
@ -66,6 +66,7 @@ SET(_link_LIBRARIES
|
||||
|
||||
SET(GEOMGUI_HEADERS
|
||||
GeometryGUI.h
|
||||
GEOMGUI_AnnotationMgr.h
|
||||
GeometryGUI_Operations.h
|
||||
GEOMGUI.h
|
||||
GEOMPluginGUI.h
|
||||
@ -75,13 +76,17 @@ SET(GEOMGUI_HEADERS
|
||||
GEOM_GEOMGUI.hxx
|
||||
GEOMGUI_CreationInfoWdg.h
|
||||
GEOMGUI_TextTreeWdg.h
|
||||
GEOMGUI_TextTreeSelector.h
|
||||
GEOMGUI_DimensionProperty.h
|
||||
GEOMGUI_AnnotationAttrs.h
|
||||
)
|
||||
|
||||
# header files / to be processed by moc
|
||||
SET(_moc_HEADERS
|
||||
GEOMGUI_AnnotationMgr.h
|
||||
GEOMGUI_CreationInfoWdg.h
|
||||
GEOMGUI_TextTreeWdg.h
|
||||
GEOMGUI_TextTreeSelector.h
|
||||
GeometryGUI.h
|
||||
)
|
||||
|
||||
@ -108,6 +113,7 @@ QT_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES})
|
||||
|
||||
SET(GEOMGUI_SOURCES
|
||||
GeometryGUI.cxx
|
||||
GEOMGUI_AnnotationMgr.cxx
|
||||
GEOMGUI.cxx
|
||||
GEOMPluginGUI.cxx
|
||||
GEOM_Displayer.cxx
|
||||
@ -115,7 +121,9 @@ SET(GEOMGUI_SOURCES
|
||||
GEOMGUI_Selection.cxx
|
||||
GEOMGUI_CreationInfoWdg.cxx
|
||||
GEOMGUI_TextTreeWdg.cxx
|
||||
GEOMGUI_TextTreeSelector.cxx
|
||||
GEOMGUI_DimensionProperty.cxx
|
||||
GEOMGUI_AnnotationAttrs.cxx
|
||||
${_moc_SOURCES}
|
||||
${_rcc_SOURCES}
|
||||
)
|
||||
|
552
src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx
Executable file
552
src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx
Executable file
@ -0,0 +1,552 @@
|
||||
// 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_AnnotationAttr.cxx
|
||||
// Author : Anton POLETAEV, Open CASCADE S.A.S.
|
||||
//
|
||||
|
||||
// SALOME includes
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <SALOMEDSImpl_AttributeParameter.hxx>
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
|
||||
|
||||
namespace
|
||||
{
|
||||
static const std::string PARAMETER_COUNT = "GEOMGUI_AnnotationAttrs_Count";
|
||||
|
||||
std::string PARAMETER_I( const std::string& s, const int i ) {
|
||||
std::stringstream ss;
|
||||
ss << i;
|
||||
return std::string( s ) + ss.str();
|
||||
}
|
||||
std::string PARAMETER_IS_VISIBLE( const int i ) {
|
||||
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_IsVisible", i );
|
||||
}
|
||||
std::string PARAMETER_IS_2D( const int i ) {
|
||||
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Is2D", i );
|
||||
}
|
||||
std::string PARAMETER_TEXT( const int i ) {
|
||||
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Text", i );
|
||||
}
|
||||
std::string PARAMETER_POSITION( const int i ) {
|
||||
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Position", i );
|
||||
}
|
||||
std::string PARAMETER_ATTACH( const int i ) {
|
||||
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Attach", i );
|
||||
}
|
||||
std::string PARAMETER_SHAPE( const int i ) {
|
||||
return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Shape", i );
|
||||
}
|
||||
|
||||
// REGEXP pattern for converting array of entries into plain text string.
|
||||
// The pattern has the following structure:
|
||||
// ENTRY: { text[string] : visibility[bool] : screen fixed[bool] : position[xyz] : attach[xyz] }
|
||||
static const QString PATTERN_ITEM_GROUP = "\\{ (Text=(?::{2,}|.)*:(?!:)Screen=.*:Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=.*:ShapeType=.*) \\}";
|
||||
static const QString PATTERN_ITEM = "Text=((?::{2,}|.)*):(?!:)Screen=(\\d{1}):Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=(\\-?\\d{1,}):ShapeType=(\\d{1})";
|
||||
static QString toPattern (const QString& theText,
|
||||
const bool theIsFixed,
|
||||
const gp_Pnt& thePosition,
|
||||
const gp_Pnt& theAttach,
|
||||
const int theShapeIndex,
|
||||
const int theShapeType)
|
||||
{
|
||||
return QString( "{ Text=" ) + theText +
|
||||
QString( ":" ) + QString( "Screen=" ) + QString::number( theIsFixed ? 1 : 0 ) +
|
||||
QString( ":" ) + QString( "Position={" ) +
|
||||
QString::number( thePosition.X() ) + QString( ":" ) +
|
||||
QString::number( thePosition.Y() ) + QString( ":" ) +
|
||||
QString::number( thePosition.Z() ) + QString( "}" ) +
|
||||
QString( ":" ) + QString( "Attach={" ) +
|
||||
QString::number( theAttach.X() ) + QString( ":" ) +
|
||||
QString::number( theAttach.Y() ) + QString( ":" ) +
|
||||
QString::number( theAttach.Z() ) + QString( "}" ) +
|
||||
QString( ":" ) + QString( "ShapeIdx=" ) + QString::number( theShapeIndex ) +
|
||||
QString( ":" ) + QString( "ShapeType=" ) + QString::number( theShapeType ) +
|
||||
QString( " }" );
|
||||
}
|
||||
};
|
||||
|
||||
//=================================================================================
|
||||
// function : FindAttributes
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindAttributes( const _PTR(SObject)& theObject )
|
||||
{
|
||||
_PTR(GenericAttribute) aGenericAttr;
|
||||
_PTR(AttributeParameter) aParameterMap;
|
||||
|
||||
if ( !theObject || !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )
|
||||
{
|
||||
return Handle(GEOMGUI_AnnotationAttrs)();
|
||||
}
|
||||
|
||||
aParameterMap = aGenericAttr;
|
||||
|
||||
if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
|
||||
{
|
||||
return Handle(GEOMGUI_AnnotationAttrs)();
|
||||
}
|
||||
|
||||
return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : FindOrCreateAttributes
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindOrCreateAttributes(
|
||||
const _PTR(SObject)& theObject, SalomeApp_Study* theStudy )
|
||||
{
|
||||
_PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
|
||||
_PTR(AttributeParameter) aParameterMap = aBuilder->FindOrCreateAttribute( theObject, "AttributeParameter" );
|
||||
if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
|
||||
{
|
||||
aParameterMap->SetInt( PARAMETER_COUNT, 0 );
|
||||
}
|
||||
|
||||
return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Remove
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject )
|
||||
{
|
||||
_PTR(GenericAttribute) aGenericAttr;
|
||||
_PTR(AttributeParameter) aParameterMap;
|
||||
|
||||
if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
aParameterMap = aGenericAttr;
|
||||
|
||||
if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int aParamCount = aParameterMap->GetInt( PARAMETER_COUNT );
|
||||
|
||||
for ( int anI = 0; anI < aParamCount; ++anI )
|
||||
{
|
||||
aParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );
|
||||
aParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );
|
||||
aParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );
|
||||
aParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );
|
||||
aParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );
|
||||
aParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );
|
||||
}
|
||||
|
||||
aParameterMap->RemoveID( PARAMETER_COUNT, PT_INTEGER );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ExportAsPropertyString
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QString GEOMGUI_AnnotationAttrs::ExportAsPropertyString() const
|
||||
{
|
||||
QStringList anItems;
|
||||
|
||||
for ( int anI = 0; anI < GetNbAnnotation(); ++anI )
|
||||
{
|
||||
Properties aEntry;
|
||||
|
||||
GetProperties( anI, aEntry );
|
||||
|
||||
anItems.append( toPattern( aEntry.Text,
|
||||
aEntry.IsScreenFixed,
|
||||
aEntry.Position,
|
||||
aEntry.Attach,
|
||||
aEntry.ShapeIndex,
|
||||
aEntry.ShapeType ) );
|
||||
}
|
||||
|
||||
return anItems.join( ":" );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ImportFromPropertyString
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::ImportFromPropertyString( const QString& theString )
|
||||
{
|
||||
SetNbAnnotation( 0 );
|
||||
|
||||
QRegExp aRegExpItemGroups( PATTERN_ITEM_GROUP );
|
||||
QRegExp aRegExpItem( "^" + PATTERN_ITEM + "$" );
|
||||
aRegExpItemGroups.setMinimal( true );
|
||||
aRegExpItem.setMinimal( true );
|
||||
|
||||
int aPos = 0;
|
||||
while ( ( aPos = aRegExpItemGroups.indexIn( theString, aPos ) ) != -1 )
|
||||
{
|
||||
aPos += aRegExpItemGroups.matchedLength();
|
||||
|
||||
QString aStrItem = aRegExpItemGroups.cap(1);
|
||||
|
||||
if ( aRegExpItem.indexIn( aStrItem ) < 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QString aStrText = aRegExpItem.cap( 1 );
|
||||
QString aStrFixed = aRegExpItem.cap( 2 );
|
||||
QString aStrPosX = aRegExpItem.cap( 3 );
|
||||
QString aStrPosY = aRegExpItem.cap( 4 );
|
||||
QString aStrPosZ = aRegExpItem.cap( 5 );
|
||||
QString aStrAttX = aRegExpItem.cap( 6 );
|
||||
QString aStrAttY = aRegExpItem.cap( 7 );
|
||||
QString aStrAttZ = aRegExpItem.cap( 8 );
|
||||
QString aStrShapeIdx = aRegExpItem.cap( 9 );
|
||||
QString aStrShapeType = aRegExpItem.cap( 10 );
|
||||
aStrText.replace( "::", ":" );
|
||||
|
||||
Properties aEntry;
|
||||
aEntry.Text = aStrText;
|
||||
aEntry.IsVisible = false;
|
||||
aEntry.IsScreenFixed = aStrFixed.toInt() != 0;
|
||||
aEntry.Position.SetX( aStrPosX.toDouble() );
|
||||
aEntry.Position.SetY( aStrPosY.toDouble() );
|
||||
aEntry.Position.SetZ( aStrPosZ.toDouble() );
|
||||
aEntry.Attach.SetX( aStrAttX.toDouble() );
|
||||
aEntry.Attach.SetY( aStrAttY.toDouble() );
|
||||
aEntry.Attach.SetZ( aStrAttZ.toDouble() );
|
||||
aEntry.ShapeIndex = aStrShapeIdx.toInt();
|
||||
aEntry.ShapeType = aStrShapeType.toInt();
|
||||
|
||||
Append( aEntry );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetNbAnnotation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetNbAnnotation( const int theCount ) const
|
||||
{
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
|
||||
if ( aCount < theCount )
|
||||
{
|
||||
// set default values
|
||||
for ( int anI = aCount; anI < theCount; ++anI )
|
||||
{
|
||||
myParameterMap->SetBool( PARAMETER_IS_VISIBLE( anI ), true );
|
||||
myParameterMap->SetBool( PARAMETER_IS_2D( anI ), false );
|
||||
myParameterMap->SetString( PARAMETER_TEXT( anI ), std::string() );
|
||||
myParameterMap->SetRealArray( PARAMETER_POSITION( anI ), std::vector<double>(3, 0.0) );
|
||||
myParameterMap->SetRealArray( PARAMETER_ATTACH( anI ), std::vector<double>(3, 0.0) );
|
||||
myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector<int>(2, 0) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove exceeding values
|
||||
for ( int anI = theCount; anI < aCount; ++anI )
|
||||
{
|
||||
myParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );
|
||||
myParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );
|
||||
myParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );
|
||||
myParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );
|
||||
myParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );
|
||||
myParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );
|
||||
}
|
||||
}
|
||||
|
||||
myParameterMap->SetInt( PARAMETER_COUNT, theCount );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetNbAnnotation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
int GEOMGUI_AnnotationAttrs::GetNbAnnotation() const
|
||||
{
|
||||
return myParameterMap->GetInt( PARAMETER_COUNT );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetVisible
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetIsVisible( const int theIndex, const bool theIsVisible )
|
||||
{
|
||||
myParameterMap->SetBool( PARAMETER_IS_VISIBLE( theIndex ), theIsVisible );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetIsVisible
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool GEOMGUI_AnnotationAttrs::GetIsVisible( const int theIndex ) const
|
||||
{
|
||||
return myParameterMap->GetBool( PARAMETER_IS_VISIBLE( theIndex ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetText
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetText( const int theIndex, const QString& theText )
|
||||
{
|
||||
myParameterMap->SetString( PARAMETER_TEXT( theIndex ), theText.toStdString() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetText
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QString GEOMGUI_AnnotationAttrs::GetText( const int theIndex ) const
|
||||
{
|
||||
return QString::fromStdString( myParameterMap->GetString( PARAMETER_TEXT( theIndex ) ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetIsScreenFixed
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed )
|
||||
{
|
||||
myParameterMap->SetBool( PARAMETER_IS_2D( theIndex ), theIsScreenFixed );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetIsScreenFixed
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool GEOMGUI_AnnotationAttrs::GetIsScreenFixed( const int theIndex ) const
|
||||
{
|
||||
return myParameterMap->GetBool( PARAMETER_IS_2D( theIndex ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetPosition
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetPosition( const int theIndex, const gp_Pnt& thePosition )
|
||||
{
|
||||
std::vector<double> aCoords( 3 );
|
||||
|
||||
aCoords[0] = thePosition.X();
|
||||
aCoords[1] = thePosition.Y();
|
||||
aCoords[2] = thePosition.Z();
|
||||
|
||||
myParameterMap->SetRealArray( PARAMETER_POSITION( theIndex ), aCoords );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetPosition
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
gp_Pnt GEOMGUI_AnnotationAttrs::GetPosition( const int theIndex ) const
|
||||
{
|
||||
std::vector<double> aCoords =
|
||||
myParameterMap->GetRealArray( PARAMETER_POSITION( theIndex ) );
|
||||
|
||||
return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetAttach
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetAttach( const int theIndex, const gp_Pnt& theAttach )
|
||||
{
|
||||
std::vector<double> aCoords( 3 );
|
||||
|
||||
aCoords[0] = theAttach.X();
|
||||
aCoords[1] = theAttach.Y();
|
||||
aCoords[2] = theAttach.Z();
|
||||
|
||||
myParameterMap->SetRealArray( PARAMETER_ATTACH( theIndex ), aCoords );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetAttach
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
gp_Pnt GEOMGUI_AnnotationAttrs::GetAttach( const int theIndex ) const
|
||||
{
|
||||
std::vector<double> aCoords =
|
||||
myParameterMap->GetRealArray( PARAMETER_ATTACH( theIndex ) );
|
||||
|
||||
return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetShapeSel
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx )
|
||||
{
|
||||
std::vector<int> aSelection( 2 );
|
||||
|
||||
aSelection[0] = theShapeType;
|
||||
aSelection[1] = theSubIdx;
|
||||
|
||||
myParameterMap->SetIntArray( PARAMETER_SHAPE( theIndex ), aSelection );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetShapeSel
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const
|
||||
{
|
||||
std::vector<int> aSelection =
|
||||
myParameterMap->GetIntArray( PARAMETER_SHAPE( theIndex ) );
|
||||
|
||||
theShapeType = aSelection[0];
|
||||
theSubIdx = aSelection[1];
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Append
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )
|
||||
{
|
||||
this->Append( theProps, gp_Ax3() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Append
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps, const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
this->SetNbAnnotation( aCount + 1 );
|
||||
this->SetProperties( aCount, theProps, theShapeLCS );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Remove
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Remove( const Standard_Integer theIndex )
|
||||
{
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
if ( theIndex < 0 || theIndex >= aCount ) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Properties> aEntries( (aCount - 1) - theIndex );
|
||||
for ( int anI = theIndex + 1; anI < aCount; ++anI ) {
|
||||
GetProperties( anI, aEntries[ anI - (theIndex + 1) ] );
|
||||
}
|
||||
|
||||
SetNbAnnotation( theIndex );
|
||||
|
||||
for ( int anI = 0; anI < static_cast<int>( aEntries.size() ); ++anI ) {
|
||||
Append( aEntries[anI] );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetProperties
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps )
|
||||
{
|
||||
this->SetProperties( theIndex, theProps, gp_Ax3() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetProperties
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps,
|
||||
const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
gp_Trsf aToShapeLCS;
|
||||
aToShapeLCS.SetTransformation( gp_Ax3(), theShapeLCS );
|
||||
|
||||
this->SetText( theIndex, theProps.Text );
|
||||
this->SetIsVisible( theIndex, theProps.IsVisible );
|
||||
this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed );
|
||||
this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
|
||||
this->SetAttach( theIndex, theProps.Attach.Transformed( aToShapeLCS ) );
|
||||
this->SetPosition( theIndex, (theProps.IsScreenFixed) ?
|
||||
theProps.Position : theProps.Position.Transformed( aToShapeLCS ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetProperties
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const
|
||||
{
|
||||
theProps.Text = this->GetText( theIndex );
|
||||
theProps.IsVisible = this->GetIsVisible( theIndex );
|
||||
theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex );
|
||||
theProps.Position = this->GetPosition( theIndex );
|
||||
theProps.Attach = this->GetAttach( theIndex );
|
||||
|
||||
this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetupPresentation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const Properties& theProps,
|
||||
const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
gp_Trsf aFromShapeLCS;
|
||||
aFromShapeLCS.SetTransformation( theShapeLCS, gp_Ax3() );
|
||||
|
||||
TCollection_ExtendedString aText;
|
||||
for (int i = 0; i < (int)theProps.Text.length(); i++ )
|
||||
aText.Insert( i + 1, theProps.Text[ i ].unicode() );
|
||||
|
||||
thePresentation->SetText( aText );
|
||||
thePresentation->SetIsScreenFixed( theProps.IsScreenFixed );
|
||||
thePresentation->SetAttachPoint( theProps.Attach.Transformed( aFromShapeLCS ) );
|
||||
thePresentation->SetPosition( (theProps.IsScreenFixed) ?
|
||||
theProps.Position : theProps.Position.Transformed( aFromShapeLCS ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetupPresentation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const int theIndex,
|
||||
const gp_Ax3& theShapeLCS )
|
||||
{
|
||||
Properties aProps;
|
||||
this->GetProperties( theIndex, aProps );
|
||||
this->SetupPresentation( thePresentation, aProps, theShapeLCS );
|
||||
}
|
220
src/GEOMGUI/GEOMGUI_AnnotationAttrs.h
Executable file
220
src/GEOMGUI/GEOMGUI_AnnotationAttrs.h
Executable file
@ -0,0 +1,220 @@
|
||||
// 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_AnnotationAttrs.h
|
||||
// Author : Anton POLETAEV, Open CASCADE S.A.S.
|
||||
//
|
||||
|
||||
#ifndef GEOMGUI_ANNOTATIONATTRS_H
|
||||
#define GEOMGUI_ANNOTATIONATTRS_H
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <GEOMGUI.h>
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
// OCCT includes
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
// Qt, STL includes
|
||||
#include <QString>
|
||||
|
||||
class GEOM_Annotation;
|
||||
class gp_Ax3;
|
||||
|
||||
/*!
|
||||
* \brief Attribute-style helper tool to manage shape annotation data of an object.
|
||||
*/
|
||||
class GEOMGUI_AnnotationAttrs : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
|
||||
|
||||
//! Find annotation data defined for an object.
|
||||
GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject );
|
||||
|
||||
//! Find or create annotation data fields for an object.
|
||||
GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject,
|
||||
SalomeApp_Study* theStudy );
|
||||
|
||||
//! Remove annotation data fields for an object.
|
||||
GEOMGUI_EXPORT static void Remove( const _PTR(SObject)& theObject );
|
||||
|
||||
// Import / Export
|
||||
public:
|
||||
|
||||
//! Exports annotation records as a property string.
|
||||
GEOMGUI_EXPORT QString ExportAsPropertyString() const;
|
||||
|
||||
//! Imports annotation records from a property string.
|
||||
GEOMGUI_EXPORT void ImportFromPropertyString( const QString& theString );
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \ brief Structure representing visual properties of the shape annotation.
|
||||
*/
|
||||
struct Properties
|
||||
{
|
||||
QString Text; //!< Displayed annotation text.
|
||||
bool IsVisible; //!< Application visibility flag 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.
|
||||
};
|
||||
|
||||
//! Setup parameters of the annotation presentation with the properties given.
|
||||
//! @param thePresentation [in] the presentation to setup.
|
||||
//! @param theProps [in] the set of properties.
|
||||
//! @param theShapeLCS [in] the local coordinate system of the shape.
|
||||
GEOMGUI_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const Properties& theProps,
|
||||
const gp_Ax3& theShapeLCS );
|
||||
|
||||
//! Setup parameters of the annotation presentation with the properties of a definition.
|
||||
//! @param thePresentation [in] the presentation to setup.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theShapeLCS [in] the local coordinate system of the shape.
|
||||
GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const int theIndex,
|
||||
const gp_Ax3& theShapeLCS );
|
||||
|
||||
public:
|
||||
|
||||
//! Changes count of annotation definitions stored on the object.
|
||||
//! If the count is decreased the extra annotation definitions are
|
||||
//! cleared out from the attribute.
|
||||
//! @param theNumber [in] the new number of annotation definitions.
|
||||
GEOMGUI_EXPORT void SetNbAnnotation( const int theCount ) const;
|
||||
|
||||
//! Returns number of annotation definitions stored on the object.
|
||||
GEOMGUI_EXPORT int GetNbAnnotation() const;
|
||||
|
||||
//! Sets application visibility state of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theIsVisible [in] the visibility state.
|
||||
GEOMGUI_EXPORT void SetIsVisible( const int theIndex, const bool theIsVisible );
|
||||
|
||||
//! Returns applicationb visibility state of an annotaion definition.
|
||||
GEOMGUI_EXPORT bool GetIsVisible( const int theIndex ) const;
|
||||
|
||||
//! Sets annotation label's text.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theText [in] the text string.
|
||||
GEOMGUI_EXPORT void SetText( const int theIndex, const QString& theText );
|
||||
|
||||
//! Returns annotation label's text.
|
||||
GEOMGUI_EXPORT QString GetText( const int theIndex ) const;
|
||||
|
||||
//! Sets screen fixed flag of the annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theIsScreenFixed [in] the presentation flag.
|
||||
GEOMGUI_EXPORT void SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed );
|
||||
|
||||
//! Returns screen fixed flag of the annotation definition.
|
||||
GEOMGUI_EXPORT bool GetIsScreenFixed( const int theIndex ) const;
|
||||
|
||||
//! Sets position of the annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param thePosition [in] the position of the annotation label.
|
||||
GEOMGUI_EXPORT void SetPosition( const int theIndex, const gp_Pnt& thePosition );
|
||||
|
||||
//! Returns position of the annotation definition.
|
||||
GEOMGUI_EXPORT gp_Pnt GetPosition( const int theIndex ) const;
|
||||
|
||||
//! Sets attach point of the annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theAttach [in] the attach point of the annotation.
|
||||
GEOMGUI_EXPORT void SetAttach( const int theIndex, const gp_Pnt& theAttach );
|
||||
|
||||
//! Returns attach point of the annotation definition.
|
||||
GEOMGUI_EXPORT gp_Pnt GetAttach( const int theIndex ) const;
|
||||
|
||||
//! Sets shape selection arguments.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theShapeType, theSubIdx [in] the type of the selected shape and the sub-shape index.
|
||||
GEOMGUI_EXPORT void SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx );
|
||||
|
||||
//! Returns shape selection arguments.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theShapeType, theSubIdx [out] the type of the selected shape and the sub-shape index.
|
||||
GEOMGUI_EXPORT void GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Appends new annotation definition with the given properties.
|
||||
GEOMGUI_EXPORT void Append( const Properties& theProps );
|
||||
|
||||
//! Appends new annotation definition with the given properties and converts
|
||||
//! position and attachment points to the given shape's local frame of reference.
|
||||
//! @param theShapeLCS [in] the position of shape's local frame of reference with respect
|
||||
//! to the world frame of reference.
|
||||
GEOMGUI_EXPORT void Append( const Properties& theProps, const gp_Ax3& theShapeLCS );
|
||||
|
||||
//! Removes annotation definition by the given index.
|
||||
//! This methods performs iterative reindexing of elements starting
|
||||
//! from the given index, so sequential removal should be performed
|
||||
//! from the last element, or avoided at all.
|
||||
GEOMGUI_EXPORT void Remove( const Standard_Integer theIndex );
|
||||
|
||||
//! Sets complete properties of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [in] the structure containing the properties.
|
||||
GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps );
|
||||
|
||||
//! Sets complete properties of an annotation definition with converting
|
||||
//! position and attachment points to the given shape's local frame
|
||||
//! of reference.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [in] the structure containing the properties.
|
||||
//! @param theShapeLCS [in] the position of shape's local frame of reference with respect
|
||||
//! to the world frame of reference.
|
||||
GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps, const gp_Ax3& theShapeLCS );
|
||||
|
||||
//! Returns complete properties of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [out] the structure containing the properties.
|
||||
GEOMGUI_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const;
|
||||
|
||||
private:
|
||||
|
||||
GEOMGUI_AnnotationAttrs( const _PTR(SObject)& theObject, const _PTR(AttributeParameter)& theParameter )
|
||||
: myObj( theObject ),
|
||||
myParameterMap( theParameter ) {}
|
||||
|
||||
GEOMGUI_AnnotationAttrs( const GEOMGUI_AnnotationAttrs& theOther ) {}
|
||||
|
||||
void operator=( const GEOMGUI_AnnotationAttrs& theOther ) {}
|
||||
|
||||
private:
|
||||
|
||||
_PTR(SObject) myObj;
|
||||
_PTR(AttributeParameter) myParameterMap;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE( GEOMGUI_AnnotationAttrs, Standard_Transient )
|
||||
|
||||
#endif
|
899
src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx
Executable file
899
src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx
Executable file
@ -0,0 +1,899 @@
|
||||
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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 "GEOMGUI_AnnotationMgr.h"
|
||||
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <GEOM_Client.hxx>
|
||||
#include <GEOM_Constants.h>
|
||||
#include <GEOM_Displayer.h>
|
||||
#include <GEOMGUI_TextTreeWdg.h>
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <SalomeApp_Study.h>
|
||||
#include <SALOME_Prs.h>
|
||||
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SUIT_ViewWindow.h>
|
||||
#include <SUIT_ViewManager.h>
|
||||
|
||||
#include <SOCC_Prs.h>
|
||||
#include <SOCC_ViewWindow.h>
|
||||
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
|
||||
#include <QFont>
|
||||
#include <QColor>
|
||||
|
||||
|
||||
GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication )
|
||||
: myApplication( theApplication )
|
||||
{
|
||||
}
|
||||
|
||||
QString GEOMGUI_AnnotationMgr::GetEntrySeparator()
|
||||
{
|
||||
return "_annotation:";
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : CreatePresentation
|
||||
// Purpose :
|
||||
//================================================================
|
||||
SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
|
||||
GEOM::GEOM_Object_ptr theObject,
|
||||
SOCC_Viewer* theView,
|
||||
const QString& theEntry )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
|
||||
if ( !theEntry.isEmpty() ) {
|
||||
// owner should be set to provide selection mechanizm
|
||||
Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
|
||||
anIO->setEntry( theEntry.toLatin1().constData() );
|
||||
aPresentation->SetOwner( anIO );
|
||||
}
|
||||
|
||||
aPresentation->SetIsScreenFixed( theProperty.IsScreenFixed );
|
||||
|
||||
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
|
||||
if ( !aShape.IsNull() ) {
|
||||
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
|
||||
GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
|
||||
|
||||
if ( theProperty.ShapeType == TopAbs_SHAPE ) {
|
||||
|
||||
aPresentation->SetHilightShape( aShape );
|
||||
}
|
||||
else if ( theProperty.ShapeIndex > 0 ) {
|
||||
|
||||
TopTools_IndexedMapOfShape aSubShapeMap;
|
||||
TopExp::MapShapes( aShape, static_cast<TopAbs_ShapeEnum>( theProperty.ShapeType ), aSubShapeMap );
|
||||
if ( theProperty.ShapeIndex <= aSubShapeMap.Extent() ) {
|
||||
|
||||
aPresentation->SetHilightShape( aSubShapeMap( theProperty.ShapeIndex ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setDisplayProperties( aPresentation, aView, getEntry( theObject ).c_str() );
|
||||
|
||||
// add Prs to preview
|
||||
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
|
||||
SOCC_Prs* aPrs =
|
||||
dynamic_cast<SOCC_Prs*>( ( aView )->CreatePrs( 0 ) );
|
||||
|
||||
if ( aPrs )
|
||||
aPrs->AddObject( aPresentation );
|
||||
|
||||
return aPrs;
|
||||
}
|
||||
|
||||
bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView ) const
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView || !myVisualized.contains( aView ) )
|
||||
return false;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return false;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
if ( !anAnnotationToPrs.contains( theIndex ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::Display
|
||||
// purpose : Displays annotation shape presentation in view. It creates an annotation presentation
|
||||
// and stores it in an internal container
|
||||
//=======================================================================
|
||||
void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView,
|
||||
const bool isStoreViewState, const bool isUpdateViewer )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView )
|
||||
return;
|
||||
|
||||
if ( IsDisplayed( theEntry, theIndex, aView ) )
|
||||
return;
|
||||
|
||||
GEOMGUI_AnnotationAttrs::Properties aProperty;
|
||||
GEOM::GEOM_Object_ptr anObject;
|
||||
getObject( theEntry, theIndex, anObject, aProperty );
|
||||
|
||||
// display presentation in the viewer
|
||||
QString anEntry = QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
|
||||
SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject, aView, anEntry );
|
||||
((SALOME_View*)aView)->Display( getDisplayer(), aPrs );
|
||||
if ( isUpdateViewer )
|
||||
getDisplayer()->UpdateViewer();
|
||||
|
||||
EntryToAnnotations anEntryToMap;
|
||||
if ( myVisualized.contains( aView ) )
|
||||
anEntryToMap = myVisualized[aView];
|
||||
|
||||
// store displayed parameters to an internal container
|
||||
AnnotationToPrs anAnnotationToPrsMap;
|
||||
if ( anEntryToMap.contains( theEntry ) )
|
||||
anAnnotationToPrsMap = anEntryToMap[theEntry];
|
||||
anAnnotationToPrsMap[theIndex] = aPrs;
|
||||
anEntryToMap[theEntry] = anAnnotationToPrsMap;
|
||||
myVisualized[aView] = anEntryToMap;
|
||||
|
||||
if ( isStoreViewState ) {
|
||||
// change persistent for the entry: set visible state in true for indices which presentations are shown
|
||||
storeVisibleState( theEntry, theView );
|
||||
storeFixedPosition( theEntry, theView );
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
|
||||
const GEOMGUI_AnnotationAttrs::Properties& theProperty )
|
||||
{
|
||||
SUIT_Session* ses = SUIT_Session::session();
|
||||
SUIT_Application* app = ses->activeApplication();
|
||||
if ( app )
|
||||
{
|
||||
SUIT_Desktop* desk = app->desktop();
|
||||
QList<SUIT_ViewWindow*> wnds = desk->windows();
|
||||
SUIT_ViewWindow* wnd;
|
||||
QListIterator<SUIT_ViewWindow*> it( wnds );
|
||||
while ( it.hasNext() && (wnd = it.next()) )
|
||||
{
|
||||
SUIT_ViewManager* vman = wnd->getViewManager();
|
||||
if ( vman )
|
||||
{
|
||||
SUIT_ViewModel* vmodel = vman->getViewModel();
|
||||
if ( vmodel )
|
||||
{
|
||||
SOCC_Viewer* aView = dynamic_cast<SOCC_Viewer*>(vmodel);
|
||||
if ( aView )
|
||||
Redisplay( theEntry, theIndex, theProperty, aView );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
|
||||
const GEOMGUI_AnnotationAttrs::Properties& theProperty,
|
||||
SOCC_Viewer* theView )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView )
|
||||
return;
|
||||
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
if ( !anAnnotationToPrs.contains( theIndex ) )
|
||||
return;
|
||||
|
||||
GEOMGUI_AnnotationAttrs::Properties aProperty;
|
||||
GEOM::GEOM_Object_ptr anObject;
|
||||
getObject( theEntry, theIndex, anObject, aProperty );
|
||||
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), anObject );
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
|
||||
// erase presentation from the viewer
|
||||
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
|
||||
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
|
||||
if ( anOCCPrs ) {
|
||||
AIS_ListOfInteractive anIOs;
|
||||
anOCCPrs->GetObjects( anIOs );
|
||||
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
|
||||
|
||||
for ( ; anIter.More(); anIter.Next() ) {
|
||||
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
|
||||
Handle(GEOM_Annotation) aPresentation = Handle(GEOM_Annotation)::DownCast( aPrs );
|
||||
|
||||
GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
|
||||
aView->getAISContext()->Redisplay( aPresentation );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView,
|
||||
const bool isUpdateViewer )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView )
|
||||
return;
|
||||
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
if ( !anAnnotationToPrs.contains( theIndex ) )
|
||||
return;
|
||||
|
||||
// erase presentation from the viewer
|
||||
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
|
||||
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
|
||||
if ( isUpdateViewer )
|
||||
getDisplayer()->UpdateViewer();
|
||||
|
||||
// remove displayed parameters from an internal container
|
||||
anAnnotationToPrs.remove( theIndex );
|
||||
anEntryToAnnotation[theEntry] = anAnnotationToPrs;
|
||||
if (anAnnotationToPrs.isEmpty()) {
|
||||
anEntryToAnnotation.remove( theEntry );
|
||||
}
|
||||
else {
|
||||
anEntryToAnnotation[theEntry] = anAnnotationToPrs;
|
||||
}
|
||||
myVisualized[aView] = anEntryToAnnotation;
|
||||
|
||||
// change persistent for the entry: set visible state in true for indices which presentations are shown
|
||||
storeVisibleState( theEntry, theView );
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView,
|
||||
const bool isUpdateViewer )
|
||||
{
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
if ( !aShapeAnnotations.IsNull() ) {
|
||||
const int aCount = aShapeAnnotations->GetNbAnnotation();
|
||||
std::vector<bool> isVisible( aCount );
|
||||
for ( int anIndex = 0; anIndex < aCount; ++anIndex )
|
||||
{
|
||||
isVisible[anIndex] = aShapeAnnotations->GetIsVisible( anIndex );
|
||||
}
|
||||
for ( int anIndex = 0; anIndex < aCount; ++anIndex )
|
||||
{
|
||||
if ( isVisible[anIndex] )
|
||||
Display( theEntry, anIndex, theView, true, isUpdateViewer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView,
|
||||
const bool isUpdateViewer )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return;
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
|
||||
const int aCount = aShapeAnnotations->GetNbAnnotation();
|
||||
for ( int anIndex = 0; anIndex < aCount; ++anIndex )
|
||||
{
|
||||
if ( !anAnnotationToPrs.contains( anIndex ) )
|
||||
continue;
|
||||
|
||||
// erase presentation from the viewer
|
||||
SALOME_Prs* aPrs = anAnnotationToPrs[anIndex];
|
||||
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
|
||||
}
|
||||
if ( isUpdateViewer )
|
||||
getDisplayer()->UpdateViewer();
|
||||
anEntryToAnnotation.remove( theEntry );
|
||||
myVisualized[aView] = anEntryToAnnotation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::EraseRemovedAnnotation
|
||||
// purpose : Method to update internal maps after removing an
|
||||
// annotation from the object.
|
||||
//=======================================================================
|
||||
void GEOMGUI_AnnotationMgr::EraseRemovedAnnotation( const QString& theEntry, const int theIndex )
|
||||
{
|
||||
QMap<SOCC_Viewer*, EntryToAnnotations>::iterator aEntryMapIt = myVisualized.begin();
|
||||
for ( ; aEntryMapIt != myVisualized.end(); ++aEntryMapIt ) {
|
||||
SOCC_Viewer* aView = aEntryMapIt.key();
|
||||
EntryToAnnotations& anEntryToAnnotation = aEntryMapIt.value();
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
continue;
|
||||
|
||||
AnnotationToPrs aUpdatedToPrs;
|
||||
AnnotationToPrs& anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
AnnotationToPrs::iterator anAnnotationIt = anAnnotationToPrs.begin();
|
||||
for ( ; anAnnotationIt != anAnnotationToPrs.end(); ++anAnnotationIt ) {
|
||||
|
||||
const int aIndex = anAnnotationIt.key();
|
||||
SALOME_Prs* aPrs = anAnnotationIt.value();
|
||||
if ( aIndex > theIndex ) {
|
||||
aUpdatedToPrs[aIndex - 1] = aPrs;
|
||||
}
|
||||
else if ( aIndex != theIndex ) {
|
||||
aUpdatedToPrs[aIndex] = aPrs;
|
||||
}
|
||||
else {
|
||||
((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
|
||||
}
|
||||
}
|
||||
|
||||
anAnnotationToPrs = aUpdatedToPrs;
|
||||
}
|
||||
getDisplayer()->UpdateViewer();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
EntryToAnnotations& anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return;
|
||||
|
||||
AnnotationToPrs& anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
AnnotationToPrs::iterator anIt = anAnnotationToPrs.begin();
|
||||
for (; anIt != anAnnotationToPrs.end(); ++anIt ) {
|
||||
SOCC_Prs* aPrs =
|
||||
dynamic_cast<SOCC_Prs*> (anIt.value());
|
||||
|
||||
GEOMGUI_AnnotationAttrs::Properties aProperty;
|
||||
GEOM::GEOM_Object_ptr anObject;
|
||||
getObject( theEntry, anIt.key(), anObject, aProperty );
|
||||
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), anObject );
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
|
||||
AIS_ListOfInteractive aIObjects;
|
||||
aPrs->GetObjects( aIObjects );
|
||||
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
|
||||
for ( ; aIOIt.More(); aIOIt.Next() ) {
|
||||
|
||||
Handle(GEOM_Annotation) aPresentation =
|
||||
Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
|
||||
|
||||
if ( aPresentation.IsNull() )
|
||||
continue;
|
||||
|
||||
if ( !aShape.IsNull() ) {
|
||||
|
||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||
GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, aProperty, aShapeLCS );
|
||||
if ( aProperty.ShapeType == TopAbs_SHAPE ) {
|
||||
aPresentation->SetHilightShape( aShape );
|
||||
}
|
||||
else if ( aProperty.ShapeIndex > 0 ) {
|
||||
TopTools_IndexedMapOfShape aSubShapeMap;
|
||||
TopExp::MapShapes( aShape, static_cast<TopAbs_ShapeEnum>( aProperty.ShapeType ), aSubShapeMap );
|
||||
if ( aProperty.ShapeIndex <= aSubShapeMap.Extent() ) {
|
||||
aPresentation->SetHilightShape( aSubShapeMap( aProperty.ShapeIndex ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setDisplayProperties( aPresentation, aView, theEntry );
|
||||
|
||||
aView->getAISContext()->Redisplay( aPresentation );
|
||||
}
|
||||
}
|
||||
getDisplayer()->UpdateViewer();
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::DisplayAllAnnotations( SOCC_Viewer* theView )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( getApplication()->activeModule() );
|
||||
GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
|
||||
QList<QString> anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
for ( int i = 0, aCount = anEntries.size(); i < aCount; i++ ) {
|
||||
QString anEntry = anEntries[i];
|
||||
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( anEntry.toStdString() );
|
||||
if ( !aSObj )
|
||||
continue;
|
||||
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
if ( aShapeAnnotations.IsNull() )
|
||||
continue;
|
||||
|
||||
int anAnnotationsCount = aShapeAnnotations->GetNbAnnotation();
|
||||
for ( int anIndex = 0; anIndex < anAnnotationsCount; ++anIndex )
|
||||
{
|
||||
Display( anEntry, anIndex, aView, false, false );
|
||||
}
|
||||
getDisplayer()->UpdateViewer();
|
||||
storeVisibleState( anEntry, aView );
|
||||
storeFixedPosition( anEntry, aView );
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::EraseAllAnnotations( SOCC_Viewer* theView )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( getApplication()->activeModule() );
|
||||
GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
|
||||
QList<QString> anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
|
||||
|
||||
for ( int i = 0, aCount = anEntries.size(); i < aCount; i++ ) {
|
||||
QString anEntry = anEntries[i];
|
||||
EraseVisibleAnnotations( anEntry, aView, false );
|
||||
storeVisibleState( anEntry, aView );
|
||||
}
|
||||
getDisplayer()->UpdateViewer();
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview )
|
||||
{
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) );
|
||||
const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) );
|
||||
|
||||
const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB );
|
||||
const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB );
|
||||
|
||||
QMap<SOCC_Viewer*, EntryToAnnotations>::Iterator aViewIt = myVisualized.begin();
|
||||
for (; aViewIt != myVisualized.end(); ++aViewIt ) {
|
||||
|
||||
Handle(GEOM_Annotation) aPresentation = getAISPresentation ( theEntry, theIndex, aViewIt.key() );
|
||||
if ( aPresentation.IsNull() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( theIsPreview ) {
|
||||
aPresentation->SetTextColor( Quantity_NOC_VIOLET );
|
||||
aPresentation->SetLineColor( Quantity_NOC_VIOLET );
|
||||
aPresentation->SetDepthCulling( Standard_False );
|
||||
}
|
||||
else {
|
||||
aPresentation->SetTextColor( aOcctFontColor );
|
||||
aPresentation->SetLineColor( aOcctLineColor );
|
||||
aPresentation->SetDepthCulling( Standard_True );
|
||||
}
|
||||
}
|
||||
getDisplayer()->UpdateViewer();
|
||||
}
|
||||
|
||||
Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( const QString& theEntry,
|
||||
const int theIndex,
|
||||
SOCC_Viewer* theView ) const
|
||||
{
|
||||
Handle(SALOME_InteractiveObject) anIO;
|
||||
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return anIO;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( theEntry ) )
|
||||
return anIO;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
if ( !anAnnotationToPrs.contains(theIndex) )
|
||||
return anIO;
|
||||
|
||||
SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
|
||||
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
|
||||
if ( !anOCCPrs )
|
||||
return anIO;
|
||||
|
||||
AIS_ListOfInteractive anIOs;
|
||||
anOCCPrs->GetObjects( anIOs );
|
||||
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
|
||||
for ( ; anIter.More() && anIO.IsNull(); anIter.Next() ) {
|
||||
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
|
||||
if ( aPrs->GetOwner() )
|
||||
anIO = Handle(SALOME_InteractiveObject)::DownCast( aPrs->GetOwner() );
|
||||
}
|
||||
return anIO;
|
||||
}
|
||||
|
||||
int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
|
||||
SOCC_Viewer* theView )
|
||||
{
|
||||
int anIndex = -1;
|
||||
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !myVisualized.contains( aView ) )
|
||||
return anIndex;
|
||||
|
||||
QString anEntry = theIO->getEntry();
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
if ( !anEntryToAnnotation.contains( anEntry ) )
|
||||
return anIndex;
|
||||
|
||||
AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[anEntry];
|
||||
//typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
|
||||
AnnotationToPrs::const_iterator anIt = anAnnotationToPrs.begin(),
|
||||
aLast = anAnnotationToPrs.end();
|
||||
for (; anIt != aLast && anIndex < 0; anIt++) {
|
||||
SALOME_Prs* aPrs = anIt.value();
|
||||
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
|
||||
if ( !anOCCPrs )
|
||||
continue;
|
||||
|
||||
AIS_ListOfInteractive anIOs;
|
||||
anOCCPrs->GetObjects( anIOs );
|
||||
AIS_ListIteratorOfListOfInteractive anIter( anIOs );
|
||||
for ( ; anIter.More() && anIndex < 0; anIter.Next() ) {
|
||||
Handle(AIS_InteractiveObject) aPrs = anIter.Value();
|
||||
if ( aPrs->GetOwner() ) {
|
||||
Handle(SALOME_InteractiveObject) aPrsOwner = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner());
|
||||
if ( aPrsOwner == theIO )
|
||||
anIndex = anIt.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anIndex;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::RemoveView
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void GEOMGUI_AnnotationMgr::RemoveView( SOCC_Viewer* theView )
|
||||
{
|
||||
if ( !theView && myVisualized.contains( theView ) )
|
||||
myVisualized.remove( theView );
|
||||
}
|
||||
|
||||
QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const
|
||||
{
|
||||
QString aDisplayedIndices;
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
|
||||
if ( !aSObj )
|
||||
{
|
||||
return aDisplayedIndices;
|
||||
}
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
if ( !aShapeAnnotations.IsNull() )
|
||||
{
|
||||
const int aCount = aShapeAnnotations->GetNbAnnotation();
|
||||
QStringList anIndices;
|
||||
for ( int anIndex = 0; anIndex < aCount; ++anIndex )
|
||||
{
|
||||
if (IsDisplayed( theEntry, anIndex, theView ) )
|
||||
anIndices.append( QString::number(anIndex) );
|
||||
}
|
||||
aDisplayedIndices = anIndices.join(";");
|
||||
}
|
||||
return aDisplayedIndices;
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView,
|
||||
const QString theIndicesInfo )
|
||||
{
|
||||
if ( theIndicesInfo.isEmpty() )
|
||||
return;
|
||||
|
||||
QStringList anIndices = theIndicesInfo.split( ";" );
|
||||
for ( int i = 0, aCount = anIndices.size(); i < aCount; i++ ) {
|
||||
Display( theEntry, anIndices[i].toInt(), theView );
|
||||
}
|
||||
}
|
||||
|
||||
GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const
|
||||
{
|
||||
LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( getApplication()->activeModule() );
|
||||
return dynamic_cast<GEOM_Displayer*>( aModule->displayer() );
|
||||
}
|
||||
|
||||
SOCC_Viewer* GEOMGUI_AnnotationMgr::viewOrActiveView( SOCC_Viewer* theView ) const
|
||||
{
|
||||
SOCC_Viewer* aView = theView;
|
||||
if ( !aView ) {
|
||||
SalomeApp_Application* anApp = getApplication();
|
||||
SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
|
||||
if ( anActiveWindow ) {
|
||||
aView = dynamic_cast<SOCC_Viewer*>( anActiveWindow->getViewManager()->getViewModel() );
|
||||
}
|
||||
}
|
||||
return aView;
|
||||
}
|
||||
|
||||
QString GEOMGUI_AnnotationMgr::makeAnnotationEntry( const QString& theEntry, const int theIndex )
|
||||
{
|
||||
return QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
|
||||
}
|
||||
|
||||
bool GEOMGUI_AnnotationMgr::getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex )
|
||||
{
|
||||
QStringList aSplit = theEntry.split( GetEntrySeparator() );
|
||||
if ( aSplit.size() < 2 )
|
||||
return false;
|
||||
|
||||
bool isOk = true;
|
||||
theObjEntry = aSplit.at( 0 );
|
||||
theIndex = aSplit.at( 1 ).toInt( &isOk );
|
||||
return isOk;
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,
|
||||
GEOM::GEOM_Object_ptr& theObject,
|
||||
GEOMGUI_AnnotationAttrs::Properties& theProperty )
|
||||
{
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
if ( !aShapeAnnotations.IsNull() ) {
|
||||
aShapeAnnotations->GetProperties( theIndex, theProperty );
|
||||
|
||||
theObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject(aSObj) );
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView || !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
if ( aShapeAnnotations.IsNull() )
|
||||
return;
|
||||
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
AnnotationToPrs anAnnotationToPrs;
|
||||
if ( anEntryToAnnotation.contains( theEntry ) )
|
||||
anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
|
||||
AnnotationToPrs::iterator anIt = anAnnotationToPrs.begin();
|
||||
for (; anIt != anAnnotationToPrs.end(); ++anIt ) {
|
||||
int anIndex = anIt.key();
|
||||
bool isFixedAnnotation = aShapeAnnotations->GetIsScreenFixed( anIndex );
|
||||
if ( !isFixedAnnotation )
|
||||
continue;
|
||||
|
||||
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*> (anIt.value());
|
||||
Handle(GEOM_Annotation) anAnnotationPresentation;
|
||||
|
||||
AIS_ListOfInteractive aIObjects;
|
||||
aPrs->GetObjects( aIObjects );
|
||||
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
|
||||
for ( ; aIOIt.More(); aIOIt.Next() ) {
|
||||
anAnnotationPresentation = Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
|
||||
if ( !anAnnotationPresentation.IsNull() )
|
||||
break;
|
||||
}
|
||||
if ( !anAnnotationPresentation.IsNull() )
|
||||
aShapeAnnotations->SetPosition( anIndex, anAnnotationPresentation->GetPosition() );
|
||||
}
|
||||
}
|
||||
|
||||
void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SOCC_Viewer* theView )
|
||||
{
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( !aView || !myVisualized.contains( aView ) )
|
||||
return;
|
||||
|
||||
EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
|
||||
AnnotationToPrs anAnnotationToPrs;
|
||||
if ( anEntryToAnnotation.contains( theEntry ) )
|
||||
anAnnotationToPrs = anEntryToAnnotation[theEntry];
|
||||
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
_PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
if ( !aShapeAnnotations.IsNull() ) {
|
||||
const int aCount = aShapeAnnotations->GetNbAnnotation();
|
||||
for ( int anIndex = 0; anIndex < aCount; ++anIndex ) {
|
||||
bool aVisible = anAnnotationToPrs.contains( anIndex );
|
||||
aShapeAnnotations->SetIsVisible( anIndex, aVisible );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::getEntry
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
std::string GEOMGUI_AnnotationMgr::getEntry( const GEOM::GEOM_Object_ptr theObject )
|
||||
{
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
if ( app )
|
||||
{
|
||||
CORBA::String_var IOR = app->orb()->object_to_string( theObject );
|
||||
if ( strcmp(IOR.in(), "") != 0 )
|
||||
{
|
||||
SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
|
||||
_PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
|
||||
if ( SO )
|
||||
return SO->GetID();
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::getName
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
std::string GEOMGUI_AnnotationMgr::getName( const GEOM::GEOM_Object_ptr theObject )
|
||||
{
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
if ( app )
|
||||
{
|
||||
CORBA::String_var IOR = app->orb()->object_to_string( theObject );
|
||||
if ( strcmp(IOR.in(), "") != 0 )
|
||||
{
|
||||
SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
|
||||
_PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
|
||||
|
||||
_PTR(GenericAttribute) anAttr;
|
||||
|
||||
if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
|
||||
{
|
||||
_PTR(AttributeName) aNameAttr( anAttr );
|
||||
return aNameAttr->Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::setDisplayProperties
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void GEOMGUI_AnnotationMgr::setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
|
||||
SOCC_Viewer* theView,
|
||||
const QString& theEntry )
|
||||
{
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
|
||||
const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 0, 0, 127 ) );
|
||||
const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 0, 0, 127 ) );
|
||||
const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 );
|
||||
const int aLineStyle = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 );
|
||||
const bool isAutoHide = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false );
|
||||
|
||||
const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB );
|
||||
const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB );
|
||||
const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize();
|
||||
|
||||
thePrs->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) );
|
||||
thePrs->SetTextHeight( aFontHeight );
|
||||
thePrs->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) );
|
||||
thePrs->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) );
|
||||
thePrs->SetLineWidth( aLineWidth );
|
||||
thePrs->SetLineStyle( static_cast<Aspect_TypeOfLine>( aLineStyle ) );
|
||||
thePrs->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
|
||||
thePrs->SetDepthCulling( Standard_True );
|
||||
|
||||
SOCC_Viewer* aView = viewOrActiveView( theView );
|
||||
if ( aView && !theEntry.isEmpty() ) {
|
||||
|
||||
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
|
||||
int aMgrId = dynamic_cast< SUIT_ViewModel* >( aView )->getViewManager()->getGlobalId();
|
||||
QVariant aVal = aStudy->getObjectProperty( aMgrId, theEntry, GEOM::propertyName( GEOM::TopLevel ), QVariant() );
|
||||
bool isBringToFront = aVal.isValid() ? aVal.toBool() : false;
|
||||
if( isBringToFront ) {
|
||||
thePrs->SetZLayer( Graphic3d_ZLayerId_Topmost );
|
||||
}
|
||||
else {
|
||||
thePrs->SetDefaultZLayer();
|
||||
}
|
||||
}
|
||||
else {
|
||||
thePrs->SetDefaultZLayer();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GEOMGUI_AnnotationMgr::getAISPresentation
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(GEOM_Annotation) GEOMGUI_AnnotationMgr::getAISPresentation ( const QString& theEntry,
|
||||
const int theIndex,
|
||||
SOCC_Viewer* theView )
|
||||
{
|
||||
if ( !myVisualized.contains( theView ) ) {
|
||||
return Handle(GEOM_Annotation)();
|
||||
}
|
||||
|
||||
EntryToAnnotations& aEntryToAnnotation = myVisualized[theView];
|
||||
if ( !aEntryToAnnotation.contains( theEntry ) ) {
|
||||
return Handle(GEOM_Annotation)();
|
||||
}
|
||||
|
||||
AnnotationToPrs& aAnnotationToPrs = aEntryToAnnotation[theEntry];
|
||||
if ( !aAnnotationToPrs.contains( theIndex ) ) {
|
||||
return Handle(GEOM_Annotation)();
|
||||
}
|
||||
|
||||
SALOME_Prs* aPrs = aAnnotationToPrs[theIndex];
|
||||
|
||||
// set or unset preview style for the presentation
|
||||
AIS_ListOfInteractive aIObjects;
|
||||
((SOCC_Prs*)aPrs)->GetObjects( aIObjects );
|
||||
AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
|
||||
for ( ; aIOIt.More(); aIOIt.Next() ) {
|
||||
return Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
|
||||
}
|
||||
|
||||
return Handle(GEOM_Annotation)();
|
||||
}
|
136
src/GEOMGUI/GEOMGUI_AnnotationMgr.h
Executable file
136
src/GEOMGUI/GEOMGUI_AnnotationMgr.h
Executable file
@ -0,0 +1,136 @@
|
||||
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef GEOMGUI_ANNOTATIONMGR_H
|
||||
#define GEOMGUI_ANNOTATIONMGR_H
|
||||
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
|
||||
#include <SALOMEconfig.h>
|
||||
#include CORBA_SERVER_HEADER(GEOM_Gen)
|
||||
|
||||
#include <QObject>
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
|
||||
#include <SALOME_Prs.h>
|
||||
#include <SALOME_InteractiveObject.hxx>
|
||||
|
||||
#include <SOCC_ViewModel.h>
|
||||
|
||||
class SalomeApp_Application;
|
||||
class GEOM_Annotation;
|
||||
class GEOM_Displayer;
|
||||
|
||||
/*!
|
||||
* \brief A help class to process visualizatin of annotation presentations.
|
||||
* It contains a map of presentations shown in each viewer.
|
||||
* and correct 2D position persistent properties of annotations of active viewer.
|
||||
* When the viewer is closed, information about the viewer is removed from the manager
|
||||
*/
|
||||
class GEOMGUI_EXPORT GEOMGUI_AnnotationMgr : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication );
|
||||
~GEOMGUI_AnnotationMgr() {}
|
||||
|
||||
static QString GetEntrySeparator();
|
||||
|
||||
SALOME_Prs* CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
|
||||
GEOM::GEOM_Object_ptr theObject,
|
||||
SOCC_Viewer* theView = 0,
|
||||
const QString& theEntry = QString() );
|
||||
|
||||
bool IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0 ) const;
|
||||
void Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
|
||||
const bool isStoreViewState = true, const bool isUpdateViewer = true );
|
||||
void Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
|
||||
const bool isUpdateViewer = true );
|
||||
void EraseRemovedAnnotation( const QString& theEntry, const int theIndex );
|
||||
void Redisplay( const QString& theEntry, const int theIndex,
|
||||
const GEOMGUI_AnnotationAttrs::Properties& theProperties);
|
||||
void Redisplay( const QString& theEntry, const int theIndex,
|
||||
const GEOMGUI_AnnotationAttrs::Properties& theProperties, SOCC_Viewer* theView );
|
||||
|
||||
void DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
|
||||
const bool isUpdateViewer = true );
|
||||
void EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
|
||||
const bool isUpdateViewer = true );
|
||||
void UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
|
||||
|
||||
void DisplayAllAnnotations( SOCC_Viewer* theView = 0 );
|
||||
void EraseAllAnnotations( SOCC_Viewer* theView = 0 );
|
||||
|
||||
void SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview );
|
||||
|
||||
void RemoveView( SOCC_Viewer* theView );
|
||||
|
||||
int FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
|
||||
SOCC_Viewer* theView = 0 );
|
||||
|
||||
Handle(SALOME_InteractiveObject) FindInteractiveObject( const QString& theEntry, const int theIndex,
|
||||
SOCC_Viewer* theView = 0 ) const;
|
||||
|
||||
QString getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const;
|
||||
|
||||
void setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView, const QString theIndicesInfo );
|
||||
|
||||
QString makeAnnotationEntry( const QString& theEntry, const int theIndex );
|
||||
|
||||
void storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView );
|
||||
|
||||
bool getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex );
|
||||
|
||||
bool isAnnotationEntry( const QString& theEntry ) { return theEntry.indexOf( GetEntrySeparator() ) != -1; }
|
||||
|
||||
protected:
|
||||
|
||||
SalomeApp_Application* getApplication() const { return myApplication; }
|
||||
|
||||
GEOM_Displayer* getDisplayer() const;
|
||||
|
||||
SOCC_Viewer* viewOrActiveView( SOCC_Viewer* theView ) const;
|
||||
|
||||
void getObject( const QString& theEntry, const int theIndex,
|
||||
GEOM::GEOM_Object_ptr& anObject,
|
||||
GEOMGUI_AnnotationAttrs::Properties& aProperty );
|
||||
|
||||
void storeVisibleState( const QString& theEntry, SOCC_Viewer* theView );
|
||||
|
||||
std::string getEntry( const GEOM::GEOM_Object_ptr theObject );
|
||||
|
||||
std::string getName( const GEOM::GEOM_Object_ptr theObject );
|
||||
|
||||
void setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
|
||||
SOCC_Viewer* theView = 0,
|
||||
const QString& theEntry = QString() );
|
||||
|
||||
Handle(GEOM_Annotation) getAISPresentation ( const QString& theEntry,
|
||||
const int theIndex,
|
||||
SOCC_Viewer* theView );
|
||||
|
||||
private:
|
||||
SalomeApp_Application* myApplication;
|
||||
|
||||
typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
|
||||
typedef QMap<QString, AnnotationToPrs> EntryToAnnotations;
|
||||
QMap<SOCC_Viewer*, EntryToAnnotations> myVisualized;
|
||||
};
|
||||
#endif
|
@ -42,6 +42,9 @@
|
||||
|
||||
class SalomeApp_Study;
|
||||
|
||||
class GEOMGUI_DimensionProperty;
|
||||
typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
|
||||
|
||||
/*!
|
||||
* \brief Utility class to unpack/pack dimension presentations as object property of study.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
||||
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
|
||||
//
|
||||
#include "GEOMGUI_OCCSelector.h"
|
||||
#include "GEOM_Annotation.hxx"
|
||||
|
||||
#include <Basics_OCCTVersion.hxx>
|
||||
|
||||
@ -300,8 +301,16 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
|
||||
{
|
||||
anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
|
||||
|
||||
if ( anOwner.IsNull() || !anOwner->HasShape() )
|
||||
if ( anOwner.IsNull() || !anOwner->HasShape() ) {
|
||||
if ( globalSelMap.contains( entryStr ) ) {
|
||||
Handle(GEOM_Annotation::GEOM_AnnotationOwner) anAnnotationOwner =
|
||||
Handle(GEOM_Annotation::GEOM_AnnotationOwner)::DownCast(owners( i ));
|
||||
if ( !anAnnotationOwner.IsNull() ) {
|
||||
ownersmap.Add( anAnnotationOwner );
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// GLOBAL selection
|
||||
if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) )
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include "GEOMGUI_Selection.h"
|
||||
#include <GEOMGUI_DimensionProperty.h>
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
#include <GEOMGUI_AnnotationMgr.h>
|
||||
|
||||
#include "GeometryGUI.h"
|
||||
#include "GEOM_Displayer.h"
|
||||
@ -151,6 +153,8 @@ QVariant GEOMGUI_Selection::parameter( const QString& p ) const
|
||||
v = hasImported();
|
||||
else if ( p == "allImported" )
|
||||
v = allImported();
|
||||
else if (p == "annotationsCount")
|
||||
v = annotationsCount();
|
||||
else
|
||||
v = LightApp_Selection::parameter( p );
|
||||
return v;
|
||||
@ -198,6 +202,10 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
|
||||
v = hasHiddenDimensions(idx);
|
||||
else if ( p == "hasVisibleDimensions" )
|
||||
v = hasVisibleDimensions(idx);
|
||||
else if ( p == "hasHiddenAnnotations" )
|
||||
v = hasHiddenAnnotations(idx);
|
||||
else if ( p == "hasVisibleAnnotations" )
|
||||
v = hasVisibleAnnotations(idx);
|
||||
else
|
||||
v = LightApp_Selection::parameter( idx, p );
|
||||
|
||||
@ -207,6 +215,9 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
|
||||
// the method to skip temporary objects from selection (called from LightApp)
|
||||
bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
|
||||
{
|
||||
if ( theOwner->entry().contains( GEOMGUI_AnnotationMgr::GetEntrySeparator() ) ) {
|
||||
myAnnotationEntries.append( theOwner->entry() );
|
||||
}
|
||||
return !theOwner->entry().contains("_");
|
||||
}
|
||||
|
||||
@ -853,3 +864,63 @@ bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const
|
||||
return isAnyVisible;
|
||||
}
|
||||
|
||||
int GEOMGUI_Selection::annotationsCount() const
|
||||
{
|
||||
return myAnnotationEntries.size();
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasAnnotations( const int theIndex, bool& theHidden, bool& theVisible ) const
|
||||
{
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
|
||||
if ( !appStudy )
|
||||
return false;
|
||||
|
||||
QString anEntry = entry( theIndex );
|
||||
_PTR(Study) aStudy = appStudy->studyDS();
|
||||
if ( !aStudy || anEntry.isNull() )
|
||||
return false;
|
||||
|
||||
_PTR(SObject) aSObj = appStudy->studyDS()->FindObjectID( anEntry.toStdString() );
|
||||
|
||||
const Handle(GEOMGUI_AnnotationAttrs)
|
||||
aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
|
||||
if ( aShapeAnnotations.IsNull() )
|
||||
return false;
|
||||
|
||||
theHidden = false;
|
||||
theVisible = false;
|
||||
|
||||
const int aCount = aShapeAnnotations->GetNbAnnotation();
|
||||
for ( int anI = 0; anI < aCount; ++anI )
|
||||
{
|
||||
if ( aShapeAnnotations->GetIsVisible( anI ) )
|
||||
theVisible = true;
|
||||
else
|
||||
theHidden = true;
|
||||
}
|
||||
|
||||
return aCount > 0;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasHiddenAnnotations( const int theIndex ) const
|
||||
{
|
||||
bool isAnyVisible, isAnyHidden = false;
|
||||
if ( !hasAnnotations( theIndex, isAnyHidden, isAnyVisible ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isAnyHidden;
|
||||
}
|
||||
|
||||
bool GEOMGUI_Selection::hasVisibleAnnotations( const int theIndex ) const
|
||||
{
|
||||
bool isAnyVisible, isAnyHidden = false;
|
||||
if ( !hasAnnotations( theIndex, isAnyHidden, isAnyVisible ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isAnyVisible;
|
||||
}
|
||||
|
@ -85,6 +85,12 @@ private:
|
||||
bool hasHiddenDimensions( const int ) const;
|
||||
bool hasVisibleDimensions( const int ) const;
|
||||
|
||||
int annotationsCount() const;
|
||||
|
||||
bool hasAnnotations( const int, bool&, bool& ) const;
|
||||
bool hasHiddenAnnotations( const int ) const;
|
||||
bool hasVisibleAnnotations( const int ) const;
|
||||
|
||||
GEOM::GEOM_Object_ptr getObject( const int ) const;
|
||||
GEOM::GEOM_BaseObject_ptr getBaseObject( const int ) const;
|
||||
|
||||
@ -98,6 +104,7 @@ private:
|
||||
|
||||
private:
|
||||
GeomObjectVector myObjects;
|
||||
QStringList myAnnotationEntries;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
168
src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx
Normal file
168
src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx
Normal file
@ -0,0 +1,168 @@
|
||||
// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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_TextTreeSelector.cxx
|
||||
// Author :
|
||||
//
|
||||
#include "GEOMGUI_TextTreeSelector.h"
|
||||
#include "GEOMGUI_TextTreeWdg.h"
|
||||
#include "GEOMGUI_AnnotationMgr.h"
|
||||
|
||||
#include "LightApp_DataOwner.h"
|
||||
#include "LightApp_DataObject.h"
|
||||
#include "LightApp_Application.h"
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_DataObjectIterator.h>
|
||||
|
||||
/*!
|
||||
\class GEOMGUI_TextTreeSelector
|
||||
\brief Text tree selection handler class. It provides selection synchronization between
|
||||
application and text tree widget. This selector listens item selection changed signal of
|
||||
text tree widget to emit common selection changed signal of SUIT selector to start selection
|
||||
synchronization. In get/setSelection selector processes annotation items. These items have
|
||||
specific entry generated in annotation manager, having the "object entry:annotation_id" structure.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\brief Constructor.
|
||||
\param widget text tree widget
|
||||
\param theManager selection manager
|
||||
*/
|
||||
GEOMGUI_TextTreeSelector::GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget,
|
||||
GEOMGUI_AnnotationMgr* theAnnotationMgr,
|
||||
SUIT_SelectionMgr* theManager )
|
||||
: SUIT_Selector( theManager, theWidget ),
|
||||
myTextTree( theWidget ), myAnnotationMgr( theAnnotationMgr )
|
||||
{
|
||||
if ( myTextTree ) {
|
||||
connect( myTextTree, SIGNAL( itemSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Destructor.
|
||||
*/
|
||||
GEOMGUI_TextTreeSelector::~GEOMGUI_TextTreeSelector()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Get object browser.
|
||||
\return a pointer to the text tree widget
|
||||
*/
|
||||
GEOMGUI_TextTreeWdg* GEOMGUI_TextTreeSelector::textTree() const
|
||||
{
|
||||
return myTextTree;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Get selector unique type.
|
||||
\return selector type
|
||||
*/
|
||||
QString GEOMGUI_TextTreeSelector::type() const
|
||||
{
|
||||
return "TextTree";
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Called when the Object browser selection is changed. It emits signal to synchronize
|
||||
selection in application.
|
||||
*/
|
||||
void GEOMGUI_TextTreeSelector::onSelectionChanged()
|
||||
{
|
||||
mySelectedList.clear();
|
||||
selectionChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Get list of currently selected annotation objects.
|
||||
\param theList list to be filled with the selected objects owners
|
||||
The list contains owners for interactive objects of annotations
|
||||
*/
|
||||
void GEOMGUI_TextTreeSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
|
||||
{
|
||||
if ( mySelectedList.count() == 0 ) {
|
||||
|
||||
GEOMGUI_TextTreeSelector* aThisSelector = (GEOMGUI_TextTreeSelector*)this;
|
||||
QMap<QString, QList<int> > aSelectedAnnotations;
|
||||
myTextTree->getSelected(aSelectedAnnotations);
|
||||
|
||||
QMap<QString, QList<int> >::const_iterator anIt = aSelectedAnnotations.begin(),
|
||||
aLast = aSelectedAnnotations.end();
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
QString anEntry = anIt.key();
|
||||
QList<int> anIndices = anIt.value();
|
||||
QList<int>::const_iterator anIdIt = anIndices.begin(), anIdLast = anIndices.end();
|
||||
for ( ; anIdIt != anIdLast; anIdIt++ ) {
|
||||
int anIndex = *anIdIt;
|
||||
Handle(SALOME_InteractiveObject) anIO = myAnnotationMgr->FindInteractiveObject( anEntry, anIndex );
|
||||
if ( anIO.IsNull() )
|
||||
continue;
|
||||
|
||||
LightApp_DataOwner* owner = new LightApp_DataOwner( anIO );
|
||||
aThisSelector->mySelectedList.append( SUIT_DataOwnerPtr( owner ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
theList = mySelectedList;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Set selection.
|
||||
\param theList list of the object owners to be set selected
|
||||
*/
|
||||
void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
|
||||
{
|
||||
if ( !myTextTree )
|
||||
return;
|
||||
|
||||
QMap<QString, QList<int> > aSelectedAnnotations;
|
||||
DataObjectList objList;
|
||||
for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin();
|
||||
it != theList.end(); ++it ) {
|
||||
const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
|
||||
if ( !anOwner )
|
||||
continue;
|
||||
Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
|
||||
if ( anIO.IsNull() )
|
||||
continue;
|
||||
|
||||
QString anIOEntry = anIO->getEntry();
|
||||
QStringList anAnnotationInfo = anIOEntry.split(GEOMGUI_AnnotationMgr::GetEntrySeparator());
|
||||
if (anAnnotationInfo.size() != 2 )
|
||||
continue;
|
||||
|
||||
QString anEntry = anAnnotationInfo[0];
|
||||
int anAnnotationId = anAnnotationInfo[1].toInt();
|
||||
if ( anAnnotationId < 0)
|
||||
continue;
|
||||
|
||||
QList<int> anIndices;
|
||||
if ( aSelectedAnnotations.contains( anEntry ) )
|
||||
anIndices = aSelectedAnnotations[anEntry];
|
||||
|
||||
if ( !anIndices.contains( anAnnotationId ) )
|
||||
anIndices.append( anAnnotationId );
|
||||
|
||||
aSelectedAnnotations[anEntry] = anIndices;
|
||||
}
|
||||
myTextTree->setSelected(aSelectedAnnotations);
|
||||
mySelectedList.clear();
|
||||
}
|
||||
|
63
src/GEOMGUI/GEOMGUI_TextTreeSelector.h
Normal file
63
src/GEOMGUI/GEOMGUI_TextTreeSelector.h
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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_TextTreeSelector.h
|
||||
// Author :
|
||||
//
|
||||
#ifndef GEOMGUI_TEXTTREESELECTOR_H
|
||||
#define GEOMGUI_TEXTTREESELECTOR_H
|
||||
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
|
||||
#include <SUIT_Selector.h>
|
||||
#include <SUIT_DataOwner.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class GEOMGUI_TextTreeWdg;
|
||||
class GEOMGUI_AnnotationMgr;
|
||||
|
||||
class GEOMGUI_EXPORT GEOMGUI_TextTreeSelector : public QObject, public SUIT_Selector
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget,
|
||||
GEOMGUI_AnnotationMgr* theAnnotationMgr,
|
||||
SUIT_SelectionMgr* theManager );
|
||||
virtual ~GEOMGUI_TextTreeSelector();
|
||||
|
||||
GEOMGUI_TextTreeWdg* textTree() const;
|
||||
|
||||
virtual QString type() const;
|
||||
|
||||
private slots:
|
||||
void onSelectionChanged();
|
||||
|
||||
protected:
|
||||
virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
|
||||
virtual void setSelection( const SUIT_DataOwnerPtrList& );
|
||||
|
||||
private:
|
||||
GEOMGUI_TextTreeWdg* myTextTree;
|
||||
GEOMGUI_AnnotationMgr* myAnnotationMgr;
|
||||
SUIT_DataOwnerPtrList mySelectedList;
|
||||
};
|
||||
|
||||
#endif
|
700
src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
Normal file → Executable file
700
src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
Normal file → Executable file
@ -22,6 +22,8 @@
|
||||
#include "GEOMGUI_TextTreeWdg.h"
|
||||
|
||||
#include "GEOMGUI_DimensionProperty.h"
|
||||
#include "GEOMGUI_AnnotationAttrs.h"
|
||||
#include "GEOMGUI_AnnotationMgr.h"
|
||||
#include "GeometryGUI.h"
|
||||
#include "GeometryGUI_Operations.h"
|
||||
#include <GEOM_Constants.h>
|
||||
@ -49,6 +51,110 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QHash>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Common style interface for managing dimension and annotation properties
|
||||
// ----------------------------------------------------------------------------
|
||||
namespace
|
||||
{
|
||||
//! Access interface implementation for shape dimension attribute/property.
|
||||
class DimensionsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
|
||||
{
|
||||
public:
|
||||
|
||||
DimensionsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) :
|
||||
myStudy( theStudy ), myEntry( theEntry ) {
|
||||
myAttr.LoadFromAttribute( theStudy, theEntry );
|
||||
}
|
||||
virtual int GetNumber() Standard_OVERRIDE {
|
||||
return myAttr.GetNumber();
|
||||
}
|
||||
virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
|
||||
return myAttr.GetName( theIndex );
|
||||
}
|
||||
virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
|
||||
return myAttr.IsVisible( theIndex );
|
||||
}
|
||||
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
|
||||
myAttr.SetVisible( theIndex, theIsVisible );
|
||||
}
|
||||
virtual void Save() Standard_OVERRIDE {
|
||||
myAttr.SaveToAttribute( myStudy, myEntry );
|
||||
}
|
||||
GEOMGUI_DimensionProperty& Attr() { return myAttr; }
|
||||
|
||||
private:
|
||||
GEOMGUI_DimensionProperty myAttr;
|
||||
SalomeApp_Study* myStudy;
|
||||
std::string myEntry;
|
||||
};
|
||||
|
||||
//! Access interface implementation for shape annotation attribute.
|
||||
class AnnotationsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
|
||||
{
|
||||
public:
|
||||
|
||||
AnnotationsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) {
|
||||
myEntry = theEntry.c_str();
|
||||
myStudy = theStudy;
|
||||
_PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
|
||||
if ( aSObj ) {
|
||||
myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
}
|
||||
}
|
||||
virtual int GetNumber() Standard_OVERRIDE {
|
||||
return !myAttr.IsNull() ? myAttr->GetNbAnnotation() : 0;
|
||||
}
|
||||
virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
|
||||
return !myAttr.IsNull() ? myAttr->GetText( theIndex ) : QString();
|
||||
}
|
||||
virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
|
||||
GEOMGUI_AnnotationMgr* aMgr = annotationMgr();
|
||||
if (!aMgr) {
|
||||
return false;
|
||||
}
|
||||
return aMgr->IsDisplayed( myEntry, theIndex );
|
||||
}
|
||||
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
|
||||
GEOMGUI_AnnotationMgr* aMgr = annotationMgr();
|
||||
if (!aMgr) {
|
||||
return;
|
||||
}
|
||||
if (theIsVisible)
|
||||
annotationMgr()->Display(myEntry, theIndex);
|
||||
else
|
||||
annotationMgr()->Erase(myEntry, theIndex);
|
||||
}
|
||||
virtual void Save() Standard_OVERRIDE {
|
||||
/* every change is automatically saved */
|
||||
}
|
||||
Handle(GEOMGUI_AnnotationAttrs) Attr() { return myAttr; }
|
||||
|
||||
protected:
|
||||
GEOMGUI_AnnotationMgr* annotationMgr() const
|
||||
{
|
||||
CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
|
||||
if (!aModule) {
|
||||
return NULL;
|
||||
}
|
||||
return aModule->GetAnnotationMgr();
|
||||
}
|
||||
|
||||
private:
|
||||
QString myEntry;
|
||||
Handle(GEOMGUI_AnnotationAttrs) myAttr;
|
||||
SalomeApp_Study* myStudy;
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Text tree widget implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
//=================================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
||||
: myDisplayer(NULL)
|
||||
{
|
||||
@ -84,6 +190,12 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
||||
myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
addTopLevelItem( myDimensionsItem );
|
||||
|
||||
rootNames.clear();
|
||||
rootNames << tr("GEOM_ANNOTATIONS") << "";
|
||||
myAnnotationsItem = new QTreeWidgetItem( this, rootNames );
|
||||
myAnnotationsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
addTopLevelItem( myAnnotationsItem );
|
||||
|
||||
// get a free dockable window id
|
||||
myWindowID = 11;
|
||||
while( app->dockWindow( myWindowID ))
|
||||
@ -93,18 +205,28 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
||||
createActions();
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
|
||||
this, SLOT( showContextMenu(const QPoint&) ) );
|
||||
this, SLOT( showContextMenu(const QPoint&) ) );
|
||||
|
||||
connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
|
||||
this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
|
||||
connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
|
||||
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
|
||||
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
|
||||
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
|
||||
this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
|
||||
|
||||
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
|
||||
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ),
|
||||
this, SLOT( updateDimensionBranch( const QString& ) ) );
|
||||
connect( aGeomGUI, SIGNAL( SignalAnnotationsUpdated( const QString& ) ),
|
||||
this, SLOT( updateAnnotationBranch( const QString& ) ) );
|
||||
connect( aGeomGUI, SIGNAL( SignalTextTreeRenameObject( const QString& ) ),
|
||||
this, SLOT( updateObjectName( const QString& ) ) );
|
||||
|
||||
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
|
||||
this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
|
||||
connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
|
||||
this, SLOT( onUpdateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Destructor
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOMGUI_TextTreeWdg::~GEOMGUI_TextTreeWdg()
|
||||
{
|
||||
//std::cout<<"~GEOMGUI_TextTreeWdg"<<std::endl;
|
||||
@ -127,7 +249,8 @@ void GEOMGUI_TextTreeWdg::createActions()
|
||||
|
||||
//=================================================================================
|
||||
// function : updateTree
|
||||
// purpose :
|
||||
// purpose : Rebuild branches of objects and remove objects if there are no more annotations
|
||||
// for it
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateTree()
|
||||
{
|
||||
@ -138,91 +261,174 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
||||
if ( SC ) {
|
||||
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
|
||||
anIter->InitEx( true );
|
||||
QList<QString> objEntries = myObjects.keys();
|
||||
QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
|
||||
QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
|
||||
while( anIter->More() ) {
|
||||
_PTR(SObject) valSO ( anIter->Value() );
|
||||
_PTR(SObject) refSO;
|
||||
if ( !valSO->ReferencedObject( refSO ) ) {
|
||||
// update tree of object's dimensions
|
||||
QString anEntry = valSO->GetID().c_str();
|
||||
updateBranch( anEntry );
|
||||
objEntries.removeAll( anEntry );
|
||||
}
|
||||
anIter->Next();
|
||||
_PTR(SObject) valSO ( anIter->Value() );
|
||||
_PTR(SObject) refSO;
|
||||
if ( !valSO->ReferencedObject( refSO ) ) {
|
||||
// update tree of object's dimensions
|
||||
QString anEntry = valSO->GetID().c_str();
|
||||
updateBranches( anEntry );
|
||||
aDimensionObjEntries.removeAll( anEntry );
|
||||
anAnnotationObjEntries.removeAll( anEntry );
|
||||
}
|
||||
anIter->Next();
|
||||
}
|
||||
foreach (QString entry, objEntries) {
|
||||
removeBranch( entry, true );
|
||||
foreach ( QString entry, aDimensionObjEntries ) {
|
||||
removeBranch( DimensionShape, entry, true );
|
||||
}
|
||||
foreach ( QString entry, anAnnotationObjEntries ) {
|
||||
removeBranch( AnnotationShape, entry, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : updateBranch
|
||||
// purpose :
|
||||
// function : updateBranches
|
||||
// purpose : Rebuild branches for object of the given entry
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
|
||||
void GEOMGUI_TextTreeWdg::updateBranches( const QString& theEntry )
|
||||
{
|
||||
updateDimensionBranch( theEntry );
|
||||
updateAnnotationBranch( theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : updateDimensionBranch
|
||||
// purpose : Rebuild branch of dimension type for object of the given entry
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateDimensionBranch( const QString& theEntry )
|
||||
{
|
||||
fillBranch( DimensionShape, theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : updateAnnotationBranch
|
||||
// purpose : Rebuild branch of annotation type for object of the given entry
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateAnnotationBranch( const QString& theEntry )
|
||||
{
|
||||
fillBranch( AnnotationShape, theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : updateObjectName
|
||||
// purpose : Find name of the given object and set the name for corresponded tree item
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateObjectName( const QString& theEntry )
|
||||
{
|
||||
QTreeWidgetItem* anObjectItem;
|
||||
|
||||
QHash<QString, QTreeWidgetItem*> anObjects = getObjects( DimensionShape );
|
||||
if ( anObjects.contains( theEntry ) )
|
||||
anObjectItem = anObjects.value( theEntry );
|
||||
else {
|
||||
anObjects = getObjects( AnnotationShape );
|
||||
if ( anObjects.contains( theEntry ) )
|
||||
anObjectItem = anObjects.value( theEntry );
|
||||
}
|
||||
if ( !anObjectItem )
|
||||
return;
|
||||
|
||||
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
if ( myStudy ) {
|
||||
_PTR(Study) aStudyDS = myStudy->studyDS();
|
||||
if ( aStudyDS ) {
|
||||
_PTR(SObject) anObject( aStudyDS->FindObjectID( theEntry.toStdString() ) );
|
||||
if ( anObject.get() )
|
||||
anObjectItem->setText( 0, anObject->GetName().c_str() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : fillBranch
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
|
||||
{
|
||||
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
|
||||
if ( myStudy && !theEntry.isEmpty() ) {
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
if ( !aProp ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_PTR(Study) aStudyDS = myStudy->studyDS();
|
||||
if ( aStudyDS ) {
|
||||
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
|
||||
QString aName = obj->GetName().c_str();
|
||||
const QString aName = obj->GetName().c_str();
|
||||
const int nbProps = aProp->GetNumber();
|
||||
|
||||
GEOMGUI_DimensionProperty aProp;
|
||||
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||
int nbProps = aProp.GetNumber();
|
||||
|
||||
QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
|
||||
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
|
||||
if ( objectItem ) {
|
||||
removeBranch( theEntry, nbProps > 0 ? false : true );
|
||||
removeBranch( theBranchType, theEntry, nbProps > 0 ? false : true );
|
||||
}
|
||||
QStringList itemName;
|
||||
if ( nbProps > 0 ) {
|
||||
itemName << aName << "";
|
||||
if ( !objectItem ) {
|
||||
objectItem = new QTreeWidgetItem( myDimensionsItem, itemName );
|
||||
objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
objectItem->setData( 1, Qt::UserRole, theEntry );
|
||||
myDimensionsItem->addChild( objectItem );
|
||||
myObjects.insert( theEntry, objectItem );
|
||||
if ( myDimensionsItem->childCount() == 1 )
|
||||
myDimensionsItem->setExpanded( true );
|
||||
}
|
||||
bool isDisplayed = myDisplayer.IsDisplayed( theEntry );
|
||||
// read dimension records from property
|
||||
for ( int anIt = 0; anIt < aProp.GetNumber(); ++anIt )
|
||||
{
|
||||
QString aName = aProp.GetName( anIt );
|
||||
bool isVisible = aProp.IsVisible( anIt );
|
||||
itemName << aName << "";
|
||||
if ( !objectItem ) {
|
||||
QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
|
||||
|
||||
QTreeWidgetItem* anItem = new QTreeWidgetItem;
|
||||
anItem->setText( 0, aName );
|
||||
// if ( isDisplayed )
|
||||
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
|
||||
anItem->setData( 0, Qt::UserRole, anIt );
|
||||
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
objectItem->addChild( anItem );
|
||||
}
|
||||
objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
|
||||
objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
objectItem->setData( 1, Qt::UserRole, theEntry );
|
||||
aPropRootItem->addChild( objectItem );
|
||||
getObjects( theBranchType ).insert( theEntry, objectItem );
|
||||
if ( aPropRootItem->childCount() == 1 )
|
||||
aPropRootItem->setExpanded( true );
|
||||
}
|
||||
for ( int anIt = 0; anIt < nbProps; ++anIt ) {
|
||||
const QString aPropName = aProp->GetName( anIt );
|
||||
const bool isVisible = aProp->GetIsVisible( anIt );
|
||||
QTreeWidgetItem* anItem = new QTreeWidgetItem;
|
||||
anItem->setText( 0, aPropName );
|
||||
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
|
||||
anItem->setData( 0, Qt::UserRole, anIt );
|
||||
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
objectItem->addChild( anItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getVisualProperty
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QSharedPointer<GEOMGUI_TextTreeWdg::VisualProperty>
|
||||
GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType,
|
||||
SalomeApp_Study* theStudy,
|
||||
const std::string& theEntry )
|
||||
{
|
||||
switch ( theBranchType )
|
||||
{
|
||||
case DimensionShape : return QSharedPointer<VisualProperty>( new DimensionsProperty( theStudy, theEntry ) );
|
||||
case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theStudy, theEntry ) );
|
||||
default: break;
|
||||
}
|
||||
return QSharedPointer<VisualProperty>();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : removeBranch
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::removeBranch( const QString& theEntry, bool force )
|
||||
void GEOMGUI_TextTreeWdg::removeBranch( const BranchType& theBranchType, const QString& theEntry,
|
||||
bool force )
|
||||
{
|
||||
QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
|
||||
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
|
||||
if ( !objectItem )
|
||||
return;
|
||||
qDeleteAll( objectItem->takeChildren() );
|
||||
if ( force ) {
|
||||
myDimensionsItem->removeChild( objectItem );
|
||||
myObjects.remove( theEntry );
|
||||
QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
|
||||
aPropRootItem->removeChild( objectItem );
|
||||
getObjects( theBranchType ).remove( theEntry );
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,17 +442,22 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
|
||||
return;
|
||||
|
||||
std::string anEntry = entryFromItem( theItem->parent() ).toStdString();
|
||||
BranchType aBranchType = branchTypeFromItem( theItem );
|
||||
|
||||
int aDimIndex = idFromItem( theItem );
|
||||
GEOMGUI_DimensionProperty aProp;
|
||||
aProp.LoadFromAttribute( myStudy, anEntry );
|
||||
if ( aProp.IsVisible( aDimIndex ) ) {
|
||||
aProp.SetVisible( aDimIndex, false );
|
||||
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
|
||||
|
||||
CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
|
||||
if ( aProp->GetIsVisible( aDimIndex ) ) {
|
||||
aModule->GetAnnotationMgr()->Erase(anEntry.c_str(), aDimIndex);
|
||||
theItem->setIcon( 1, myInvisibleIcon );
|
||||
} else {
|
||||
aProp.SetVisible( aDimIndex, true );
|
||||
aModule->GetAnnotationMgr()->Display(anEntry.c_str(), aDimIndex);
|
||||
|
||||
theItem->setIcon( 1, myVisibleIcon );
|
||||
}
|
||||
aProp.SaveToAttribute( myStudy, anEntry );
|
||||
redisplay( anEntry.c_str() );
|
||||
}
|
||||
|
||||
@ -269,7 +480,7 @@ int GEOMGUI_TextTreeWdg::idFromItem( QTreeWidgetItem* theItem )
|
||||
// function : entryFromItem
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
|
||||
QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem ) const
|
||||
{
|
||||
if ( !theShapeItem )
|
||||
return "";
|
||||
@ -281,33 +492,49 @@ QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
|
||||
// function : itemFromEntry
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( QString theEntry )
|
||||
QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranchType, QString theEntry )
|
||||
{
|
||||
if ( theEntry.isEmpty() )
|
||||
return 0;
|
||||
|
||||
return myObjects.value( theEntry, 0 );
|
||||
return getObjects(theBranchType).value( theEntry, 0 );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : onUpdateVisibilityColumn
|
||||
// purpose : Update visible state of icons of entry items.
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
|
||||
{
|
||||
// dimension property branch
|
||||
updateVisibilityColumn( DimensionShape, theEntry, theState );
|
||||
|
||||
// annotation property branch
|
||||
updateVisibilityColumn( AnnotationShape, theEntry, theState );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : updateVisibilityColumn
|
||||
// purpose : Update icons of dimension items.
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
|
||||
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchType, QString theEntry,
|
||||
Qtx::VisibilityState theState )
|
||||
{
|
||||
QTreeWidgetItem* anItem = itemFromEntry( theEntry );
|
||||
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
|
||||
if ( !anItem )
|
||||
return;
|
||||
anItem->setDisabled( theState != Qtx::ShownState );
|
||||
QTreeWidgetItem* aChildItem;
|
||||
GEOMGUI_DimensionProperty aProp;
|
||||
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
|
||||
for ( int i=0; i < anItem->childCount(); i++ ) {
|
||||
aChildItem = anItem->child( i );
|
||||
if ( theState == Qtx::ShownState ) {
|
||||
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||
if ( aProp.GetNumber() == 0 )
|
||||
continue;
|
||||
aChildItem->setIcon( 1, aProp.IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon : myInvisibleIcon );
|
||||
if ( aProp->GetNumber() == 0 )
|
||||
continue;
|
||||
aChildItem->setIcon( 1, aProp->GetIsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
|
||||
: myInvisibleIcon );
|
||||
aChildItem->setDisabled( false );
|
||||
} else {
|
||||
aChildItem->setIcon( 1, QIcon() );
|
||||
@ -322,95 +549,278 @@ void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::Visibil
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
|
||||
{
|
||||
if ( selectedItems().isEmpty() )
|
||||
return;
|
||||
CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
|
||||
|
||||
QMenu aMenu;
|
||||
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
||||
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
||||
if ( selectedItems().count() == 1 ) {
|
||||
if ( !selectedItems().isEmpty() && selectedItems().count() == 1 ) {
|
||||
QTreeWidgetItem* anItem = selectedItems().first();
|
||||
QString anEntry = entryFromItem( anItem->parent() );
|
||||
if ( !anEntry.isEmpty() ) {
|
||||
GEOMGUI_DimensionProperty aProp;
|
||||
aProp.LoadFromAttribute( myStudy, anEntry.toStdString() );
|
||||
if ( aProp.GetNumber() == 0 )
|
||||
return;
|
||||
aMenu.clear();
|
||||
if ( aProp.IsVisible( idFromItem( anItem ) ) )
|
||||
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
||||
BranchType aBranchType = branchTypeFromItem( anItem );
|
||||
QSharedPointer<VisualProperty>
|
||||
aProp = getVisualProperty( aBranchType, myStudy, anEntry.toStdString() );
|
||||
|
||||
if ( aProp->GetNumber() == 0 )
|
||||
return;
|
||||
// Edit annotation action
|
||||
QAction* anEditAction = aModule->action(GEOMOp::OpEditAnnotation);
|
||||
if ( anEditAction )
|
||||
aMenu.addAction( anEditAction );
|
||||
QAction* aDeleteAction = aModule->action(GEOMOp::OpDeleteAnnotation);
|
||||
if ( aDeleteAction )
|
||||
aMenu.addAction( aDeleteAction );
|
||||
// Show/Hide actions
|
||||
if ( aProp->GetIsVisible( idFromItem( anItem ) ) )
|
||||
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
||||
else
|
||||
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
||||
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItems().isEmpty() && currentItem()) {
|
||||
QTreeWidgetItem* anItem = currentItem();
|
||||
bool aShowAll = false;
|
||||
if (anItem == getPropertyRootItem(AnnotationShape))
|
||||
aShowAll = true;
|
||||
else {
|
||||
QHash<QString, QTreeWidgetItem*> anObjects = getObjects( AnnotationShape );
|
||||
QHash<QString, QTreeWidgetItem*>::const_iterator anIt = anObjects.begin(),
|
||||
aLast = anObjects.end();
|
||||
for (; anIt != aLast && !aShowAll; anIt++) {
|
||||
aShowAll = anIt.value() == anItem;
|
||||
}
|
||||
}
|
||||
if (aShowAll) {
|
||||
aMenu.addAction( aModule->action(GEOMOp::OpShowAllAnnotations) );
|
||||
aMenu.addAction( aModule->action(GEOMOp::OpHideAllAnnotations) );
|
||||
}
|
||||
}
|
||||
QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
|
||||
if ( selPopupItem == myActions[GEOMOp::OpShow] )
|
||||
setVisibility( true );
|
||||
else if ( selPopupItem == myActions[GEOMOp::OpHide] )
|
||||
setVisibility( false );
|
||||
|
||||
if ( selPopupItem == myActions[GEOMOp::OpShow] ||
|
||||
selPopupItem == myActions[GEOMOp::OpHide] ) {
|
||||
bool isVisible = selPopupItem == myActions[GEOMOp::OpShow];
|
||||
foreach ( QTreeWidgetItem* anItem, selectedItems() ) {
|
||||
setVisibility( anItem, isVisible );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setVisibility
|
||||
// purpose :
|
||||
// purpose : set item visible
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::setVisibility( bool theVisibility )
|
||||
void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisibility )
|
||||
{
|
||||
if ( myDimensionsItem->isSelected() ) {
|
||||
// set visibility for all dimensions
|
||||
BranchType aBranchType = branchTypeFromItem( theItem );
|
||||
if ( theItem == myDimensionsItem ||
|
||||
theItem == myAnnotationsItem ) {
|
||||
|
||||
QTreeWidgetItem* anItem;
|
||||
foreach ( QString entry, myObjects.keys() ) {
|
||||
anItem = itemFromEntry( entry );
|
||||
foreach ( QString entry, getObjects( aBranchType ).keys() ) {
|
||||
anItem = itemFromEntry( aBranchType, entry );
|
||||
if ( !anItem->isDisabled() )
|
||||
setShapeDimensionsVisibility( entry, theVisibility );
|
||||
setAllShapeItemsVisibility( aBranchType, entry, theVisibility );
|
||||
}
|
||||
return;
|
||||
}
|
||||
foreach ( QTreeWidgetItem* item, selectedItems() ) {
|
||||
if ( item->isDisabled() || item->parent()->isSelected() )
|
||||
continue;
|
||||
QString anEntry = entryFromItem( item );
|
||||
if ( !anEntry.isEmpty() ) {
|
||||
// it is a shape item
|
||||
setShapeDimensionsVisibility( anEntry, theVisibility );
|
||||
} else {
|
||||
// it is a dimension item
|
||||
anEntry = entryFromItem( item->parent() );
|
||||
setDimensionVisibility( anEntry, item, theVisibility );
|
||||
else {
|
||||
if ( !theItem->isDisabled() && !theItem->parent()->isSelected() ) {
|
||||
QString anEntry = entryFromItem( theItem );
|
||||
if ( !anEntry.isEmpty() ) {
|
||||
// it is a shape item
|
||||
setAllShapeItemsVisibility( aBranchType, anEntry, theVisibility );
|
||||
} else {
|
||||
// it is a dimension item
|
||||
anEntry = entryFromItem( theItem->parent() );
|
||||
setShapeItemVisibility( aBranchType, anEntry, theItem, theVisibility );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setShapeDimensionsVisibility
|
||||
// function : setAllShapeItemsVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( QString theEntry, bool theVisibility )
|
||||
void GEOMGUI_TextTreeWdg::setAllShapeItemsVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
const bool theVisibility )
|
||||
{
|
||||
QTreeWidgetItem* anItem = itemFromEntry( theEntry );
|
||||
QSharedPointer<VisualProperty>
|
||||
aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
|
||||
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
|
||||
QTreeWidgetItem* aChildItem;
|
||||
for ( int i=0; i < anItem->childCount(); i++ ) {
|
||||
aChildItem = anItem->child( i );
|
||||
setDimensionVisibility( theEntry, aChildItem, theVisibility );
|
||||
setShapeItemVisibility( aProp, aChildItem, theVisibility );
|
||||
}
|
||||
|
||||
aProp->Save();
|
||||
|
||||
redisplay( theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setDimensionVisibility
|
||||
// function : setShapeItemVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility )
|
||||
void GEOMGUI_TextTreeWdg::setShapeItemVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility )
|
||||
{
|
||||
GEOMGUI_DimensionProperty aProp;
|
||||
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||
int aDimIndex = idFromItem( theDimItem );
|
||||
if ( aProp.GetNumber() == 0 || aProp.IsVisible( aDimIndex ) == theVisibility )
|
||||
return;;
|
||||
aProp.SetVisible( aDimIndex, theVisibility );
|
||||
aProp.SaveToAttribute( myStudy, theEntry.toStdString() );
|
||||
QSharedPointer<VisualProperty>
|
||||
aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
|
||||
theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
|
||||
redisplay( theEntry );
|
||||
if ( setShapeItemVisibility( aProp, theWidgetItem, theVisibility ) ) {
|
||||
aProp->Save();
|
||||
redisplay( theEntry );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setShapeItemVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateVisibility()
|
||||
{
|
||||
//QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
|
||||
BranchType aBranchType = AnnotationShape;
|
||||
|
||||
QList<QString> anAnnotationObjEntries = getObjects( aBranchType ).keys();
|
||||
|
||||
QTreeWidgetItem* anEntryItem;
|
||||
foreach ( QString anEntry, getObjects( aBranchType ).keys() )
|
||||
{
|
||||
anEntryItem = itemFromEntry( aBranchType, anEntry );
|
||||
|
||||
QTreeWidgetItem* anItem;
|
||||
for ( int i = 0; i < anEntryItem->childCount(); i++ ) {
|
||||
anItem = anEntryItem->child( i );
|
||||
int aDimIndex = idFromItem( anItem );
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy,
|
||||
anEntry.toStdString() );
|
||||
bool isItemVisible = aProp->GetIsVisible( aDimIndex );
|
||||
anItem->setIcon( 1, isItemVisible ? myVisibleIcon : myInvisibleIcon );
|
||||
}
|
||||
|
||||
redisplay( anEntry );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getSelected
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::getSelected( QMap<QString, QList<int> >& theAnnotations )
|
||||
{
|
||||
theAnnotations.clear();
|
||||
|
||||
QItemSelectionModel* aSelectionModel = selectionModel();
|
||||
QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
|
||||
|
||||
for (int i = 0, aNbItems = aSelectedIndices.size(); i < aNbItems; i++) {
|
||||
QTreeWidgetItem* anItem = itemFromIndex( aSelectedIndices[i] );
|
||||
if ( !anItem )
|
||||
continue;
|
||||
QString anEntry = entryFromItem( anItem->parent() );
|
||||
int aDimIndex = idFromItem( anItem );
|
||||
if ( aDimIndex < 0 )
|
||||
continue;
|
||||
|
||||
if ( theAnnotations.contains( anEntry ) )
|
||||
theAnnotations[anEntry].append( aDimIndex );
|
||||
else {
|
||||
QList<int> anIndices;
|
||||
anIndices.append( aDimIndex );
|
||||
theAnnotations[anEntry] = anIndices;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setSelected
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::setSelected( const QMap<QString, QList<int> >& theAnnotations )
|
||||
{
|
||||
QItemSelectionModel* aSelectionModel = selectionModel();
|
||||
aSelectionModel->clearSelection();
|
||||
|
||||
QMap<QString, QList<int> >::const_iterator anIt = theAnnotations.begin(),
|
||||
aLast = theAnnotations.end();
|
||||
BranchType aBranchType = AnnotationShape;
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
QString anEntry = anIt.key();
|
||||
QTreeWidgetItem* anEntryItem = itemFromEntry( aBranchType, anEntry );
|
||||
if ( !anEntryItem )
|
||||
continue;
|
||||
|
||||
QList<int> anAnnotationIds = anIt.value();
|
||||
QTreeWidgetItem* anItem;
|
||||
for ( int i = 0; i < anEntryItem->childCount(); i++ ) {
|
||||
anItem = anEntryItem->child( i );
|
||||
int aDimIndex = idFromItem( anItem );
|
||||
if ( anAnnotationIds.contains( aDimIndex ) ) {
|
||||
QModelIndex anIndex = indexFromItem( anItem );
|
||||
aSelectionModel->select( anIndex, QItemSelectionModel::Select );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getAllEntries
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QList<QString> GEOMGUI_TextTreeWdg::getAllEntries( const BranchType& theBranchType )
|
||||
{
|
||||
return getObjects( theBranchType ).keys();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getSingleSelectedObject
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QString GEOMGUI_TextTreeWdg::getSingleSelectedObject()
|
||||
{
|
||||
QString anEntry;
|
||||
QTreeWidgetItem* anItem = currentItem();
|
||||
if (anItem) {
|
||||
QHash<QString, QTreeWidgetItem*> anObjects = getObjects( AnnotationShape );
|
||||
QHash<QString, QTreeWidgetItem*>::const_iterator anIt = anObjects.begin(),
|
||||
aLast = anObjects.end();
|
||||
for (; anIt != aLast; anIt++) {
|
||||
if ( anIt.value() == anItem ) {
|
||||
anEntry = anIt.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return anEntry;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setShapeItemVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool GEOMGUI_TextTreeWdg::setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility )
|
||||
{
|
||||
int aDimIndex = idFromItem( theWidgetItem );
|
||||
if ( theProps->GetNumber() == 0
|
||||
|| theProps->GetIsVisible( aDimIndex ) == theVisibility ) {
|
||||
return false;
|
||||
}
|
||||
theProps->SetIsVisible( aDimIndex, theVisibility );
|
||||
|
||||
theWidgetItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -422,3 +832,45 @@ void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
|
||||
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toLatin1().constData(), "GEOM", "TEMP_IO" );
|
||||
myDisplayer.Redisplay( io );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getPropertyRootItem
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType )
|
||||
{
|
||||
return (theBranchType == DimensionShape) ? myDimensionsItem : myAnnotationsItem;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getObjects
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType )
|
||||
{
|
||||
return (theBranchType == DimensionShape) ? myDimensionObjects : myAnnotationObjects;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : branchTypeFromItem
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem )
|
||||
{
|
||||
BranchType aBranchType = DimensionShape;
|
||||
|
||||
bool aBranchTypeFound = false;
|
||||
QTreeWidgetItem* anItem = theItem;
|
||||
while( !aBranchTypeFound && anItem ) {
|
||||
if ( anItem == myDimensionsItem ||
|
||||
anItem == myAnnotationsItem) {
|
||||
aBranchTypeFound = true;
|
||||
aBranchType = (anItem == myDimensionsItem) ? DimensionShape : AnnotationShape;
|
||||
}
|
||||
else {
|
||||
anItem = anItem->parent();
|
||||
}
|
||||
}
|
||||
|
||||
return aBranchType;
|
||||
}
|
||||
|
@ -23,8 +23,11 @@
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
#include "GEOM_Displayer.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <SALOMEDSClient.hxx>
|
||||
|
||||
@ -44,46 +47,97 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
enum BranchType { DimensionShape, AnnotationShape };
|
||||
|
||||
public:
|
||||
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
|
||||
~GEOMGUI_TextTreeWdg();
|
||||
|
||||
int getWinID() { return myWindowID; }
|
||||
|
||||
void removeBranch( const QString& theEntry,
|
||||
bool force = true );
|
||||
void removeBranch( const BranchType& theBranchType, const QString& theEntry,
|
||||
bool force = true );
|
||||
int idFromItem( QTreeWidgetItem* theItem );
|
||||
QString entryFromItem( QTreeWidgetItem* theShapeItem );
|
||||
QTreeWidgetItem* itemFromEntry( QString theEntry );
|
||||
void setShapeDimensionsVisibility( QString theEntry, bool theVisibility );
|
||||
void setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility );
|
||||
QString entryFromItem( QTreeWidgetItem* theShapeItem ) const;
|
||||
QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
|
||||
void setAllShapeItemsVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
const bool theVisibility );
|
||||
void setShapeItemVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility );
|
||||
void updateVisibility();
|
||||
|
||||
void getSelected( QMap<QString, QList<int> >& theAnnotations );
|
||||
void setSelected( const QMap<QString, QList<int> >& theAnnotations );
|
||||
|
||||
QList<QString> getAllEntries( const BranchType& theBranchType );
|
||||
|
||||
QString getSingleSelectedObject();
|
||||
|
||||
protected:
|
||||
void createActions();
|
||||
void redisplay( QString theEntry );
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void updateTree();
|
||||
void updateBranch( const QString& theEntry );
|
||||
void updateBranches( const QString& theEntry );
|
||||
void updateDimensionBranch( const QString& theEntry );
|
||||
void updateAnnotationBranch( const QString& theEntry );
|
||||
void updateObjectName( const QString& theEntry );
|
||||
|
||||
private slots:
|
||||
void onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
|
||||
void onItemClicked(QTreeWidgetItem*, int );
|
||||
void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
|
||||
void setVisibility( bool visibility );
|
||||
void setVisibility( QTreeWidgetItem* theItem, bool visibility );
|
||||
void showContextMenu( const QPoint& pos );
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
int myWindowID;
|
||||
/*!
|
||||
* \brief Common interface for working with shape dimension and annotation properties
|
||||
* of object in a unified way irrespectively of the implementation.
|
||||
*/
|
||||
class VisualProperty
|
||||
{
|
||||
public:
|
||||
virtual int GetNumber() = 0;
|
||||
virtual QString GetName( const int theIndex ) = 0;
|
||||
virtual bool GetIsVisible( const int theIndex ) = 0;
|
||||
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) = 0;
|
||||
virtual void Save() = 0;
|
||||
};
|
||||
|
||||
QIcon myVisibleIcon;
|
||||
QIcon myInvisibleIcon;
|
||||
QHash<QString, QTreeWidgetItem*> myObjects;
|
||||
SalomeApp_Study* myStudy;
|
||||
QTreeWidgetItem* myDimensionsItem;
|
||||
GEOM_Displayer myDisplayer;
|
||||
private:
|
||||
bool setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility );
|
||||
QSharedPointer<VisualProperty> getVisualProperty( const BranchType& theBranchType,
|
||||
SalomeApp_Study* theStudy,
|
||||
const std::string& theEntry );
|
||||
void fillBranch( const BranchType& theBranchType,
|
||||
const QString& theEntry );
|
||||
void updateVisibilityColumn( const BranchType& theBranchType,
|
||||
QString theEntry,
|
||||
Qtx::VisibilityState theState );
|
||||
QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType );
|
||||
QHash<QString, QTreeWidgetItem*>& getObjects( const BranchType& theBranchType );
|
||||
BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
|
||||
|
||||
QMap<int, QAction*> myActions; //!< menu actions list
|
||||
private:
|
||||
|
||||
int myWindowID;
|
||||
QIcon myVisibleIcon;
|
||||
QIcon myInvisibleIcon;
|
||||
QHash<QString, QTreeWidgetItem*> myDimensionObjects;
|
||||
QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
|
||||
SalomeApp_Study* myStudy;
|
||||
QTreeWidgetItem* myDimensionsItem;
|
||||
QTreeWidgetItem* myAnnotationsItem;
|
||||
GEOM_Displayer myDisplayer;
|
||||
QMap<int, QAction*> myActions; //!< menu actions list
|
||||
};
|
||||
|
||||
#endif
|
||||
|
49
src/GEOMGUI/GEOM_Displayer.cxx
Normal file → Executable file
49
src/GEOMGUI/GEOM_Displayer.cxx
Normal file → Executable file
@ -25,7 +25,6 @@
|
||||
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
|
||||
|
||||
#include "GEOM_Displayer.h"
|
||||
#include "GEOMGUI_DimensionProperty.h"
|
||||
#include "GeometryGUI.h"
|
||||
|
||||
#include <GEOM_Constants.h>
|
||||
@ -39,12 +38,17 @@
|
||||
|
||||
#include <GEOM_Actor.h>
|
||||
#include <GEOM_AISDimension.hxx>
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <GEOM_TopWireframeShape.hxx>
|
||||
#include <GEOM_AISVector.hxx>
|
||||
#include <GEOM_AISTrihedron.hxx>
|
||||
#include <GEOM_VTKTrihedron.hxx>
|
||||
#include <GEOM_VTKPropertyMaterial.hxx>
|
||||
|
||||
#include <GEOMGUI_DimensionProperty.h>
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
#include <GEOMGUI_AnnotationMgr.h>
|
||||
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <Material_Model.h>
|
||||
@ -460,6 +464,7 @@ static std::string getName( GEOM::GEOM_BaseObject_ptr object )
|
||||
*/
|
||||
//=================================================================
|
||||
GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
|
||||
: myIsRedisplayed( false )
|
||||
{
|
||||
if( st )
|
||||
myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
|
||||
@ -510,7 +515,8 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
|
||||
#if OCC_VERSION_MAJOR >= 7
|
||||
myColorScale = new AIS_ColorScale;
|
||||
myColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||
myColorScale->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
|
||||
myColorScale->SetTransformPersistence (
|
||||
Graphic3d_TransformPers::FromDeprecatedParams(Graphic3d_TMF_2d, gp_Pnt (-1,-1,0)));
|
||||
#endif
|
||||
|
||||
myFieldDataType = GEOM::FDT_Double;
|
||||
@ -636,6 +642,8 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
|
||||
const bool updateViewer,
|
||||
const bool checkActiveViewer )
|
||||
{
|
||||
bool aRedisplayed = myIsRedisplayed;
|
||||
myIsRedisplayed = true;
|
||||
// Remove the object permanently (<forced> == true)
|
||||
SUIT_Session* ses = SUIT_Session::session();
|
||||
SUIT_Application* app = ses->activeApplication();
|
||||
@ -665,6 +673,7 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
|
||||
}
|
||||
}
|
||||
}
|
||||
myIsRedisplayed = aRedisplayed;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
@ -684,8 +693,23 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
|
||||
return;
|
||||
}
|
||||
|
||||
bool aRedisplayed = myIsRedisplayed;
|
||||
myIsRedisplayed = true;
|
||||
Erase( theIO, true, false, theViewFrame );
|
||||
Display( theIO, theUpdateViewer, theViewFrame );
|
||||
myIsRedisplayed = aRedisplayed;
|
||||
// hide annotations for erased presentation
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
|
||||
if ( aModule ) {
|
||||
if ( !theViewFrame->isVisible( theIO ) ) {
|
||||
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast<SOCC_Viewer*>( theViewFrame ));
|
||||
}
|
||||
else {
|
||||
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast<SOCC_Viewer*>( theViewFrame ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
@ -2052,6 +2076,18 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
|
||||
void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
|
||||
{
|
||||
UpdateColorScale(false,false);
|
||||
|
||||
// visualize annotations for displayed presentation
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
|
||||
if ( aModule ) {
|
||||
if ( !myIsRedisplayed ) {
|
||||
aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
|
||||
} else {
|
||||
aModule->GetAnnotationMgr()->UpdateVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p )
|
||||
@ -2064,6 +2100,15 @@ void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
|
||||
{
|
||||
LightApp_Displayer::AfterErase( v, p );
|
||||
UpdateColorScale(false,false);
|
||||
|
||||
if ( !myIsRedisplayed ) {
|
||||
// hide annotations for erased presentation
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
|
||||
if ( aModule )
|
||||
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
|
2
src/GEOMGUI/GEOM_Displayer.h
Normal file → Executable file
2
src/GEOMGUI/GEOM_Displayer.h
Normal file → Executable file
@ -263,6 +263,7 @@ protected:
|
||||
void updateShapeProperties( const Handle(GEOM_AISShape)&, bool );
|
||||
void updateActorProperties( GEOM_Actor*, bool );
|
||||
void updateDimensions( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
|
||||
void updateShapeAnnotations( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
|
||||
|
||||
PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 );
|
||||
PropMap getDefaultPropertyMap();
|
||||
@ -317,6 +318,7 @@ protected:
|
||||
Aspect_TypeOfMarker myTypeOfMarker;
|
||||
double myScaleOfMarker;
|
||||
double myTransparency;
|
||||
bool myIsRedisplayed;
|
||||
|
||||
private:
|
||||
SalomeApp_Application* myApp;
|
||||
|
@ -1215,6 +1215,10 @@
|
||||
<source>ICO_MANAGE_DIMENSIONS</source>
|
||||
<translation>managedimensions.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_ANNOTATION</source>
|
||||
<translation>annotation.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_POINT</source>
|
||||
<translation>point2.png</translation>
|
||||
|
163
src/GEOMGUI/GEOM_msg_en.ts
Normal file → Executable file
163
src/GEOMGUI/GEOM_msg_en.ts
Normal file → Executable file
@ -575,6 +575,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>GEOM_DIMENSIONS</source>
|
||||
<translation>Dimensions</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_ANNOTATIONS</source>
|
||||
<translation>Annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_SKETCHER_DIST</source>
|
||||
<translation>Distance</translation>
|
||||
@ -3500,6 +3504,50 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>PREF_DIMENSIONS_USE_TEXT3D</source>
|
||||
<translation>Use 3D text</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS</source>
|
||||
<translation>Shape annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_FONT</source>
|
||||
<translation>Font</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_FONT_COLOR</source>
|
||||
<translation>Font color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_COLOR</source>
|
||||
<translation>Line color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_WIDTH</source>
|
||||
<translation>Line width</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_STYLE</source>
|
||||
<translation>Line style</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_AUTOHIDE</source>
|
||||
<translation>Hide when attachment is invisible</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID</source>
|
||||
<translation>Solid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH</source>
|
||||
<translation>Dashed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT</source>
|
||||
<translation>Dotted</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH</source>
|
||||
<translation>Mixed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_HIDE_INPUT_OBJECT</source>
|
||||
<translation>Hide input objects from the viewer</translation>
|
||||
@ -4956,6 +5004,42 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_MANAGE_DIMENSIONS</source>
|
||||
<translation>Manage measurement dimensions of an object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_ANNOTATION</source>
|
||||
<translation>Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_ANNOTATION</source>
|
||||
<translation>Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_ANNOTATION</source>
|
||||
<translation>Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_EDIT_ANNOTATION</source>
|
||||
<translation>Edit Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_EDIT_ANNOTATION</source>
|
||||
<translation>Edit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_EDIT_ANNOTATION</source>
|
||||
<translation>Edit Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_DELETE_ANNOTATION</source>
|
||||
<translation>Delete Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_DELETE_ANNOTATION</source>
|
||||
<translation>Delete</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_DELETE_ANNOTATION</source>
|
||||
<translation>Delete Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_DEPENDENCY_TREE</source>
|
||||
<translation>Show dependency tree</translation>
|
||||
@ -4996,6 +5080,30 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
|
||||
<translation>Show all visible measures (dimension) created for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation>Show all annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation>Show all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation>Show all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation>Hide all annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation>Hide all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation>Hide all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_AUTO_COLOR</source>
|
||||
<translation>Auto color</translation>
|
||||
@ -6675,6 +6783,61 @@ Do you want to continue?</translation>
|
||||
Please specify suitable arguments.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MeasureGUI_AnnotationDlg</name>
|
||||
<message>
|
||||
<source>CREATE_ANNOTATION_TITLE</source>
|
||||
<translation>Create annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>EDIT_ANNOTATION_TITLE</source>
|
||||
<translation>Edit annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_PREFIX</source>
|
||||
<translation>Annotation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_NAME</source>
|
||||
<translation>Annotation name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_PROPERTIES</source>
|
||||
<translation>Properties</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_TEXT</source>
|
||||
<translation>Text</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_SHAPE</source>
|
||||
<translation>Shape</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_TYPE</source>
|
||||
<translation>Type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_SUB_SHAPE</source>
|
||||
<translation>Sub-shape type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_IS_SCREEN_FIXED</source>
|
||||
<translation>Fixed screen position</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WHOLE_SHAPE</source>
|
||||
<translation>Whole shape</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_STYLE</source>
|
||||
<translation>Style</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ANNOTATION_FONT</source>
|
||||
<translation>Font</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MeasureGUI_CheckShapeDlg</name>
|
||||
<message>
|
||||
|
68
src/GEOMGUI/GEOM_msg_fr.ts
Normal file → Executable file
68
src/GEOMGUI/GEOM_msg_fr.ts
Normal file → Executable file
@ -3492,6 +3492,50 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<source>PREF_DIMENSIONS_USE_TEXT3D</source>
|
||||
<translation>Utiliser du texte 3D</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Shape annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_FONT</source>
|
||||
<translation type="unfinished">Font</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_FONT_COLOR</source>
|
||||
<translation type="unfinished">Font color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_COLOR</source>
|
||||
<translation type="unfinished">Line color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_WIDTH</source>
|
||||
<translation type="unfinished">Line width</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_STYLE</source>
|
||||
<translation type="unfinished">Line style</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_AUTOHIDE</source>
|
||||
<translation type="unfinished">Hide when attachment is invisible</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID</source>
|
||||
<translation type="unfinished">Solid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH</source>
|
||||
<translation type="unfinished">Dashed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT</source>
|
||||
<translation type="unfinished">Dotted</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH</source>
|
||||
<translation type="unfinished">Mixed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_HIDE_INPUT_OBJECT</source>
|
||||
<translation>Cacher dans la vue les objets en entrée</translation>
|
||||
@ -4988,6 +5032,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
|
||||
<translation>Afficher toutes les cotations visibles créées sur l'objet</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Show all annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Show all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Show all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Hide all annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Hide all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Hide all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_AUTO_COLOR</source>
|
||||
<translation>Couleur automatique</translation>
|
||||
|
68
src/GEOMGUI/GEOM_msg_ja.ts
Normal file → Executable file
68
src/GEOMGUI/GEOM_msg_ja.ts
Normal file → Executable file
@ -3495,6 +3495,50 @@
|
||||
<source>PREF_DIMENSIONS_USE_TEXT3D</source>
|
||||
<translation>3Dテキストの使用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Shape annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_FONT</source>
|
||||
<translation type="unfinished">Font</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_FONT_COLOR</source>
|
||||
<translation type="unfinished">Font color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_COLOR</source>
|
||||
<translation type="unfinished">Line color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_WIDTH</source>
|
||||
<translation type="unfinished">Line width</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINE_STYLE</source>
|
||||
<translation type="unfinished">Line style</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_AUTOHIDE</source>
|
||||
<translation type="unfinished">Hide when attachment is invisible</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID</source>
|
||||
<translation type="unfinished">Solid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH</source>
|
||||
<translation type="unfinished">Dashed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT</source>
|
||||
<translation type="unfinished">Dotted</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH</source>
|
||||
<translation type="unfinished">Mixed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PREF_HIDE_INPUT_OBJECT</source>
|
||||
<translation>ビューワから入力したオブジェクトの非表示</translation>
|
||||
@ -4991,6 +5035,30 @@
|
||||
<source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
|
||||
<translation>オブジェクトのために作成されたすべての見える基準寸法を表示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Show all annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Show all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_SHOW_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Show all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Hide all annotations</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Hide all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_HIDE_ALL_ANNOTATIONS</source>
|
||||
<translation type="unfinished">Hide all shape annotations for the object</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_POP_AUTO_COLOR</source>
|
||||
<translation>自動色</translation>
|
||||
|
215
src/GEOMGUI/GeometryGUI.cxx
Normal file → Executable file
215
src/GEOMGUI/GeometryGUI.cxx
Normal file → Executable file
@ -39,6 +39,8 @@
|
||||
#include "GEOM_Displayer.h"
|
||||
#include "GEOM_AISShape.hxx"
|
||||
#include "GEOMUtils_XmlHandler.hxx"
|
||||
#include "GEOMGUI_AnnotationMgr.h"
|
||||
#include "GEOMGUI_TextTreeSelector.h"
|
||||
|
||||
#include "GEOM_Actor.h"
|
||||
|
||||
@ -227,6 +229,7 @@ GeometryGUI::GeometryGUI() :
|
||||
|
||||
myCreationInfoWdg = 0;
|
||||
myTextTreeWdg = 0;
|
||||
myAnnotationMgr = 0;
|
||||
|
||||
connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
|
||||
|
||||
@ -373,6 +376,26 @@ void GeometryGUI::ActiveWorkingPlane()
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GeometryGUI::SetActiveDialogBox()
|
||||
// purpose : Set active dialog box
|
||||
//=======================================================================
|
||||
GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
|
||||
{
|
||||
if ( !myAnnotationMgr )
|
||||
myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
|
||||
return myAnnotationMgr;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GeometryGUI::SetActiveDialogBox()
|
||||
// purpose : Set active dialog box
|
||||
//=======================================================================
|
||||
GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
|
||||
{
|
||||
return myTextTreeWdg;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GeometryGUI::SetActiveDialogBox()
|
||||
// purpose : Set active dialog box
|
||||
@ -661,11 +684,16 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
||||
case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
|
||||
case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
|
||||
case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
|
||||
case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
|
||||
case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
|
||||
case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
|
||||
#ifndef DISABLE_PLOT2DVIEWER
|
||||
case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
|
||||
#endif
|
||||
case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
|
||||
case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
|
||||
case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
|
||||
case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
|
||||
libName = "MeasureGUI";
|
||||
break;
|
||||
case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
|
||||
@ -1042,6 +1070,9 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
|
||||
createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
|
||||
createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
|
||||
createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
|
||||
createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
|
||||
createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
|
||||
|
||||
createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
|
||||
createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
|
||||
@ -1115,9 +1146,11 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
#ifndef DISABLE_GRAPHICSVIEW
|
||||
createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
|
||||
#endif
|
||||
createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
|
||||
createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
|
||||
createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
|
||||
createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
|
||||
createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
|
||||
createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
|
||||
createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
|
||||
createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
|
||||
|
||||
// Create actions for increase/decrease transparency shortcuts
|
||||
createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
|
||||
@ -1310,6 +1343,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( GEOMOp::OpAngle, dimId, -1 );
|
||||
createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
|
||||
|
||||
createMenu( GEOMOp::OpAnnotation, measurId, -1 );
|
||||
|
||||
createMenu( separator(), measurId, -1 );
|
||||
createMenu( GEOMOp::OpTolerance, measurId, -1 );
|
||||
createMenu( separator(), measurId, -1 );
|
||||
@ -1466,6 +1501,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createTool( GEOMOp::OpBoundingBox, measureTbId );
|
||||
createTool( GEOMOp::OpMinDistance, measureTbId );
|
||||
createTool( GEOMOp::OpAngle, measureTbId );
|
||||
createTool( GEOMOp::OpAnnotation, measureTbId );
|
||||
createTool( GEOMOp::OpTolerance , measureTbId );
|
||||
createTool( separator(), measureTbId );
|
||||
createTool( GEOMOp::OpFreeBoundaries, measureTbId );
|
||||
@ -1586,6 +1622,12 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( separator(), -1, -1 ); // -----------
|
||||
|
||||
mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
|
||||
mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
|
||||
mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( separator(), -1, -1 ); // -----------
|
||||
|
||||
QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
|
||||
onlyComponent = "((type='Component') and selcount=1)",
|
||||
rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
|
||||
@ -1640,6 +1682,10 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
|
||||
mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
|
||||
mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
|
||||
mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
|
||||
mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
|
||||
|
||||
mgr->insert( separator(), -1, -1 ); // -----------
|
||||
mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
|
||||
@ -1821,8 +1867,11 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
|
||||
getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
|
||||
getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
|
||||
|
||||
if ( !myTextTreeWdg )
|
||||
if ( !myTextTreeWdg ) {
|
||||
myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
|
||||
new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
|
||||
}
|
||||
|
||||
getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
|
||||
getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
|
||||
|
||||
@ -2028,6 +2077,10 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
|
||||
break;
|
||||
}
|
||||
}
|
||||
SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
|
||||
if ( aSOCCView ) {
|
||||
GetAnnotationMgr()->RemoveView( aSOCCView );
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -2355,6 +2408,10 @@ void GeometryGUI::createPreferences()
|
||||
addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
|
||||
LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Dimensions (Measurements) preferences
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
|
||||
setPreferenceProperty( aDimGroupId, "columns", 2 );
|
||||
|
||||
@ -2438,6 +2495,53 @@ void GeometryGUI::createPreferences()
|
||||
addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
|
||||
LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Shape annotation preferences
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
|
||||
setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
|
||||
|
||||
addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
|
||||
addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
|
||||
const int aShapeAnnFont =
|
||||
addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
|
||||
|
||||
int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
|
||||
setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
|
||||
setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
|
||||
setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
|
||||
|
||||
const int aShapeAnnLineWidth =
|
||||
addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
|
||||
|
||||
setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
|
||||
setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
|
||||
|
||||
addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
|
||||
|
||||
const int aShapeAnnLineStyle =
|
||||
addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
|
||||
|
||||
QStringList aLineStyleList;
|
||||
aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
|
||||
aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
|
||||
aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
|
||||
aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
|
||||
|
||||
QList<QVariant> aLineStyleIds;
|
||||
aLineStyleIds.append(0);
|
||||
aLineStyleIds.append(1);
|
||||
aLineStyleIds.append(2);
|
||||
aLineStyleIds.append(3);
|
||||
|
||||
setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
|
||||
setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Isoline drawing preferences
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
|
||||
setPreferenceProperty( isoGroup, "columns", 2 );
|
||||
int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
|
||||
@ -2703,14 +2807,21 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
|
||||
aDisplayer.UpdateColorScale( anIsRedisplayFieldSteps, true );
|
||||
}
|
||||
}
|
||||
else if ( param == QString("dimensions_color") ||
|
||||
param == QString("dimensions_line_width") ||
|
||||
param == QString("dimensions_font") ||
|
||||
param == QString("dimensions_arrow_length") ||
|
||||
param == QString("dimensions_show_units") ||
|
||||
param == QString("dimensions_length_units") ||
|
||||
param == QString("dimensions_angle_units") ||
|
||||
param == QString("dimensions_use_text3d") ||
|
||||
else if ( param == QString("dimensions_color") ||
|
||||
param == QString("dimensions_line_width") ||
|
||||
param == QString("dimensions_font") ||
|
||||
param == QString("dimensions_arrow_length") ||
|
||||
param == QString("dimensions_show_units") ||
|
||||
param == QString("dimensions_length_units") ||
|
||||
param == QString("dimensions_angle_units") ||
|
||||
param == QString("dimensions_use_text3d") ||
|
||||
param == QString("shape_annotation_font_color") ||
|
||||
param == QString("shape_annotation_line_color") ||
|
||||
param == QString("shape_annotation_font") ||
|
||||
param == QString("shape_annotation_line_width") ||
|
||||
param == QString("shape_annotation_autohide") ||
|
||||
param == QString("shape_annotation_line_style") ||
|
||||
param == QString("shape_annotation_line_style") ||
|
||||
param == QString("label_color") )
|
||||
{
|
||||
SalomeApp_Application* anApp = getApp();
|
||||
@ -2740,6 +2851,20 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
|
||||
|
||||
SALOME_ListIO aVisible;
|
||||
aViewer->GetVisible( aVisible );
|
||||
|
||||
GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
|
||||
if ( anAnnotationMgr ) {
|
||||
SALOME_ListIteratorOfListIO anIter( aVisible );
|
||||
while ( anIter.More() ) {
|
||||
if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
|
||||
aVisible.Remove( anIter );
|
||||
}
|
||||
else {
|
||||
anIter.Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aDisplayer.Redisplay( aVisible, false, aViewer );
|
||||
}
|
||||
if ( param == QString( "label_color" ) ) {
|
||||
@ -2796,6 +2921,7 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
|
||||
if ( !appStudy || !appStudy->studyDS() )
|
||||
return;
|
||||
|
||||
_PTR(Study) studyDS = appStudy->studyDS();
|
||||
|
||||
// componentName is used for encoding of entries when storing them in IParameters
|
||||
@ -2813,12 +2939,17 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
QList<SUIT_ViewManager*> lst;
|
||||
QList<SUIT_ViewManager*>::Iterator it;
|
||||
|
||||
GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
|
||||
|
||||
// main cycle to store parameters of displayed objects
|
||||
lst.clear();
|
||||
getApp()->viewManagers(lst);
|
||||
for (it = lst.begin(); it != lst.end(); it++) {
|
||||
SUIT_ViewManager* vman = *it;
|
||||
QString vType = vman->getType();
|
||||
SUIT_ViewModel* vmodel = vman->getViewModel();
|
||||
SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
|
||||
|
||||
int aMgrId = vman->getGlobalId();
|
||||
// saving VTK actors properties
|
||||
QVector<SUIT_ViewWindow*> views = vman->getViews();
|
||||
@ -2940,28 +3071,41 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
param = occParam + GEOM::propertyName( GEOM::IsosWidth );
|
||||
ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
|
||||
}
|
||||
|
||||
if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
|
||||
std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
|
||||
o_it.key().toLatin1().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
|
||||
if (!anAnnotationInfo.empty()) {
|
||||
param = occParam + "ShapeAnnotationVisibleItems";
|
||||
ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
|
||||
}
|
||||
}
|
||||
} // object iterator
|
||||
} // for (views)
|
||||
} // for (viewManagers)
|
||||
|
||||
// store dimension attributes of objects:
|
||||
// store shape annotation and dimension attributes of objects:
|
||||
// since the displayed object always persists in property map, we remember the object entries
|
||||
// on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
|
||||
QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
|
||||
const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
|
||||
const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
|
||||
QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
|
||||
for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
|
||||
{
|
||||
std::string aStudyEntry = (*aEntryIt).toLatin1().data();
|
||||
std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName);
|
||||
std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
|
||||
|
||||
// store dimension parameters
|
||||
GEOMGUI_DimensionProperty aDimensions( appStudy, aStudyEntry );
|
||||
|
||||
if ( aDimensions.GetNumber() == 0 )
|
||||
{
|
||||
continue;
|
||||
if ( aDimensions.GetNumber() != 0 ) {
|
||||
ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
|
||||
}
|
||||
|
||||
ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
|
||||
_PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
|
||||
const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
|
||||
if ( !aShapeAnnAttr.IsNull() ) {
|
||||
ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toLatin1().data() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3044,6 +3188,13 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
|
||||
aDimensionProp.SaveToAttribute( appStudy, entry.toLatin1().data() );
|
||||
}
|
||||
else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
|
||||
{
|
||||
Handle(GEOMGUI_AnnotationAttrs) anAttr =
|
||||
GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
|
||||
|
||||
anAttr->ImportFromPropertyString( aValuesStr );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -3099,7 +3250,10 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
|
||||
} else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
|
||||
aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
|
||||
} else if (paramNameStr == "ShapeAnnotationVisibleItems") {
|
||||
aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
|
||||
}
|
||||
|
||||
} // for names/parameters iterator
|
||||
|
||||
QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
|
||||
@ -3111,7 +3265,16 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
|
||||
SUIT_ViewManager* vman = lst.at(index);
|
||||
SUIT_ViewModel* vmodel = vman->getViewModel();
|
||||
displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
|
||||
SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
|
||||
displayer()->Display(entry, true, aView);
|
||||
|
||||
if ( vmodel->getType() == SOCC_Viewer::Type() ) {
|
||||
PropMap& aProps = aListOfMap[index];
|
||||
if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
|
||||
SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
|
||||
GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for entries iterator
|
||||
@ -3135,6 +3298,10 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
occVMod->Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
if ( myTextTreeWdg ) {
|
||||
myTextTreeWdg->updateTree();
|
||||
}
|
||||
}
|
||||
|
||||
// Compute current name mode of the viewer
|
||||
@ -3367,6 +3534,7 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name)
|
||||
if (!CORBA::is_nil(anObj)) {
|
||||
anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
|
||||
emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
|
||||
emit SignalTextTreeRenameObject( entry );
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
@ -3534,3 +3702,8 @@ void GeometryGUI::emitDimensionsUpdated( QString entry )
|
||||
{
|
||||
emit DimensionsUpdated( entry );
|
||||
}
|
||||
|
||||
void GeometryGUI::emitAnnotationsUpdated( QString entry )
|
||||
{
|
||||
emit SignalAnnotationsUpdated( entry );
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <GEOM_Client.hxx>
|
||||
#include <SALOME_InteractiveObject.hxx>
|
||||
#include <SALOMEDSClient.hxx>
|
||||
#include <Qtx.h>
|
||||
|
||||
#include "GEOMGUI.h"
|
||||
#include "GEOMPluginGUI.h"
|
||||
@ -65,6 +66,7 @@ class SUIT_ViewManager;
|
||||
class SalomeApp_Study;
|
||||
class GEOMGUI_CreationInfoWdg;
|
||||
class GEOMGUI_TextTreeWdg;
|
||||
class GEOMGUI_AnnotationMgr;
|
||||
|
||||
//=================================================================================
|
||||
// class : GeometryGUI
|
||||
@ -98,6 +100,10 @@ public:
|
||||
|
||||
GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
|
||||
|
||||
GEOMGUI_AnnotationMgr* GetAnnotationMgr();
|
||||
|
||||
GEOMGUI_TextTreeWdg* GetTextTreeWdg() const;
|
||||
|
||||
// Get active dialog box
|
||||
QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
|
||||
// Set active dialog box
|
||||
@ -150,6 +156,7 @@ public:
|
||||
const int row, Qt::DropAction action );
|
||||
|
||||
void emitDimensionsUpdated( QString entry );
|
||||
void emitAnnotationsUpdated( QString entry );
|
||||
|
||||
public slots:
|
||||
virtual bool deactivateModule( SUIT_Study* );
|
||||
@ -179,6 +186,8 @@ signals :
|
||||
void SignalDefaultStepValueChanged( double newVal );
|
||||
void SignalDependencyTreeParamChanged( const QString&, const QString& );
|
||||
void SignalDependencyTreeRenameObject( const QString& );
|
||||
void SignalTextTreeRenameObject( const QString& );
|
||||
void SignalAnnotationsUpdated( const QString& );
|
||||
void DimensionsUpdated( const QString& );
|
||||
|
||||
protected:
|
||||
@ -228,7 +237,8 @@ private:
|
||||
|
||||
GEOMGUI_CreationInfoWdg* myCreationInfoWdg;
|
||||
|
||||
GEOMGUI_TextTreeWdg* myTextTreeWdg;
|
||||
GEOMGUI_TextTreeWdg* myTextTreeWdg;
|
||||
GEOMGUI_AnnotationMgr* myAnnotationMgr;
|
||||
|
||||
SALOME_ListIO myTopLevelIOList;
|
||||
|
||||
|
5
src/GEOMGUI/GeometryGUI_Operations.h
Normal file → Executable file
5
src/GEOMGUI/GeometryGUI_Operations.h
Normal file → Executable file
@ -207,6 +207,11 @@ namespace GEOMOp {
|
||||
#ifndef DISABLE_PLOT2DVIEWER
|
||||
OpShapeStatistics = 5019, // MENU MEASURES - SHAPE STATISTICS
|
||||
#endif
|
||||
OpAnnotation = 5020, // MENU MEASURES - ANNOTATION
|
||||
OpEditAnnotation = 5021, // POPUP MENU - EDIT ANNOTATION
|
||||
OpShowAllAnnotations = 5022, // POPUP MENU - SHOW ALL ANNOTATIONS
|
||||
OpHideAllAnnotations = 5023, // POPUP MENU - HIDE ALL ANNOTATIONS
|
||||
OpDeleteAnnotation = 5024, // POPUP MENU - DELETE ANNOTATION
|
||||
// GroupGUI --------------------//--------------------------------
|
||||
OpGroupCreate = 6000, // MENU GROUP - CREATE
|
||||
OpGroupEdit = 6001, // MENU GROUP - EDIT
|
||||
|
@ -88,6 +88,8 @@ SET(MeasureGUI_HEADERS
|
||||
MeasureGUI_InertiaDlg.h
|
||||
MeasureGUI_BndBoxDlg.h
|
||||
MeasureGUI_DistanceDlg.h
|
||||
MeasureGUI_AnnotationDlg.h
|
||||
MeasureGUI_AnnotationInteractor.h
|
||||
MeasureGUI_AngleDlg.h
|
||||
MeasureGUI_MaxToleranceDlg.h
|
||||
MeasureGUI_WhatisDlg.h
|
||||
@ -116,6 +118,8 @@ SET(_moc_HEADERS
|
||||
MeasureGUI_InertiaDlg.h
|
||||
MeasureGUI_BndBoxDlg.h
|
||||
MeasureGUI_DistanceDlg.h
|
||||
MeasureGUI_AnnotationDlg.h
|
||||
MeasureGUI_AnnotationInteractor.h
|
||||
MeasureGUI_AngleDlg.h
|
||||
MeasureGUI_MaxToleranceDlg.h
|
||||
MeasureGUI_WhatisDlg.h
|
||||
@ -154,6 +158,8 @@ SET(MeasureGUI_SOURCES
|
||||
MeasureGUI_InertiaDlg.cxx
|
||||
MeasureGUI_BndBoxDlg.cxx
|
||||
MeasureGUI_DistanceDlg.cxx
|
||||
MeasureGUI_AnnotationDlg.cxx
|
||||
MeasureGUI_AnnotationInteractor.cxx
|
||||
MeasureGUI_AngleDlg.cxx
|
||||
MeasureGUI_MaxToleranceDlg.cxx
|
||||
MeasureGUI_WhatisDlg.cxx
|
||||
|
180
src/MeasureGUI/MeasureGUI.cxx
Normal file → Executable file
180
src/MeasureGUI/MeasureGUI.cxx
Normal file → Executable file
@ -28,8 +28,11 @@
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
#include "GeometryGUI_Operations.h"
|
||||
#include <GEOMGUI_TextTreeWdg.h>
|
||||
|
||||
#include <GEOMGUI_DimensionProperty.h>
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
#include <GEOMGUI_AnnotationMgr.h>
|
||||
|
||||
#include <LightApp_SelectionMgr.h>
|
||||
#include <SUIT_OverrideCursor.h>
|
||||
@ -44,6 +47,7 @@
|
||||
#include "MeasureGUI_BndBoxDlg.h" // Method BNDBOX
|
||||
#include "MeasureGUI_DistanceDlg.h" // Method DISTANCE
|
||||
#include "MeasureGUI_AngleDlg.h" // Method ANGLE
|
||||
#include "MeasureGUI_AnnotationDlg.h" // Method ANNOTATION
|
||||
#include "MeasureGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE
|
||||
#include "MeasureGUI_WhatisDlg.h" // Method WHATIS
|
||||
#include "MeasureGUI_CheckShapeDlg.h" // Method CHECKSHAPE
|
||||
@ -111,6 +115,12 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
case GEOMOp::OpAngle:
|
||||
dlg = new MeasureGUI_AngleDlg( getGeometryGUI(), parent );
|
||||
break; // ANGLE
|
||||
case GEOMOp::OpAnnotation:
|
||||
dlg = new MeasureGUI_AnnotationDlg( getGeometryGUI(), true, parent );
|
||||
break; // ANNOTATION
|
||||
case GEOMOp::OpEditAnnotation:
|
||||
dlg = new MeasureGUI_AnnotationDlg( getGeometryGUI(), false, parent );
|
||||
break; // ANNOTATION
|
||||
case GEOMOp::OpTolerance:
|
||||
dlg = new MeasureGUI_MaxToleranceDlg( getGeometryGUI(), parent );
|
||||
break; // MAXTOLERANCE
|
||||
@ -154,6 +164,15 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
case GEOMOp::OpHideAllDimensions:
|
||||
ChangeDimensionsVisibility( false );
|
||||
break; // HIDE ALL DIMENSIONS
|
||||
case GEOMOp::OpShowAllAnnotations:
|
||||
ChangeAnnotationsVisibility( true );
|
||||
break; // SHOW ALL ANNOTATIONS
|
||||
case GEOMOp::OpHideAllAnnotations:
|
||||
ChangeAnnotationsVisibility( false );
|
||||
break; // HIDE ALL ANNOTATIONS
|
||||
case GEOMOp::OpDeleteAnnotation:
|
||||
DeleteAnnotation();
|
||||
break; // DELETE ANNOTATIOn
|
||||
default:
|
||||
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
|
||||
break;
|
||||
@ -173,42 +192,23 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible )
|
||||
{
|
||||
SalomeApp_Application* anApp = getGeometryGUI()->getApp();
|
||||
if (!anApp)
|
||||
{
|
||||
if ( !anApp )
|
||||
return;
|
||||
}
|
||||
|
||||
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
|
||||
if ( !anActiveStudy )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr();
|
||||
if ( !aSelMgr )
|
||||
{
|
||||
Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
|
||||
if ( anIObject.IsNull()
|
||||
|| !anIObject->hasEntry() )
|
||||
return;
|
||||
}
|
||||
|
||||
SALOME_ListIO aListIO;
|
||||
aSelMgr->selectedObjects( aListIO );
|
||||
if ( aListIO.Extent() != 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(SALOME_InteractiveObject) anIObject = aListIO.First();
|
||||
if ( !anIObject->hasEntry() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SUIT_OverrideCursor wc;
|
||||
|
||||
GEOMGUI_DimensionProperty aDimensions( anActiveStudy, anIObject->getEntry() );
|
||||
|
||||
for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt )
|
||||
{
|
||||
for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt ) {
|
||||
aDimensions.SetVisible( anIt, theIsVisible );
|
||||
}
|
||||
|
||||
@ -217,6 +217,138 @@ void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible )
|
||||
GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ChangeAnnotationsVisibility
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
|
||||
{
|
||||
SalomeApp_Application* anApp = getGeometryGUI()->getApp();
|
||||
if ( !anApp )
|
||||
return;
|
||||
|
||||
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
|
||||
if ( !anActiveStudy )
|
||||
return;
|
||||
|
||||
QString anEntry;
|
||||
Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
|
||||
if ( !anIObject.IsNull() && anIObject->hasEntry() ) {
|
||||
anEntry = anIObject->getEntry();
|
||||
}
|
||||
if ( anEntry.isEmpty() ) {
|
||||
anEntry = getGeometryGUI()->GetTextTreeWdg()->getSingleSelectedObject();
|
||||
}
|
||||
|
||||
if ( !anEntry.isEmpty() ) {
|
||||
_PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( anEntry.toStdString() );
|
||||
|
||||
const Handle(GEOMGUI_AnnotationAttrs)
|
||||
aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
|
||||
if ( aShapeAnnotations.IsNull() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int aCount = aShapeAnnotations->GetNbAnnotation();
|
||||
|
||||
if ( aCount > 0 ) {
|
||||
|
||||
SUIT_OverrideCursor wc;
|
||||
|
||||
for ( int anI = 0; anI < aCount; ++anI ) {
|
||||
|
||||
if ( !theIsVisible ) {
|
||||
getGeometryGUI()->GetAnnotationMgr()->Erase( anEntry, anI );
|
||||
}
|
||||
else {
|
||||
getGeometryGUI()->GetAnnotationMgr()->Display( anEntry , anI );
|
||||
}
|
||||
}
|
||||
|
||||
getGeometryGUI()->emitAnnotationsUpdated( anEntry );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( theIsVisible ) {
|
||||
getGeometryGUI()->GetAnnotationMgr()->DisplayAllAnnotations();
|
||||
}
|
||||
else {
|
||||
getGeometryGUI()->GetAnnotationMgr()->EraseAllAnnotations();
|
||||
}
|
||||
getGeometryGUI()->GetTextTreeWdg()->updateVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DeleteAnnotation
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void MeasureGUI::DeleteAnnotation()
|
||||
{
|
||||
SalomeApp_Application* anApp = getGeometryGUI()->getApp();
|
||||
if ( !anApp )
|
||||
return;
|
||||
|
||||
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
|
||||
if ( !anActiveStudy )
|
||||
return;
|
||||
|
||||
Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
|
||||
if ( anIObject.IsNull()
|
||||
|| !anIObject->hasEntry() )
|
||||
return;
|
||||
|
||||
const QString aEntry = anIObject->getEntry();
|
||||
|
||||
QString aObjEntry;
|
||||
|
||||
int aIndex = 0;
|
||||
|
||||
if ( getGeometryGUI()->GetAnnotationMgr()->getIndexFromEntry( aEntry, aObjEntry, aIndex ) )
|
||||
{
|
||||
_PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aObjEntry.toStdString() );
|
||||
|
||||
const Handle(GEOMGUI_AnnotationAttrs)
|
||||
aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
|
||||
if ( aShapeAnnotations.IsNull() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
aShapeAnnotations->Remove( aIndex );
|
||||
|
||||
getGeometryGUI()->GetAnnotationMgr()->EraseRemovedAnnotation( aObjEntry, aIndex );
|
||||
|
||||
getGeometryGUI()->emitAnnotationsUpdated( aObjEntry );
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : getSingleSelectedIO
|
||||
// purpose : returns selected interactive object for single selection.
|
||||
//=======================================================================
|
||||
Handle(SALOME_InteractiveObject) MeasureGUI::getSingleSelectedIO()
|
||||
{
|
||||
SalomeApp_Application* anApp = getGeometryGUI()->getApp();
|
||||
if ( !anApp ) {
|
||||
return Handle(SALOME_InteractiveObject)();
|
||||
}
|
||||
|
||||
LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr();
|
||||
if ( !aSelMgr ) {
|
||||
return Handle(SALOME_InteractiveObject)();
|
||||
}
|
||||
|
||||
SALOME_ListIO aListIO;
|
||||
aSelMgr->selectedObjects( aListIO );
|
||||
if ( aListIO.Extent() != 1 ) {
|
||||
return Handle(SALOME_InteractiveObject)();
|
||||
}
|
||||
|
||||
return aListIO.First();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : onFinished
|
||||
// purpose : called then "Manage Dimension" dialog is closed.
|
||||
|
15
src/MeasureGUI/MeasureGUI.h
Normal file → Executable file
15
src/MeasureGUI/MeasureGUI.h
Normal file → Executable file
@ -27,8 +27,12 @@
|
||||
#ifndef MEASUREGUI_H
|
||||
#define MEASUREGUI_H
|
||||
|
||||
// GEOM includes
|
||||
#include <GEOMGUI.h>
|
||||
|
||||
// GUI includes
|
||||
#include <SALOME_InteractiveObject.hxx>
|
||||
|
||||
class QDialog;
|
||||
|
||||
//=================================================================================
|
||||
@ -52,6 +56,17 @@ public:
|
||||
|
||||
// Show/hide all dimension created for object
|
||||
void ChangeDimensionsVisibility( const bool theIsVisible );
|
||||
|
||||
// Show/hide all shape annotations created for GEOM object
|
||||
void ChangeAnnotationsVisibility( const bool theIsVisible );
|
||||
|
||||
// Deletes the selected annotation
|
||||
void DeleteAnnotation();
|
||||
|
||||
private:
|
||||
// Returns selected interactive object for single selection
|
||||
Handle(SALOME_InteractiveObject) getSingleSelectedIO();
|
||||
|
||||
private:
|
||||
QDialog* myManageDimensionDlg;
|
||||
private slots:
|
||||
|
1008
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
Executable file
1008
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
Executable file
File diff suppressed because it is too large
Load Diff
129
src/MeasureGUI/MeasureGUI_AnnotationDlg.h
Executable file
129
src/MeasureGUI/MeasureGUI_AnnotationDlg.h
Executable file
@ -0,0 +1,129 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : MeasureGUI_AnnotationDlg.h
|
||||
|
||||
#ifndef MeasureGUI_AnnotationDlg_H
|
||||
#define MeasureGUI_AnnotationDlg_H
|
||||
|
||||
#include <GEOMBase_Skeleton.h>
|
||||
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <GEOM_Constants.h>
|
||||
#include <GEOMGUI_AnnotationAttrs.h>
|
||||
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
//#include <TColStd_DataMapOfIntegerInteger.hxx>
|
||||
//#include <TColStd_IndexedMapOfInteger.hxx>
|
||||
//#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
//#include <QMap>
|
||||
//#include <QSet>
|
||||
//#include <QVector>
|
||||
//#include <QTableWidget>
|
||||
|
||||
class QGroupBox;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class SalomeApp_IntSpinBox;
|
||||
class MeasureGUI_AnnotationInteractor;
|
||||
|
||||
//=================================================================================
|
||||
// class : MeasureGUI_AnnotationDlg
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
class MeasureGUI_AnnotationDlg : public GEOMBase_Skeleton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MeasureGUI_AnnotationDlg ( GeometryGUI* theGeometryGUI,
|
||||
const bool theIsCreate,
|
||||
QWidget* parent=0,
|
||||
bool modal=false, Qt::WindowFlags fl=0 );
|
||||
~MeasureGUI_AnnotationDlg();
|
||||
|
||||
protected:
|
||||
// redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
virtual bool isValid ( QString& );
|
||||
virtual bool execute ();
|
||||
|
||||
SALOME_Prs* buildPrs();
|
||||
void updateSubShapeEnableState();
|
||||
void redisplayPreview();
|
||||
|
||||
void closeEvent( QCloseEvent* theEv );
|
||||
|
||||
private slots:
|
||||
void ClickOnOk();
|
||||
bool ClickOnApply();
|
||||
void SelectionIntoArgument();
|
||||
void SetEditCurrentArgument();
|
||||
|
||||
void onTextChange();
|
||||
void onTypeChange();
|
||||
void onSubShapeTypeChange();
|
||||
|
||||
void onDragged( Handle_GEOM_Annotation theAnnotation );
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
void activateSelectionArgument( QPushButton* theSelectionButton );
|
||||
void activateSelection();
|
||||
TopAbs_ShapeEnum getShapeType() const;
|
||||
|
||||
bool getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape );
|
||||
gp_Pnt getAttachPoint( const TopoDS_Shape& theShape, bool& theIsOk );
|
||||
gp_Pnt getDefaultPosition( const gp_Pnt& theAttach );
|
||||
|
||||
private:
|
||||
TopAbs_ShapeEnum mySelectionMode;
|
||||
QString myEditAnnotationEntry;
|
||||
int myEditAnnotationIndex;
|
||||
GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties;
|
||||
bool myIsPositionDefined;
|
||||
/// an index of edited annotation in the list shape annotations, -1 in create operation
|
||||
bool myIsCreation;
|
||||
GEOM::GeomObjPtr myShape;
|
||||
|
||||
QLineEdit* myTextEdit;
|
||||
|
||||
QPushButton* myShapeSelBtn;
|
||||
// update shape name by shape selection if it has not been manually modified yet
|
||||
bool myShapeNameModified;
|
||||
QLineEdit* myShapeName;
|
||||
QCheckBox* myIsScreenFixed;
|
||||
|
||||
QComboBox* mySubShapeTypeCombo;
|
||||
|
||||
QPushButton* mySubShapeSelBtn;
|
||||
QLineEdit* mySubShapeName;
|
||||
|
||||
MeasureGUI_AnnotationInteractor* myInteractor;
|
||||
};
|
||||
|
||||
#endif
|
333
src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx
Executable file
333
src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx
Executable file
@ -0,0 +1,333 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : MeasureGUI_AnnotationInteractor.cxx
|
||||
// Author : Anton POLETAEV, Open CASCADE S.A.S.
|
||||
|
||||
#include "MeasureGUI_AnnotationInteractor.h"
|
||||
|
||||
// SALOME includes
|
||||
#include <GeometryGUI.h>
|
||||
#include <OCCViewer_ViewManager.h>
|
||||
#include <OCCViewer_ViewPort3d.h>
|
||||
#include <OCCViewer_ViewWindow.h>
|
||||
#include <SUIT_ViewManager.h>
|
||||
#include <SUIT_ViewWindow.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QMouseEvent>
|
||||
|
||||
// OCCT includes
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
//=================================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
MeasureGUI_AnnotationInteractor::MeasureGUI_AnnotationInteractor( GeometryGUI* theGUI,
|
||||
QObject* theParent )
|
||||
: QObject( theParent ),
|
||||
myGeomGUI( theGUI ),
|
||||
myIsEnabled( false ),
|
||||
myVM( NULL ),
|
||||
myViewer( NULL ),
|
||||
myActiveViewPort( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Deactivate
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
MeasureGUI_AnnotationInteractor::~MeasureGUI_AnnotationInteractor()
|
||||
{
|
||||
if ( myActiveViewPort )
|
||||
{
|
||||
myActiveViewPort->releaseMouse();
|
||||
myActiveViewPort = NULL;
|
||||
}
|
||||
|
||||
Disable();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Enable
|
||||
// purpose : Enables event processing and interaction handlers.
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationInteractor::Enable()
|
||||
{
|
||||
if ( myIsEnabled )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myIsEnabled = true;
|
||||
|
||||
// install event filtering on viewer windows
|
||||
SalomeApp_Application* anApp = myGeomGUI->getApp();
|
||||
if ( !anApp )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myVM = (OCCViewer_ViewManager*) anApp->getViewManager( OCCViewer_Viewer::Type(), false );
|
||||
myViewer = (OCCViewer_Viewer*) myVM->getViewModel();
|
||||
if ( !myVM || !myViewer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
connect( myVM, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), SLOT( OnViewCreated( SUIT_ViewWindow* ) ) );
|
||||
connect( myVM, SIGNAL( deleteView ( SUIT_ViewWindow* ) ), SLOT( OnViewRemoved( SUIT_ViewWindow* ) ) );
|
||||
|
||||
QVector<SUIT_ViewWindow*> aViews = myVM->getViews();
|
||||
QVector<SUIT_ViewWindow*>::iterator aViewIt = aViews.begin();
|
||||
for ( ; aViewIt != aViews.end(); ++aViewIt )
|
||||
{
|
||||
ConnectView( *aViewIt );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Disable
|
||||
// purpose : Disables event processing and interaction handlers.
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationInteractor::Disable()
|
||||
{
|
||||
if ( !myIsEnabled )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myIsEnabled = false;
|
||||
|
||||
// remove event filtering from viewer windows
|
||||
QVector<SUIT_ViewWindow*> aViews = myVM->getViews();
|
||||
QVector<SUIT_ViewWindow*>::iterator aViewIt = aViews.begin();
|
||||
for ( ; aViewIt != aViews.end(); ++aViewIt )
|
||||
{
|
||||
DisconnectView( *aViewIt );
|
||||
}
|
||||
|
||||
if ( myActiveViewPort )
|
||||
{
|
||||
myActiveViewPort->releaseMouse();
|
||||
myActiveViewPort = NULL;
|
||||
}
|
||||
|
||||
if ( !myActiveIO.IsNull() )
|
||||
{
|
||||
emit SignalInteractionFinished( myActiveIO );
|
||||
myActiveIO.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ConnectView
|
||||
// purpose : Connect interactor's event handler to the view window given.
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationInteractor::ConnectView( SUIT_ViewWindow* theView )
|
||||
{
|
||||
( (OCCViewer_ViewWindow*) theView )->getViewPort()->installEventFilter( this );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : DisconnectView
|
||||
// purpose : Disconnect interactor's event handler from the view window given.
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationInteractor::DisconnectView( SUIT_ViewWindow* theView )
|
||||
{
|
||||
( (OCCViewer_ViewWindow*) theView )->getViewPort()->removeEventFilter( this );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : OnViewCreated
|
||||
// purpose : Handler for signal coming from GUI layer.
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationInteractor::OnViewCreated( SUIT_ViewWindow* theView )
|
||||
{
|
||||
ConnectView( theView );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : OnViewRemoved
|
||||
// purpose : Handler for signal coming from GUI layer.
|
||||
//=================================================================================
|
||||
void MeasureGUI_AnnotationInteractor::OnViewRemoved( SUIT_ViewWindow* theView )
|
||||
{
|
||||
DisconnectView( theView );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : eventFilter
|
||||
// purpose : Hooks and process events from OCCT viewer prior to their coming into the base viewer class.
|
||||
//=================================================================================
|
||||
bool MeasureGUI_AnnotationInteractor::eventFilter( QObject* theObject, QEvent* theEvent )
|
||||
{
|
||||
OCCViewer_ViewPort3d* aViewPort = (OCCViewer_ViewPort3d*)theObject;
|
||||
|
||||
const Handle(V3d_View) aView3d = aViewPort->getView();
|
||||
|
||||
switch( theEvent->type() )
|
||||
{
|
||||
// ------------------------------------------------------------------------
|
||||
// Start dragging ("grab") event
|
||||
// ------------------------------------------------------------------------
|
||||
case QEvent::MouseButtonPress :
|
||||
{
|
||||
QMouseEvent* aMouseEv = dynamic_cast<QMouseEvent*>( theEvent );
|
||||
|
||||
if ( myEditEntry.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !( aMouseEv->buttons() & Qt::LeftButton ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
|
||||
|
||||
anAISContext->MoveTo( aMouseEv->x(), aMouseEv->y(), aView3d );
|
||||
|
||||
if ( !anAISContext->HasDetected() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const Handle(SelectMgr_EntityOwner) aDetected = anAISContext->DetectedOwner();
|
||||
|
||||
if( aDetected.IsNull() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const Handle(GEOM_Annotation) aAnnotation =
|
||||
Handle(GEOM_Annotation)::DownCast( aDetected->Selectable() );
|
||||
|
||||
if ( aAnnotation.IsNull() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const Handle(SALOME_InteractiveObject) anIO =
|
||||
Handle(SALOME_InteractiveObject)::DownCast( aAnnotation->GetOwner() );
|
||||
|
||||
if ( anIO.IsNull() || anIO->getEntry() != myEditEntry )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
myStartPoint = aMouseEv->pos();
|
||||
mySelection.Clear();
|
||||
|
||||
for ( anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected() )
|
||||
{
|
||||
mySelection.Append( anAISContext->SelectedOwner() );
|
||||
}
|
||||
|
||||
anAISContext->ClearSelected( Standard_False );
|
||||
anAISContext->Unhilight( myActiveIO, Standard_True );
|
||||
|
||||
myActiveViewPort = aViewPort;
|
||||
myActiveViewPort->grabMouse();
|
||||
myActiveIO = aAnnotation;
|
||||
myActiveIO->BeginDrag();
|
||||
|
||||
emit SignalInteractionStarted( myActiveIO );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Perform dragging operation
|
||||
// ------------------------------------------------------------------------
|
||||
case QEvent::MouseMove :
|
||||
{
|
||||
QMouseEvent* aMouseEv = (QMouseEvent*) theEvent;
|
||||
|
||||
if ( !myActiveIO.IsNull() )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
|
||||
|
||||
if ( anAISContext->IsHilighted( myActiveIO ) )
|
||||
{
|
||||
anAISContext->Unhilight( myActiveIO, Standard_False );
|
||||
}
|
||||
|
||||
const QPoint aDelta = aMouseEv->pos() - myStartPoint;
|
||||
myActiveIO->Drag( aDelta.x(), (-aDelta.y()), aView3d );
|
||||
anAISContext->Update( myActiveIO, Standard_False );
|
||||
anAISContext->UpdateCurrentViewer();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Stop dragging operation
|
||||
// ------------------------------------------------------------------------
|
||||
case QEvent::FocusOut :
|
||||
case QEvent::MouseButtonRelease :
|
||||
{
|
||||
QMouseEvent* aMouseEv = (QMouseEvent*) theEvent;
|
||||
|
||||
if ( myActiveViewPort )
|
||||
{
|
||||
myActiveViewPort->releaseMouse();
|
||||
myActiveViewPort = NULL;
|
||||
}
|
||||
if ( !myActiveIO.IsNull() )
|
||||
{
|
||||
myActiveIO->EndDrag();
|
||||
|
||||
const Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
|
||||
|
||||
anAISContext->ClearSelected( Standard_False );
|
||||
SelectMgr_SequenceOfOwner::Iterator anIt( mySelection );
|
||||
for( ; anIt.More(); anIt.Next() )
|
||||
{
|
||||
anAISContext->AddOrRemoveSelected( anIt.Value(), Standard_False );
|
||||
}
|
||||
|
||||
anAISContext->Update( myActiveIO, Standard_False );
|
||||
anAISContext->UpdateCurrentViewer();
|
||||
anAISContext->MoveTo( aMouseEv->pos().x(), aMouseEv->pos().y(), aView3d );
|
||||
|
||||
emit SignalInteractionFinished( myActiveIO );
|
||||
|
||||
mySelection.Clear();
|
||||
myActiveIO.Nullify();
|
||||
return (theEvent->type() == QEvent::MouseButtonRelease);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
122
src/MeasureGUI/MeasureGUI_AnnotationInteractor.h
Executable file
122
src/MeasureGUI/MeasureGUI_AnnotationInteractor.h
Executable file
@ -0,0 +1,122 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : MeasureGUI_AnnotationInteractor.h
|
||||
// Author : Anton POLETAEV, Open CASCADE S.A.S.
|
||||
//
|
||||
#ifndef MEASUREGUI_ANNOTATIONINTERACTOR_H
|
||||
#define MEASUREGUI_ANNOTATIONINTERACTOR_H
|
||||
|
||||
#include <GEOM_Annotation.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <SelectMgr_SequenceOfOwner.hxx>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
|
||||
class GeometryGUI;
|
||||
class OCCViewer_Viewer;
|
||||
class OCCViewer_ViewManager;
|
||||
class OCCViewer_ViewPort3d;
|
||||
class SUIT_ViewWindow;
|
||||
|
||||
/*!
|
||||
* \class MeasureGUI_AnnotationInteractor
|
||||
* \brief Class implementing logical layer for interactive dragging of annotation
|
||||
* labels. It includes two components: listener for GUI events occuring
|
||||
* inside of OCCT 3D viewer and processor for hooked events to perform
|
||||
* interactive modification of the selected annotation within current
|
||||
* AIS context.
|
||||
*/
|
||||
class MeasureGUI_AnnotationInteractor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
//! Connects to existing viewer/view windows to process events.
|
||||
//! \param theGUI [in] the geometry module's GUI interface.
|
||||
//! \param theOwner [in] the owner of the instance.
|
||||
MeasureGUI_AnnotationInteractor( GeometryGUI* theGUI, QObject* theOwner );
|
||||
|
||||
//! Destructor.
|
||||
virtual ~MeasureGUI_AnnotationInteractor();
|
||||
|
||||
public:
|
||||
|
||||
//! Enables event processing and interaction handlers.
|
||||
void Enable();
|
||||
|
||||
//! Disables event processing and interaction handlers.
|
||||
void Disable();
|
||||
|
||||
//! Set entry of allowed annotation presentations.
|
||||
void SetEditEntry( const QString& theEntry ) { myEditEntry = theEntry; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Connect interactor's event handler to the view window given.
|
||||
void ConnectView( SUIT_ViewWindow* theWindow );
|
||||
|
||||
//! Disconnect interactor's event handler from the view window given.
|
||||
void DisconnectView( SUIT_ViewWindow* theWindow );
|
||||
|
||||
signals:
|
||||
|
||||
//! Emitted when interactor begins modification of the interactive object.
|
||||
void SignalInteractionStarted( Handle_GEOM_Annotation theIO );
|
||||
|
||||
//! Emitted when interactor finished modification of the interactive object.
|
||||
void SignalInteractionFinished( Handle_GEOM_Annotation theIO );
|
||||
|
||||
protected slots:
|
||||
|
||||
//! Handler for signal coming from GUI layer.
|
||||
void OnViewCreated( SUIT_ViewWindow* );
|
||||
|
||||
//! Handler for signal coming from GUI layer.
|
||||
void OnViewRemoved( SUIT_ViewWindow* );
|
||||
|
||||
protected:
|
||||
|
||||
//! Hooks and process events from OCCT viewer prior to their coming into the base viewer class.
|
||||
//! It handles the events coming to viewport and identifies whether the events can
|
||||
//! invoke an interaction operation or not. If yes, the operation is performed within the
|
||||
//! interactor class and events are "accepted". Otherwise, the events are passed to
|
||||
//! viewer's subroutines.
|
||||
virtual bool eventFilter( QObject*, QEvent* );
|
||||
|
||||
private:
|
||||
|
||||
GeometryGUI* myGeomGUI;
|
||||
bool myIsEnabled;
|
||||
OCCViewer_ViewManager* myVM;
|
||||
OCCViewer_Viewer* myViewer;
|
||||
OCCViewer_ViewPort3d* myActiveViewPort;
|
||||
Handle(GEOM_Annotation) myActiveIO;
|
||||
SelectMgr_SequenceOfOwner mySelection;
|
||||
QPoint myStartPoint;
|
||||
QString myEditEntry;
|
||||
};
|
||||
|
||||
#endif
|
@ -228,9 +228,9 @@ void MeasureGUI_ManageDimensionsDlg::StartSelection( const Selection theSelectio
|
||||
myDimensionInteractor->Enable();
|
||||
|
||||
connect( myDimensionInteractor,
|
||||
SIGNAL( InteractionFinished( Handle(AIS_InteractiveObject) ) ),
|
||||
SIGNAL( InteractionFinished( Handle_AIS_InteractiveObject ) ),
|
||||
this,
|
||||
SLOT( OnInteractionFinished( Handle(AIS_InteractiveObject) ) ) );
|
||||
SLOT( OnInteractionFinished( Handle_AIS_InteractiveObject ) ) );
|
||||
|
||||
anAISContext->UpdateCurrentViewer();
|
||||
}
|
||||
@ -290,9 +290,9 @@ void MeasureGUI_ManageDimensionsDlg::StopSelection()
|
||||
myDimensionInteractor->Disable();
|
||||
|
||||
disconnect( myDimensionInteractor,
|
||||
SIGNAL( InteractionFinished( Handle(AIS_InteractiveObject) ) ),
|
||||
SIGNAL( InteractionFinished( Handle_AIS_InteractiveObject ) ),
|
||||
this,
|
||||
SLOT( OnInteractionFinished( Handle(AIS_InteractiveObject) ) ) );
|
||||
SLOT( OnInteractionFinished( Handle_AIS_InteractiveObject ) ) );
|
||||
}
|
||||
|
||||
myCurrentSelection = Selection_None;
|
||||
@ -628,7 +628,7 @@ void MeasureGUI_ManageDimensionsDlg::OnHideAll()
|
||||
// function : OnInteractionFinished
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void MeasureGUI_ManageDimensionsDlg::OnInteractionFinished( Handle(AIS_InteractiveObject) theIO )
|
||||
void MeasureGUI_ManageDimensionsDlg::OnInteractionFinished( Handle_AIS_InteractiveObject theIO )
|
||||
{
|
||||
// update property data
|
||||
SalomeApp_Application* anApp = myGeomGUI->getApp();
|
||||
|
@ -76,6 +76,7 @@ SET(OBJECT_HEADERS
|
||||
GEOM_DeviceActor.h
|
||||
GEOM_Constants.h
|
||||
GEOM_AISDimension.hxx
|
||||
GEOM_Annotation.hxx
|
||||
)
|
||||
# --- sources ---
|
||||
|
||||
@ -93,6 +94,7 @@ SET(OBJECT_SOURCES
|
||||
GEOM_DeviceActor.cxx
|
||||
GEOM_Constants.cxx
|
||||
GEOM_AISDimension.cxx
|
||||
GEOM_Annotation.cxx
|
||||
)
|
||||
|
||||
# --- rules ---
|
||||
|
943
src/OBJECT/GEOM_Annotation.cxx
Executable file
943
src/OBJECT/GEOM_Annotation.cxx
Executable file
@ -0,0 +1,943 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM OBJECT : interactive object for Geometry entities visualization
|
||||
// File : GEOM_Annotation.hxx
|
||||
// Module : GEOM
|
||||
//
|
||||
#include <GEOM_Annotation.hxx>
|
||||
|
||||
// OCCT includes
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Font_FTFont.hxx>
|
||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <Graphic3d_Vec4.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <OpenGl_Group.hxx>
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Text.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Select3D_SensitiveBox.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT( GEOM_Annotation, AIS_InteractiveObject )
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject()
|
||||
{
|
||||
SetPosition( gp_Pnt( 0.0, 0.0, 0.0 ) );
|
||||
SetIsScreenFixed( Standard_False );
|
||||
SetAttachPoint( gp_Pnt( 0.0, 0.0, 0.0 ) );
|
||||
SetDisplayMode( 0 );
|
||||
SetZLayer( Graphic3d_ZLayerId_Default );
|
||||
SetAutoHide( Standard_True );
|
||||
SetHilightMode( HighlightAll );
|
||||
SetMutable( Standard_True );
|
||||
SetDepthCulling( Standard_True );
|
||||
|
||||
Handle(Prs3d_TextAspect) aTextAspect = new Prs3d_TextAspect();
|
||||
aTextAspect->SetHeight( 20.0 );
|
||||
aTextAspect->SetColor( Quantity_Color( 1.0, 1.0, 1.0, Quantity_TOC_RGB ) );
|
||||
myDrawer->SetTextAspect( aTextAspect );
|
||||
|
||||
Handle(Prs3d_LineAspect) aLineAspect =
|
||||
new Prs3d_LineAspect( Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0 );
|
||||
myDrawer->SetLineAspect( aLineAspect );
|
||||
|
||||
Handle(Prs3d_LineAspect) aHiddenLineAspect =
|
||||
new Prs3d_LineAspect( Quantity_NOC_WHITE, Aspect_TOL_DOT, 1.0 );
|
||||
myDrawer->SetHiddenLineAspect( aHiddenLineAspect );
|
||||
|
||||
Handle(Prs3d_PointAspect) aPointAspect =
|
||||
new Prs3d_PointAspect( Aspect_TOM_POINT, Quantity_NOC_WHITE, 4.0 );
|
||||
myDrawer->SetPointAspect( aPointAspect );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetText( const TCollection_ExtendedString& theText )
|
||||
{
|
||||
if (myText != theText)
|
||||
{
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
myText = theText;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetPosition( const gp_Pnt& thePosition )
|
||||
{
|
||||
SetPosition( thePosition, Standard_True );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetPosition( const gp_Pnt& thePosition, const Standard_Boolean theUpdateSelection )
|
||||
{
|
||||
myPosition = thePosition;
|
||||
|
||||
if ( !myIsScreenFixed )
|
||||
{
|
||||
Handle(Graphic3d_TransformPers) aPersistence =
|
||||
new Graphic3d_TransformPers( Graphic3d_TMF_ZoomRotatePers, thePosition );
|
||||
|
||||
AIS_InteractiveObject::SetTransformPersistence( aPersistence );
|
||||
}
|
||||
|
||||
SetToUpdate();
|
||||
|
||||
if( theUpdateSelection )
|
||||
{
|
||||
UpdateSelection();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetIsScreenFixed
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetIsScreenFixed( const Standard_Boolean theIsFixed )
|
||||
{
|
||||
myIsScreenFixed = theIsFixed;
|
||||
|
||||
Handle(Graphic3d_TransformPers) aPersistence;
|
||||
|
||||
if (!myIsScreenFixed)
|
||||
{
|
||||
aPersistence = new Graphic3d_TransformPers( Graphic3d_TMF_ZoomRotatePers, myPosition );
|
||||
}
|
||||
else
|
||||
{
|
||||
aPersistence = new Graphic3d_TransformPers( Graphic3d_TMF_2d, Aspect_TOTP_CENTER );
|
||||
}
|
||||
|
||||
AIS_InteractiveObject::SetTransformPersistence( aPersistence );
|
||||
|
||||
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
|
||||
|
||||
SetToUpdate();
|
||||
|
||||
UpdateSelection();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Set2dPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::Set2dPosition( const Handle(V3d_View)& theView )
|
||||
{
|
||||
if ( myIsScreenFixed )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Pnt aPosition2d = ConvertPosition2d( myPosition, myAttach, theView );
|
||||
|
||||
SetIsScreenFixed( Standard_True );
|
||||
|
||||
SetPosition( aPosition2d );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Set3dPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::Set3dPosition( const Handle(V3d_View)& theView )
|
||||
{
|
||||
if ( !myIsScreenFixed )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Pnt aPosition3d = ConvertPosition3d( myPosition, myAttach, theView );
|
||||
|
||||
SetIsScreenFixed( Standard_False );
|
||||
|
||||
SetPosition( aPosition3d );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAttachPoint
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetAttachPoint( const gp_Pnt& thePoint )
|
||||
{
|
||||
myAttach = thePoint;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHilightShape
|
||||
// purpose : Sets shape (annotated shape) that will be used for hilighting.
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetHilightShape( const TopoDS_Shape& theShape )
|
||||
{
|
||||
if ( myShape.IsEqual( theShape ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myShape = theShape;
|
||||
SetToUpdate();
|
||||
UpdateSelection();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetColor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetColor( const Quantity_Color& theColor )
|
||||
{
|
||||
SetTextColor( theColor );
|
||||
SetLineColor( theColor );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetTextColor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetTextColor( const Quantity_Color& theColor )
|
||||
{
|
||||
myDrawer->TextAspect()->SetColor( theColor );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineColor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineColor( const Quantity_Color& theColor )
|
||||
{
|
||||
myDrawer->LineAspect()->SetColor( theColor );
|
||||
myDrawer->HiddenLineAspect()->SetColor( theColor );
|
||||
myDrawer->PointAspect()->SetColor( theColor );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineWidth
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineWidth( const Standard_Real theLineWidth )
|
||||
{
|
||||
if ( GetLineWidth() != theLineWidth )
|
||||
{
|
||||
myDrawer->LineAspect()->SetWidth( theLineWidth );
|
||||
myDrawer->HiddenLineAspect()->SetWidth( theLineWidth );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetLineStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetLineStyle( const Aspect_TypeOfLine theStyle )
|
||||
{
|
||||
if ( GetLineStyle() != theStyle )
|
||||
{
|
||||
myDrawer->LineAspect()->SetTypeOfLine( theStyle );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHiddenLineStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetHiddenLineStyle( const Aspect_TypeOfLine theStyle )
|
||||
{
|
||||
if ( GetHiddenLineStyle() != theStyle )
|
||||
{
|
||||
myDrawer->HiddenLineAspect()->SetTypeOfLine( theStyle );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetTextHeight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetTextHeight( const Standard_Real theHeight )
|
||||
{
|
||||
if ( GetTextHeight() != theHeight )
|
||||
{
|
||||
myDrawer->TextAspect()->SetHeight( theHeight );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFontAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetFontAspect( const Font_FontAspect theFontAspect )
|
||||
{
|
||||
if ( GetFontAspect() != theFontAspect )
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetTextFontAspect( theFontAspect );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFont
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetFont( const TCollection_AsciiString& theFont )
|
||||
{
|
||||
if ( GetFont() != theFont )
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetFont( theFont );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetDepthCulling
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetDepthCulling( const Standard_Boolean theToEnable )
|
||||
{
|
||||
if ( GetDepthCulling() != theToEnable )
|
||||
{
|
||||
myIsDepthCulling = theToEnable;
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetDefaultZLayer
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::SetDefaultZLayer()
|
||||
{
|
||||
SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetDefaultPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
gp_Pnt GEOM_Annotation::GetDefaultPosition( const Standard_Boolean theIsScreenFixed,
|
||||
const gp_Pnt& theAttachPnt,
|
||||
const Standard_Real theOffset,
|
||||
const Handle(V3d_View)& theView )
|
||||
{
|
||||
Standard_Integer aWinWidth = 0;
|
||||
Standard_Integer aWinHeight = 0;
|
||||
theView->Window()->Size( aWinWidth, aWinHeight );
|
||||
|
||||
gp_Pnt aPositionProj = theView->Camera()->Project( theAttachPnt );
|
||||
aPositionProj.SetX( (aPositionProj.X() / 2.) * aWinWidth + theOffset );
|
||||
aPositionProj.SetY( (aPositionProj.Y() / 2.) * aWinHeight + theOffset );
|
||||
aPositionProj.SetZ( 0.0 );
|
||||
|
||||
if ( theIsScreenFixed )
|
||||
{
|
||||
return aPositionProj;
|
||||
}
|
||||
|
||||
gp_Pnt aAttachProj = theView->Camera()->Project ( theAttachPnt );
|
||||
gp_Pnt aPosition3d = theView->Camera()->UnProject ( gp_Pnt ( aPositionProj.X() / aWinWidth * 2.,
|
||||
aPositionProj.Y() / aWinHeight * 2.,
|
||||
aAttachProj.Z() ));
|
||||
|
||||
return aPosition3d;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ConvertPosition2d
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
gp_Pnt GEOM_Annotation::ConvertPosition2d( const gp_Pnt& thePosition,
|
||||
const gp_Pnt& /*theAttach*/,
|
||||
const Handle(V3d_View)& theView )
|
||||
{
|
||||
Standard_Integer aWinWidth = 0;
|
||||
Standard_Integer aWinHeight = 0;
|
||||
theView->Window()->Size( aWinWidth, aWinHeight );
|
||||
|
||||
gp_Pnt aPositionProj = theView->Camera()->Project( thePosition );
|
||||
aPositionProj.SetX( (aPositionProj.X() / 2.) * aWinWidth );
|
||||
aPositionProj.SetY( (aPositionProj.Y() / 2.) * aWinHeight );
|
||||
aPositionProj.SetZ( 0.0 );
|
||||
return aPositionProj;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ConvertPosition3d
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
gp_Pnt GEOM_Annotation::ConvertPosition3d( const gp_Pnt& thePosition,
|
||||
const gp_Pnt& theAttach,
|
||||
const Handle(V3d_View)& theView )
|
||||
{
|
||||
Standard_Integer aWinWidth = 0;
|
||||
Standard_Integer aWinHeight = 0;
|
||||
theView->Window()->Size( aWinWidth, aWinHeight );
|
||||
|
||||
gp_Pnt aAttachProj = theView->Camera()->Project( theAttach );
|
||||
gp_Pnt aPosition3d = theView->Camera()->UnProject(
|
||||
gp_Pnt ( thePosition.X() / aWinWidth * 2., thePosition.Y() / aWinHeight * 2., aAttachProj.Z() ) );
|
||||
|
||||
return aPosition3d;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Compute
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::Compute( const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode )
|
||||
{
|
||||
thePresentation->Clear();
|
||||
|
||||
if (theMode < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast( Prs3d_Root::NewGroup( thePresentation ) );
|
||||
if (aGroup.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
|
||||
NCollection_String aUtfText( myText.ToExtString() );
|
||||
OpenGl_Annotation* aAnnotationDraw =
|
||||
new OpenGl_Annotation( this, static_cast<Standard_Integer>( anAsp->Height() ), aGroup->GlStruct()->GlDriver() );
|
||||
|
||||
aAnnotationDraw->SetDepthMode( 0 );
|
||||
aGroup->SetGroupPrimitivesAspect( myDrawer->TextAspect()->Aspect() );
|
||||
aGroup->SetGroupPrimitivesAspect( myDrawer->LineAspect()->Aspect() );
|
||||
aGroup->SetGroupPrimitivesAspect( myDrawer->PointAspect()->Aspect() );
|
||||
aGroup->AddElement( aAnnotationDraw );
|
||||
|
||||
if ( !myIsDepthCulling )
|
||||
{
|
||||
OpenGl_Annotation* aAnnotationDraw =
|
||||
new OpenGl_Annotation( this, static_cast<Standard_Integer>( anAsp->Height() ), aGroup->GlStruct()->GlDriver() );
|
||||
|
||||
aAnnotationDraw->SetDepthMode( GL_GREATER );
|
||||
aGroup->SetPrimitivesAspect( myDrawer->TextAspect()->Aspect() );
|
||||
aGroup->SetPrimitivesAspect( myDrawer->HiddenLineAspect()->Aspect() );
|
||||
aGroup->SetPrimitivesAspect( myDrawer->PointAspect()->Aspect() );
|
||||
aGroup->AddElement( aAnnotationDraw );
|
||||
}
|
||||
|
||||
Bnd_Box aBox = TextBoundingBox();
|
||||
if ( myIsScreenFixed )
|
||||
{
|
||||
gp_Trsf aOffset2d;
|
||||
aOffset2d.SetTranslation( gp_Vec( myPosition.X(), myPosition.Y(), 0.0 ) );
|
||||
aBox = aBox.Transformed( aOffset2d );
|
||||
}
|
||||
|
||||
const gp_Pnt aBoxMin = aBox.CornerMin();
|
||||
const gp_Pnt aBoxMax = aBox.CornerMax();
|
||||
aGroup->ChangeBoundingBox() = Graphic3d_BndBox4f (
|
||||
Graphic3d_Vec4( static_cast<Standard_ShortReal>( aBoxMin.X() ),
|
||||
static_cast<Standard_ShortReal>( aBoxMin.Y() ),
|
||||
static_cast<Standard_ShortReal>( aBoxMin.Z() ), 1.0F ),
|
||||
Graphic3d_Vec4( static_cast<Standard_ShortReal>( aBoxMax.X() ),
|
||||
static_cast<Standard_ShortReal>( aBoxMax.Y() ),
|
||||
static_cast<Standard_ShortReal>( aBoxMax.Z() ), 1.0F ) );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ComputeSelection
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode )
|
||||
{
|
||||
if (theMode != GlobalSelectionMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theSelection->Clear();
|
||||
|
||||
Bnd_Box aBox = TextBoundingBox();
|
||||
if ( myIsScreenFixed )
|
||||
{
|
||||
gp_Trsf aOffset2d;
|
||||
aOffset2d.SetTranslation( gp_Vec( myPosition.X(), myPosition.Y(), 0.0 ) );
|
||||
aBox = aBox.Transformed( aOffset2d );
|
||||
}
|
||||
|
||||
const Handle(GEOM_AnnotationOwner) anEntityOwner = new GEOM_AnnotationOwner( myShape, this, 10 );
|
||||
const Handle(GEOM_AnnotationSensEntity) aSensitive =
|
||||
new GEOM_AnnotationSensEntity( anEntityOwner, aBox, myIsDepthCulling );
|
||||
|
||||
theSelection->Add( aSensitive );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : TextBoundingBox
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Bnd_Box GEOM_Annotation::TextBoundingBox() const
|
||||
{
|
||||
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
|
||||
Font_FTFont aFont;
|
||||
unsigned int aResolution = GetContext()->CurrentViewer()->DefaultRenderingParams().Resolution;
|
||||
if ( aFont.Init( anAsp->Aspect()->Font().ToCString(),
|
||||
anAsp->Aspect()->GetTextFontAspect(),
|
||||
(unsigned int)anAsp->Height(),
|
||||
aResolution ) )
|
||||
{
|
||||
const NCollection_String aText( (Standard_Utf16Char* )myText.ToExtString() );
|
||||
const Font_Rect aFontRect = aFont.BoundingBox( aText, Graphic3d_HTA_CENTER, Graphic3d_VTA_CENTER );
|
||||
Bnd_Box aBox;
|
||||
aBox.Add( gp_Pnt( aFontRect.Left, aFontRect.Bottom, 0.0 ) );
|
||||
aBox.Add( gp_Pnt( aFontRect.Right, aFontRect.Top, 0.0 ) );
|
||||
return aBox;
|
||||
}
|
||||
|
||||
return Bnd_Box();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BeginDrag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::BeginDrag()
|
||||
{
|
||||
myStartPosition = myPosition;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Drag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::Drag( const Standard_Integer theDx,
|
||||
const Standard_Integer theDy,
|
||||
const Handle(V3d_View)& theView )
|
||||
{
|
||||
if (myIsScreenFixed)
|
||||
{
|
||||
SetPosition( myStartPosition.Translated( gp_Vec( theDx, theDy, 0.0 ) ), Standard_False );
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aWidth, aHeight;
|
||||
theView->Window()->Size( aWidth, aHeight );
|
||||
gp_Pnt aNormalized = theView->Camera()->Project( myStartPosition );
|
||||
gp_Pnt aNormalizedDrag =
|
||||
aNormalized.Translated( gp_Vec( static_cast<Standard_Real>(theDx) * 2.0 / aWidth,
|
||||
static_cast<Standard_Real>(theDy) * 2.0 / aHeight,
|
||||
0.0 ) );
|
||||
|
||||
SetPosition( theView->Camera()->UnProject( aNormalizedDrag ), Standard_False );
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : EndDrag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::EndDrag()
|
||||
{
|
||||
UpdateSelection();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UndoDrag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::UndoDrag()
|
||||
{
|
||||
SetPosition( myStartPosition, Standard_True );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : OpenGl_Annotation
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
GEOM_Annotation::OpenGl_Annotation::OpenGl_Annotation( GEOM_Annotation* theAnnotation,
|
||||
const Standard_Integer theTextHeight,
|
||||
const OpenGl_GraphicDriver* theDriver )
|
||||
: OpenGl_Element(),
|
||||
myDepthMode( 0 ),
|
||||
myAISObject( theAnnotation ),
|
||||
myText( theAnnotation->myText.ToExtString() ),
|
||||
myTextLineY( 0.f ),
|
||||
myTextDPI( 0 )
|
||||
{
|
||||
// graphical resources for drawing text and underline
|
||||
myTextParams.Height = theTextHeight;
|
||||
myTextParams.HAlign = Graphic3d_HTA_CENTER;
|
||||
myTextParams.VAlign = Graphic3d_VTA_CENTER;
|
||||
myTextDraw = new OpenGl_Text( myText.ToCString(), OpenGl_Vec3(), myTextParams );
|
||||
myTextLineDraw = new OpenGl_PrimitiveArray( theDriver );
|
||||
|
||||
// graphical resources for drawing extension line and marker
|
||||
Handle(Graphic3d_ArrayOfSegments)
|
||||
aExtVertexArray = new Graphic3d_ArrayOfSegments( 2 );
|
||||
aExtVertexArray->AddVertex( 0.0, 0.0, 0.0 );
|
||||
aExtVertexArray->AddVertex( 0.0, 0.0, 1.0 );
|
||||
myExtLineDraw = new OpenGl_PrimitiveArray( theDriver, Graphic3d_TOPA_SEGMENTS,
|
||||
aExtVertexArray->Indices(), aExtVertexArray->Attributes(), aExtVertexArray->Bounds() );
|
||||
|
||||
Handle(Graphic3d_ArrayOfPoints)
|
||||
aExtMakerArray = new Graphic3d_ArrayOfPoints( 1 );
|
||||
aExtMakerArray->AddVertex( 0.0, 0.0, 1.0 );
|
||||
myExtMarkerDraw = new OpenGl_PrimitiveArray( theDriver, Graphic3d_TOPA_POINTS,
|
||||
aExtMakerArray->Indices(), aExtMakerArray->Attributes(), aExtMakerArray->Bounds() );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : OpenGl_Annotation
|
||||
// function : Destructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
GEOM_Annotation::OpenGl_Annotation::~OpenGl_Annotation()
|
||||
{
|
||||
Release( NULL );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : OpenGl_Annotation
|
||||
// function : Release
|
||||
// purpose : Releases GL resources with the given GL context.
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::OpenGl_Annotation::Release( OpenGl_Context* theCtx )
|
||||
{
|
||||
if (myTextDraw)
|
||||
{
|
||||
myTextDraw->Release( theCtx );
|
||||
myTextLineDraw->Release( theCtx );
|
||||
myExtLineDraw->Release( theCtx );
|
||||
myExtMarkerDraw->Release( theCtx );
|
||||
}
|
||||
myTextDraw = NULL;
|
||||
myTextLineDraw = NULL;
|
||||
myExtLineDraw = NULL;
|
||||
myExtMarkerDraw = NULL;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : OpenGl_Annotation
|
||||
// function : Render
|
||||
// purpose : Renders the annotation graphical elements.
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& theWorkspace ) const
|
||||
{
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// initialize text's font and configure some properties when DPI changes
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const unsigned int aDPI = theWorkspace->View()->RenderingParams().Resolution;
|
||||
if (myTextDPI != aDPI)
|
||||
{
|
||||
const OpenGl_AspectText* anAspect = theWorkspace->AspectText();
|
||||
|
||||
// getting string size will also initialize font library
|
||||
myTextDraw->StringSize( aContext,
|
||||
myText, *anAspect, myTextParams, aDPI,
|
||||
myTextSize.x, myTextSize.a, myTextSize.d );
|
||||
|
||||
myTextDPI = aDPI;
|
||||
myTextSize.y = myTextSize.a - myTextSize.d;
|
||||
switch (myTextParams.HAlign)
|
||||
{
|
||||
case Graphic3d_HTA_LEFT: myTextUnderline.x() = 0.f; break;
|
||||
case Graphic3d_HTA_CENTER: myTextUnderline.x() = -myTextSize.x / 2.f; break;
|
||||
case Graphic3d_HTA_RIGHT: myTextUnderline.x() = -myTextSize.x; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (myTextParams.VAlign)
|
||||
{
|
||||
case Graphic3d_VTA_TOPFIRSTLINE:
|
||||
case Graphic3d_VTA_TOP: myTextUnderline.y() = -myTextSize.y; break;
|
||||
case Graphic3d_VTA_CENTER: myTextUnderline.y() = -myTextSize.y / 2.f; break;
|
||||
case Graphic3d_VTA_BOTTOM: myTextUnderline.y() = myTextSize.d; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfSegments)
|
||||
aVertexArray = new Graphic3d_ArrayOfSegments( 2 );
|
||||
aVertexArray->AddVertex( myTextUnderline.x(), myTextUnderline.y(), 0.0f );
|
||||
aVertexArray->AddVertex( myTextUnderline.x() + myTextSize.x, myTextUnderline.y(), 0.0f );
|
||||
myTextLineDraw->InitBuffers( aContext, Graphic3d_TOPA_SEGMENTS,
|
||||
aVertexArray->Indices(), aVertexArray->Attributes(), aVertexArray->Bounds() );
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// perform view culling test by attachment point
|
||||
// ---------------------------------------------
|
||||
|
||||
const OpenGl_Vec4 aAttach( static_cast<float>( myAISObject->myAttach.X() ),
|
||||
static_cast<float>( myAISObject->myAttach.Y() ),
|
||||
static_cast<float>( myAISObject->myAttach.Z() ), 1.F );
|
||||
|
||||
const Handle(Graphic3d_Camera) aCamera = theWorkspace->View()->Camera();
|
||||
const OpenGl_Mat4& aCameraProjMat = aCamera->ProjectionMatrixF();
|
||||
const OpenGl_Mat4& aCameraViewMat = aCamera->OrientationMatrixF();
|
||||
const OpenGl_Vec4 aAttachView = aCameraViewMat * aAttach;
|
||||
if (myAISObject->myIsAutoHide)
|
||||
{
|
||||
const OpenGl_Vec4 aAttachClip = aCameraProjMat * aAttachView;
|
||||
if (Abs( aAttachClip.x() ) > aAttachClip.w()
|
||||
|| Abs( aAttachClip.y() ) > aAttachClip.w()
|
||||
|| Abs( aAttachClip.z() ) > aAttachClip.w())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const bool toHighlight = theWorkspace->ToHighlight();
|
||||
|
||||
if (toHighlight && myAISObject->myHilightMode == HighlightLabel)
|
||||
{
|
||||
theWorkspace->SetHighlight( false );
|
||||
theWorkspace->ApplyAspectLine();
|
||||
}
|
||||
|
||||
GLint myOldDepthMode = 0;
|
||||
|
||||
if ( myDepthMode )
|
||||
{
|
||||
aContext->core11fwd->glGetIntegerv( GL_DEPTH_FUNC, &myOldDepthMode );
|
||||
aContext->core11fwd->glDepthFunc( myDepthMode );
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// render text label in current persistence matrix and underline
|
||||
// -------------------------------------------------------------
|
||||
|
||||
if ( myAISObject->myIsScreenFixed )
|
||||
{
|
||||
// use text position property instead of matrix setup
|
||||
// to avoid jittering when dragging text
|
||||
myTextDraw->SetPosition( OpenGl_Vec3( static_cast<float>( myAISObject->myPosition.X() ),
|
||||
static_cast<float>( myAISObject->myPosition.Y() ),
|
||||
static_cast<float>( myAISObject->myPosition.Z() ) ) );
|
||||
}
|
||||
|
||||
myTextDraw->Render( theWorkspace );
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// render annotation text's underline
|
||||
// ------------------------------------------------------------
|
||||
|
||||
if ( myAISObject->myIsScreenFixed )
|
||||
{
|
||||
// setup local transformation (in 2D persistence reference)
|
||||
// to represent position of annotation label on screen
|
||||
const OpenGl_Mat4& aViewMat = aContext->WorldViewState.Current();
|
||||
OpenGl_Mat4 aPositionMat;
|
||||
aPositionMat.SetValue( 0, 3, static_cast<float>( myAISObject->myPosition.X() ) );
|
||||
aPositionMat.SetValue( 1, 3, static_cast<float>( myAISObject->myPosition.Y() ) );
|
||||
aPositionMat.SetValue( 2, 3, static_cast<float>( myAISObject->myPosition.Z() ) );
|
||||
OpenGl_Mat4 aPosViewMat = aViewMat * aPositionMat;
|
||||
aContext->WorldViewState.Push();
|
||||
aContext->WorldViewState.SetCurrent( aPosViewMat );
|
||||
aContext->ApplyModelViewMatrix();
|
||||
}
|
||||
|
||||
myTextLineDraw->Render( theWorkspace );
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// render dynamic extension line using synthetic transformation
|
||||
// ------------------------------------------------------------
|
||||
|
||||
OpenGl_Vec4 aCenter (0.f, 0.f, 0.f, 1.f);
|
||||
switch (myTextParams.HAlign)
|
||||
{
|
||||
case Graphic3d_HTA_LEFT: aCenter.x() = myTextSize.x / 2.f; break;
|
||||
case Graphic3d_HTA_CENTER: aCenter.x() = 0.f; break;
|
||||
case Graphic3d_HTA_RIGHT: aCenter.x() = -myTextSize.x / 2.f; break;
|
||||
default: break;
|
||||
}
|
||||
switch (myTextParams.VAlign)
|
||||
{
|
||||
case Graphic3d_VTA_TOPFIRSTLINE:
|
||||
case Graphic3d_VTA_TOP: aCenter.y() = -myTextSize.y / 2.f; break;
|
||||
case Graphic3d_VTA_CENTER: aCenter.y() = 0.f; break;
|
||||
case Graphic3d_VTA_BOTTOM: aCenter.y() = myTextSize.y / 2.f; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// compute label's center in view coordinate space
|
||||
const OpenGl_Mat4& aViewMat = aContext->WorldViewState.Current();
|
||||
const OpenGl_Vec4 aCenterView = aViewMat * aCenter;
|
||||
|
||||
// the value below defines whether the extension line should be hanging
|
||||
// on the left side of the label or on the right
|
||||
const bool isLeftHanded = aAttachView.x() < aCenterView.x();
|
||||
|
||||
// compute extension line point at the text label in view coordinate space
|
||||
const OpenGl_Vec4 aHingeView = aViewMat * OpenGl_Vec4(
|
||||
( isLeftHanded ? myTextUnderline.x() : myTextUnderline.x() + myTextSize.x ), myTextUnderline.y(), 0.0f, 1.0f );
|
||||
|
||||
// prepare matrix to specify geometry of extension line in view space
|
||||
// by multiplication of unit z coordinate vector on given matrix.
|
||||
OpenGl_Mat4 aExtGeometryMat;
|
||||
aExtGeometryMat.SetColumn( 2, aAttachView - aHingeView );
|
||||
aExtGeometryMat.SetColumn( 3, aHingeView );
|
||||
|
||||
// setup and draw
|
||||
aContext->ModelWorldState.Push();
|
||||
aContext->ModelWorldState.SetIdentity();
|
||||
aContext->WorldViewState.Push();
|
||||
aContext->WorldViewState.SetCurrent( aExtGeometryMat );
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
myExtLineDraw->Render( theWorkspace );
|
||||
myExtMarkerDraw->Render( theWorkspace );
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// restore original state
|
||||
// ------------------------------------------------------------
|
||||
|
||||
aContext->ModelWorldState.Pop();
|
||||
aContext->WorldViewState.Pop();
|
||||
|
||||
if ( myOldDepthMode )
|
||||
{
|
||||
aContext->core11fwd->glDepthFunc( myOldDepthMode );
|
||||
}
|
||||
|
||||
if ( myAISObject->myIsScreenFixed )
|
||||
{
|
||||
aContext->WorldViewState.Pop();
|
||||
}
|
||||
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
if ( toHighlight != theWorkspace->ToHighlight() )
|
||||
{
|
||||
theWorkspace->SetHighlight( toHighlight );
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : GEOM_AnnotationOwner
|
||||
// function : HilightWithColor
|
||||
// purpose : Perform highlighting of the presentation.
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::GEOM_AnnotationOwner::HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Handle(Graphic3d_HighlightStyle)& theStyle,
|
||||
const Standard_Integer theMode )
|
||||
{
|
||||
if ( myPrsSh.IsNull() )
|
||||
{
|
||||
Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer;
|
||||
aDrawer->Link( Selectable()->HilightAttributes() );
|
||||
|
||||
Handle(Prs3d_IsoAspect) aUIsoAspect = new Prs3d_IsoAspect(
|
||||
aDrawer->UIsoAspect()->Aspect()->Color(),
|
||||
aDrawer->UIsoAspect()->Aspect()->Type(),
|
||||
aDrawer->UIsoAspect()->Aspect()->Width(), 0 );
|
||||
|
||||
Handle(Prs3d_IsoAspect) aVIsoAspect = new Prs3d_IsoAspect(
|
||||
aDrawer->UIsoAspect()->Aspect()->Color(),
|
||||
aDrawer->UIsoAspect()->Aspect()->Type(),
|
||||
aDrawer->UIsoAspect()->Aspect()->Width(), 0 );
|
||||
|
||||
aDrawer->SetIsoOnPlane( Standard_False );
|
||||
aDrawer->SetUIsoAspect( aUIsoAspect );
|
||||
aDrawer->SetVIsoAspect( aVIsoAspect );
|
||||
myPrsSh = new StdSelect_Shape( myShape, aDrawer );
|
||||
}
|
||||
|
||||
myPrsSh->SetZLayer ( Selectable()->ZLayer() );
|
||||
|
||||
thePM->Color( Selectable(), theStyle, theMode, NULL, Graphic3d_ZLayerId_Topmost );
|
||||
|
||||
thePM->Color( myPrsSh, theStyle, theMode, Selectable(), Graphic3d_ZLayerId_Topmost );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : GEOM_AnnotationOwner
|
||||
// function : Unhilight
|
||||
// purpose : Removes highlighting from the type of shape.
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::GEOM_AnnotationOwner::Unhilight ( const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode )
|
||||
{
|
||||
SelectMgr_EntityOwner::Unhilight( thePM, theMode );
|
||||
|
||||
thePM->Unhighlight( myPrsSh, theMode );
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// subclass : GEOM_AnnotationOwner
|
||||
// function : Clear
|
||||
// purpose : Clears the presentation manager object aPM of all shapes
|
||||
// with the given selection mode.
|
||||
// =======================================================================
|
||||
void GEOM_Annotation::GEOM_AnnotationOwner::Clear ( const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode )
|
||||
{
|
||||
SelectMgr_EntityOwner::Clear( thePM, theMode );
|
||||
|
||||
if ( !myPrsSh.IsNull() ) {
|
||||
thePM->Clear( myPrsSh, theMode );
|
||||
}
|
||||
|
||||
myPrsSh.Nullify();
|
||||
}
|
417
src/OBJECT/GEOM_Annotation.hxx
Executable file
417
src/OBJECT/GEOM_Annotation.hxx
Executable file
@ -0,0 +1,417 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
// GEOM OBJECT : interactive object for Geometry entities visualization
|
||||
// File : GEOM_Annotation.hxx
|
||||
// Module : GEOM
|
||||
//
|
||||
#ifndef GEOM_Annotation_HeaderFile
|
||||
#define GEOM_Annotation_HeaderFile
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_String.hxx>
|
||||
#include <OpenGl_Element.hxx>
|
||||
#include <OpenGl_TextParam.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <Select3D_SensitiveBox.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <StdSelect_Shape.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
class OpenGl_GraphicDriver;
|
||||
class OpenGl_PrimitiveArray;
|
||||
class OpenGl_Text;
|
||||
class V3d_View;
|
||||
|
||||
/*!
|
||||
* \class GEOM_Annotation
|
||||
* \brief Interactive object, representating annotation entity
|
||||
*/
|
||||
class GEOM_Annotation : public AIS_InteractiveObject
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT( GEOM_Annotation, AIS_InteractiveObject )
|
||||
|
||||
//! Enumerates supported highlighting modes.
|
||||
//! - HighlightAll : all elements of the annotation are highlighted.
|
||||
//! - HighlightLabel : only annotation label is highlighted.
|
||||
enum HighlightMode
|
||||
{
|
||||
HighlightAll = 0,
|
||||
HighlightLabel = 1
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT GEOM_Annotation();
|
||||
|
||||
//! Destructor.
|
||||
virtual ~GEOM_Annotation() {}
|
||||
|
||||
//! Sets annotation text string.
|
||||
//! \param theText [in] the string displayed in annotation label.
|
||||
Standard_EXPORT void SetText( const TCollection_ExtendedString& theText );
|
||||
|
||||
//! Returns annotation text string.
|
||||
const TCollection_ExtendedString& GetText() const { return myText; }
|
||||
|
||||
//! Sets position of the annotation text label.
|
||||
//! \param thePosition [in] the cartesian point defining the position of lower left
|
||||
//! corner of the text label. When displayed in fixed screen position mode
|
||||
//! (\sa SetScreenFixed) the position is defined as {x,y} pixel coordinate
|
||||
//! of window space, otherwise 3D point defined in world's coordinate system
|
||||
//! is used.
|
||||
Standard_EXPORT void SetPosition( const gp_Pnt& thePosition );
|
||||
|
||||
//! Returns position of the annotation text label.
|
||||
const gp_Pnt& GetPosition() const { return myPosition; }
|
||||
|
||||
//! Sets or disables "2D screen fixed" positioning mode. In this mode the annotation
|
||||
//! is fixed at predefined pixel location in the window coordinate space. Other mode
|
||||
//! is "3D screen aligned" positioning, when the label is aligned in plane of the
|
||||
//! screen, while its position is a 3D point defined in world's coordinate system.
|
||||
Standard_EXPORT void SetIsScreenFixed( const Standard_Boolean theIsFixed );
|
||||
|
||||
//! Retuns value of "screen fixed" positioning mode.
|
||||
Standard_Boolean GetIsScreenFixed() const { return myIsScreenFixed; }
|
||||
|
||||
//! Converts annotation position to screen fixed coordinates and
|
||||
//! modifies its "2D screen fixed" flag correspondingly.
|
||||
//! @param theView [in] the view to perform projection of coordinates.
|
||||
Standard_EXPORT void Set2dPosition( const Handle(V3d_View)& theView );
|
||||
|
||||
//! Converts annotation position from screen fixed coordinates
|
||||
//! to 3D position and modifies its "2D screen fixed" flag
|
||||
//! correspondingly.
|
||||
//! @param theView [in] the view to perform projection of coordinates.
|
||||
Standard_EXPORT void Set3dPosition( const Handle(V3d_View)& theView );
|
||||
|
||||
//! Sets attachment point of extension line.
|
||||
//! \param thePoint [in] the 3D cartesian point defined in world's coordinate system
|
||||
//! (a point on annotated geometry).
|
||||
Standard_EXPORT void SetAttachPoint( const gp_Pnt& thePoint );
|
||||
|
||||
//! Returns attachment point of extension line.
|
||||
const gp_Pnt& GetAttachPoint() const { return myAttach; }
|
||||
|
||||
//! Sets shape (annotated shape) that will be used for hilighting.
|
||||
Standard_EXPORT void SetHilightShape( const TopoDS_Shape& theShape );
|
||||
|
||||
//! Returns the hilighting shape.
|
||||
const TopoDS_Shape HilightShape() const { return myShape; }
|
||||
|
||||
public:
|
||||
|
||||
//! Sets color for the presentation.
|
||||
Standard_EXPORT virtual void SetColor( const Quantity_Color& theColor ) Standard_OVERRIDE;
|
||||
|
||||
//! Sets text color.
|
||||
Standard_EXPORT void SetTextColor( const Quantity_Color& theColor );
|
||||
|
||||
//! Returns color for the text's label.
|
||||
Quantity_Color GetTextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
|
||||
|
||||
//! Sets line's color.
|
||||
Standard_EXPORT void SetLineColor( const Quantity_Color& theColor);
|
||||
|
||||
//! Returns color for the connection line.
|
||||
Quantity_Color GetLineColor() const { return myDrawer->LineAspect()->Aspect()->Color(); }
|
||||
|
||||
//! Sets line width to be used for drawing the annotation's extension line and underline.
|
||||
Standard_EXPORT void SetLineWidth( const Standard_Real theLineWidth );
|
||||
|
||||
//! Returns line width for drawing the annotation's extension line and underline.
|
||||
Standard_Real GetLineWidth() const { return myDrawer->LineAspect()->Aspect()->Width(); }
|
||||
|
||||
//! Sets style of connection line.
|
||||
Standard_EXPORT void SetLineStyle( const Aspect_TypeOfLine theStyle );
|
||||
|
||||
//! Retusn style of connection line.
|
||||
Aspect_TypeOfLine GetLineStyle() const { return myDrawer->LineAspect()->Aspect()->Type(); }
|
||||
|
||||
//! Sets style of hidden connection line.
|
||||
Standard_EXPORT void SetHiddenLineStyle( const Aspect_TypeOfLine theStyle );
|
||||
|
||||
//! Retusn style of hidden connection line.
|
||||
Aspect_TypeOfLine GetHiddenLineStyle() const { return myDrawer->HiddenLineAspect()->Aspect()->Type(); }
|
||||
|
||||
//! Sets text height in pixels.
|
||||
Standard_EXPORT void SetTextHeight( const Standard_Real theHeight );
|
||||
|
||||
//! Returns text's height in pixels.
|
||||
Standard_Real GetTextHeight() const { return myDrawer->TextAspect()->Height(); }
|
||||
|
||||
//! Sets font aspect for label.
|
||||
Standard_EXPORT void SetFontAspect( const Font_FontAspect theFontAspect );
|
||||
|
||||
//! Returns label's font aspect.
|
||||
Font_FontAspect GetFontAspect() const { return myDrawer->TextAspect()->Aspect()->GetTextFontAspect(); }
|
||||
|
||||
//! Sets font used for drawing the label.
|
||||
Standard_EXPORT void SetFont( const TCollection_AsciiString& theFont );
|
||||
|
||||
//! Returns font used for drawing the label.
|
||||
TCollection_AsciiString GetFont() const { return myDrawer->TextAspect()->Aspect()->Font(); }
|
||||
|
||||
//! Sets annotation auto-hiding option.
|
||||
//! \param theIsEnable [in] the option flag. If passed true, the annotation
|
||||
//! will be automatically hidden in the view if the attachment point
|
||||
//! goes outside of the view.
|
||||
void SetAutoHide( const Standard_Boolean theIsEnable ) { myIsAutoHide = theIsEnable; }
|
||||
|
||||
//! Returns current state of the auto-hiding option.
|
||||
Standard_Boolean GetAutoHide() const { return myIsAutoHide; }
|
||||
|
||||
//! Sets highlight mode used for display of presentation.
|
||||
//! \param theMode [in] the one of the supported highlight modes.
|
||||
void SetHighlightMode( const HighlightMode theMode ) { myHilightMode = theMode; }
|
||||
|
||||
//! Returns highlight mode
|
||||
HighlightMode GetHilightMode() const { return myHilightMode; }
|
||||
|
||||
//! Sets special flag that allows disabling depth testing when rendering
|
||||
//! the graphical presentation. When disable the hidden parts such as
|
||||
//! lines and text become visible and a rendered with another drawing
|
||||
//! aspect. This mode should be explicitly used with setting top layer
|
||||
//! for the presentation. Otherwise the behavior is undefined.
|
||||
Standard_EXPORT void SetDepthCulling( const Standard_Boolean theToEnable );
|
||||
|
||||
//! Returns depth culling state.
|
||||
Standard_Boolean GetDepthCulling() const { return myIsDepthCulling; }
|
||||
|
||||
// Helper tools:
|
||||
public:
|
||||
|
||||
//! Restores default z-layer for this presentation.
|
||||
Standard_EXPORT void SetDefaultZLayer();
|
||||
|
||||
//! Returns default position for placing annotation when its attachment point
|
||||
//! has been determined.
|
||||
//! @param theIsScreenFixed [in] the state of annotation's "2D screen fixed" mode.
|
||||
//! @param theAttachPnt [in] the attachment point.
|
||||
//! @param theOffset [in] the offset value for placing the position relative to attachment.s
|
||||
//! @param theView [in] the view for projecting coordinates.
|
||||
Standard_EXPORT static gp_Pnt GetDefaultPosition( const Standard_Boolean theIsScreenFixed,
|
||||
const gp_Pnt& theAttachPnt,
|
||||
const Standard_Real theOffset,
|
||||
const Handle(V3d_View)& theView );
|
||||
|
||||
//! Converts 3d position to 2d on screen point.
|
||||
//! @param thePosition [in] the 3d position.
|
||||
//! @param theAttach [in] the attachment point.
|
||||
//! @param theView [in] the view for projecting coordinates.
|
||||
Standard_EXPORT static gp_Pnt ConvertPosition2d( const gp_Pnt& thePosition,
|
||||
const gp_Pnt& theAttach,
|
||||
const Handle(V3d_View)& theView );
|
||||
|
||||
//! Converts 2d position to 3d point.
|
||||
//! @param thePosition [in] the 2d position.
|
||||
//! @param theAttach [in] the attachment point.
|
||||
//! @param theView [in] the view for projecting coordinates.
|
||||
Standard_EXPORT static gp_Pnt ConvertPosition3d( const gp_Pnt& thePosition,
|
||||
const gp_Pnt& theAttach,
|
||||
const Handle(V3d_View)& theView );
|
||||
|
||||
// Interactive dragging:
|
||||
public:
|
||||
|
||||
//! Prepares necessary data to perform dragging.
|
||||
Standard_EXPORT void BeginDrag();
|
||||
|
||||
//! Drags annotation presentation in the screen plane using the given pixel delta.
|
||||
//! \param theDx, theDy [in] the drag offset in pixels (from beginning of dragging).
|
||||
//! \param theView [in] the current view for evaluating drag with 3D position mode.
|
||||
Standard_EXPORT void Drag( const Standard_Integer theDx,
|
||||
const Standard_Integer theDy,
|
||||
const Handle(V3d_View)& theView );
|
||||
|
||||
//! Perform necessary update when dragging is finished.
|
||||
Standard_EXPORT void EndDrag();
|
||||
|
||||
//! Perform necessary update when dragging need undo.
|
||||
Standard_EXPORT void UndoDrag();
|
||||
|
||||
private:
|
||||
|
||||
virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
|
||||
|
||||
virtual void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode ) Standard_OVERRIDE;
|
||||
|
||||
virtual void setLocalTransformation( const Handle(Geom_Transformation)& /*theTransformation*/ ) Standard_OVERRIDE {}
|
||||
|
||||
virtual void SetTransformPersistence( const Handle(Graphic3d_TransformPers)& /*theTrsfPers*/ ) Standard_OVERRIDE {}
|
||||
|
||||
Bnd_Box TextBoundingBox() const;
|
||||
|
||||
void SetPosition( const gp_Pnt& thePosition, const Standard_Boolean theUpdateSelection );
|
||||
|
||||
private:
|
||||
|
||||
gp_Pnt myAttach; //!< Attachment point of extension line.
|
||||
gp_Pnt myPosition; //!< Position of text label.
|
||||
gp_Pnt myStartPosition; //!< Position before starting dragging operation.
|
||||
Standard_Boolean myIsScreenFixed; //!< Flag indicating whether "screen fixed" positioning mode is turned on or off.
|
||||
Standard_Boolean myIsAutoHide; //!< Flag indicating whether "auto-hiding" option is turned on.
|
||||
Standard_Boolean myIsDepthCulling; //!< Flag indiciating whether the "depth culling" is turned on.
|
||||
HighlightMode myHilightMode; //!< Highlight mode for presentation.
|
||||
TCollection_ExtendedString myText; //!< Text string of the label presentation.
|
||||
TopoDS_Shape myShape; //!< Hilighting shape.
|
||||
|
||||
private:
|
||||
|
||||
//! Custom element implementing dynamic rendering of 3D annotation
|
||||
//! and invoking dynamic callback in presentation class.
|
||||
class OpenGl_Annotation : public OpenGl_Element
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor. Some of the input properties are assigned by reference for dynamic draw
|
||||
//! (it is not likely that GL element will ever outlive the interactive object).
|
||||
//! \param theAnnotation [in] the instance of interactive presentation class.
|
||||
//! \param theTextHeight [in] the height of the text label.
|
||||
//! \param theDriver [in] the instance of graphical driver required for initialization.
|
||||
OpenGl_Annotation( GEOM_Annotation* theAnnotation,
|
||||
const Standard_Integer theTextHeight,
|
||||
const OpenGl_GraphicDriver* theDriver );
|
||||
|
||||
//! Destructor. Releases GL resources with NULL context.
|
||||
virtual ~OpenGl_Annotation();
|
||||
|
||||
//! Releases GL resources with the given GL context.
|
||||
virtual void Release( OpenGl_Context* theCtx ) Standard_OVERRIDE;
|
||||
|
||||
//! Renders the annotation graphical elements.
|
||||
virtual void Render( const Handle(OpenGl_Workspace)& theWorkspace ) const Standard_OVERRIDE;
|
||||
|
||||
void SetDepthMode( const int theMode ) { myDepthMode = theMode; }
|
||||
|
||||
private:
|
||||
|
||||
struct TextSize {
|
||||
float x; // width
|
||||
float y; // height
|
||||
float a; // ascent
|
||||
float d; // descent
|
||||
};
|
||||
|
||||
GEOM_Annotation* myAISObject; //!< Instance of presentation class.
|
||||
NCollection_String myText; //!< Text string of annotation label.
|
||||
OpenGl_TextParam myTextParams; //!< Text draw parameters.
|
||||
OpenGl_Text* myTextDraw; //!< Text draw element.
|
||||
OpenGl_PrimitiveArray* myTextLineDraw; //!< Text underline draw element.
|
||||
OpenGl_PrimitiveArray* myExtLineDraw; //!< Extension line draw element.
|
||||
OpenGl_PrimitiveArray* myExtMarkerDraw; //!< Extension marker draw element.
|
||||
int myDepthMode; //!< Depth mode for drawing hidden line presentation.
|
||||
mutable float myTextLineY; //!< Text's underlines relative position.
|
||||
mutable TextSize myTextSize; //!< Text's size parameters
|
||||
mutable Graphic3d_Vec2 myTextUnderline; //!< Text's underline position.
|
||||
mutable unsigned int myTextDPI; //!< Text's DPI scale used for last rendering.
|
||||
};
|
||||
|
||||
friend class OpenGl_Annotation; // allow opengl element to get private data and invoke callback methods
|
||||
|
||||
public:
|
||||
|
||||
//! Custom entity owner implementing correct highlight for topmost mode.
|
||||
class GEOM_AnnotationOwner : public SelectMgr_EntityOwner
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
GEOM_AnnotationOwner( const TopoDS_Shape& theShape,
|
||||
const Handle(SelectMgr_SelectableObject)& theSelectable,
|
||||
const Standard_Integer thePriority )
|
||||
: SelectMgr_EntityOwner( theSelectable, thePriority ),
|
||||
myShape( theShape ) {}
|
||||
|
||||
//! Perform highlighting of the presentation.
|
||||
//! \param thePresentationMgr [in] the presentation manager.
|
||||
//! \param theColor [in] the highlighting color.
|
||||
//! \param theMode [in] the display mode.
|
||||
virtual void
|
||||
HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Handle(Graphic3d_HighlightStyle)& theStyle,
|
||||
const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
|
||||
|
||||
//! Removes highlighting from the type of shape.
|
||||
virtual void
|
||||
Unhilight ( const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
|
||||
|
||||
//! Clears the presentation manager object aPM of all shapes
|
||||
//! with the given selection mode.
|
||||
virtual void
|
||||
Clear ( const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
Handle(StdSelect_Shape) myPrsSh;
|
||||
};
|
||||
|
||||
//! Custom sensitive entity with implementing option to support selection
|
||||
//! with depth culling flag turned off.
|
||||
class GEOM_AnnotationSensEntity : public Select3D_SensitiveBox
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
GEOM_AnnotationSensEntity( const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Bnd_Box& theBox,
|
||||
const Standard_Boolean theIsDepthCulling )
|
||||
: Select3D_SensitiveBox( theOwner, theBox ),
|
||||
myIsDepthCulling( theIsDepthCulling ) {}
|
||||
|
||||
//! Checks whether the box overlaps current selecting volume.
|
||||
virtual Standard_Boolean Matches( SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult ) Standard_OVERRIDE
|
||||
{
|
||||
const Standard_Boolean isMatches = Select3D_SensitiveBox::Matches( theMgr, thePickResult );
|
||||
if ( !myIsDepthCulling )
|
||||
{
|
||||
thePickResult = SelectBasics_PickResult( -DBL_MAX, thePickResult.DistToGeomCenter() );
|
||||
}
|
||||
return isMatches;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Standard_Boolean myIsDepthCulling;
|
||||
};
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE( GEOM_Annotation, AIS_InteractiveObject )
|
||||
|
||||
#endif
|
@ -104,7 +104,9 @@ namespace GEOM
|
||||
// texture
|
||||
"Texture", // -
|
||||
// dimensions
|
||||
"Dimensions" // -
|
||||
"Dimensions", // -
|
||||
// shape annotations
|
||||
"ShapeAnnotations" // -
|
||||
};
|
||||
return ( type >= GEOM::Visibility && type <= GEOM::LastProperty ) ? names[type] : QString();
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ namespace GEOM
|
||||
OutlineColor,
|
||||
Texture,
|
||||
Dimensions,
|
||||
LastProperty = Dimensions,
|
||||
ShapeAnnotations,
|
||||
LastProperty = ShapeAnnotations,
|
||||
};
|
||||
|
||||
GEOM_OBJECT_EXPORT double minDeflection();
|
||||
|
Loading…
Reference in New Issue
Block a user