Skip to content

Commit

Permalink
fixed: Wrong selection of control points, points when interacting with
Browse files Browse the repository at this point in the history
shapes having a diff number of points
https://bugs.launchpad.net/latexdraw/+bug/1287687
  • Loading branch information
arnobl committed Mar 8, 2014
1 parent fc321c8 commit 2d15746
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 2 additions & 0 deletions latexdraw-core/net.sf.latexdraw/release_note.txt
@@ -1,6 +1,8 @@
************************************************************
Version 3.2.0

- fixed: Wrong selection of control points, points when interacting with shapes having a diff number of points
https://bugs.launchpad.net/latexdraw/+bug/1287687
- fixed: Wrong bounding box when creating a bezier curve with show points
https://bugs.launchpad.net/latexdraw/+bug/1284310
- fixed: Gradient shading feature is not read from SVG file
Expand Down
Expand Up @@ -214,7 +214,7 @@ class Border(canvas : ICanvas) extends CanvasInstrument(canvas) with Picker {
if(isArcHandlerShowable) {
val sh = _selection(0).getShape

if(sh.isTypeOf(classOf[IArc])) {
if(sh.isInstanceOf[IArc]) {
val arc = sh.asInstanceOf[IArc]
_arcHandlerStart.update(arc, canvas.getZoom)
_arcHandlerEnd.update(arc, canvas.getZoom)
Expand All @@ -231,7 +231,7 @@ class Border(canvas : ICanvas) extends CanvasInstrument(canvas) with Picker {
if(isCtrlPtMvHandlersShowable) {
val sh = _selection(0).getShape

if(sh.isTypeOf(classOf[IControlPointShape]))
if(sh.isInstanceOf[IControlPointShape])
// Lazy initialisation
initialiseCtrlMvHandlers(sh.asInstanceOf[IControlPointShape])
}
Expand All @@ -244,23 +244,23 @@ class Border(canvas : ICanvas) extends CanvasInstrument(canvas) with Picker {

// Adding missing handlers.
if(_ctrlPt1Handlers.size<nbPts)
for(i <- _ctrlPt1Handlers.size to nbPts-1) {
for(i <- _ctrlPt1Handlers.size until nbPts) {
_ctrlPt1Handlers += new CtrlPointHandler(i)
_ctrlPt2Handlers += new CtrlPointHandler(i)
}
// Removing extra handlers.
else if(_ctrlPt1Handlers.size>nbPts)
else
while(_ctrlPt1Handlers.size>nbPts) {
_ctrlPt1Handlers.remove(0)
_ctrlPt2Handlers.remove(0)
_ctrlPt1Handlers.remove(_ctrlPt1Handlers.size-1)
_ctrlPt2Handlers.remove(_ctrlPt2Handlers.size-1)
}

// Updating handlers.
for(i <- 0 to _ctrlPt1Handlers.size-1) {
for(i <- 0 until _ctrlPt1Handlers.size) {
val pt1 = cps.getFirstCtrlPtAt(i)
_ctrlPt1Handlers.apply(i).setPoint(pt1.getX*zoom, pt1.getY*zoom)
_ctrlPt1Handlers(i).setPoint(pt1.getX*zoom, pt1.getY*zoom)
val pt2 = cps.getSecondCtrlPtAt(i)
_ctrlPt2Handlers.apply(i).setPoint(pt2.getX*zoom, pt2.getY*zoom)
_ctrlPt2Handlers(i).setPoint(pt2.getX*zoom, pt2.getY*zoom)
}
}

Expand All @@ -274,21 +274,21 @@ class Border(canvas : ICanvas) extends CanvasInstrument(canvas) with Picker {
if(isPtMvHandlersShowable) {
val sh = _selection(0).getShape

if(sh.isTypeOf(classOf[IModifiablePointsShape])) {
if(sh.isInstanceOf[IModifiablePointsShape]) {
val pts = sh.asInstanceOf[IModifiablePointsShape]
val nbPts = pts.getNbPoints
val zoom = canvas.getZoom

if(_mvPtHandlers.size<nbPts)
for(i <- _mvPtHandlers.size to nbPts-1)
for(i <- _mvPtHandlers.size until nbPts)
_mvPtHandlers += new MovePtHandler(i)
else if(_mvPtHandlers.size>nbPts)
while(_mvPtHandlers.size>nbPts)
_mvPtHandlers.remove(0)
else
while(_mvPtHandlers.size>nbPts)
_mvPtHandlers.remove(_mvPtHandlers.size-1)

for(i <- 0 to _mvPtHandlers.size-1) {
for(i <- 0 until _mvPtHandlers.size) {
val pt = pts.getPtAt(i)
_mvPtHandlers.apply(i).setPoint(pt.getX*zoom, pt.getY*zoom)
_mvPtHandlers(i).setPoint(pt.getX*zoom, pt.getY*zoom)
}
}
}
Expand Down Expand Up @@ -571,7 +571,7 @@ private sealed class DnD2MoveCtrlPoint(ins : Border) extends Link[MoveCtrlPoint,
override def initAction() {
val group = instrument.canvas.getDrawing.getSelection

if(group.size==1 && group.getShapeAt(0).isTypeOf(classOf[IControlPointShape])) {
if(group.size==1 && group.getShapeAt(0).isInstanceOf[IControlPointShape]) {
val handler = ctrlPtHandler.get
sourcePt = ShapeFactory.createPoint(handler.getCentre)
action.setIndexPt(handler.getIndexPt)
Expand Down Expand Up @@ -622,7 +622,7 @@ private sealed class DnD2MovePoint(ins : Border) extends Link[MovePointShape, Dn
override def initAction() {
val group = instrument.canvas.getDrawing.getSelection

if(group.size==1 && group.getShapeAt(0).isTypeOf(classOf[IModifiablePointsShape])) {
if(group.size==1 && group.getShapeAt(0).isInstanceOf[IModifiablePointsShape]) {
val handler = movePtHandler.get
sourcePt = ShapeFactory.createPoint(handler.getCentre)
action.setIndexPt(handler.getIndexPt)
Expand Down

0 comments on commit 2d15746

Please sign in to comment.