2013-04-01 19:05:47 +06:00
|
|
|
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2005-08-23 14:55:09 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2005-08-23 14:55:09 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License.
|
2005-08-23 14:55:09 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// File : SMESHGUI_SelectionOp.h
|
|
|
|
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
|
|
|
|
//
|
|
|
|
#ifndef SMESHGUI_SELECTIONOP_H
|
|
|
|
#define SMESHGUI_SELECTIONOP_H
|
2005-08-23 14:55:09 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SMESH includes
|
2008-03-07 12:47:05 +05:00
|
|
|
#include "SMESH_SMESHGUI.hxx"
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include "SMESHGUI_Operation.h"
|
|
|
|
#include "SMESHGUI_Dialog.h"
|
|
|
|
|
|
|
|
// SALOME GUI includes
|
2005-08-23 14:55:09 +06:00
|
|
|
#include <SVTK_Selection.h>
|
|
|
|
#include <SALOME_InteractiveObject.hxx>
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// IDL includes
|
2005-08-23 14:55:09 +06:00
|
|
|
#include <SALOMEconfig.h>
|
2009-02-17 10:27:49 +05:00
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
class SUIT_SelectionFilter;
|
|
|
|
class TColStd_MapOfInteger;
|
|
|
|
class SVTK_ViewWindow;
|
|
|
|
class SVTK_Selector;
|
|
|
|
class SMESH_Actor;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Class : SMESHGUI_SelectionOp
|
|
|
|
Description : Base operation for all operations using object selection in viewer or objectbrowser
|
2005-11-03 13:38:17 +05:00
|
|
|
through common widgets created by LightApp_Dialog::createObject
|
2005-08-23 14:55:09 +06:00
|
|
|
*/
|
2008-03-07 12:47:05 +05:00
|
|
|
class SMESHGUI_EXPORT SMESHGUI_SelectionOp : public SMESHGUI_Operation
|
2005-08-23 14:55:09 +06:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2009-02-17 10:27:49 +05:00
|
|
|
typedef QList<int> IdList; //! List of node or element ids
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
public:
|
|
|
|
SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
|
|
|
|
virtual ~SMESHGUI_SelectionOp();
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
static void extractIds( const QStringList&, IdList&, const QChar );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
protected:
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
Object,
|
|
|
|
MeshNode,
|
|
|
|
MeshElement
|
|
|
|
|
|
|
|
} EntityType;
|
|
|
|
/*!
|
|
|
|
This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements,
|
|
|
|
because node end element ids may overlap
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void startOperation();
|
|
|
|
virtual void commitOperation();
|
|
|
|
virtual void abortOperation();
|
|
|
|
virtual void selectionDone();
|
|
|
|
|
|
|
|
//! sets the dialog widgets to state just after operation start
|
|
|
|
virtual void initDialog();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Creates filter being used when certain object selection widget is active
|
|
|
|
* If no filter must be used, then function must return 0
|
|
|
|
* if id is negative, then function must return filter for common using independently of active widget
|
|
|
|
*/
|
|
|
|
virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
|
|
|
|
|
|
|
//! Remove only filters set by this operation (they are in map myFilters )
|
2009-02-17 10:27:49 +05:00
|
|
|
void removeCustomFilters();
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Return what selection mode is set in VTK viewer
|
2009-02-17 10:27:49 +05:00
|
|
|
Selection_Mode selectionMode() const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Set selection mode in VTK viewer
|
2009-02-17 10:27:49 +05:00
|
|
|
void setSelectionMode( const Selection_Mode );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Hilight object in VTK viewer
|
2009-02-17 10:27:49 +05:00
|
|
|
void highlight( const Handle( SALOME_InteractiveObject )&,
|
2012-08-09 16:03:55 +06:00
|
|
|
const bool, const bool = true );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Select some nodes or elements in VTK
|
2009-02-17 10:27:49 +05:00
|
|
|
void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
|
2012-08-09 16:03:55 +06:00
|
|
|
const TColStd_MapOfInteger&, const bool isModeShift);
|
2005-08-23 14:55:09 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
SVTK_ViewWindow* viewWindow() const;
|
|
|
|
SVTK_Selector* selector() const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Get names, types and ids of selected objects
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual void selected( QStringList&,
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESHGUI_Dialog::TypesList&, QStringList& ) const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Find type by id
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual int typeById( const QString&, const EntityType ) const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Char using to divide <entry> and <id> in string id representation. By default, '#'
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual QChar idChar() const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Try to find in certain object selection widget selected node or element ids and return it
|
2009-02-17 10:27:49 +05:00
|
|
|
void selectedIds( const int, IdList& ) const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Find in QStringList correct node or element ids representation and append integer(id) to IdList
|
2009-02-17 10:27:49 +05:00
|
|
|
void extractIds( const QStringList&, IdList& ) const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Return selected mesh if selection mode isn't ActorSelection and only one object is selected
|
2009-02-17 10:27:49 +05:00
|
|
|
SMESH::SMESH_Mesh_var mesh() const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Return actor according to selected mesh if selection mode isn't ActorSelection
|
2009-02-17 10:27:49 +05:00
|
|
|
SMESH_Actor* actor() const;
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
//! Installs filter corresponding to certain object selection widget
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual void onActivateObject( int );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
//! Removes filter corresponding to certain object selection widget
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual void onDeactivateObject( int );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Empty default implementation. In successors it may be used for more advanced selection checking.
|
|
|
|
* This slot is connected to signal when the selection changed in some object selection widget
|
|
|
|
*/
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual void onSelectionChanged( int );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
/*! Default implementation allowing user to edit selected ids "by hands".
|
|
|
|
In order to run default mechanism, you must set for some
|
|
|
|
object selection widget the "name indication" to "ListOfNames",
|
|
|
|
"read only" state to false and connect the dialog's signal "objectChanged"
|
|
|
|
to this slot
|
|
|
|
Warning: this mechanism can process only integer ids, NOT MESH OR GROUP NAMES!!!
|
|
|
|
*/
|
2009-02-17 10:27:49 +05:00
|
|
|
virtual void onTextChanged( int, const QStringList& );
|
2005-08-23 14:55:09 +06:00
|
|
|
|
|
|
|
private:
|
|
|
|
typedef QMap<int, SUIT_SelectionFilter*> Filters;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Filters myFilters;
|
|
|
|
Selection_Mode myDefSelectionMode, myOldSelectionMode;
|
|
|
|
};
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#endif // SMESHGUI_SELECTIONOP_H
|