Code style correction; myShapeNameModified state for initial filling annotation text.

This commit is contained in:
nds 2016-10-12 14:29:36 +03:00
parent 5414e209c2
commit ca6fba5742
2 changed files with 230 additions and 206 deletions

View File

@ -1,12 +1,12 @@
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright ( C ) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// 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.
// 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
@ -93,104 +93,104 @@
//purpose :
//=======================================================================
MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI, const bool theIsCreate,
MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI, const bool theIsCreate,
QWidget* parent, bool modal, Qt::WindowFlags fl )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
myIsCreation( theIsCreate )
myIsCreation( theIsCreate ), myShapeNameModified( false )
{
myEditCurrentArgument = 0;
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
QPixmap iconSelect( resMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
setWindowTitle( myIsCreation ? tr("CREATE_ANNOTATION_TITLE") : tr("EDIT_ANNOTATION_TITLE"));
setWindowTitle( myIsCreation ? tr( "CREATE_ANNOTATION_TITLE" ) : tr( "EDIT_ANNOTATION_TITLE" ) );
// Shape type button group
mainFrame()->GroupConstructors->hide();
// Field name
mainFrame()->GroupBoxName->setTitle(tr("ANNOTATION_NAME"));
mainFrame()->GroupBoxName->setTitle( tr( "ANNOTATION_NAME" ) );
// Field properties
QGroupBox* propGroup = new QGroupBox(tr("ANNOTATION_PROPERTIES"), centralWidget());
QGridLayout* propLayout = new QGridLayout(propGroup);
propLayout->setMargin(9);
propLayout->setSpacing(6);
QGroupBox* propGroup = new QGroupBox( tr( "ANNOTATION_PROPERTIES" ), centralWidget() );
QGridLayout* propLayout = new QGridLayout( propGroup );
propLayout->setMargin( 9 );
propLayout->setSpacing( 6 );
QLabel* textLabel = new QLabel(tr("ANNOTATION_TEXT"), propGroup);
myTextEdit = new QLineEdit(propGroup);
propLayout->addWidget(textLabel, 0, 0);
propLayout->addWidget(myTextEdit, 0, 1, 1, 2);
QLabel* textLabel = new QLabel( tr( "ANNOTATION_TEXT" ), propGroup );
myTextEdit = new QLineEdit( propGroup );
propLayout->addWidget( textLabel, 0, 0 );
propLayout->addWidget( myTextEdit, 0, 1, 1, 2 );
// shape
QLabel* shapeLabel = new QLabel(tr("ANNOTATION_SHAPE"), propGroup);
myShapeSelBtn = new QPushButton(propGroup);
myShapeSelBtn->setIcon(iconSelect);
myShapeSelBtn->setEnabled(myIsCreation);
myShapeName = new QLineEdit(propGroup);
myShapeName->setReadOnly(true);
myShapeName->setEnabled(myIsCreation);
QLabel* shapeLabel = new QLabel( tr( "ANNOTATION_SHAPE" ), propGroup );
myShapeSelBtn = new QPushButton( propGroup );
myShapeSelBtn->setIcon( iconSelect );
myShapeSelBtn->setEnabled( myIsCreation );
myShapeName = new QLineEdit( propGroup );
myShapeName->setReadOnly( true );
myShapeName->setEnabled( myIsCreation );
// data type
QLabel* typeLabel = new QLabel(tr("ANNOTATION_TYPE"), propGroup);
myTypeCombo = new QComboBox(propGroup);
myTypeCombo->insertItem(0, tr("3D"));
myTypeCombo->insertItem(1, tr("2D"));
myTypeCombo->setCurrentIndex(0); // 3D, not fixed
QLabel* typeLabel = new QLabel( tr( "ANNOTATION_TYPE" ), propGroup );
myTypeCombo = new QComboBox( propGroup );
myTypeCombo->insertItem( 0, tr( "3D" ) );
myTypeCombo->insertItem( 1, tr( "2D" ) );
myTypeCombo->setCurrentIndex( 0 ); // 3D, not fixed
propLayout->addWidget(shapeLabel, 1, 0);
propLayout->addWidget(myShapeSelBtn, 1, 1);
propLayout->addWidget(myShapeName, 1, 2);
propLayout->addWidget(typeLabel, 2, 0, 1, 2);
propLayout->addWidget(myTypeCombo, 2, 2);
propLayout->setColumnStretch(2, 5);
propLayout->addWidget( shapeLabel, 1, 0 );
propLayout->addWidget( myShapeSelBtn, 1, 1 );
propLayout->addWidget( myShapeName, 1, 2 );
propLayout->addWidget( typeLabel, 2, 0, 1, 2 );
propLayout->addWidget( myTypeCombo, 2, 2 );
propLayout->setColumnStretch( 2, 5 );
QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
mySubShapeTypeCombo = new QComboBox(propGroup);
mySubShapeTypeCombo->addItem(tr("WHOLE_SHAPE"), TopAbs_SHAPE);
mySubShapeTypeCombo->addItem(tr("GEOM_VERTEX"), TopAbs_VERTEX);
mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE);
mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE);
mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID);
mySubShapeTypeCombo->setCurrentIndex(0); // SHAPE
QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup );
mySubShapeTypeCombo = new QComboBox( propGroup );
mySubShapeTypeCombo->addItem( tr( "WHOLE_SHAPE" ), TopAbs_SHAPE );
mySubShapeTypeCombo->addItem( tr( "GEOM_VERTEX" ), TopAbs_VERTEX );
mySubShapeTypeCombo->addItem( tr( "GEOM_EDGE" ), TopAbs_EDGE );
mySubShapeTypeCombo->addItem( tr( "GEOM_FACE" ), TopAbs_FACE );
mySubShapeTypeCombo->addItem( tr( "GEOM_SOLID" ), TopAbs_SOLID );
mySubShapeTypeCombo->setCurrentIndex( 0 ); // SHAPE
propLayout->addWidget(shapeTypeLabel, 3, 0);
propLayout->addWidget(mySubShapeTypeCombo, 3, 1, 1, 2);
propLayout->addWidget( shapeTypeLabel, 3, 0 );
propLayout->addWidget( mySubShapeTypeCombo, 3, 1, 1, 2 );
// sub-shape
mySubShapeSelBtn = new QPushButton(propGroup);
mySubShapeSelBtn->setIcon(iconSelect);
mySubShapeSelBtn->setEnabled(myIsCreation);
mySubShapeName = new QLineEdit(propGroup);
mySubShapeName->setReadOnly(true);
mySubShapeName->setEnabled(myIsCreation);
mySubShapeSelBtn = new QPushButton( propGroup );
mySubShapeSelBtn->setIcon( iconSelect );
mySubShapeSelBtn->setEnabled( myIsCreation );
mySubShapeName = new QLineEdit( propGroup );
mySubShapeName->setReadOnly( true );
mySubShapeName->setEnabled( myIsCreation );
propLayout->addWidget(mySubShapeSelBtn, 4, 1);
propLayout->addWidget(mySubShapeName, 4, 2);
propLayout->addWidget( mySubShapeSelBtn, 4, 1 );
propLayout->addWidget( mySubShapeName, 4, 2 );
// Field properties
QGroupBox* styleGroup = new QGroupBox(tr("ANNOTATION_STYLE"),
centralWidget());
QGridLayout* styleLayout = new QGridLayout(styleGroup);
styleLayout->setMargin(9);
styleLayout->setSpacing(6);
QGroupBox* styleGroup = new QGroupBox( tr( "ANNOTATION_STYLE" ),
centralWidget() );
QGridLayout* styleLayout = new QGridLayout( styleGroup );
styleLayout->setMargin( 9 );
styleLayout->setSpacing( 6 );
QLabel* fontLabel = new QLabel(tr("ANNOTATION_FONT"), styleGroup);
styleLayout->addWidget(fontLabel, 0, 0);
QLabel* fontLabel = new QLabel( tr( "ANNOTATION_FONT" ), styleGroup );
styleLayout->addWidget( fontLabel, 0, 0 );
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0);
layout->setSpacing(6);
layout->addWidget(propGroup);
layout->addWidget(styleGroup);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 );
layout->setSpacing( 6 );
layout->addWidget( propGroup );
layout->addWidget( styleGroup );
setHelpFileName("annotation_page.html");
setHelpFileName( "annotation_page.html" );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
connect(aSelMgr, SIGNAL(currentSelectionChanged()), this,
SLOT(SelectionIntoArgument()));
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this,
SLOT( SelectionIntoArgument() ) );
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
myInteractor = new MeasureGUI_AnnotationInteractor( theGeometryGUI, parent );
myInteractor->Enable();
@ -209,51 +209,53 @@ MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg() {
//=================================================================================
// function : Init()
// purpose : fills annotation properties with default values(in create mode) or
// purpose : fills annotation properties with default values( in create mode ) or
// the values of modified object
//=================================================================================
void MeasureGUI_AnnotationDlg::Init() {
if (myIsCreation) {
initName(tr("ANNOTATION_PREFIX"));
void MeasureGUI_AnnotationDlg::Init()
{
if ( myIsCreation ) {
initName( tr( "ANNOTATION_PREFIX" ) );
// default presentation values
myAnnotationProperties.Name = getNewObjectName();
myAnnotationProperties.Position = gp_Pnt(250, 250, 250);
myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
myAnnotationProperties.Position = gp_Pnt( 250, 250, 250 );
myAnnotationProperties.Text = tr( "ANNOTATION_PREFIX" );
myAnnotationProperties.IsVisible = false;
myAnnotationProperties.IsScreenFixed = false;
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
myAnnotationProperties.Attach = gp_Pnt( 0, 0, 0 );
myAnnotationProperties.ShapeIndex = -1;
myAnnotationProperties.ShapeType = (int) TopAbs_SHAPE;
myAnnotationProperties.ShapeType = ( int ) TopAbs_SHAPE;
// update internal controls and fields following to default values
activateSelectionArgument(myShapeSelBtn);
myTextEdit->setText(myAnnotationProperties.Text);
myTypeCombo->setCurrentIndex(!myAnnotationProperties.IsScreenFixed);
activateSelectionArgument( myShapeSelBtn );
myTextEdit->setText( myAnnotationProperties.Text );
myShapeNameModified = false;
myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed );
int aSubShapeTypeIndex = -1;
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
for (int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++) {
int aType = mySubShapeTypeCombo->itemData(i).toInt();
if (aType == myAnnotationProperties.ShapeType)
for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
int aType = mySubShapeTypeCombo->itemData( i ).toInt();
if ( aType == myAnnotationProperties.ShapeType )
aSubShapeTypeIndex = i;
}
mySubShapeTypeCombo->setCurrentIndex(aSubShapeTypeIndex);
mySubShapeTypeCombo->setCurrentIndex( aSubShapeTypeIndex );
mySelectionMode = (TopAbs_ShapeEnum) myAnnotationProperties.ShapeType;
mySelectionMode = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
SelectionIntoArgument();
updateSubShapeEnableState();
// connect controls
connect(myShapeSelBtn, SIGNAL(clicked()), this,
SLOT(SetEditCurrentArgument()));
connect(mySubShapeSelBtn, SIGNAL(clicked()), this,
SLOT(SetEditCurrentArgument()));
connect( myShapeSelBtn, SIGNAL( clicked() ), this,
SLOT( SetEditCurrentArgument() ) );
connect( mySubShapeSelBtn, SIGNAL( clicked() ), this,
SLOT( SetEditCurrentArgument() ) );
connect(myTextEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChange()));
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange()));
connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onSubShapeTypeChange()));
connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) );
connect( myTypeCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onTypeChange() ) );
connect( mySubShapeTypeCombo, SIGNAL( currentIndexChanged( int ) ),
this, SLOT( onSubShapeTypeChange() ) );
//SelectionIntoArgument();
} else { // edition
@ -266,10 +268,11 @@ void MeasureGUI_AnnotationDlg::Init() {
// function : activateSelection
// purpose : Activate local selection
//=================================================================================
void MeasureGUI_AnnotationDlg::activateSelection() {
//globalSelection(GEOM_ALLSHAPES);
//if (!myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE) {
// localSelection(myShape.get(), mySelectionMode);
void MeasureGUI_AnnotationDlg::activateSelection()
{
//globalSelection( GEOM_ALLSHAPES );
//if ( !myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE ) {
// localSelection( myShape.get(), mySelectionMode );
//}
}
@ -277,64 +280,67 @@ void MeasureGUI_AnnotationDlg::activateSelection() {
// function : getShapeType()
// purpose :
//=================================================================================
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
return (TopAbs_ShapeEnum) mySubShapeTypeCombo->itemData(
mySubShapeTypeCombo->currentIndex()).toInt();
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const
{
return ( TopAbs_ShapeEnum ) mySubShapeTypeCombo->itemData(
mySubShapeTypeCombo->currentIndex() ).toInt();
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void MeasureGUI_AnnotationDlg::ClickOnOk() {
setIsApplyAndClose(true);
if (ClickOnApply())
void MeasureGUI_AnnotationDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if ( ClickOnApply() )
ClickOnCancel();
setIsApplyAndClose(false);
setIsApplyAndClose( false );
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool MeasureGUI_AnnotationDlg::ClickOnApply() {
if (!isApplyAndClose()) {
setIsDisableBrowsing(true);
setIsDisplayResult(false);
bool MeasureGUI_AnnotationDlg::ClickOnApply()
{
if ( !isApplyAndClose() ) {
setIsDisableBrowsing( true );
setIsDisplayResult( false );
}
QString msg;
if (!isValid(msg)) {
showError(msg);
if ( !isValid( msg ) ) {
showError( msg );
return false;
}
SUIT_OverrideCursor wc;
SUIT_Session::session()->activeApplication()->putInfo("");
SUIT_Session::session()->activeApplication()->putInfo( "" );
try {
if (openCommand())
if (!execute(/*isApplyAndClose()*/)) {
if ( openCommand() )
if ( !execute( /*isApplyAndClose()*/ ) ) {
abortCommand();
showError();
return false;
}
} catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
} catch ( const SALOME::SALOME_Exception& e ) {
SalomeApp_Tools::QtCatchCorbaException( e );
abortCommand();
return false;
}
commitCommand();
if (!isApplyAndClose()) {
setIsDisableBrowsing(false);
setIsDisplayResult(true);
if ( !isApplyAndClose() ) {
setIsDisableBrowsing( false );
setIsDisplayResult( true );
}
/*if (myIsCreation)
/*if ( myIsCreation )
{
myAnnotation = GEOM::GEOM_Field::_nil();
if (!isApplyAndClose())
if ( !isApplyAndClose() )
Init();
}*/
return true;
@ -345,10 +351,11 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply() {
// purpose : process click on shape/sub-shape button. It stores as current edit argument
// the corresponded line edit, set focus in it and unpress other button if it was pressed
//=================================================================================
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() {
QPushButton* aSelectButton = (QPushButton*) sender();
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
{
QPushButton* aSelectButton = ( QPushButton* ) sender();
activateSelectionArgument(aSelectButton);
activateSelectionArgument( aSelectButton );
SelectionIntoArgument();
}
@ -358,23 +365,24 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() {
// purpose : it stores as current edit argument the corresponded line edit,
// sets the focus on it and unpresses other button if it was pressed
//=================================================================================
void MeasureGUI_AnnotationDlg::activateSelectionArgument(
QPushButton* theSelectionButton) {
void MeasureGUI_AnnotationDlg::activateSelectionArgument
(
QPushButton* theSelectionButton ) {
QPushButton* anOtherButton = 0;
if (theSelectionButton == myShapeSelBtn) {
if ( theSelectionButton == myShapeSelBtn ) {
myEditCurrentArgument = myShapeName;
anOtherButton = mySubShapeSelBtn;
} else if (theSelectionButton == mySubShapeSelBtn) {
} else if ( theSelectionButton == mySubShapeSelBtn ) {
myEditCurrentArgument = mySubShapeName;
anOtherButton = myShapeSelBtn;
} else
myEditCurrentArgument = 0;
if (myEditCurrentArgument)
if ( myEditCurrentArgument )
myEditCurrentArgument->setFocus();
theSelectionButton->setDown(true);
anOtherButton->setDown(false);
theSelectionButton->setDown( true );
anOtherButton->setDown( false );
}
//=================================================================================
@ -382,57 +390,63 @@ void MeasureGUI_AnnotationDlg::activateSelectionArgument(
// purpose : Called when selection has changed. Sets the current selection in the
// annotation property and redisplays presentation
//=================================================================================
void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
if (myIsCreation && myEditCurrentArgument) {
myEditCurrentArgument->setText("");
void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
{
if ( myIsCreation && myEditCurrentArgument )
{
myEditCurrentArgument->setText( "" );
GEOM::GeomObjPtr anObj = getSelected(mySelectionMode);
GEOM::GeomObjPtr anObj = getSelected( mySelectionMode );
gp_Pnt anAttachPoint(0, 0, 0);
gp_Pnt anAttachPoint( 0, 0, 0 );
int aSubShapeIndex = -1;
if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active
if (anObj->_is_nil() || mySelectionMode != TopAbs_SHAPE) {
if ( myEditCurrentArgument == myShapeName ) { // Selection of a shape is active
if ( anObj->_is_nil() || mySelectionMode != TopAbs_SHAPE ) {
myShape = GEOM::GEOM_Object::_nil();
} else {
myShape = anObj;
QString aName = GEOMBase::GetName(anObj.get());
myEditCurrentArgument->setText(aName);
QString aName = GEOMBase::GetName( anObj.get() );
myEditCurrentArgument->setText( aName );
if ( !myShapeNameModified ) {
myTextEdit->setText( aName );
myShapeNameModified = false;
}
}
bool aNullShape = myShape->_is_nil();
mySubShapeTypeCombo->setEnabled(!aNullShape);
mySubShapeTypeCombo->setEnabled( !aNullShape );
updateSubShapeEnableState();
activateSelection();
if (!myShape->_is_nil()) {
if ( !myShape->_is_nil() ) {
TopoDS_Shape aShape;
GEOMBase::GetShape(myShape.get(), aShape);
anAttachPoint = getAttachPoint(aShape);
GEOMBase::GetShape( myShape.get(), aShape );
anAttachPoint = getAttachPoint( aShape );
}
} else if (myEditCurrentArgument == mySubShapeName) {
if (!myShape->_is_nil()) {
QString aName = GEOMBase::GetName(anObj.get());
myEditCurrentArgument->setText(aName);
} else if ( myEditCurrentArgument == mySubShapeName ) {
if ( !myShape->_is_nil() ) {
QString aName = GEOMBase::GetName( anObj.get() );
myEditCurrentArgument->setText( aName );
TopTools_IndexedMapOfShape aMainMap;
TopoDS_Shape aMainShape;
GEOMBase::GetShape(myShape.get(), aMainShape);
TopExp::MapShapes(aMainShape, aMainMap);
GEOMBase::GetShape( myShape.get(), aMainShape );
TopExp::MapShapes( aMainShape, aMainMap );
TopExp_Explorer anExp(aMainShape, getShapeType());
TopExp_Explorer anExp( aMainShape, getShapeType() );
bool isShowWarning = true;
TopoDS_Shape aSubShape;
for (; anExp.More() && aSubShapeIndex < 0; anExp.Next()) {
for ( ; anExp.More() && aSubShapeIndex < 0; anExp.Next() ) {
TopoDS_Shape aCurrentSubShape = anExp.Current();
int anIndex = aMainMap.FindIndex(aCurrentSubShape);
if (anIndex >= 0) {
int anIndex = aMainMap.FindIndex( aCurrentSubShape );
if ( anIndex >= 0 ) {
aSubShapeIndex = anIndex;
aSubShape = aCurrentSubShape;
}
}
anAttachPoint = getAttachPoint(aSubShape);
anAttachPoint = getAttachPoint( aSubShape );
myAnnotationProperties.ShapeIndex = aSubShapeIndex;
}
}
@ -445,8 +459,12 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
//function : onTextChange
//purpose : change annotation text
//=======================================================================
void MeasureGUI_AnnotationDlg::onTextChange() {
void MeasureGUI_AnnotationDlg::onTextChange()
{
myAnnotationProperties.Text = myTextEdit->text();
if ( !myShapeNameModified )
myShapeNameModified = true;
redisplayPreview();
}
@ -454,7 +472,8 @@ void MeasureGUI_AnnotationDlg::onTextChange() {
//function : onTypeChange
//purpose : change annotation type: 2D or 3D
//=======================================================================
void MeasureGUI_AnnotationDlg::onTypeChange() {
void MeasureGUI_AnnotationDlg::onTypeChange()
{
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
redisplayPreview();
}
@ -463,13 +482,14 @@ void MeasureGUI_AnnotationDlg::onTypeChange() {
//function : onSubShapeTypeChange
//purpose :
//=======================================================================
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
activateSelectionArgument(mySubShapeSelBtn);
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
{
activateSelectionArgument( mySubShapeSelBtn );
TopAbs_ShapeEnum aShapeType = getShapeType();
myAnnotationProperties.ShapeType = aShapeType;
if (aShapeType != mySelectionMode) {
mySubShapeName->setText("");
if ( aShapeType != mySelectionMode ) {
mySubShapeName->setText( "" );
myAnnotationProperties.ShapeIndex = -1;
mySelectionMode = aShapeType;
}
@ -480,9 +500,9 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
redisplayPreview();
}
#define RETURN_WITH_MSG(a, b) \
if ((a)) { \
theMessage += (b); \
#define RETURN_WITH_MSG( a, b ) \
if ( ( a ) ) { \
theMessage += ( b ); \
return false; \
}
@ -492,30 +512,31 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
//=================================================================================
GEOM::GEOM_IOperations_ptr MeasureGUI_AnnotationDlg::createOperation()
{
return getGeomEngine()->GetILocalOperations(getStudyId());
return getGeomEngine()->GetILocalOperations( getStudyId() );
}
//=================================================================================
// function : isValid()
// purpose : Verify validity of input data
//=================================================================================
bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) {
bool MeasureGUI_AnnotationDlg::isValid( QString& theMessage )
{
SalomeApp_Study* study = getStudy();
RETURN_WITH_MSG(!study, tr("GEOM_NO_STUDY"))
RETURN_WITH_MSG(study->studyDS()->GetProperties()->IsLocked(),
tr("GEOM_STUDY_LOCKED"))
RETURN_WITH_MSG( !study, tr( "GEOM_NO_STUDY" ) )
RETURN_WITH_MSG( study->studyDS()->GetProperties()->IsLocked(),
tr( "GEOM_STUDY_LOCKED" ) )
if (myIsCreation) {
RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE"))
if ( myIsCreation ) {
RETURN_WITH_MSG( myShape->_is_nil(), tr( "NO_SHAPE" ) )
} else {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
//RETURN_WITH_MSG( CORBA::is_nil( myShape ), tr( "NO_FIELD" ) )
}
if (getShapeType() != TopAbs_SHAPE) {
if (myIsCreation) {
RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE"))
if ( getShapeType() != TopAbs_SHAPE ) {
if ( myIsCreation ) {
RETURN_WITH_MSG( myAnnotationProperties.ShapeIndex < 0, tr( "NO_SUB_SHAPE" ) )
} else {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
//RETURN_WITH_MSG( CORBA::is_nil( myShape ), tr( "NO_FIELD" ) )
}
}
return true;
@ -528,10 +549,10 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) {
bool MeasureGUI_AnnotationDlg::execute()
{
QString anError;
if (!isValid(anError))
if ( !isValid( anError ) )
return false;
if (myIsCreation) {
if ( myIsCreation ) {
SalomeApp_Study* aStudy = getStudy();
GEOMGUI_ShapeAnnotations aProp =
aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
@ -548,8 +569,8 @@ bool MeasureGUI_AnnotationDlg::execute()
// store modified property data
aStudy->setObjectProperty( GEOM::sharedPropertiesId(),
myShape->GetStudyEntry(), GEOM::propertyName(GEOM::ShapeAnnotations),
aProp);
myShape->GetStudyEntry(), GEOM::propertyName( GEOM::ShapeAnnotations ),
aProp );
aProp.SaveToAttribute( aStudy, myShape->GetStudyEntry() );
myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) );
}
@ -569,9 +590,9 @@ bool MeasureGUI_AnnotationDlg::execute()
// function : buildPrs
// purpose : creates annotation presentation object and corresponded SALOME presentation
//=================================================================================
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() {
Handle (GEOM_Annotation)
aPresentation = new GEOM_Annotation();
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
{
Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
@ -594,19 +615,19 @@ SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() {
aPresentation->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
TopoDS_Shape aShape;
GEOMBase::GetShape(myShape.get(), aShape);
gp_Ax3 aShapeLCS = gp_Ax3().Transformed(aShape.Location().Transformation());
myAnnotationProperties.ToPresentation(aPresentation, aShapeLCS);
GEOMBase::GetShape( myShape.get(), aShape );
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
myAnnotationProperties.ToPresentation( aPresentation, aShapeLCS );
// add Prs to preview
SUIT_ViewWindow* vw =
SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs =
dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*) (vw->getViewManager()->getViewModel()))->CreatePrs(
0));
dynamic_cast<SOCC_Prs*>( ( ( SOCC_Viewer* ) ( vw->getViewManager()->getViewModel() ) )->CreatePrs(
0 ) );
if (aPrs)
aPrs->AddObject(aPresentation);
if ( aPrs )
aPrs->AddObject( aPresentation );
return aPrs;
}
@ -619,18 +640,19 @@ void MeasureGUI_AnnotationDlg::updateSubShapeEnableState()
{
bool isWholeShape = getShapeType() == TopAbs_SHAPE;
bool aNullShape = myShape->_is_nil();
mySubShapeSelBtn->setEnabled(!aNullShape && !isWholeShape);
mySubShapeName->setEnabled(!aNullShape && !isWholeShape);
mySubShapeSelBtn->setEnabled( !aNullShape && !isWholeShape );
mySubShapeName->setEnabled( !aNullShape && !isWholeShape );
}
//=================================================================================
// function : buildPrs
// purpose : creates annotation presentation object and corresponded SALOME presentation
//=================================================================================
void MeasureGUI_AnnotationDlg::redisplayPreview() {
void MeasureGUI_AnnotationDlg::redisplayPreview()
{
QString aMess;
if (!isValid(aMess)) {
erasePreview(true);
if ( !isValid( aMess ) ) {
erasePreview( true );
return;
}
@ -638,14 +660,14 @@ void MeasureGUI_AnnotationDlg::redisplayPreview() {
try {
//SUIT_OverrideCursor wc;
//getDisplayer()->SetColor(Quantity_NOC_VIOLET);
//getDisplayer()->SetToActivate(false);
//getDisplayer()->SetColor( Quantity_NOC_VIOLET );
//getDisplayer()->SetToActivate( false );
if ( SALOME_Prs* aPrs = buildPrs() )
displayPreview(aPrs);
displayPreview( aPrs );
} catch ( const SALOME::SALOME_Exception& e ) {
SalomeApp_Tools::QtCatchCorbaException( e );
} catch (...) {
} catch ( ... ) {
}
}
@ -653,7 +675,7 @@ void MeasureGUI_AnnotationDlg::redisplayPreview() {
// function : getAttachPoint
// purpose : finds a point on shape to attach annotation object
//=================================================================================
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint(const TopoDS_Shape& theShape)
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint( const TopoDS_Shape& theShape )
{
gp_Pnt aPoint = gp_Pnt( 0, 0, 0 );

View File

@ -57,16 +57,16 @@ 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 ( 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 isValid ( QString& );
virtual bool execute ();
SALOME_Prs* buildPrs();
@ -86,10 +86,10 @@ private slots:
private:
void Init();
void activateSelectionArgument(QPushButton* theSelectionButton);
void activateSelectionArgument( QPushButton* theSelectionButton );
void activateSelection();
TopAbs_ShapeEnum getShapeType() const;
gp_Pnt getAttachPoint(const TopoDS_Shape& theShape);
gp_Pnt getAttachPoint( const TopoDS_Shape& theShape );
private:
TopAbs_ShapeEnum mySelectionMode;
@ -101,6 +101,8 @@ private:
QLineEdit* myTextEdit;
QPushButton* myShapeSelBtn;
// update shape name by shape selection if it has not been manually modified yet
bool myShapeNameModified;
QLineEdit* myShapeName;
QComboBox* myTypeCombo;