Version: 6.3.1
Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes

StdMeshersGUI_ObjectReferenceParamWdg Class Reference

Widget controlling hypothesis parameter that is an object reference. More...

#include <StdMeshersGUI_ObjectReferenceParamWdg.h>

Inheritance diagram for StdMeshersGUI_ObjectReferenceParamWdg:
Inheritance graph
[legend]

Public Slots

void activateSelection ()
 Activates selection (if not yet done), emits selectionActivated()
void deactivateSelection ()
 SLOT: stop treating selection changes.

Signals

void selectionActivated ()
 Emitted when selection is activated.
void contentModified ()

Public Member Functions

 StdMeshersGUI_ObjectReferenceParamWdg (SUIT_SelectionFilter *filter, QWidget *parent, bool multiSelection=false, bool stretch=true)
 Constructor initialized by filter.
 StdMeshersGUI_ObjectReferenceParamWdg (MeshObjectType objType, QWidget *parent, bool multiSelection=false)
 Constructor initialized by object type.
 ~StdMeshersGUI_ObjectReferenceParamWdg ()
 Destructor.
void SetObject (CORBA::Object_ptr obj)
 Initialize selected object name.
void SetObjects (SMESH::string_array_var &objEntries)
 Initialize selected objects.
template<class TInterface >
TInterface::_var_type GetObject (unsigned i=0) const
int NbObjects () const
QString GetValue () const
bool IsObjectSelected (unsigned i=0) const
void AvoidSimultaneousSelection (StdMeshersGUI_ObjectReferenceParamWdg *other)
 Connect selection slots.
void SetDefaultText (QString defaultText="", QString styleSheet="")

Private Slots

void onSelectionDone ()
 Takes selected object.

Private Member Functions

void init ()
 Create a leayout, initialize fields.

Private Attributes

bool myMultiSelection
std::vector< CORBA::Object_var > myObjects
SUIT_SelectionFiltermyFilter
bool mySelectionActivated
bool myStretchActivated
SMESHGUImySMESHGUI
LightApp_SelectionMgr * mySelectionMgr
QLineEdit * myObjNameLineEdit
QPushButton * mySelButton
QString myParamValue
QString myEmptyText
QString myEmptyStyleSheet

Detailed Description

Widget controlling hypothesis parameter that is an object reference.

Definition at line 51 of file StdMeshersGUI_ObjectReferenceParamWdg.h.


Constructor & Destructor Documentation

StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg ( SUIT_SelectionFilter f,
QWidget parent,
bool  multiSelection = false,
bool  stretch = true 
)

Constructor initialized by filter.

Parameters:
f- object filter

Definition at line 59 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

  : QWidget( parent ), myMultiSelection( multiSelection )
{
  myFilter = f;
  myStretchActivated = stretch;
  init();
}
StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg ( MeshObjectType  objType,
QWidget parent,
bool  multiSelection = false 
)

Constructor initialized by object type.

Parameters:
MeshObjectType- type of object to select

Definition at line 75 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

  : QWidget( parent ), myMultiSelection( multiSelection )
{
  myFilter = new SMESH_TypeFilter( objType );
  init();
}
StdMeshersGUI_ObjectReferenceParamWdg::~StdMeshersGUI_ObjectReferenceParamWdg ( )

Destructor.

Definition at line 87 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References myFilter, and mySelectionMgr.

{
  if ( myFilter )
  {
    mySelectionMgr->removeFilter( myFilter );
    delete myFilter;
  }
}

Member Function Documentation

void StdMeshersGUI_ObjectReferenceParamWdg::activateSelection ( ) [slot]

Activates selection (if not yet done), emits selectionActivated()

SLOT: Installs selection filter that is not done automatically.

Useful to deactivate one Object Reference param widget when an other one is activated

Definition at line 143 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References SMESH.GetViewWindow(), myFilter, mySelButton, mySelectionActivated, mySelectionMgr, mySMESHGUI, onSelectionDone(), and selectionActivated().

Referenced by init(), and StdMeshersGUI_StdHypothesisCreator.retrieveParams().

