FreeCAD C++
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SketcherGui::ViewProviderSketch Class Reference

#include <Mod/Sketcher/Gui/ViewProviderSketch.h>

Detailed Description

The Sketch ViewProvider This class handles mainly the drawing and editing of the sketch. It draws the geometry and the constraints applied to the sketch. It uses the class DrawSketchHandler to facilitate the creation of new geometry while editing.

Classes

struct  constrIconQueueItem
 Internal type used for drawing constraint icons. More...
 

Public Member Functions

 ViewProviderSketch ()
 constructor
 
virtual ~ViewProviderSketch ()
 destructor
 
void drawConstraintIcons ()
 Draw all constraint icons. More...
 
void draw (bool temp=false, bool rebuildinformationlayer=true)
 
void drawEdit (const std::vector< Base::Vector2d > &EditCurve)
 draw the edit curve
 
bool isSelectable (void) const
 Is the view provider selectable.
 
virtual void onSelectionChanged (const Gui::SelectionChanges &msg)
 Observer message from the Selection.
 
void showRestoreInformationLayer ()
 Show/Hide nodes from information layer.
 
void updateVirtualSpace (void)
 updates the visibility of the virtual space
 
handler control
void activateHandler (DrawSketchHandler *newHandler)
 sets an DrawSketchHandler in control
 
void purgeHandler (void)
 removes the active handler
 
void setAxisPickStyle (bool on)
 set the pick style of the sketch coordinate axes
 
helper functions
void getCoordsOnSketchPlane (double &u, double &v, const SbVec3f &point, const SbVec3f &normal)
 give the coordinates of a line on the sketch plane in sketcher (2D) coordinates
 
void getProjectingLine (const SbVec2s &, const Gui::View3DInventorViewer *viewer, SbLine &) const
 give projecting line of position
 
bool detectPreselection (const SoPickedPoint *Point, const Gui::View3DInventorViewer *viewer, const SbVec2s &cursorPos)
 helper to detect preselection
 
std::set< int > detectPreselectionConstr (const SoPickedPoint *Point, const Gui::View3DInventorViewer *viewer, const SbVec2s &cursorPos)
 Helper for detectPreselection(), for constraints only.
 
void centerSelection ()
 
void doBoxSelection (const SbVec2s &startPos, const SbVec2s &endPos, const Gui::View3DInventorViewer *viewer)
 box selection method
 
void updateColor (void)
 helper change the color of the sketch according to selection and solver status
 
Sketcher::SketchObject * getSketchObject (void) const
 get the pointer to the sketch document object
 
void snapToGrid (double &x, double &y)
 snap points x,y (mouse coordinates) onto grid if enabled
 
void moveConstraint (int constNum, const Base::Vector2d &toPos)
 moves a selected constraint
 
Base::Vector3d seekConstraintPosition (const Base::Vector3d &origPos, const Base::Vector3d &norm, const Base::Vector3d &dir, float step, const SoNode *constraint)
 finds a free position for placing a constraint icon
 
float getScaleFactor ()
 
int getPreselectPoint (void) const
 
int getPreselectCurve (void) const
 
int getPreselectCross (void) const
 
base class implementer
virtual void attach (App::DocumentObject *)
 
virtual void updateData (const App::Property *)
 
virtual void setupContextMenu (QMenu *menu, QObject *receiver, const char *member)
 
virtual bool onDelete (const std::vector< std::string > &)
 is called when the Provider is in edit and a deletion request occurs
 
virtual bool doubleClicked (void)
 is called by the tree if the user double click on the object
 
virtual bool mouseMove (const SbVec2s &pos, Gui::View3DInventorViewer *viewer)
 is called when the Provider is in edit and the mouse is moved
 
virtual bool keyPressed (bool pressed, int key)
 is called when the Provider is in edit and a key event ocours. Only ESC ends edit.
 
virtual bool mouseButtonPressed (int Button, bool pressed, const SbVec2s &cursorPos, const Gui::View3DInventorViewer *viewer)
 is called when the Provider is in edit and the mouse is clicked
 
- Public Member Functions inherited from Gui::SelectionObserver
 SelectionObserver ()
 Constructor.
 
void attachSelection ()
 
void detachSelection ()
 

Public Attributes

boost::signals2::signal< void()> signalConstraintsChanged
 signals if the constraints list has changed
 
boost::signals2::signal< void(QString msg)> signalSetUp
 signals if the sketch has been set up
 
boost::signals2::signal< void(QString msg)> signalSolved
 signals if the sketch has been solved
 
boost::signals2::signal< void()> signalElementsChanged
 signals if the elements list has changed
 

Protected Member Functions

void UpdateSolverInformation (void)
 update solver information based on last solving at SketchObject
 
bool isPointOnSketch (const SoPickedPoint *pp) const
 helper to detect whether the picked point lies on the sketch
 
virtual void onChanged (const App::Property *prop)
 get called by the container whenever a property has been changed
 
void editDoubleClicked (void)
 get called if a subelement is double clicked while editing
 
void createEditInventorNodes (void)
 set up the edition data structure EditData
 
void rebuildConstraintsVisual (void)
 build up the visual of the constraints
 
QString getPresentationString (const Sketcher::Constraint *constraint)
 Return display string for constraint including hiding units if.
 

Protected Attributes

EditData * edit
 pointer to the edit data structure if the ViewProvider is in edit.
 

modus handling

