Back to index

salome-geom  6.5.0
Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes
BlocksGUI_ExplodeDlg Class Reference

#include <BlocksGUI_ExplodeDlg.h>

Collaboration diagram for BlocksGUI_ExplodeDlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BlocksGUI_ExplodeDlg (GeometryGUI *, QWidget *)
 ~BlocksGUI_ExplodeDlg ()

Protected Member Functions

virtual GEOM::GEOM_IOperations_ptr createOperation ()
virtual bool isValid (QString &)
virtual bool execute (ObjectList &)
virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr)
virtual QString getNewObjectName () const

Private Slots

void ClickOnOk ()
bool ClickOnApply ()
void ActivateThisDialog ()
void ConstructorsClicked (int)
void SelectionIntoArgument ()
void SetEditCurrentArgument ()
void SubShapeToggled ()
void ValueChangedInSpinBox ()

Private Member Functions

void Init ()
void enterEvent (QEvent *)
void activateSelection ()
void updateButtonState ()
bool isAllSubShapes () const
int shapeType () const
void clearTemporary ()

Private Attributes

int myConstructorId
CORBA::Long myNbBlocks
GEOM::GEOM_Object_var myObject
ObjectList myTmpObjs
DlgRef_1Sel2Spin1View1Check * myGrp1

Detailed Description

Definition at line 38 of file BlocksGUI_ExplodeDlg.h.


Constructor & Destructor Documentation

BlocksGUI_ExplodeDlg::BlocksGUI_ExplodeDlg ( GeometryGUI *  theGeometryGUI,
QWidget *  parent 
)

Definition at line 48 of file BlocksGUI_ExplodeDlg.cxx.

  : GEOMBase_Skeleton( theGeometryGUI, parent )
{
  QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BLOCK_EXPLODE" ) ) );
  QPixmap imageS( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );

  setWindowTitle( tr( "GEOM_BLOCK_EXPLODE_TITLE" ) );

  /***************************************************************/
  mainFrame()->GroupConstructors->setTitle( tr( "GEOM_BLOCK_EXPLODE" ) );

  mainFrame()->RadioButton1->setIcon( image1 );
  mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
  mainFrame()->RadioButton2->close();
  mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
  mainFrame()->RadioButton3->close();

  // Create first group
  myGrp1 = new DlgRef_1Sel2Spin1View1Check( centralWidget() );
  myGrp1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
  myGrp1->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
  myGrp1->PushButton1->setIcon( imageS );
  myGrp1->LineEdit1->setReadOnly( true );
  myGrp1->TextLabel2->setText( tr( "NB_FACES_MIN" ) );
  myGrp1->TextLabel3->setText( tr( "NB_FACES_MAX" ) );
  myGrp1->CheckBox1->setText( tr( "GEOM_SUBSHAPE_SELECT" ) );

  // Add groups to layout
  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
  layout->setMargin( 0 ); layout->setSpacing( 6 );
  layout->addWidget( myGrp1 );
  /***************************************************************/

  setHelpFileName( "explode_on_blocks_operation_page.html" );

  Init();
}

Here is the call graph for this function:

Definition at line 90 of file BlocksGUI_ExplodeDlg.cxx.