{
  if ( !mySelectionActivated && mySelectionMgr )
  {
    mySelectionActivated = true;
    mySelectionMgr->clearFilters();
    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
      aViewWindow->SetSelectionMode(ActorSelection);
    if ( myFilter )
      mySelectionMgr->installFilter( myFilter );
    connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
  }
  emit selectionActivated();
  onSelectionDone();

  mySelButton->setChecked( mySelectionActivated );
}
void StdMeshersGUI_ObjectReferenceParamWdg::AvoidSimultaneousSelection ( StdMeshersGUI_ObjectReferenceParamWdg other)

Connect selection slots.

Parameters:
other- another StdMeshersGUI_ObjectReferenceParamWdg

Definition at line 184 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

Referenced by StdMeshersGUI_StdHypothesisCreator.retrieveParams().

{
  connect(other, SIGNAL(selectionActivated()), this, SLOT(deactivateSelection()));
  connect(this, SIGNAL(selectionActivated()), other, SLOT(deactivateSelection()));
}
void StdMeshersGUI_ObjectReferenceParamWdg.contentModified ( ) [signal]

Referenced by SetObject(), and SetObjects().

void StdMeshersGUI_ObjectReferenceParamWdg::deactivateSelection ( ) [slot]

SLOT: stop treating selection changes.

Definition at line 167 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References myFilter, mySelButton, mySelectionActivated, and mySelectionMgr.

{
  mySelectionActivated = false;
  disconnect(mySelectionMgr, 0, this, 0 );
  mySelectionMgr->removeFilter( myFilter );

  mySelButton->setChecked( mySelectionActivated );
}
template<class TInterface >
TInterface::_var_type StdMeshersGUI_ObjectReferenceParamWdg.GetObject ( unsigned  i = 0) const

Definition at line 70 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

                                                               {
    if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]);
    return TInterface::_nil();
  }
QString StdMeshersGUI_ObjectReferenceParamWdg.GetValue ( ) const
void StdMeshersGUI_ObjectReferenceParamWdg::init ( ) [private]

Create a leayout, initialize fields.

Definition at line 103 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References activateSelection(), SMESH.GetResourceMgr(), SMESH.GetSelectionMgr(), SMESHGUI.GetSMESHGUI(), myEmptyStyleSheet, myEmptyText, myObjNameLineEdit, myParamValue, mySelButton, mySelectionActivated, mySelectionMgr, mySMESHGUI, myStretchActivated, and SPACING.

{
  QHBoxLayout* aHBox = new QHBoxLayout(this);

  aHBox->setMargin(0);
  aHBox->setSpacing(SPACING);

  mySMESHGUI     = SMESHGUI::GetSMESHGUI();
  mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI );
  mySelectionActivated = false;
  myParamValue = "";
  myEmptyText = "";
  myEmptyStyleSheet ="";

  SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
  QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));

  mySelButton = new QPushButton(this);
  mySelButton->setIcon(iconSlct);
  mySelButton->setCheckable( true );

  myObjNameLineEdit = new QLineEdit(this);
  myObjNameLineEdit->setReadOnly(true);
  myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet);

  aHBox->addWidget( mySelButton );
  aHBox->addWidget( myObjNameLineEdit );
  if (myStretchActivated){
    aHBox->addStretch();
  }

  connect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
}
bool StdMeshersGUI_ObjectReferenceParamWdg.IsObjectSelected ( unsigned  i = 0) const

Definition at line 79 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

Referenced by StdMeshersGUI_StdHypothesisCreator.checkParams().

  { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); }
int StdMeshersGUI_ObjectReferenceParamWdg.NbObjects ( ) const

Definition at line 75 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

{ return myObjects.size(); }
void StdMeshersGUI_ObjectReferenceParamWdg::onSelectionDone ( ) [private, slot]

Takes selected object.

Definition at line 263 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References Handle(), SMESH.IObjectToObject(), myMultiSelection, mySelectionActivated, mySelectionMgr, SetObject(), and SetObjects().

Referenced by activateSelection().

