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

@ -96,7 +96,7 @@
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;
@ -212,7 +212,8 @@ MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg() {
// purpose : fills annotation properties with default values( in create mode ) or
// the values of modified object
//=================================================================================
void MeasureGUI_AnnotationDlg::Init() {
void MeasureGUI_AnnotationDlg::Init()
{
if ( myIsCreation ) {
initName( tr( "ANNOTATION_PREFIX" ) );
@ -229,6 +230,7 @@ void MeasureGUI_AnnotationDlg::Init() {
// update internal controls and fields following to default values
activateSelectionArgument( myShapeSelBtn );
myTextEdit->setText( myAnnotationProperties.Text );
myShapeNameModified = false;
myTypeCombo->setCurrentIndex( !myAnnotationProperties.IsScreenFixed );
int aSubShapeTypeIndex = -1;
@ -266,7 +268,8 @@ void MeasureGUI_AnnotationDlg::Init() {
// function : activateSelection
// purpose : Activate local selection
//=================================================================================
void MeasureGUI_AnnotationDlg::activateSelection() {
void MeasureGUI_AnnotationDlg::activateSelection()
{
//globalSelection( GEOM_ALLSHAPES );
//if ( !myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE ) {
// localSelection( myShape.get(), mySelectionMode );
@ -277,7 +280,8 @@ void MeasureGUI_AnnotationDlg::activateSelection() {
// function : getShapeType()
// purpose :
//=================================================================================
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const
{
return ( TopAbs_ShapeEnum ) mySubShapeTypeCombo->itemData(
mySubShapeTypeCombo->currentIndex() ).toInt();
}
@ -286,7 +290,8 @@ TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
// function : ClickOnOk()
// purpose :
//=================================================================================
void MeasureGUI_AnnotationDlg::ClickOnOk() {
void MeasureGUI_AnnotationDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if ( ClickOnApply() )
ClickOnCancel();
@ -297,7 +302,8 @@ void MeasureGUI_AnnotationDlg::ClickOnOk() {
// function : ClickOnApply()
// purpose :
//=================================================================================
bool MeasureGUI_AnnotationDlg::ClickOnApply() {
bool MeasureGUI_AnnotationDlg::ClickOnApply()
{
if ( !isApplyAndClose() ) {
setIsDisableBrowsing( true );
setIsDisplayResult( false );
@ -345,7 +351,8 @@ 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() {
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
{
QPushButton* aSelectButton = ( QPushButton* ) sender();
activateSelectionArgument( aSelectButton );
@ -358,7 +365,8 @@ 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(
void MeasureGUI_AnnotationDlg::activateSelectionArgument
(
QPushButton* theSelectionButton ) {
QPushButton* anOtherButton = 0;
if ( theSelectionButton == myShapeSelBtn ) {
@ -382,8 +390,10 @@ 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) {
void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
{
if ( myIsCreation && myEditCurrentArgument )
{
myEditCurrentArgument->setText( "" );
GEOM::GeomObjPtr anObj = getSelected( mySelectionMode );
@ -397,6 +407,10 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
myShape = anObj;
QString aName = GEOMBase::GetName( anObj.get() );
myEditCurrentArgument->setText( aName );
if ( !myShapeNameModified ) {
myTextEdit->setText( aName );
myShapeNameModified = false;
}
}
bool aNullShape = myShape->_is_nil();
@ -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,7 +482,8 @@ void MeasureGUI_AnnotationDlg::onTypeChange() {
//function : onSubShapeTypeChange
//purpose :
//=======================================================================
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
{
activateSelectionArgument( mySubShapeSelBtn );
TopAbs_ShapeEnum aShapeType = getShapeType();
@ -499,7 +519,8 @@ GEOM::GEOM_IOperations_ptr MeasureGUI_AnnotationDlg::createOperation()
// 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(),
@ -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 ) );
@ -627,7 +648,8 @@ void MeasureGUI_AnnotationDlg::updateSubShapeEnableState()
// 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 );

View File

@ -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;