mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-16 13:43:07 +05:00
Code style correction; myShapeNameModified state for initial filling annotation text.
This commit is contained in:
parent
5414e209c2
commit
ca6fba5742
@ -96,7 +96,7 @@
|
|||||||
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 )
|
QWidget* parent, bool modal, Qt::WindowFlags fl )
|
||||||
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
|
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
|
||||||
myIsCreation( theIsCreate )
|
myIsCreation( theIsCreate ), myShapeNameModified( false )
|
||||||
{
|
{
|
||||||
myEditCurrentArgument = 0;
|
myEditCurrentArgument = 0;
|
||||||
|
|
||||||
@ -212,7 +212,8 @@ MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg() {
|
|||||||
// 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
|
// the values of modified object
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::Init() {
|
void MeasureGUI_AnnotationDlg::Init()
|
||||||
|
{
|
||||||
if ( myIsCreation ) {
|
if ( myIsCreation ) {
|
||||||
initName( tr( "ANNOTATION_PREFIX" ) );
|
initName( tr( "ANNOTATION_PREFIX" ) );
|
||||||
|
|
||||||
@ -229,6 +230,7 @@ void MeasureGUI_AnnotationDlg::Init() {
|
|||||||
// update internal controls and fields following to default values
|
// update internal controls and fields following to default values
|
||||||
activateSelectionArgument( myShapeSelBtn );
|
activateSelectionArgument( myShapeSelBtn );
|
||||||
myTextEdit->setText( myAnnotationProperties.Text );
|
myTextEdit->setText( myAnnotationProperties.Text );
|
||||||
|
myShapeNameModified = false;
|
||||||
myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed );
|
myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed );
|
||||||
|
|
||||||
int aSubShapeTypeIndex = -1;
|
int aSubShapeTypeIndex = -1;
|
||||||
@ -266,7 +268,8 @@ void MeasureGUI_AnnotationDlg::Init() {
|
|||||||
// function : activateSelection
|
// function : activateSelection
|
||||||
// purpose : Activate local selection
|
// purpose : Activate local selection
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::activateSelection() {
|
void MeasureGUI_AnnotationDlg::activateSelection()
|
||||||
|
{
|
||||||
//globalSelection( GEOM_ALLSHAPES );
|
//globalSelection( GEOM_ALLSHAPES );
|
||||||
//if ( !myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE ) {
|
//if ( !myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE ) {
|
||||||
// localSelection( myShape.get(), mySelectionMode );
|
// localSelection( myShape.get(), mySelectionMode );
|
||||||
@ -277,7 +280,8 @@ void MeasureGUI_AnnotationDlg::activateSelection() {
|
|||||||
// function : getShapeType()
|
// function : getShapeType()
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
|
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const
|
||||||
|
{
|
||||||
return ( TopAbs_ShapeEnum ) mySubShapeTypeCombo->itemData(
|
return ( TopAbs_ShapeEnum ) mySubShapeTypeCombo->itemData(
|
||||||
mySubShapeTypeCombo->currentIndex() ).toInt();
|
mySubShapeTypeCombo->currentIndex() ).toInt();
|
||||||
}
|
}
|
||||||
@ -286,7 +290,8 @@ TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
|
|||||||
// function : ClickOnOk()
|
// function : ClickOnOk()
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::ClickOnOk() {
|
void MeasureGUI_AnnotationDlg::ClickOnOk()
|
||||||
|
{
|
||||||
setIsApplyAndClose( true );
|
setIsApplyAndClose( true );
|
||||||
if ( ClickOnApply() )
|
if ( ClickOnApply() )
|
||||||
ClickOnCancel();
|
ClickOnCancel();
|
||||||
@ -297,7 +302,8 @@ void MeasureGUI_AnnotationDlg::ClickOnOk() {
|
|||||||
// function : ClickOnApply()
|
// function : ClickOnApply()
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
bool MeasureGUI_AnnotationDlg::ClickOnApply() {
|
bool MeasureGUI_AnnotationDlg::ClickOnApply()
|
||||||
|
{
|
||||||
if ( !isApplyAndClose() ) {
|
if ( !isApplyAndClose() ) {
|
||||||
setIsDisableBrowsing( true );
|
setIsDisableBrowsing( true );
|
||||||
setIsDisplayResult( false );
|
setIsDisplayResult( false );
|
||||||
@ -345,7 +351,8 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply() {
|
|||||||
// purpose : process click on shape/sub-shape button. It stores as current edit argument
|
// 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
|
// the corresponded line edit, set focus in it and unpress other button if it was pressed
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() {
|
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
|
||||||
|
{
|
||||||
QPushButton* aSelectButton = ( QPushButton* ) sender();
|
QPushButton* aSelectButton = ( QPushButton* ) sender();
|
||||||
|
|
||||||
activateSelectionArgument( aSelectButton );
|
activateSelectionArgument( aSelectButton );
|
||||||
@ -358,7 +365,8 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() {
|
|||||||
// purpose : it stores as current edit argument the corresponded line edit,
|
// purpose : it stores as current edit argument the corresponded line edit,
|
||||||
// sets the focus on it and unpresses other button if it was pressed
|
// sets the focus on it and unpresses other button if it was pressed
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::activateSelectionArgument(
|
void MeasureGUI_AnnotationDlg::activateSelectionArgument
|
||||||
|
(
|
||||||
QPushButton* theSelectionButton ) {
|
QPushButton* theSelectionButton ) {
|
||||||
QPushButton* anOtherButton = 0;
|
QPushButton* anOtherButton = 0;
|
||||||
if ( theSelectionButton == myShapeSelBtn ) {
|
if ( theSelectionButton == myShapeSelBtn ) {
|
||||||
@ -382,8 +390,10 @@ void MeasureGUI_AnnotationDlg::activateSelectionArgument(
|
|||||||
// purpose : Called when selection has changed. Sets the current selection in the
|
// purpose : Called when selection has changed. Sets the current selection in the
|
||||||
// annotation property and redisplays presentation
|
// annotation property and redisplays presentation
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
|
void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
||||||
if (myIsCreation && myEditCurrentArgument) {
|
{
|
||||||
|
if ( myIsCreation && myEditCurrentArgument )
|
||||||
|
{
|
||||||
myEditCurrentArgument->setText( "" );
|
myEditCurrentArgument->setText( "" );
|
||||||
|
|
||||||
GEOM::GeomObjPtr anObj = getSelected( mySelectionMode );
|
GEOM::GeomObjPtr anObj = getSelected( mySelectionMode );
|
||||||
@ -397,6 +407,10 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
|
|||||||
myShape = anObj;
|
myShape = anObj;
|
||||||
QString aName = GEOMBase::GetName( anObj.get() );
|
QString aName = GEOMBase::GetName( anObj.get() );
|
||||||
myEditCurrentArgument->setText( aName );
|
myEditCurrentArgument->setText( aName );
|
||||||
|
if ( !myShapeNameModified ) {
|
||||||
|
myTextEdit->setText( aName );
|
||||||
|
myShapeNameModified = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool aNullShape = myShape->_is_nil();
|
bool aNullShape = myShape->_is_nil();
|
||||||
@ -445,8 +459,12 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
|
|||||||
//function : onTextChange
|
//function : onTextChange
|
||||||
//purpose : change annotation text
|
//purpose : change annotation text
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeasureGUI_AnnotationDlg::onTextChange() {
|
void MeasureGUI_AnnotationDlg::onTextChange()
|
||||||
|
{
|
||||||
myAnnotationProperties.Text = myTextEdit->text();
|
myAnnotationProperties.Text = myTextEdit->text();
|
||||||
|
if ( !myShapeNameModified )
|
||||||
|
myShapeNameModified = true;
|
||||||
|
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +472,8 @@ void MeasureGUI_AnnotationDlg::onTextChange() {
|
|||||||
//function : onTypeChange
|
//function : onTypeChange
|
||||||
//purpose : change annotation type: 2D or 3D
|
//purpose : change annotation type: 2D or 3D
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeasureGUI_AnnotationDlg::onTypeChange() {
|
void MeasureGUI_AnnotationDlg::onTypeChange()
|
||||||
|
{
|
||||||
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
|
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
@ -463,7 +482,8 @@ void MeasureGUI_AnnotationDlg::onTypeChange() {
|
|||||||
//function : onSubShapeTypeChange
|
//function : onSubShapeTypeChange
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
|
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
|
||||||
|
{
|
||||||
activateSelectionArgument( mySubShapeSelBtn );
|
activateSelectionArgument( mySubShapeSelBtn );
|
||||||
|
|
||||||
TopAbs_ShapeEnum aShapeType = getShapeType();
|
TopAbs_ShapeEnum aShapeType = getShapeType();
|
||||||
@ -499,7 +519,8 @@ GEOM::GEOM_IOperations_ptr MeasureGUI_AnnotationDlg::createOperation()
|
|||||||
// function : isValid()
|
// function : isValid()
|
||||||
// purpose : Verify validity of input data
|
// purpose : Verify validity of input data
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) {
|
bool MeasureGUI_AnnotationDlg::isValid( QString& theMessage )
|
||||||
|
{
|
||||||
SalomeApp_Study* study = getStudy();
|
SalomeApp_Study* study = getStudy();
|
||||||
RETURN_WITH_MSG( !study, tr( "GEOM_NO_STUDY" ) )
|
RETURN_WITH_MSG( !study, tr( "GEOM_NO_STUDY" ) )
|
||||||
RETURN_WITH_MSG( study->studyDS()->GetProperties()->IsLocked(),
|
RETURN_WITH_MSG( study->studyDS()->GetProperties()->IsLocked(),
|
||||||
@ -569,9 +590,9 @@ bool MeasureGUI_AnnotationDlg::execute()
|
|||||||
// function : buildPrs
|
// function : buildPrs
|
||||||
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() {
|
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
|
||||||
Handle (GEOM_Annotation)
|
{
|
||||||
aPresentation = new GEOM_Annotation();
|
Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
|
||||||
|
|
||||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||||
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
|
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
|
||||||
@ -627,7 +648,8 @@ void MeasureGUI_AnnotationDlg::updateSubShapeEnableState()
|
|||||||
// function : buildPrs
|
// function : buildPrs
|
||||||
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::redisplayPreview() {
|
void MeasureGUI_AnnotationDlg::redisplayPreview()
|
||||||
|
{
|
||||||
QString aMess;
|
QString aMess;
|
||||||
if ( !isValid( aMess ) ) {
|
if ( !isValid( aMess ) ) {
|
||||||
erasePreview( true );
|
erasePreview( true );
|
||||||
|
@ -101,6 +101,8 @@ private:
|
|||||||
QLineEdit* myTextEdit;
|
QLineEdit* myTextEdit;
|
||||||
|
|
||||||
QPushButton* myShapeSelBtn;
|
QPushButton* myShapeSelBtn;
|
||||||
|
// update shape name by shape selection if it has not been manually modified yet
|
||||||
|
bool myShapeNameModified;
|
||||||
QLineEdit* myShapeName;
|
QLineEdit* myShapeName;
|
||||||
QComboBox* myTypeCombo;
|
QComboBox* myTypeCombo;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user