{
  if ( mySelectionActivated ) {
    CORBA::Object_var obj;
    SALOME_ListIO aList;
    mySelectionMgr->selectedObjects(aList);
    if (aList.Extent() == 1)
    {
      obj = SMESH::IObjectToObject( aList.First() );
      SetObject( obj.in() );
    }
    else if (myMultiSelection)
    {
      SMESH::string_array_var objIds = new SMESH::string_array;
      objIds->length( aList.Extent());
      SALOME_ListIteratorOfListIO io( aList );
      int i = 0;
      for ( ; io.More(); io.Next(), ++i )
      {
        Handle(SALOME_InteractiveObject) anIO = io.Value();
        if ( anIO->hasEntry() )
          objIds[i] = anIO->getEntry();
        else
          i--;
      }
      objIds->length(i);
      SetObjects( objIds );
    }
  }
}
void StdMeshersGUI_ObjectReferenceParamWdg.selectionActivated ( ) [signal]

Emitted when selection is activated.

Useful to deactivate one Object Reference param widget when an other one is activated

Referenced by activateSelection().

void StdMeshersGUI_ObjectReferenceParamWdg::SetDefaultText ( QString  defaultText = "",
QString  styleSheet = "" 
)

Definition at line 294 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References myEmptyStyleSheet, myEmptyText, and myObjNameLineEdit.

{
  myEmptyText = defaultText;
  myEmptyStyleSheet = styleSheet;
  myObjNameLineEdit->setText( myEmptyText );
  myObjNameLineEdit->setStyleSheet( myEmptyStyleSheet);
}
void StdMeshersGUI_ObjectReferenceParamWdg::SetObject ( CORBA::Object_ptr  obj)

Initialize selected object name.

Parameters:
obj- the current object

Definition at line 197 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References _PTR(), contentModified(), myEmptyStyleSheet, myEmptyText, myObjects, myObjNameLineEdit, myParamValue, and ex21_lamp.name.

Referenced by StdMeshersGUI_StdHypothesisCreator.checkParams(), and onSelectionDone().

{
  myObjects.clear();
  myObjNameLineEdit->setText( myEmptyText );
  myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet);
  myParamValue = "";

  _PTR(SObject) sobj;
  if ( !CORBA::is_nil( obj ))
    sobj = SMESH::FindSObject (obj);
  if ( sobj ) {
    std::string name = sobj->GetName();
    myObjNameLineEdit->setText( name.c_str() );
    myObjNameLineEdit->setStyleSheet("");
    myObjects.push_back( CORBA::Object::_duplicate( obj ));
    myParamValue = sobj->GetID().c_str();
    emit contentModified();
  }
}
void StdMeshersGUI_ObjectReferenceParamWdg::SetObjects ( SMESH::string_array_var &  objects)

Initialize selected objects.

Parameters:
objects- entries of objects

Definition at line 224 of file StdMeshersGUI_ObjectReferenceParamWdg.cxx.

References _PTR(), contentModified(), myEmptyStyleSheet, myEmptyText, myObjects, myObjNameLineEdit, myParamValue, ex21_lamp.name, and SMESH.SObjectToObject().

Referenced by onSelectionDone().

{
  myObjects.clear();
  myObjNameLineEdit->setText( myEmptyText );
  myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet);
  myParamValue = "";
  bool selChanged = false;
  
  for ( unsigned i = 0; i < objects->length(); ++i )
  {
    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
    _PTR(SObject) aSObj = aStudy->FindObjectID(objects[i].in());
    CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
    if ( !CORBA::is_nil( anObj )) {
      std::string name = aSObj->GetName();
      QString text = myObjNameLineEdit->text();
      if ( text != myEmptyText )
        text += " ";
      else
        text = "";
      text += name.c_str();
      myObjNameLineEdit->setText( text );
      myObjNameLineEdit->setStyleSheet("");
      myObjects.push_back( anObj );
      myParamValue += " ";
      myParamValue += objects[i];
      selChanged = true;
    }
  }
  if (selChanged)
    emit contentModified();
}

Field Documentation

Definition at line 114 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

Referenced by onSelectionDone().

std::vector<CORBA::Object_var> StdMeshersGUI_ObjectReferenceParamWdg.myObjects [private]

Definition at line 115 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

Referenced by SetObject(), and SetObjects().

Definition at line 126 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

Referenced by init(), SetObject(), and SetObjects().

LightApp_SelectionMgr* StdMeshersGUI_ObjectReferenceParamWdg.mySelectionMgr [private]

Definition at line 121 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

Referenced by activateSelection(), and init().

Definition at line 119 of file StdMeshersGUI_ObjectReferenceParamWdg.h.

Referenced by init().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS