Files
create/src/Gui/SoFCUnifiedSelection.h
2018-10-26 00:39:15 +02:00

221 lines
6.7 KiB
C++

/***************************************************************************
* Copyright (c) 2005 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_SOFCUNIFIEDSELECTION_H
#define GUI_SOFCUNIFIEDSELECTION_H
#include <Inventor/nodes/SoSubNode.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/fields/SoSFColor.h>
#include <Inventor/fields/SoSFEnum.h>
#include <Inventor/fields/SoSFString.h>
#include <Inventor/nodes/SoLightModel.h>
#include <Inventor/lists/SoPathList.h>
#include "View3DInventorViewer.h"
#include <list>
class SoFullPath;
class SoPickedPoint;
class SoDetail;
namespace Gui {
class Document;
/** Unified Selection node
* This is the new selection node for the 3D Viewer which will
* gradually remove all the low level selection nodes in the view
* provider. The handling of the highlighting and the selection will
* be unified here.
* \author Jürgen Riegel
*/
class GuiExport SoFCUnifiedSelection : public SoSeparator {
typedef SoSeparator inherited;
SO_NODE_HEADER(Gui::SoFCUnifiedSelection);
public:
static void initClass(void);
static void finish(void);
SoFCUnifiedSelection(void);
void applySettings();
enum HighlightModes {
AUTO, ON, OFF
};
const char* getFileFormatName(void) const;
void write(SoWriteAction * action);
int getNumSelected(void) const;
const SoPathList* getList(void) const;
SoSFColor colorHighlight;
SoSFColor colorSelection;
SoSFEnum highlightMode;
SoSFEnum selectionMode;
SoSFBool selectionRole;
virtual void doAction(SoAction *action);
//virtual void GLRender(SoGLRenderAction * action);
virtual void handleEvent(SoHandleEventAction * action);
virtual void GLRenderBelowPath(SoGLRenderAction * action);
//virtual void GLRenderInPath(SoGLRenderAction * action);
//static void turnOffCurrentHighlight(SoGLRenderAction * action);
bool checkSelectionStyle(int type, ViewProvider *vp);
friend class View3DInventorViewer;
protected:
virtual ~SoFCUnifiedSelection();
//virtual void redrawHighlighted(SoAction * act, SbBool flag);
//virtual SbBool readInstance(SoInput * in, unsigned short flags);
/** @name Nodes selection.
* The SoBoxSelectionRenderAction uses these nodes to draw a
* bounding box.
*/
//@{
void addPath(SoPath * path);
void removePath(const int which);
SoPath * copyFromThis(const SoPath * path) const;
SoPath * searchNode(SoNode * node) const;
int findPath(const SoPath * path) const;
void select(SoNode * node);
void deselect(const SoPath * path);
void deselect(SoNode * node);
//@}
private:
//static void turnoffcurrent(SoAction * action);
//void setOverride(SoGLRenderAction * action);
//SbBool isHighlighted(SoAction *action);
//SbBool preRender(SoGLRenderAction *act, GLint &oldDepthFunc);
static int getPriority(const SoPickedPoint* p);
const SoPickedPoint* getPickedPoint(SoHandleEventAction*) const;
Gui::Document *pcDocument;
static SoFullPath * currenthighlight;
SoPathList selectionList;
SbBool highlighted;
SbBool setPreSelection;
// -1 = not handled, 0 = not selected, 1 = selected
int32_t preSelection;
SoColorPacker colorpacker;
};
/**
* @author Werner Mayer
*/
class GuiExport SoHighlightElementAction : public SoAction
{
SO_ACTION_HEADER(SoHighlightElementAction);
public:
SoHighlightElementAction ();
~SoHighlightElementAction();
void setHighlighted(SbBool);
SbBool isHighlighted() const;
void setColor(const SbColor&);
const SbColor& getColor() const;
void setElement(const SoDetail*);
const SoDetail* getElement() const;
static void initClass();
protected:
virtual void beginTraversal(SoNode *node);
private:
static void callDoAction(SoAction *action,SoNode *node);
private:
SbBool _highlight;
SbColor _color;
const SoDetail* _det;
};
/**
* @author Werner Mayer
*/
class GuiExport SoSelectionElementAction : public SoAction
{
SO_ACTION_HEADER(SoSelectionElementAction);
public:
enum Type {None, Append, Remove, All};
SoSelectionElementAction (Type);
~SoSelectionElementAction();
Type getType() const;
void setColor(const SbColor&);
const SbColor& getColor() const;
void setElement(const SoDetail*);
const SoDetail* getElement() const;
static void initClass();
protected:
virtual void beginTraversal(SoNode *node);
private:
static void callDoAction(SoAction *action,SoNode *node);
private:
Type _type;
SbColor _color;
const SoDetail* _det;
};
/**
* @author Werner Mayer
*/
class GuiExport SoVRMLAction : public SoAction
{
SO_ACTION_HEADER(SoVRMLAction);
public:
SoVRMLAction();
~SoVRMLAction();
void setOverrideMode(SbBool);
SbBool isOverrideMode() const;
static void initClass();
private:
SbBool overrideMode;
std::list<int> bindList;
static void callDoAction(SoAction *action,SoNode *node);
};
} // namespace Gui
#endif // !GUI_SOFCUNIFIEDSELECTION_H