{
  // no need to delete child widgets, Qt does it all for us
  clearTemporary();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 294 of file BlocksGUI_ExplodeDlg.cxx.

{
  clearTemporary();
  erasePreview( true );

  if ( isAllSubShapes() ) { // Sub-shapes selection disabled
    disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
                SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
    globalSelection( GEOM_ALLSHAPES );
    if ( myObject->_is_nil() ) {
      SelectionIntoArgument();
    }
    connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
             SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
  } 
  else {
    displayPreview( true, true, true, false );
    globalSelection( GEOM_PREVIEW );
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void BlocksGUI_ExplodeDlg::ActivateThisDialog ( ) [private, slot]

Definition at line 249 of file BlocksGUI_ExplodeDlg.cxx.

{
  GEOMBase_Skeleton::ActivateThisDialog();
  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 
           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );

  activateSelection();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 489 of file BlocksGUI_ExplodeDlg.cxx.

{
  ObjectList::iterator anIter;
  for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter )
    getGeomEngine()->RemoveObject( *anIter );

  myTmpObjs.clear();
}

Here is the caller graph for this function:

bool BlocksGUI_ExplodeDlg::ClickOnApply ( ) [private, slot]

Definition at line 175 of file BlocksGUI_ExplodeDlg.cxx.

{
  SUIT_Session::session()->activeApplication()->putInfo( tr( "" ) );

  // Explode all sub-shapes
  if ( isAllSubShapes() ) {
    // More than 30 sub-shapes : ask confirmation
    if ( myNbBlocks > 30 ) {
      if ( SUIT_MessageBox::warning( this, 
                                     tr( "GEOM_CONFIRM" ),
                                     tr( "GEOM_CONFIRM_INFO" ).arg( myNbBlocks ),
                                     tr( "GEOM_BUT_EXPLODE" ),
                                     tr( "GEOM_BUT_CANCEL" ) ) != 0 )
        return false;  /* aborted */
    }
  }

  if ( !onAccept() )
    return false;

  activateSelection();

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void BlocksGUI_ExplodeDlg::ClickOnOk ( ) [private, slot]

Definition at line 164 of file BlocksGUI_ExplodeDlg.cxx.

{
  setIsApplyAndClose( true );
  if ( ClickOnApply() )
    ClickOnCancel();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void BlocksGUI_ExplodeDlg::ConstructorsClicked ( int  constructorId) [private, slot]

Definition at line 135 of file BlocksGUI_ExplodeDlg.cxx.

{
  if ( myConstructorId == constructorId )
    return;

  myConstructorId = constructorId;

  switch ( constructorId ) {
  case 0:
    myGrp1->show();
    myGrp1->SpinBox1->setValue( 6 );
    myGrp1->SpinBox2->setValue( 6 );
    myGrp1->CheckBox1->setChecked( false );
    break;
  default:
    break;
  }

  // init fields
  myEditCurrentArgument = myGrp1->LineEdit1;
  myObject = GEOM::GEOM_Object::_nil();

  activateSelection();
}

Here is the call graph for this function:

Here is the caller graph for this function:

GEOM::GEOM_IOperations_ptr BlocksGUI_ExplodeDlg::createOperation ( ) [protected, virtual]

Definition at line 361 of file BlocksGUI_ExplodeDlg.cxx.

{
  return getGeomEngine()->GetIBlocksOperations( getStudyId() );
}
void BlocksGUI_ExplodeDlg::enterEvent ( QEvent *  ) [private]

Definition at line 262 of file BlocksGUI_ExplodeDlg.cxx.

{
  if ( !mainFrame()->GroupConstructors->isEnabled() )
    this->ActivateThisDialog();
}

Here is the call graph for this function:

bool BlocksGUI_ExplodeDlg::execute ( ObjectList objects) [protected, virtual]

Definition at line 401 of file BlocksGUI_ExplodeDlg.cxx.

{
  GEOM::ListOfGO_var aList;

  GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());

  switch ( getConstructorId() ) {
  case 0:
    aList = anOper->ExplodeCompoundOfBlocks( myObject,
                                             myGrp1->SpinBox1->value(),
                                             myGrp1->SpinBox2->value() );
    break;
  }
  
  if ( !aList->length() )
    return false;

  if ( IsPreview() ) {
    clearTemporary();
    
    // Store objects. They will be put in study when "Apply" is pressed
    for ( int i = 0, n = aList->length(); i < n; i++ ) {
      objects.push_back( GEOM::GEOM_Object::_duplicate( aList[i] ) );
      myTmpObjs.push_back( GEOM::GEOM_Object::_duplicate( aList[i] ) );
    }

    return objects.size() > 0;
  }

  QStringList aParameters;
  aParameters << myGrp1->SpinBox1->text();
  aParameters << myGrp1->SpinBox2->text();

  // Throw away sub-shapes not selected by user if not in preview mode
  // and manual selection is active
  if ( !isAllSubShapes() ) {
    QMap<QString, char> selected;

    LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
    SALOME_ListIO aSelList;
    aSelMgr->selectedObjects(aSelList);

    // Get names of selected objects
    SALOME_ListIteratorOfListIO it (aSelList);
    for ( ; it.More(); it.Next() ) {
      selected.insert( it.Value()->getName(), 0 );
    }

    // Iterate through result and select objects with names from selection
    ObjectList toRemoveFromEngine;
    ObjectList::iterator anIter;
    for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter ) {
      CORBA::String_var objStr = myGeomGUI->getApp()->orb()->object_to_string( *anIter );
      if ( selected.contains( QString( objStr.in() ) ) )
      {
        if ( !IsPreview() )
          (*anIter)->SetParameters(aParameters.join(":").toLatin1().constData());
        objects.push_back( *anIter );
      }
      else
        toRemoveFromEngine.push_back( *anIter );
    }

    // Remove from engine useless objects
    ObjectList::iterator anIter2 = toRemoveFromEngine.begin();
    for ( ; anIter2 != toRemoveFromEngine.end(); ++anIter2 )
      getGeomEngine()->RemoveObject( *anIter2 );

    myTmpObjs.clear();

  }
  else {
    for ( int i = 0, n = aList->length(); i < n; i++ )
    {
      GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( aList[i] );
      if ( !IsPreview() )
        anObj->SetParameters(aParameters.join(":").toLatin1().constData());
      objects.push_back( anObj._retn() );
    }
  }

  return objects.size();
}

Here is the call graph for this function:

GEOM::GEOM_Object_ptr BlocksGUI_ExplodeDlg::getFather ( GEOM::GEOM_Object_ptr  ) [protected, virtual]

Definition at line 503 of file BlocksGUI_ExplodeDlg.cxx.

{
  return myObject;
}
QString BlocksGUI_ExplodeDlg::getNewObjectName ( ) const [protected, virtual]

Definition at line 512 of file BlocksGUI_ExplodeDlg.cxx.

{
  return QString::null;
}
void BlocksGUI_ExplodeDlg::Init ( ) [private]

Definition at line 100 of file BlocksGUI_ExplodeDlg.cxx.

{
  mainFrame()->GroupBoxName->hide();

  // Set range of spinboxes
  int SpecificStep = 1;
  initSpinBox( myGrp1->SpinBox1, 0, 999, SpecificStep );
  initSpinBox( myGrp1->SpinBox2, 0, 999, SpecificStep );

  if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() 
       != OCCViewer_Viewer::Type() )
    myGrp1->CheckBox1->setEnabled( false );

  // signals and slots connections
  connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
  connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );

  connect( myGrp1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );

  connect( myGrp1->SpinBox1, SIGNAL( valueChanged( int ) ), this, SLOT( ValueChangedInSpinBox( int ) ) );
  connect( myGrp1->SpinBox2, SIGNAL( valueChanged( int ) ), this, SLOT( ValueChangedInSpinBox( int ) ) );

  connect( myGrp1->CheckBox1, SIGNAL( stateChanged( int ) ), this, SLOT( SubShapeToggled() ) );

  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );

  myConstructorId = -1;
  ConstructorsClicked( 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool BlocksGUI_ExplodeDlg::isAllSubShapes ( ) const [private]

Definition at line 352 of file BlocksGUI_ExplodeDlg.cxx.

{
  return !myGrp1->CheckBox1->isChecked() || !myGrp1->CheckBox1->isEnabled();
}

Here is the caller graph for this function:

bool BlocksGUI_ExplodeDlg::isValid ( QString &  msg) [protected, virtual]

Definition at line 370 of file BlocksGUI_ExplodeDlg.cxx.

{
  bool okSP = true;
  okSP = myGrp1->SpinBox1->isValid( msg, !IsPreview() ) && okSP;
  okSP = myGrp1->SpinBox2->isValid( msg, !IsPreview() ) && okSP;

  bool ok = false;
  switch ( getConstructorId() ) {
  case 0:
    if ( IsPreview() ) {
      ok = !myObject->_is_nil();
    }
    else {
      LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
      SALOME_ListIO aSelList;
      aSelMgr->selectedObjects(aSelList);

      ok = !myObject->_is_nil() && (isAllSubShapes() || aSelList.Extent());
    }
    break;
  default:
    break;
  }

  return ok && okSP;
}

Here is the call graph for this function:

Definition at line 204 of file BlocksGUI_ExplodeDlg.cxx.

{
  if (!isAllSubShapes())
    return;

  myObject = GEOM::GEOM_Object::_nil();
  myGrp1->LineEdit1->setText("");

  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
  SALOME_ListIO aSelList;
  aSelMgr->selectedObjects(aSelList);

  if (aSelList.Extent() == 1) {
    GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );

    if ( GEOMBase::IsShape(anObj) ) {
      myObject = anObj;
      myGrp1->LineEdit1->setText(GEOMBase::GetName(anObj));
    }
  }

  updateButtonState();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file BlocksGUI_ExplodeDlg.cxx.

{
  QPushButton* aSender = (QPushButton*)sender();

  if ( myGrp1->PushButton1 == aSender ) {
    myGrp1->LineEdit1->setFocus();
    myEditCurrentArgument = myGrp1->LineEdit1;
    myGrp1->CheckBox1->setChecked( false );
  }

  activateSelection();
}

Here is the call graph for this function:

Here is the caller graph for this function:

int BlocksGUI_ExplodeDlg::shapeType ( ) const [private]
void BlocksGUI_ExplodeDlg::SubShapeToggled ( ) [private, slot]

Definition at line 285 of file BlocksGUI_ExplodeDlg.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 319 of file BlocksGUI_ExplodeDlg.cxx.

{
  if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() 
       != OCCViewer_Viewer::Type() || myObject->_is_nil() ) {
    myGrp1->CheckBox1->setChecked( false );
    myGrp1->CheckBox1->setEnabled( false );
  } 
  else {
    myGrp1->CheckBox1->setEnabled( true );
  }

  myNbBlocks = 0;

  if ( myObject->_is_nil() ) {
    myGrp1->TextBrowser1->setText( "" );
  } 
  else {
    GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());
    bool isOnlyBlocks = anOper->IsCompoundOfBlocks( myObject,
                                                    myGrp1->SpinBox1->value(),
                                                    myGrp1->SpinBox2->value(),
                                                    myNbBlocks );
    if ( isOnlyBlocks )
      myGrp1->TextBrowser1->setText( tr( "GEOM_NB_BLOCKS_NO_OTHERS" ).arg( myNbBlocks ) );
    else
      myGrp1->TextBrowser1->setText( tr( "GEOM_NB_BLOCKS_SOME_OTHERS" ).arg( myNbBlocks ) );
  }
}

Here is the caller graph for this function:

Definition at line 272 of file BlocksGUI_ExplodeDlg.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 68 of file BlocksGUI_ExplodeDlg.h.

DlgRef_1Sel2Spin1View1Check* BlocksGUI_ExplodeDlg::myGrp1 [private]

Definition at line 75 of file BlocksGUI_ExplodeDlg.h.

CORBA::Long BlocksGUI_ExplodeDlg::myNbBlocks [private]

Definition at line 70 of file BlocksGUI_ExplodeDlg.h.

GEOM::GEOM_Object_var BlocksGUI_ExplodeDlg::myObject [private]

Definition at line 71 of file BlocksGUI_ExplodeDlg.h.

Definition at line 73 of file BlocksGUI_ExplodeDlg.h.


The documentation for this class was generated from the following files: