clean and align code

This commit is contained in:
jfa 2009-11-04 10:58:08 +00:00
parent 656071da94
commit 2d7fa83c28

View File

@ -22,7 +22,7 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : GroupGUI_GroupDlg.cxx // File : GroupGUI_GroupDlg.cxx
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
//
#include "GroupGUI_GroupDlg.h" #include "GroupGUI_GroupDlg.h"
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
@ -162,11 +162,9 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
void GroupGUI_GroupDlg::Init() void GroupGUI_GroupDlg::Init()
{ {
// san -- TODO: clear selected sub-shapes... // san -- TODO: clear selected sub-shapes...
//mySelSubBtn->setChecked( true );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
//unset shape type to avoid preparation of selection before exact user shape type selection //unset shape type to avoid preparation of selection before exact user shape type selection
//setConstructorId( -1 ); //non valid shape type
unsetConstructorId(); unsetConstructorId();
myIsShapeType = false; myIsShapeType = false;
@ -239,11 +237,10 @@ void GroupGUI_GroupDlg::enterEvent( QEvent* e )
ActivateThisDialog(); ActivateThisDialog();
} }
//======================================================================= //=================================================================================
//function : closeEvent //function : closeEvent
//purpose : remove temporary geom object //purpose : remove temporary geom object
//======================================================================= //=================================================================================
void GroupGUI_GroupDlg::closeEvent(QCloseEvent* e) void GroupGUI_GroupDlg::closeEvent(QCloseEvent* e)
{ {
setInPlaceObj(GEOM::GEOM_Object::_nil()); setInPlaceObj(GEOM::GEOM_Object::_nil());
@ -289,8 +286,8 @@ void GroupGUI_GroupDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); this, SLOT(SelectionIntoArgument()));
activateSelection(); activateSelection();
} }
@ -325,18 +322,16 @@ void GroupGUI_GroupDlg::SetEditCurrentArgument()
myEditCurrentArgument = myMainName; myEditCurrentArgument = myMainName;
myShape2Name->setText(""); myShape2Name->setText("");
} }
else if ( /*(QRadioButton*)sender() == mySelSubBtn ||*/ send == mySelAllBtn ) else if (send == mySelAllBtn)
myEditCurrentArgument = 0; myEditCurrentArgument = 0;
else if (send == mySelBtn2 || sender() == mySelectionWayGroup) { else if (send == mySelBtn2 || sender() == mySelectionWayGroup) {
setInPlaceObj(GEOM::GEOM_Object::_nil()); setInPlaceObj(GEOM::GEOM_Object::_nil());
//if ( myPlaceCheckBox->isChecked() )
myShape2Name->setText(""); myShape2Name->setText("");
if (subSelectionWay() != ALL_SUBSHAPES) if (subSelectionWay() != ALL_SUBSHAPES)
{ {
myEditCurrentArgument = myShape2Name; myEditCurrentArgument = myShape2Name;
} }
else { else {
//myEditCurrentArgument = myMainName;
myEditCurrentArgument = 0; myEditCurrentArgument = 0;
} }
} }
@ -344,10 +339,6 @@ void GroupGUI_GroupDlg::SetEditCurrentArgument()
activateSelection(); activateSelection();
if (send == mySelAllBtn) { if (send == mySelAllBtn) {
// myShape2Name->setText( "" );
// myPlaceCheckBox->setChecked( false );
// mySelBtn2->setEnabled( false );
// myShape2Name->setEnabled( false );
selectAllSubShapes(); selectAllSubShapes();
} }
else else
@ -402,11 +393,10 @@ void GroupGUI_GroupDlg::onGetInPlace()
} }
} }
//======================================================================= //=================================================================================
//function : setInPlaceObj //function : setInPlaceObj
//purpose : temporarily add an object to study and remove old InPlaceObj //purpose : temporarily add an object to study and remove old InPlaceObj
//======================================================================= //=================================================================================
void GroupGUI_GroupDlg::setInPlaceObj(GEOM::GEOM_Object_var theObj, const bool isVisible) void GroupGUI_GroupDlg::setInPlaceObj(GEOM::GEOM_Object_var theObj, const bool isVisible)
{ {
if (! myInPlaceObj->_is_equivalent(theObj)) if (! myInPlaceObj->_is_equivalent(theObj))
@ -459,7 +449,6 @@ void GroupGUI_GroupDlg::setInPlaceObj( GEOM::GEOM_Object_var theObj, const bool
//================================================================================= //=================================================================================
void GroupGUI_GroupDlg::SelectionIntoArgument() void GroupGUI_GroupDlg::SelectionIntoArgument()
{ {
// if (myPlaceCheckBox->isChecked() && myEditCurrentArgument == myShape2Name )
if (subSelectionWay() != ALL_SUBSHAPES && myEditCurrentArgument == myShape2Name) { if (subSelectionWay() != ALL_SUBSHAPES && myEditCurrentArgument == myShape2Name) {
onGetInPlace(); onGetInPlace();
return; return;
@ -509,7 +498,6 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
bool subselected = aMapIndex.Extent(); bool subselected = aMapIndex.Extent();
// convert inPlace indices to main indices // convert inPlace indices to main indices
//if ( subselected && myPlaceCheckBox->isChecked() )
if (subselected && subSelectionWay() != ALL_SUBSHAPES) if (subselected && subSelectionWay() != ALL_SUBSHAPES)
{ {
TColStd_IndexedMapOfInteger aMapIndex2; TColStd_IndexedMapOfInteger aMapIndex2;
@ -557,7 +545,6 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
CORBA::Long anIndex; CORBA::Long anIndex;
anIndex = aLocOp->GetSubShapeIndex(myMainObj, aSubObjects[i]); anIndex = aLocOp->GetSubShapeIndex(myMainObj, aSubObjects[i]);
if (anIndex >= 0) { if (anIndex >= 0) {
//if ( myPlaceCheckBox->isChecked() && ! myMain2InPlaceIndices.IsBound( anIndex ))
if (subSelectionWay() != ALL_SUBSHAPES && if (subSelectionWay() != ALL_SUBSHAPES &&
! myMain2InPlaceIndices.IsBound(anIndex)) ! myMain2InPlaceIndices.IsBound(anIndex))
continue; continue;
@ -566,7 +553,7 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
} }
} }
} }
if ( !myMainObj->_is_nil() && myIsShapeType/*&& mySelSubBtn->isChecked()*/) if (!myMainObj->_is_nil() && myIsShapeType)
if (subSelectionWay() == ALL_SUBSHAPES) if (subSelectionWay() == ALL_SUBSHAPES)
localSelection(myMainObj, getShapeType()); localSelection(myMainObj, getShapeType());
else if (!myInPlaceObj->_is_nil()) else if (!myInPlaceObj->_is_nil())
@ -614,7 +601,6 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
return; return;
GEOM::ListOfLong_var aSubShapes; GEOM::ListOfLong_var aSubShapes;
// if ( !myPlaceCheckBox->isChecked() )
if (subSelectionWay() == ALL_SUBSHAPES) if (subSelectionWay() == ALL_SUBSHAPES)
{ {
if (!myIsShapeType) if (!myIsShapeType)
@ -770,11 +756,10 @@ void GroupGUI_GroupDlg::remove()
highlightSubShapes(); highlightSubShapes();
} }
//======================================================================= //=================================================================================
//function : subSelectionWay //function : subSelectionWay
//purpose : //purpose :
//======================================================================= //=================================================================================
int GroupGUI_GroupDlg::subSelectionWay() const int GroupGUI_GroupDlg::subSelectionWay() const
{ {
return mySelectionWayGroup->checkedId(); return mySelectionWayGroup->checkedId();
@ -812,7 +797,6 @@ void GroupGUI_GroupDlg::setShapeType( const TopAbs_ShapeEnum theType )
myIsShapeType = true; myIsShapeType = true;
} }
//================================================================================= //=================================================================================
// function : activateSelection // function : activateSelection
// purpose : Activate selection in accordance with myEditCurrentArgument // purpose : Activate selection in accordance with myEditCurrentArgument
@ -822,10 +806,10 @@ void GroupGUI_GroupDlg::activateSelection()
globalSelection(GEOM_ALLSHAPES); globalSelection(GEOM_ALLSHAPES);
// local selection // local selection
if ( !myMainObj->_is_nil() && !myEditCurrentArgument/* && mySelSubBtn->isChecked()*/ if (!myMainObj->_is_nil() && !myEditCurrentArgument
&& myIsShapeType) { // check if shape type is already choosen by user && myIsShapeType) // check if shape type is already choosen by user
{
// if ( !myPlaceCheckBox->isChecked() )
if (subSelectionWay() == ALL_SUBSHAPES) if (subSelectionWay() == ALL_SUBSHAPES)
localSelection(myMainObj, getShapeType()); localSelection(myMainObj, getShapeType());
else if (!myInPlaceObj->_is_nil()) else if (!myInPlaceObj->_is_nil())
@ -860,7 +844,6 @@ void GroupGUI_GroupDlg::updateState()
// try to find out and process the object browser selection // try to find out and process the object browser selection
if (!aMapIndex.Extent() && !CORBA::is_nil(myMainObj)) { if (!aMapIndex.Extent() && !CORBA::is_nil(myMainObj)) {
GEOM::ListOfGO anObjects; GEOM::ListOfGO anObjects;
//GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
GEOMBase::ConvertListOfIOInListOfGO(aSelIOs, anObjects); GEOMBase::ConvertListOfIOInListOfGO(aSelIOs, anObjects);
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId()); GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId());
@ -918,15 +901,10 @@ void GroupGUI_GroupDlg::updateState()
myAddBtn->setEnabled(!myEditCurrentArgument && !CORBA::is_nil(myMainObj) && isAdd); myAddBtn->setEnabled(!myEditCurrentArgument && !CORBA::is_nil(myMainObj) && isAdd);
bool hasSel = myIdList->selectedItems().count() > 0; bool hasSel = myIdList->selectedItems().count() > 0;
myRemBtn->setEnabled(hasSel); myRemBtn->setEnabled(hasSel);
//mySelSubBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
//myPlaceCheckBox->setEnabled( !CORBA::is_nil( myMainObj ) );
mySelectionWayGroupBox->setEnabled(!CORBA::is_nil(myMainObj)); mySelectionWayGroupBox->setEnabled(!CORBA::is_nil(myMainObj));
mySelAllBtn->setEnabled(!CORBA::is_nil(myMainObj)); mySelAllBtn->setEnabled(!CORBA::is_nil(myMainObj));
// mySelBtn2->setEnabled( myPlaceCheckBox->isChecked() );
// myShape2Name->setEnabled( myPlaceCheckBox->isChecked() );
mySelBtn2->setEnabled( subSelectionWay() != ALL_SUBSHAPES); mySelBtn2->setEnabled( subSelectionWay() != ALL_SUBSHAPES);
myShape2Name->setEnabled(subSelectionWay() != ALL_SUBSHAPES); myShape2Name->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
// if ( !myPlaceCheckBox->isChecked() )
if (subSelectionWay() == ALL_SUBSHAPES) if (subSelectionWay() == ALL_SUBSHAPES)
setInPlaceObj(GEOM::GEOM_Object::_nil()); setInPlaceObj(GEOM::GEOM_Object::_nil());
} }
@ -971,7 +949,6 @@ void GroupGUI_GroupDlg::highlightSubShapes()
{ {
if (myIdList->item(ii)->isSelected()) { if (myIdList->item(ii)->isSelected()) {
int id = myIdList->item(ii)->text().toInt(); int id = myIdList->item(ii)->text().toInt();
// if ( myPlaceCheckBox->isChecked() )
if (subSelectionWay() != ALL_SUBSHAPES) if (subSelectionWay() != ALL_SUBSHAPES)
{ {
if (myMain2InPlaceIndices.IsBound(id)) if (myMain2InPlaceIndices.IsBound(id))