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:
wmayer
2014-07-30 00:35:26 +02:00
parent 1349b7cbf2
commit 4f71c3543e
6 changed files with 884 additions and 245 deletions

View File

@@ -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();