enum  SketchMode {
  STATUS_NONE, STATUS_SELECT_Point, STATUS_SELECT_Edge, STATUS_SELECT_Constraint,
  STATUS_SELECT_Cross, STATUS_SKETCH_DragPoint, STATUS_SKETCH_DragCurve, STATUS_SKETCH_DragConstraint,
  STATUS_SKETCH_UseHandler, STATUS_SKETCH_StartRubberBand, STATUS_SKETCH_UseRubberBand
}
 mode table More...
 
void setSketchMode (SketchMode mode)
 is called by GuiCommands to set the drawing mode
 
SketchMode getSketchMode (void) const
 get the sketch mode
 

Protected helpers for drawing constraint icons

typedef std::vector< constrIconQueueItemIconQueue
 Internal type used for drawing constraint icons.
 
typedef std::pair< QRect, std::set< int > > ConstrIconBB
 For constraint icon bounding boxes.
 
typedef std::vector< ConstrIconBBConstrIconBBVec
 For constraint icon bounding boxes.
 
QString iconTypeFromConstraint (Sketcher::Constraint *constraint)
 
QColor constrColor (int constraintId)
 Returns a QColor object appropriate for constraint with given id. More...
 
int constrColorPriority (int constraintId)
 Used by drawMergedConstraintIcons to decide what color to make icons. More...
 
void combineConstraintIcons (IconQueue iconQueue)
 
void drawTypicalConstraintIcon (const constrIconQueueItem &i)
 Renders an icon for a single constraint and sends it to Coin.
 
void drawMergedConstraintIcons (IconQueue iconQueue)
 Combines multiple constraint icons and sends them to Coin.
 
QImage renderConstrIcon (const QString &type, const QColor &iconColor, const QStringList &labels, const QList< QColor > &labelColors, double iconRotation, std::vector< QRect > *boundingBoxes=NULL, int *vPad=NULL)
 Helper for drawMergedConstraintIcons and drawTypicalConstraintIcon. More...
 
void sendConstraintIconToCoin (const QImage &icon, SoImage *soImagePtr)
 Copies a QImage constraint icon into a SoImage*. More...
 
void clearCoinImage (SoImage *soImagePtr)
 Essentially a version of sendConstraintIconToCoin, with a blank icon.
 
SbVec3s getDisplayedSize (const SoImage *) const
 Returns the size that Coin should display the indicated image at.
 

Member Enumeration Documentation

◆ SketchMode

mode table

Enumerator
STATUS_NONE 

enum value View provider is in neutral.

STATUS_SELECT_Point 

enum value a point was selected.

STATUS_SELECT_Edge 

enum value an edge was selected.

STATUS_SELECT_Constraint 

enum value a constraint was selected.

STATUS_SELECT_Cross 

enum value the base coordinate system was selected.

STATUS_SKETCH_DragPoint 

enum value while dragging a point.

STATUS_SKETCH_DragCurve 

enum value while dragging a curve.

STATUS_SKETCH_DragConstraint 

enum value while dragging a compatible constraint.

STATUS_SKETCH_UseHandler 

enum value a DrawSketchHandler is in control.

STATUS_SKETCH_StartRubberBand 

enum value for initiating a rubber band selection

STATUS_SKETCH_UseRubberBand 

enum value when making a rubber band selection enum value a DrawSketchHandler is in control.

Member Function Documentation

◆ centerSelection()

void SketcherGui::ViewProviderSketch::centerSelection ( )

Look at the center of the bounding of all selected items

◆ constrColor()

QColor SketcherGui::ViewProviderSketch::constrColor ( int  constraintId)
protected

Returns a QColor object appropriate for constraint with given id.

In the case of combined icons, the icon color is chosen based on the constraint with the highest priority from constrColorPriority()

◆ constrColorPriority()

int SketcherGui::ViewProviderSketch::constrColorPriority ( int  constraintId)
protected

Used by drawMergedConstraintIcons to decide what color to make icons.

See constrColor()

◆ draw()

void SketcherGui::ViewProviderSketch::draw ( bool  temp = false,
bool  rebuildinformationlayer = true 
)

draw the sketch in the inventor nodes temp => use temporary solver solution in SketchObject recreateinformationscenography => forces a rebuild of the information layer scenography

◆ drawConstraintIcons()

void SketcherGui::ViewProviderSketch::drawConstraintIcons ( )

Draw all constraint icons.

Except maybe the radius and lock ones?

◆ renderConstrIcon()

QImage SketcherGui::ViewProviderSketch::renderConstrIcon ( const QString &  type,
const QColor &  iconColor,
const QStringList &  labels,
const QList< QColor > &  labelColors,
double  iconRotation,
std::vector< QRect > *  boundingBoxes = NULL,
int *  vPad = NULL 
)
protected

Helper for drawMergedConstraintIcons and drawTypicalConstraintIcon.

Parameters
boundingBoxesGets populated with bounding boxes (in icon image coordinates) for the icon at left, then labels for different constraints.
vPadIf not NULL, gets set to the number of pixels that the text extends below the icon base.

◆ sendConstraintIconToCoin()

void SketcherGui::ViewProviderSketch::sendConstraintIconToCoin ( const QImage &  icon,
SoImage *  soImagePtr 
)
protected

Copies a QImage constraint icon into a SoImage*.

Used by drawTypicalConstraintIcon() and drawMergedConstraintIcons()