Squashed commit of the following:
commit 8853bf442b6e1a98699fa90fca5eb30b3f6d3a5e Author: Ian Rees <ian.rees@gmail.com> Date: Tue Jul 29 15:46:59 2014 +1200 Refactoring and small fix in constraint icon bounding boxes commit c03e4c13d8fd657e18e3c78d16bbdef209f8c779 Author: Ian Rees <ian.rees@gmail.com> Date: Mon Jul 28 15:41:15 2014 +1200 Implemented picking of individual constraints from combined icons commit 254aaab450fe6646bee7542c532c454af91b6597 Author: Ian Rees <ian.rees@gmail.com> Date: Mon Jul 28 13:04:18 2014 +1200 Added bounding boxes for combined constraint icons commit 4f0738ec30220fbf1abdea14dd121d0a134e5dfd Author: Ian Rees <ian.rees@gmail.com> Date: Sat Jul 26 18:53:33 2014 +1200 Added screenCoordsOfPath() to View3DInventorViewer commit 14e2dc7b4aa79db97cbacd2c848728a66276d644 Author: Ian Rees <ian.rees@gmail.com> Date: Sun Jul 20 14:24:27 2014 +1200 Bit of code to make constraint icon text rendering nicer. This won't be useful unless the font changes, but wanted to add it while I was thinking about it. commit 8020d2d62214d71875cbae101d5ac5e96d998201 Author: Ian Rees <ian.rees@gmail.com> Date: Sun Jul 20 13:54:51 2014 +1200 Fixed an off-by-one in ViewProviderSketch::combineConstratintIcons Bug resulted in icons occasionally not being combined into groups, when they should've been. commit 20d92a3ccc1f795be1cb86f6f92045518dc8eb81 Author: Ian Rees <ian.rees@gmail.com> Date: Tue Jul 15 19:38:20 2014 +1200 Fixed a bug that was introduced two commits ago. commit 69e1ea848e3bc3c8c372c539f30a7b4d2a563aa2 Author: Ian Rees <ian.rees@gmail.com> Date: Tue Jul 15 15:33:30 2014 +1200 Fixed dumb copy-and-paste error commit a998b75a905cc31e1f4f49869e81ecaef5858b69 Author: Ian Rees <ian.rees@gmail.com> Date: Sun Jul 13 18:39:22 2014 +1200 Fixed crash reported by sponssi More info at http://forum.freecadweb.org/viewtopic.php?f=10&t=6965&p=56590 commit 27b7b804790dda5164c7ef0b9418f6c160228859 Author: Ian Rees <ian.rees@gmail.com> Date: Thu Jul 10 13:32:16 2014 +1200 Cleaning up my git repo for FreeCAD. This branch now has just the Sketcher icon fixes, plus a few random comment edits.
This commit is contained in:
parent
b74c96dcc4
commit
6ca580456b
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2002 J<EFBFBD>rgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
|
@ -52,6 +52,11 @@ using namespace Gui::PropertyEditor;
|
|||
|
||||
/* TRANSLATOR Gui::PropertyView */
|
||||
|
||||
/*! Property Editor Widget
|
||||
*
|
||||
* Provides two Gui::PropertyEditor::PropertyEditor widgets, for "View" and "Data",
|
||||
* in two tabs.
|
||||
*/
|
||||
PropertyView::PropertyView(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2004 J<EFBFBD>rgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
|
@ -58,7 +58,7 @@ protected:
|
|||
|
||||
/** The 3D view window
|
||||
* It consists out of the 3D view
|
||||
* \author Jürgen Riegel
|
||||
* \author J<EFBFBD>rgen Riegel
|
||||
*/
|
||||
class GuiExport View3DInventor : public MDIView, public ParameterGrp::ObserverType
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
# endif
|
||||
# include <Inventor/SbBox.h>
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/actions/SoGetMatrixAction.h>
|
||||
# include <Inventor/actions/SoHandleEventAction.h>
|
||||
# include <Inventor/actions/SoToVRML2Action.h>
|
||||
# include <Inventor/actions/SoWriteAction.h>
|
||||
|
@ -738,6 +739,51 @@ const std::vector<SbVec2s>& View3DInventorViewer::getPolygon(SbBool* clip_inner)
|
|||
return navigation->getPolygon(clip_inner);
|
||||
}
|
||||
|
||||
SbVec2f View3DInventorViewer::screenCoordsOfPath(SoPath *path) const
|
||||
{
|
||||
// Generate a matrix (well, a SoGetMatrixAction) that
|
||||
// moves us us to the picked object's coordinate space.
|
||||
SoGetMatrixAction *gma;
|
||||
gma = new SoGetMatrixAction(getViewportRegion());
|
||||
gma->apply(path);
|
||||
|
||||
// Use that matrix to translate the origin in the picked
|
||||
// object's coordinate space into object space
|
||||
SbVec3f imageCoords(0, 0, 0);
|
||||
SbMatrix m = gma->getMatrix().transpose();
|
||||
m.multMatrixVec(imageCoords, imageCoords);
|
||||
|
||||
// Now, project the object space coordinates of the object
|
||||
// into "normalized" screen coordinates.
|
||||
SbViewVolume vol = getCamera()->getViewVolume();
|
||||
vol.projectToScreen(imageCoords, imageCoords);
|
||||
|
||||
// Translate "normalized" screen coordinates to pixel coords.
|
||||
//
|
||||
// Note: for some reason, projectToScreen() doesn't seem to
|
||||
// handle non-square viewports properly. The X and Y are
|
||||
// scaled such that [0,1] fits within the smaller of the window
|
||||
// width or height. For instance, in a window that's 400px
|
||||
// tall and 800px wide, the Y will be within [0,1], but X can
|
||||
// vary within [-0.5,1.5]...
|
||||
int width = getGLWidget()->width(),
|
||||
height = getGLWidget()->height();
|
||||
|
||||
if(width >= height) {
|
||||
// "Landscape" orientation, to square
|
||||
imageCoords[0] *= height;
|
||||
imageCoords[0] += (width-height) / 2.0;
|
||||
imageCoords[1] *= height;
|
||||
|
||||
} else {
|
||||
// "Portrait" orientation
|
||||
imageCoords[0] *= width;
|
||||
imageCoords[1] *= width;
|
||||
imageCoords[1] += (height-width) / 2.0;
|
||||
}
|
||||
return SbVec2f(imageCoords[0], imageCoords[1]);
|
||||
}
|
||||
|
||||
std::vector<SbVec2f> View3DInventorViewer::getGLPolygon(const std::vector<SbVec2s>& pnts) const
|
||||
{
|
||||
const SbViewportRegion& vp = this->getViewportRegion();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2004 J<EFBFBD>rgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
|
@ -61,7 +61,7 @@ class SoFCUnifiedSelection;
|
|||
class GLGraphicsItem;
|
||||
class SoShapeScale;
|
||||
|
||||
/** The Inventor viewer
|
||||
/** GUI view into a 3-D Scene provided by View3DInventor
|
||||
*
|
||||
*/
|
||||
class GuiExport View3DInventorViewer : public SoQtViewer, public Gui::SelectionSingleton::ObserverType
|
||||
|
@ -100,10 +100,9 @@ public:
|
|||
//@}
|
||||
|
||||
/** @name Anti-Aliasing modes of the rendered 3D scene
|
||||
* Here you can switch between different methods for anti aliasing wich provide quite different results
|
||||
* at different runtime impact.
|
||||
* - Smoothing enables openGL line and vertex smoothing which is basicly deprecadet
|
||||
* - MSAA is hardeware multi sampling (with 2, 4 or 8 passes), a quite commom and efficient AA technique
|
||||
* Specifies Anti-Aliasing (AA) method
|
||||
* - Smoothing enables OpenGL line and vertex smoothing (basicly depreciated)
|
||||
* - MSAA is hardware multi sampling (with 2, 4 or 8 passes), a quite commom and efficient AA technique
|
||||
*/
|
||||
//@{
|
||||
enum AntiAliasing {
|
||||
|
@ -128,6 +127,10 @@ public:
|
|||
SbBool isBacklight(void) const;
|
||||
void setSceneGraph (SoNode *root);
|
||||
|
||||
// TODO: I think it might be cleaner to move this functionality into a
|
||||
// different class, with this class supporting something like a
|
||||
// rotate() slot that gets triggered by the new Animator class?
|
||||
// IR 20140630
|
||||
void setAnimationEnabled(const SbBool enable);
|
||||
SbBool isAnimationEnabled(void) const;
|
||||
|
||||
|
@ -204,6 +207,10 @@ public:
|
|||
std::vector<SbVec2f> getGLPolygon(const std::vector<SbVec2s>&) const;
|
||||
const std::vector<SbVec2s>& getPolygon(SbBool* clip_inner=0) const;
|
||||
//@}
|
||||
|
||||
/// Returns the screen coordinates of the origin of the path's tail object
|
||||
/*! Return value is in floating-point pixels, origin at bottom-left. */
|
||||
SbVec2f screenCoordsOfPath(SoPath *path) const;
|
||||
|
||||
/** @name Edit methods */
|
||||
//@{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2009 J<EFBFBD>rgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
|
@ -25,6 +25,7 @@
|
|||
#define SKETCHERGUI_VIEWPROVIDERSKETCH_H
|
||||
|
||||
#include <Mod/Part/Gui/ViewProvider2DObject.h>
|
||||
#include <Inventor/SbImage.h>
|
||||
#include <Inventor/SbColor.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
@ -38,11 +39,16 @@ class SoSeparator;
|
|||
class SbLine;
|
||||
class SbVec3f;
|
||||
class SoCoordinate3;
|
||||
class SoInfo;
|
||||
class SoPointSet;
|
||||
class SoTransform;
|
||||
class SoLineSet;
|
||||
class SoMarkerSet;
|
||||
|
||||
class SoImage;
|
||||
class QImage;
|
||||
class QColor;
|
||||
|
||||
class SoText2;
|
||||
class SoTranslation;
|
||||
class SbString;
|
||||
|
@ -56,6 +62,7 @@ namespace Gui {
|
|||
}
|
||||
|
||||
namespace Sketcher {
|
||||
class Constraint;
|
||||
class Sketch;
|
||||
class SketchObject;
|
||||
}
|
||||
|
@ -88,10 +95,13 @@ public:
|
|||
|
||||
App::PropertyBool Autoconstraints;
|
||||
|
||||
/// draw constraint icon given the constraint id
|
||||
/// Draw all constraint icons
|
||||
/*! Except maybe the radius and lock ones? */
|
||||
void drawConstraintIcons();
|
||||
|
||||
/// draw the sketch in the inventor nodes
|
||||
void draw(bool temp=false);
|
||||
|
||||
/// draw the edit curve
|
||||
void drawEdit(const std::vector<Base::Vector2D> &EditCurve);
|
||||
|
||||
|
@ -135,13 +145,23 @@ public:
|
|||
/** @name helper functions */
|
||||
//@{
|
||||
/// give the coordinates of a line on the sketch plane in sketcher (2D) coordinates
|
||||
void getCoordsOnSketchPlane(double &u, double &v,const SbVec3f &point, const SbVec3f &normal);
|
||||
void getCoordsOnSketchPlane(double &u, double &v, const SbVec3f &point,
|
||||
const SbVec3f &normal);
|
||||
|
||||
/// give projecting line of position
|
||||
void getProjectingLine(const SbVec2s&, const Gui::View3DInventorViewer *viewer, SbLine&) const;
|
||||
void getProjectingLine(const SbVec2s&,
|
||||
const Gui::View3DInventorViewer *viewer,
|
||||
SbLine&) const;
|
||||
|
||||
/// helper to detect preselection
|
||||
bool detectPreselection(const SoPickedPoint *Point, int &PtIndex,int &GeoIndex, int &ConstrIndex, int &CrossIndex);
|
||||
bool detectPreselection(const SoPickedPoint *Point,
|
||||
const Gui::View3DInventorViewer *viewer,
|
||||
const SbVec2s &cursorPos);
|
||||
|
||||
/// Helper for detectPreselection(), for constraints only.
|
||||
std::set<int> detectPreselectionConstr(const SoPickedPoint *Point,
|
||||
const Gui::View3DInventorViewer *viewer,
|
||||
const SbVec2s &cursorPos);
|
||||
|
||||
/// box selection method
|
||||
void doBoxSelection(const SbVec2s &startPos, const SbVec2s &endPos,
|
||||
|
@ -167,7 +187,6 @@ public:
|
|||
int getPreselectPoint(void) const;
|
||||
int getPreselectCurve(void) const;
|
||||
int getPreselectCross(void) const;
|
||||
int getPreselectConstraint(void) const;
|
||||
//@}
|
||||
|
||||
/** @name base class implementer */
|
||||
|
@ -190,6 +209,7 @@ public:
|
|||
//@}
|
||||
|
||||
friend class DrawSketchHandler;
|
||||
friend struct ::EditData;
|
||||
|
||||
/// signals if the constraints list has changed
|
||||
boost::signal<void ()> signalConstraintsChanged;
|
||||
|
@ -221,6 +241,80 @@ protected:
|
|||
/// build up the visual of the constraints
|
||||
void rebuildConstraintsVisual(void);
|
||||
|
||||
/** @name Protected helpers for drawing constraint icons*/
|
||||
//@{
|
||||
QString iconTypeFromConstraint(Sketcher::Constraint *constraint);
|
||||
|
||||
/// 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()
|
||||
*/
|
||||
QColor constrColor(int constraintId);
|
||||
/// Used by drawMergedConstraintIcons to decide what color to make icons
|
||||
/*! See constrColor() */
|
||||
int constrColorPriority(int constraintId);
|
||||
|
||||
/// Internal type used for drawing constraint icons
|
||||
struct constrIconQueueItem {
|
||||
/// Type of constraint the icon represents. Eg: "small/Constraint_PointOnObject_sm"
|
||||
QString type;
|
||||
|
||||
/// Internal constraint ID number
|
||||
/// These map to results of getSketchObject()->Constraints.getValues()
|
||||
int constraintId;
|
||||
|
||||
/// Label to be rendered with this icon, if any
|
||||
QString label;
|
||||
|
||||
/// Absolute coordinates of the constraint icon
|
||||
SbVec3f position;
|
||||
|
||||
/// Pointer to the SoImage object where the icon should be written
|
||||
SoImage *destination;
|
||||
|
||||
/// Pointer to SoInfo object where we store the constraint IDs that the icon refers to
|
||||
SoInfo *infoPtr;
|
||||
};
|
||||
|
||||
/// Internal type used for drawing constraint icons
|
||||
typedef std::vector<constrIconQueueItem> IconQueue;
|
||||
/// For constraint icon bounding boxes
|
||||
typedef std::pair<QRect, std::set<int> > ConstrIconBB;
|
||||
/// For constraint icon bounding boxes
|
||||
typedef std::vector<ConstrIconBB> ConstrIconBBVec;
|
||||
|
||||
void combineConstraintIcons(IconQueue iconQueue);
|
||||
|
||||
/// Renders an icon for a single constraint and sends it to Coin
|
||||
void drawTypicalConstraintIcon(const constrIconQueueItem &i);
|
||||
|
||||
/// Combines multiple constraint icons and sends them to Coin
|
||||
void drawMergedConstraintIcons(IconQueue iconQueue);
|
||||
|
||||
/// Helper for drawMergedConstraintIcons and drawTypicalConstraintIcon
|
||||
QImage renderConstrIcon(const QString &type,
|
||||
const QColor &iconColor,
|
||||
const QStringList &labels,
|
||||
const QList<QColor> &labelColors,
|
||||
//! Gets populated with bounding boxes (in icon
|
||||
//! image coordinates) for the icon at left, then
|
||||
//! labels for different constraints.
|
||||
std::vector<QRect> *boundingBoxes = NULL,
|
||||
//! If not NULL, gets set to the number of pixels
|
||||
//! that the text extends below the icon base.
|
||||
int *vPad = NULL);
|
||||
|
||||
/// Copies a QImage constraint icon into a SoImage*
|
||||
/*! Used by drawTypicalConstraintIcon() and drawMergedConstraintIcons() */
|
||||
void sendConstraintIconToCoin(const QImage &icon, SoImage *soImagePtr);
|
||||
|
||||
/// Essentially a version of sendConstraintIconToCoin, with a blank icon
|
||||
void clearCoinImage(SoImage *soImagePtr);
|
||||
|
||||
/// Returns the size that Coin should display the indicated image at
|
||||
SbVec3s getDisplayedSize(const SoImage *) const;
|
||||
//@}
|
||||
|
||||
void setPositionText(const Base::Vector2D &Pos, const SbString &txt);
|
||||
void setPositionText(const Base::Vector2D &Pos);
|
||||
void resetPositionText(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user