geom/src/GEOMBase/GEOMBase_Helper.h

235 lines
10 KiB
C
Raw Normal View History

2019-02-14 15:09:13 +05:00
// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +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-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +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-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2013-04-01 18:25:01 +06:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : GEOMBase_Helper.h
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
2013-02-12 17:35:16 +06:00
2004-12-01 15:39:14 +05:00
#ifndef GEOMBASE_HELPER_H
#define GEOMBASE_HELPER_H
#include "GEOM_GEOMBase.hxx"
2012-08-09 13:58:02 +06:00
#include "GEOM_GenericObjPtr.h"
2009-02-13 17:16:39 +05:00
#include <GEOM_Displayer.h>
#include <SALOME_ListIO.hxx>
2004-12-01 15:39:14 +05:00
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(GEOM_Gen)
2016-02-24 18:45:13 +05:00
#include <TColStd_MapOfInteger.hxx>
2009-02-13 17:16:39 +05:00
#include <QString>
#include <QMap>
2004-12-01 15:39:14 +05:00
#include <list>
2004-12-01 15:39:14 +05:00
typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
class SalomeApp_Study;
class SUIT_Desktop;
class SUIT_ViewWindow;
2009-02-13 17:16:39 +05:00
class SALOME_Prs;
2004-12-01 15:39:14 +05:00
class GEOM_Operation;
//================================================================
// Class : GEOMBase_Helper
2013-02-12 17:35:16 +06:00
// Description : Helper class for dialog box development, can be used as
2004-12-01 15:39:14 +05:00
// the second base class for dialog boxes. Contains convenient methods
// performing common operations (display/erase, selection activation,
// publication in a study, transaction management)
//================================================================
class GEOMBASE_EXPORT GEOMBase_Helper
2004-12-01 15:39:14 +05:00
{
public:
GEOMBase_Helper( SUIT_Desktop* );
2004-12-01 15:39:14 +05:00
virtual ~GEOMBase_Helper();
2013-10-30 22:50:50 +06:00
static SUIT_ViewWindow* getActiveView();
2004-12-01 15:39:14 +05:00
protected:
typedef std::list<SALOME_Prs*> PrsList;
2004-12-01 15:39:14 +05:00
static GEOM::GEOM_Gen_ptr getGeomEngine();
void display ( const ObjectList&, const bool = true );
void display ( GEOM::GEOM_Object_ptr, const bool = true );
void erase ( const ObjectList&, const bool = true );
void erase ( GEOM::GEOM_Object_ptr, const bool = true );
void redisplay ( const ObjectList&, const bool = true, const bool = true );
void redisplay ( GEOM::GEOM_Object_ptr, const bool = true, const bool = true );
2012-08-09 13:58:02 +06:00
virtual void displayPreview ( const bool display,
2013-02-12 17:35:16 +06:00
const bool activate = false,
2004-12-01 15:39:14 +05:00
const bool update = true,
const bool toRemoveFromEngine = true,
2013-02-12 17:35:16 +06:00
const double lineWidth = -1,
const int displayMode = -1,
const int color = -1,
const bool append = false );
2004-12-01 15:39:14 +05:00
// This is the easiest way to show preview. It is based on execute() method.
// It removes temporary GEOM::GEOM_Objects automatically.
2013-02-12 17:35:16 +06:00
virtual void displayPreview ( GEOM::GEOM_Object_ptr obj,
const bool append = false,
const bool activate = false,
2004-12-01 15:39:14 +05:00
const bool update = true,
2013-02-12 17:35:16 +06:00
const double lineWidth = -1,
const int displayMode = -1,
const int color = -1 );
2013-02-12 17:35:16 +06:00
void displayPreview ( const SALOME_Prs* prs,
const bool append = false,
2012-08-09 13:58:02 +06:00
const bool = true );
2004-12-01 15:39:14 +05:00
void erasePreview ( const bool = true );
const PrsList& getPreview() const { return myPreview; }
void localSelection( const ObjectList&, const std::list<int> );
2004-12-01 15:39:14 +05:00
void localSelection( const ObjectList&, const int );
void localSelection( GEOM::GEOM_Object_ptr, const std::list<int> );
2004-12-01 15:39:14 +05:00
void localSelection( GEOM::GEOM_Object_ptr, const int );
void localSelection( const std::list<int> );
void localSelection( const int );
2004-12-01 15:39:14 +05:00
void activate( const int );
void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
void globalSelection( const TColStd_MapOfInteger&, const bool = false );
2009-02-13 17:16:39 +05:00
void globalSelection( const TColStd_MapOfInteger&, const QList<int>& ,const bool = false );
2004-12-01 15:39:14 +05:00
void updateViewer ();
void prepareSelection( const ObjectList&, const int );
void prepareSelection( GEOM::GEOM_Object_ptr, const int );
2013-02-12 17:35:16 +06:00
QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName );
2004-12-01 15:39:14 +05:00
bool openCommand ();
bool abortCommand ();
bool commitCommand ( const char* = 0 );
bool hasCommand () const;
void updateObjBrowser() const;
SalomeApp_Study* getStudy () const;
bool checkViewWindow ();
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
bool onAccept( const bool publish = true, const bool useTransaction = true, bool erasePreviewFlag = true);
2004-12-01 15:39:14 +05:00
// This method should be called from "OK" button handler.
2013-02-12 17:35:16 +06:00
// <publish> == true means that objects returned by execute()
2004-12-01 15:39:14 +05:00
// should be published in a study.
void showError();
// Shows a message box with information about an error taken from getOperation()->GetErrorCode()
2004-12-01 15:39:14 +05:00
void showError( const QString& msg );
// Shows a error message followed by <msg>
GEOM::GEOM_IOperations_ptr getOperation();
// If <myOperation> is nil --> calls createOperation() and put the result
// into <myOperation> and returns it;
// otherwise, simply returns <myOperation>
inline void setPrefix( const QString& prefix ) { myPrefix = prefix; }
QString getPrefix( GEOM::GEOM_Object_ptr = GEOM::GEOM_Object::_nil() ) const;
2013-02-12 17:35:16 +06:00
bool selectObjects( ObjectList& objects );
2013-02-12 17:35:16 +06:00
// Selects list of objects
2004-12-01 15:39:14 +05:00
////////////////////////////////////////////////////////////////////////////
// Virtual methods, to be redefined in dialog classes
////////////////////////////////////////////////////////////////////////////
virtual GEOM::GEOM_IOperations_ptr createOperation();
2013-02-12 17:35:16 +06:00
// This method should be redefined in dialog boxes so as to return
2004-12-01 15:39:14 +05:00
// proper GEOM_IOperation interface.
// Returns nil reference by default
virtual bool isValid( QString& msg );
// Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
virtual bool execute( ObjectList& objects );
2013-02-12 17:35:16 +06:00
// This method is called by onAccept().
// It should perform the required operation and put all new or modified objects into
// <objects> argument.Should return <false> if some error occurs during its execution.
2004-12-01 15:39:14 +05:00
2017-06-13 14:57:14 +05:00
virtual void restoreSubShapes( SALOMEDS::SObject_ptr theSObject );
2009-02-13 17:16:39 +05:00
// This method is called by addInStudy().
2004-12-01 15:39:14 +05:00
virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr theObj );
// This method is called by addInStudy(). It should return a father object
// for <theObj> or a nil reference if <theObj> should be published
// as a top-level object.
2013-02-12 17:35:16 +06:00
virtual QString getNewObjectName (int CurrObj = -1) const;
virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const;
2012-08-09 13:58:02 +06:00
virtual bool extractPrefix() const;
virtual void addSubshapesToStudy();
virtual QList<GEOM::GeomObjPtr> getSourceObjects();
2009-02-13 17:16:39 +05:00
GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName );
2012-08-09 13:58:02 +06:00
GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, int theIndex );
// These methods are used to find published sub-object (sub-shape) in the parent object (main shape)
2012-08-09 13:58:02 +06:00
GEOM::GeomObjPtr getSelected( TopAbs_ShapeEnum type );
GEOM::GeomObjPtr getSelected( const QList<TopAbs_ShapeEnum>& types );
QList<GEOM::GeomObjPtr> getSelected( TopAbs_ShapeEnum type, int count, bool strict = true );
QList<GEOM::GeomObjPtr> getSelected( const QList<TopAbs_ShapeEnum>& types, int count, bool strict = true );
2004-12-01 15:39:14 +05:00
void hideSourceObjects( QList<GEOM::GeomObjPtr> theObjectList );
2004-12-01 15:39:14 +05:00
void SetIsPreview(const bool thePreview) {isPreview = thePreview;}
bool IsPreview() {return isPreview;}
GEOM_Displayer* getDisplayer();
SUIT_Desktop* getDesktop() const;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
virtual void setIsApplyAndClose( const bool theFlag );
virtual bool isApplyAndClose() const;
virtual void setIsOptimizedBrowsing( const bool theFlag );
virtual bool isOptimizedBrowsing() const;
2013-02-12 17:35:16 +06:00
2012-08-09 13:58:02 +06:00
virtual void setIsWaitCursorEnabled( const bool theFlag ) {myIsWaitCursorEnabled = theFlag;}
virtual bool isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;}
virtual void setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; }
virtual bool isDisableBrowsing() const { return myIsDisableBrowsing; }
2013-02-12 17:35:16 +06:00
virtual void setIsDisplayResult( const bool theFlag ) {myIsDisplayResult = theFlag; }
virtual bool isDisplayResult() const { return myIsDisplayResult; }
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
private:
2012-08-09 13:58:02 +06:00
QString getEntry( GEOM::GEOM_Object_ptr ) const;
2004-12-01 15:39:14 +05:00
void clearShapeBuffer( GEOM::GEOM_Object_ptr );
private:
PrsList myPreview;
GEOM_Displayer* myDisplayer;
GEOM_Operation* myCommand;
GEOM::GEOM_IOperations_var myOperation;
SUIT_ViewWindow* myViewWindow;
2004-12-01 15:39:14 +05:00
QString myPrefix;
bool isPreview;
SALOME_ListIO mySelected;
SUIT_Desktop* myDesktop;
2012-08-09 13:58:02 +06:00
bool myIsApplyAndClose;
bool myIsOptimizedBrowsing;
bool myIsWaitCursorEnabled;
2013-02-12 17:35:16 +06:00
bool myIsDisableBrowsing; //This flag enable/disable selection
2012-08-09 13:58:02 +06:00
//in the Object Browser newly created objects.
2013-02-12 17:35:16 +06:00
bool myIsDisplayResult; //This flag display/hide newly created objects.
2004-12-01 15:39:14 +05:00
};
2009-02-13 17:16:39 +05:00
#endif // GEOMBASE_HELPER_H