From 5140c320d8addf4bd8dcaa7f350b6accdc4ffbaf Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 23 Jul 2019 19:42:36 -0400
Subject: [PATCH] ClickInfo fixed.
---
Torus.java | 48 +++---
Cone.java | 44 +++--
BezierSurface.java | 26 ++-
CameraPane.java | 88 +++++++-----
BezierPatch.java | 26 ++-
Object3D.java | 168 +++++++++++++++--------
ClickInfo.java | 3
Composite.java | 2
Spline.java | 13 +
9 files changed, 255 insertions(+), 163 deletions(-)
diff --git a/BezierPatch.java b/BezierPatch.java
index 294bdec..7686627 100644
--- a/BezierPatch.java
+++ b/BezierPatch.java
@@ -139,39 +139,43 @@
Point prev = new Point(0, 0);
Point curr = new Point(0, 0);
Rectangle dummy = new Rectangle();
- calcHotSpot(sample, info, prev, dummy);
+ calcHotSpot(sample, //info,
+ prev, dummy);
sample = ((Sphere)ctrlPnts.get(i)).getCenter();
- calcHotSpot(sample, info, curr, dummy);
+ calcHotSpot(sample, //info,
+ curr, dummy);
info.g.drawLine(prev.x, prev.y, curr.x, curr.y);
prev.x = curr.x;
prev.y = curr.y;
}
}
- void drawEditHandles(ClickInfo info, int level)
+ void drawEditHandles(//ClickInfo info,
+ int level)
{
- info.g.setColor(Color.red);
+ clickInfo.g.setColor(Color.red);
int count = ctrlPnts.size();
for (int i=0; i < count; i++)
{
cVector p = ((Sphere)ctrlPnts.elementAt(i)).getCenter();
- Rectangle spot = calcHotSpot(p, info);
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+ Rectangle spot = calcHotSpot(p); //, info);
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
}
}
- boolean doEditClick(ClickInfo info, int level)
+ boolean doEditClick(//ClickInfo info,
+ int level)
{
- startX = info.x;
- startY = info.y;
+ startX = clickInfo.x;
+ startY = clickInfo.y;
int nPoints = ctrlPnts.size();
hitSomething = false;
for (int i=0; i < nPoints; i++)
{
cVector p = ((Sphere)ctrlPnts.elementAt(i)).getCenter();
- Rectangle r = calcHotSpot(p, info);
- if (r.contains(info.x, info.y))
+ Rectangle r = calcHotSpot(p); //, clickInfo);
+ if (r.contains(clickInfo.x, clickInfo.y))
{
hitSomething = true;
hitIndex = i;
diff --git a/BezierSurface.java b/BezierSurface.java
index 7cd1fca..da75a3a 100644
--- a/BezierSurface.java
+++ b/BezierSurface.java
@@ -117,39 +117,43 @@
Point prev = new Point(0, 0);
Point curr = new Point(0, 0);
Rectangle dummy = new Rectangle();
- calcHotSpot(sample, info, prev, dummy);
+ calcHotSpot(sample, //info,
+ prev, dummy);
sample = ((Sphere)ctrlPnts.get(i)).getCenter();
- calcHotSpot(sample, info, curr, dummy);
+ calcHotSpot(sample, //info,
+ curr, dummy);
info.g.drawLine(prev.x, prev.y, curr.x, curr.y);
prev.x = curr.x;
prev.y = curr.y;
}
}
- void drawEditHandles(ClickInfo info, int level)
+ void drawEditHandles(//ClickInfo info,
+ int level)
{
- info.g.setColor(Color.red);
+ clickInfo.g.setColor(Color.red);
int count = ctrlPnts.size();
for (int i=0; i < count; i++)
{
cVector p = ((Sphere)ctrlPnts.elementAt(i)).getCenter();
- Rectangle spot = calcHotSpot(p, info);
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+ Rectangle spot = calcHotSpot(p); //, info);
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
}
}
- boolean doEditClick(ClickInfo info, int level)
+ boolean doEditClick(//ClickInfo info,
+ int level)
{
- startX = info.x;
- startY = info.y;
+ startX = clickInfo.x;
+ startY = clickInfo.y;
int nPoints = ctrlPnts.size();
hitSomething = false;
for (int i=0; i < nPoints; i++)
{
cVector p = ((Sphere)ctrlPnts.elementAt(i)).getCenter();
- Rectangle r = calcHotSpot(p, info);
- if (r.contains(info.x, info.y))
+ Rectangle r = calcHotSpot(p); //, info);
+ if (r.contains(clickInfo.x, clickInfo.y))
{
hitSomething = true;
hitIndex = i;
diff --git a/CameraPane.java b/CameraPane.java
index 69d4882..e4c20f1 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -14255,14 +14255,15 @@
drag = false;
//System.out.println("Mouse DOWN");
editObj = false;
- ClickInfo info = new ClickInfo();
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
- info.pane = this;
- info.camera = renderCamera;
- info.x = x;
- info.y = y;
- info.modifiers = modifiersex;
- editObj = object.doEditClick(info, 0);
+ //ClickInfo info = new ClickInfo();
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
+ object.clickInfo.pane = this;
+ object.clickInfo.camera = renderCamera;
+ object.clickInfo.x = x;
+ object.clickInfo.y = y;
+ object.clickInfo.modifiers = modifiersex;
+ editObj = object.doEditClick(//info,
+ 0);
if (!editObj)
{
hasMarquee = true;
@@ -14662,15 +14663,16 @@
if (editObj)
{
drag = true;
- ClickInfo info = new ClickInfo();
- info.bounds.setBounds(0, 0,
+ //ClickInfo info = new ClickInfo();
+ object.clickInfo.bounds.setBounds(0, 0,
(int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
- info.pane = this;
- info.camera = renderCamera;
- info.x = x;
- info.y = y;
- object.GetWindow().copy
- .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
+ object.clickInfo.pane = this;
+ object.clickInfo.camera = renderCamera;
+ object.clickInfo.x = x;
+ object.clickInfo.y = y;
+ object //.GetWindow().copy
+ .doEditDrag(//info,
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
} else
{
if (x < startX)
@@ -14819,24 +14821,27 @@
}
}
+// ClickInfo clickInfo = new ClickInfo();
+
public void mouseMoved(MouseEvent e)
{
//System.out.println("mouseMoved: " + e);
if (isRenderer)
return;
- ClickInfo ci = new ClickInfo();
- ci.x = e.getX();
- ci.y = e.getY();
- ci.modifiers = e.getModifiersEx();
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
- ci.pane = this;
- ci.camera = renderCamera;
+ // Mouse cursor feedback
+ object.clickInfo.x = e.getX();
+ object.clickInfo.y = e.getY();
+ object.clickInfo.modifiers = e.getModifiersEx();
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
+ object.clickInfo.pane = this;
+ object.clickInfo.camera = renderCamera;
if (!isRenderer)
{
//ObjEditor editWindow = object.editWindow;
//Object3D copy = editWindow.copy;
- if (object.doEditClick(ci, 0))
+ if (object.doEditClick(//clickInfo,
+ 0))
{
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else
@@ -15862,8 +15867,6 @@
int width = getBounds().width;
int height = getBounds().height;
- ClickInfo info = new ClickInfo();
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
//Image img = CreateImage(width, height);
//System.out.println("width = " + width + "; height = " + height + "\n");
@@ -15940,31 +15943,37 @@
}
if (object != null && !hasMarquee)
{
+ if (object.clickInfo == null)
+ object.clickInfo = new ClickInfo();
+ ClickInfo info = object.clickInfo;
+ //ClickInfo info = new ClickInfo();
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
+
if (isRenderer)
{
- info.flags++;
+ object.clickInfo.flags++;
double frameAspect = (double) width / (double) height;
if (frameAspect > renderCamera.aspect)
{
int desired = (int) ((double) height * renderCamera.aspect);
- info.bounds.width -= width - desired;
- info.bounds.x += (width - desired) / 2;
+ object.clickInfo.bounds.width -= width - desired;
+ object.clickInfo.bounds.x += (width - desired) / 2;
} else
{
int desired = (int) ((double) width / renderCamera.aspect);
- info.bounds.height -= height - desired;
- info.bounds.y += (height - desired) / 2;
+ object.clickInfo.bounds.height -= height - desired;
+ object.clickInfo.bounds.y += (height - desired) / 2;
}
}
- info.g = gr;
- info.camera = renderCamera;
+ object.clickInfo.g = gr;
+ object.clickInfo.camera = renderCamera;
/*
// Memory intensive (brep.verticescopy)
if (!(object instanceof Composite))
object.draw(info, 0, false); // SLOW :
*/
- if (!isRenderer)
+ if (!isRenderer) // && drag)
{
Grafreed.Assert(object != null);
Grafreed.Assert(object.selection != null);
@@ -15972,9 +15981,9 @@
{
int hitSomething = object.selection.get(0).hitSomething;
- info.DX = 0;
- info.DY = 0;
- info.W = 1;
+ object.clickInfo.DX = 0;
+ object.clickInfo.DY = 0;
+ object.clickInfo.W = 1;
if (hitSomething == Object3D.hitCenter)
{
info.DX = X;
@@ -15986,7 +15995,8 @@
info.DY -= info.bounds.height/2;
}
- object.drawEditHandles(info, 0);
+ object.drawEditHandles(//info,
+ 0);
if (drag && (X != 0 || Y != 0))
{
@@ -15999,7 +16009,7 @@
gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
break;
case Object3D.hitScale: gr.setColor(Color.cyan);
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
+ gr.drawLine(X, Y, 0, 0);
break;
}
diff --git a/ClickInfo.java b/ClickInfo.java
index 0377695..f85414c 100644
--- a/ClickInfo.java
+++ b/ClickInfo.java
@@ -12,6 +12,7 @@
ClickInfo()
{
bounds = new Rectangle();
+ System.out.println("CLICKINFO");
}
static final int kCamera = 1;
@@ -28,6 +29,8 @@
Graphics g;
int DX, DY;
float W = 1;
+
+ double scale; // Distance from clicked point to origin
static double matbuffer[][] = new double[4][4];
}
diff --git a/Composite.java b/Composite.java
index 9244c31..63b89d4 100644
--- a/Composite.java
+++ b/Composite.java
@@ -790,6 +790,8 @@
void draw(ClickInfo info, int level, boolean select)
{
+ new Exception().printStackTrace();
+
ClickInfo newInfo = new ClickInfo();
newInfo.flags = info.flags;
newInfo.bounds = info.bounds;
diff --git a/Cone.java b/Cone.java
index 938fe77..63892ae 100644
--- a/Cone.java
+++ b/Cone.java
@@ -2,7 +2,7 @@
class Cone extends Biparam implements java.io.Serializable
{
- //static final long serialVersionUID = -679715043452968126L;
+ static final long serialVersionUID = -2558098774090336324L; // -679715043452968126L;
Cone()
{
@@ -263,9 +263,11 @@
editWindow = objectUI.GetEditor();
}
- void drawEditHandles(ClickInfo info, int level)
+ void drawEditHandles(//ClickInfo info,
+ int level)
{
- super.drawEditHandles(info, level);
+ super.drawEditHandles(//info,
+ level);
if (level == 1)
{
return;
@@ -273,37 +275,39 @@
{
cVector temp = new cVector();
LA.xformPos(base, toParent, temp);
- Rectangle baseSpot = calcHotSpot(temp, info);
+ Rectangle baseSpot = calcHotSpot(temp); //, info);
LA.xformPos(apex, toParent, temp);
- Rectangle apexSpot = calcHotSpot(temp, info);
- info.g.setColor(Color.green);
- info.g.fillRect(baseSpot.x, baseSpot.y, baseSpot.width, baseSpot.height);
- info.g.fillRect(apexSpot.x, apexSpot.y, apexSpot.width, apexSpot.height);
+ Rectangle apexSpot = calcHotSpot(temp); //, info);
+ clickInfo.g.setColor(Color.green);
+ clickInfo.g.fillRect(baseSpot.x, baseSpot.y, baseSpot.width, baseSpot.height);
+ clickInfo.g.fillRect(apexSpot.x, apexSpot.y, apexSpot.width, apexSpot.height);
return;
}
}
- boolean doEditClick(ClickInfo info, int level)
+ boolean doEditClick(//ClickInfo info,
+ int level)
{
//if (level == 0)
//return false;
hitSomething = 0;
- if (super.doEditClick(info, level))
+ if (super.doEditClick(//info,
+ level))
{
hitSomething = 1;
return true;
}
cVector temp = new cVector();
LA.xformPos(base, toParent, temp);
- Rectangle baseSpot = calcHotSpot(temp, info);
+ Rectangle baseSpot = calcHotSpot(temp); //, info);
LA.xformPos(apex, toParent, temp);
- Rectangle apexSpot = calcHotSpot(temp, info);
- if (baseSpot.contains(info.x, info.y))
+ Rectangle apexSpot = calcHotSpot(temp); //, info);
+ if (baseSpot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = 2;
startRad = baseRadius;
} else
- if (apexSpot.contains(info.x, info.y))
+ if (apexSpot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = 3;
startRad = apexRadius;
@@ -311,20 +315,22 @@
{
return false;
}
- startX = info.x;
+ startX = clickInfo.x;
return true;
}
- void doEditDrag(ClickInfo info, boolean opposite)
+ void doEditDrag(//ClickInfo info,
+ boolean opposite)
{
if (hitSomething == 0)
return;
if (hitSomething == 1)
{
- super.doEditDrag(info, opposite);
+ super.doEditDrag(//info,
+ opposite);
return;
}
- double deltaR = info.x - startX;
+ double deltaR = clickInfo.x - startX;
double newRad = startRad + deltaR;
if (newRad < 0)
newRad = 0;
@@ -333,7 +339,7 @@
else
apexRadius = newRad;
recalculate();
- info.pane.repaint();
+ clickInfo.pane.repaint();
}
cVector base;
diff --git a/Object3D.java b/Object3D.java
index 1b9b4c0..95b3484 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -2567,7 +2567,8 @@
private static final int editSelf = 1;
private static final int editChild = 2;
- void drawEditHandles(ClickInfo info, int level)
+ void drawEditHandles(//ClickInfo info,
+ int level)
{
if (level == 0)
{
@@ -2575,7 +2576,8 @@
return;
Object3D selectee;
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
+ level + 1))
{
selectee = (Object3D) e.nextElement();
}
@@ -2583,19 +2585,22 @@
} else
{
//super.
- drawEditHandles0(info, level + 1);
+ drawEditHandles0(//info,
+ level + 1);
}
}
- boolean doEditClick(ClickInfo info, int level)
+ boolean doEditClick(//ClickInfo info,
+ int level)
{
doSomething = 0;
if (level == 0)
{
- return doParentClick(info);
+ return doParentClick(); //info);
}
if (//super.
- doEditClick0(info, level))
+ doEditClick0(//info,
+ level))
{
doSomething = 1;
return true;
@@ -2605,7 +2610,7 @@
}
}
- boolean doParentClick(ClickInfo info)
+ boolean doParentClick() //ClickInfo info)
{
if (selection == null)
{
@@ -2618,7 +2623,8 @@
for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
{
Object3D selectee = (Object3D) e.nextElement();
- if (selectee.doEditClick(info, 1))
+ if (selectee.doEditClick(//info,
+ 1))
{
childToDrag = selectee;
doSomething = 2;
@@ -2630,13 +2636,15 @@
return retval;
}
- void doEditDrag(ClickInfo info, boolean opposite)
+ void doEditDrag(//ClickInfo clickInfo,
+ boolean opposite)
{
switch (doSomething)
{
case 1: // '\001'
//super.
- doEditDrag0(info, opposite);
+ doEditDrag0(//clickInfo,
+ opposite);
break;
case 2: // '\002'
@@ -2649,11 +2657,13 @@
{
//sel.hitSomething = childToDrag.hitSomething;
//childToDrag.doEditDrag(info);
- sel.doEditDrag(info, opposite);
+ sel.doEditDrag(//clickInfo,
+ opposite);
} else
{
//super.
- doEditDrag0(info, opposite);
+ doEditDrag0(//clickInfo,
+ opposite);
}
}
break;
@@ -2671,6 +2681,9 @@
{
deselectAll();
}
+
+ new Exception().printStackTrace();
+
ClickInfo newInfo = new ClickInfo();
newInfo.flags = info.flags;
newInfo.bounds = info.bounds;
@@ -7298,20 +7311,23 @@
}
}
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
+ static ClickInfo clickInfo = new ClickInfo();
+
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
+ Point outPt, Rectangle outRec)
{
- int hc = info.bounds.x + info.bounds.width / 2;
- int vc = info.bounds.y + info.bounds.height / 2;
- double[][] toscreen = info.toScreen;
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
+ double[][] toscreen = clickInfo.toScreen;
if (toscreen == null)
{
- toscreen = new Camera(info.camera.viewCode).toScreen;
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
}
cVector vec = in;
LA.xformPos(in, toscreen, in);
//System.out.println("Distance = " + info.camera.Distance());
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
outPt.x = hc + (int) vec.x;
outPt.y = vc - (int) vec.y;
outRec.x = outPt.x - 3;
@@ -7319,15 +7335,18 @@
outRec.width = outRec.height = 6;
}
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
+ )
{
Point pt = new Point(0, 0);
Rectangle rec = new Rectangle();
- calcHotSpot(in, info, pt, rec);
+ calcHotSpot(in, //clickInfo,
+ pt, rec);
return rec;
}
- void drawEditHandles0(ClickInfo info, int level)
+ void drawEditHandles0(//ClickInfo clickInfo,
+ int level)
{
if (level == 0)
{
@@ -7336,16 +7355,19 @@
{
cVector origin = new cVector();
//LA.xformPos(origin, toParent, origin);
- Rectangle spot = calcHotSpot(origin, info);
+ if (this.clickInfo == null)
+ this.clickInfo = new ClickInfo();
+
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
Rectangle boundary = new Rectangle();
boundary.x = spot.x - 30;
boundary.y = spot.y - 30;
boundary.width = spot.width + 60;
boundary.height = spot.height + 60;
- info.g.setColor(Color.red);
+ clickInfo.g.setColor(Color.red);
int spotw = spot.x + spot.width;
int spoth = spot.y + spot.height;
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
// if (CameraPane.Xmin > spot.x)
// {
// CameraPane.Xmin = spot.x;
@@ -7365,8 +7387,8 @@
spot.translate(32, 32);
spotw = spot.x + spot.width;
spoth = spot.y + spot.height;
- info.g.setColor(Color.cyan);
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+ clickInfo.g.setColor(Color.cyan);
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
// if (CameraPane.Xmin > spot.x)
// {
// CameraPane.Xmin = spot.x;
@@ -7386,9 +7408,9 @@
// bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
//info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
spot.translate(0, -32);
- info.g.setColor(Color.yellow);
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
- info.g.setColor(Color.green);
+ clickInfo.g.setColor(Color.yellow);
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+ clickInfo.g.setColor(Color.green);
// if (CameraPane.Xmin > spot.x)
// {
// CameraPane.Xmin = spot.x;
@@ -7405,8 +7427,8 @@
// {
// CameraPane.Ymax = spoth;
// }
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
//info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
// if (CameraPane.Xmin > boundary.x)
// {
@@ -7428,7 +7450,8 @@
}
}
- boolean doEditClick0(ClickInfo info, int level)
+ boolean doEditClick0(//ClickInfo clickInfo,
+ int level)
{
if (level == 0)
{
@@ -7437,8 +7460,8 @@
boolean retval = false;
- startX = info.x;
- startY = info.y;
+ startX = clickInfo.x;
+ startY = clickInfo.y;
hitSomething = -1;
cVector origin = new cVector();
@@ -7448,22 +7471,51 @@
{
centerPt = new Point(0, 0);
}
- calcHotSpot(origin, info, centerPt, spot);
- if (spot.contains(info.x, info.y))
+ calcHotSpot(origin, //info,
+ centerPt, spot);
+ if (spot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = hitCenter;
retval = true;
}
spot.translate(32, 0);
- if (spot.contains(info.x, info.y))
+ if (spot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = hitRotate;
retval = true;
}
spot.translate(0, 32);
- if (spot.contains(info.x, info.y))
+ if (spot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = hitScale;
+
+ double scale = 0.005f * clickInfo.camera.Distance();
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
+ double sign = 1;
+ if (hScale < 0)
+ {
+ sign = -1;
+ }
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
+ if (hScale < 0.01)
+ {
+ //hScale = 0.01;
+ }
+
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
+ sign = 1;
+ if (vScale < 0)
+ {
+ sign = -1;
+ }
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
+ if (vScale < 0.01)
+ {
+ //vScale = 0.01;
+ }
+
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
+
retval = true;
}
@@ -7473,7 +7525,7 @@
}
//System.out.println("info.modifiers = " + info.modifiers);
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
//System.out.println("modified = " + modified);
//new Exception().printStackTrace();
//viewCode = info.pane.renderCamera.viewCode;
@@ -7501,7 +7553,8 @@
return true;
}
- void doEditDrag0(ClickInfo info, boolean opposite)
+ void doEditDrag0(//ClickInfo info,
+ boolean opposite)
{
if (hitSomething == 0)
{
@@ -7515,7 +7568,7 @@
//System.out.println("hitSomething = " + hitSomething);
- double scale = 0.005f * info.camera.Distance();
+ double scale = 0.005f * clickInfo.camera.Distance();
cVector xlate = new cVector();
//cVector xlate2 = new cVector();
@@ -7549,8 +7602,8 @@
toParent[3][i] = xlate.get(i);
LA.matInvert(toParent, fromParent);
*/
- cVector delta = LA.newVector(0, 0, startY - info.y);
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
LA.matCopy(startMat, toParent);
LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
@@ -7559,7 +7612,7 @@
} else
{
//LA.xformDir(delta, info.camera.fromScreen, delta);
- cVector up = new cVector(info.camera.up);
+ cVector up = new cVector(clickInfo.camera.up);
cVector away = new cVector();
//cVector right2 = new cVector();
//LA.vecCross(up, cVector.Z, right);
@@ -7576,19 +7629,19 @@
LA.xformDir(up, ClickInfo.matbuffer, up);
// if (!CameraPane.LOCALTRANSFORM)
LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
// if (!CameraPane.LOCALTRANSFORM)
LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
//LA.vecCross(up, cVector.Z, right2);
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
//System.out.println("DELTA0 = " + delta);
//System.out.println("AWAY = " + info.camera.away);
//System.out.println("UP = " + info.camera.up);
if (away.z > 0)
{
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
{
delta.x = -delta.x;
} else
@@ -7603,7 +7656,7 @@
//System.out.println("DELTA1 = " + delta);
LA.xformDir(delta, ClickInfo.matbuffer, delta);
//System.out.println("DELTA2 = " + delta);
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
LA.matCopy(startMat, toParent);
//System.out.println("DELTA3 = " + delta);
LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
@@ -7613,8 +7666,8 @@
break;
case hitRotate: // rotate
- int dx = info.x - centerPt.x;
- int dy = -(info.y - centerPt.y);
+ int dx = clickInfo.x - centerPt.x;
+ int dy = -(clickInfo.y - centerPt.y);
double angle = (double) Math.atan2(dx, dy);
angle = -(1.570796 - angle);
@@ -7637,7 +7690,7 @@
}
/**/
- switch (info.pane.RenderCamera().viewCode)
+ switch (clickInfo.pane.RenderCamera().viewCode)
{
case 1: // '\001'
LA.matZRotate(toParent, angle);
@@ -7664,7 +7717,7 @@
break;
case hitScale: // scale
- double hScale = (double) (info.x - centerPt.x) / 32;
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
double sign = 1;
if (hScale < 0)
{
@@ -7676,7 +7729,7 @@
//hScale = 0.01;
}
- double vScale = (double) (info.y - centerPt.y) / 32;
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
sign = 1;
if (vScale < 0)
{
@@ -7687,6 +7740,7 @@
{
//vScale = 0.01;
}
+
LA.matCopy(startMat, toParent);
/**/
for (int i = 0; i < 3; i++)
@@ -7696,14 +7750,14 @@
}
/**/
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
if (totalScale < 0.01)
{
totalScale = 0.01;
}
- switch (info.pane.RenderCamera().viewCode)
+ switch (clickInfo.pane.RenderCamera().viewCode)
{
case 3: // '\001'
if (modified || opposite)
@@ -7770,7 +7824,7 @@
} // NEW ...
- info.pane.repaint();
+ clickInfo.pane.repaint();
}
boolean overflow = false;
diff --git a/Spline.java b/Spline.java
index 45c5a1d..4fdf5a6 100644
--- a/Spline.java
+++ b/Spline.java
@@ -157,11 +157,13 @@
Point prev = new Point(0, 0);
Point curr = new Point(0, 0);
Rectangle dummy = new Rectangle();
- calcHotSpot(sample, info, prev, dummy);
+ calcHotSpot(sample, //info,
+ prev, dummy);
for (double t = 0.1; t < 1.01; t += 0.1)
{
solve(t, a, b, c, d, sample);
- calcHotSpot(sample, info, curr, dummy);
+ calcHotSpot(sample, //info,
+ curr, dummy);
info.g.drawLine(prev.x, prev.y, curr.x, curr.y);
info.g.drawLine(prev.x, prev.y + 1, curr.x, curr.y + 1);
info.g.drawLine(prev.x + 1, prev.y, curr.x + 1, curr.y);
@@ -181,7 +183,7 @@
for (int i=0; i < count; i++)
{
cVector p = (cVector)ctrlPnts.elementAt(i);
- Rectangle spot = calcHotSpot(p, info);
+ Rectangle spot = calcHotSpot(p); //, info);
info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
}
@@ -197,7 +199,7 @@
for (int i=0; i < nPoints; i++)
{
cVector p = (cVector)ctrlPnts.elementAt(i);
- Rectangle r = calcHotSpot(p, info);
+ Rectangle r = calcHotSpot(p); //, info);
if (r.contains(info.x, info.y))
{
hitSomething = true;
@@ -235,7 +237,8 @@
for (double t = 0; t < 1.001; t += 0.01)
{
solve(t, a, b, c, d, sample);
- calcHotSpot(sample, info, pnt, rect);
+ calcHotSpot(sample, //info,
+ pnt, rect);
if (!rect.contains(info.x, info.y))
continue;
hitSomething = true;
diff --git a/Torus.java b/Torus.java
index d9a7b44..4573395 100644
--- a/Torus.java
+++ b/Torus.java
@@ -2,7 +2,7 @@
class Torus extends Biparam implements java.io.Serializable
{
- //static final long serialVersionUID = -7637054329820073252L;
+ static final long serialVersionUID = -7637054329820073252L; // Old
Torus()
{
@@ -64,7 +64,7 @@
v = 0;
double uAng = u * 2 * Math.PI;
- double vAng = v * 2 * Math.PI;
+ double vAng = -v * 2 * Math.PI;
double cosua = Math.cos(uAng);
double sinua = Math.sin(uAng);
double cosva = Math.cos(vAng);
@@ -118,55 +118,59 @@
return rad2 <= minor * minor;
}
- void drawEditHandles(ClickInfo info, int level)
+ void drawEditHandles(//ClickInfo info,
+ int level)
{
if (level == 0)
{
return;
} else
{
- super.drawEditHandles(info, level);
+ super.drawEditHandles(//info,
+ level);
cVector temp = LA.newVector(0, 0, minor);
LA.xformPos(temp, toParent, temp);
- Rectangle majorSpot = calcHotSpot(temp, info);
+ Rectangle majorSpot = calcHotSpot(temp); //, info);
majorSpot.translate(4, 4);
temp.x = major;
temp.y = temp.z = 0;
LA.xformPos(temp, toParent, temp);
- Rectangle minorSpot = calcHotSpot(temp, info);
+ Rectangle minorSpot = calcHotSpot(temp); //, info);
minorSpot.translate(4, 4);
- info.g.setColor(Color.green);
- info.g.fillRect(majorSpot.x, majorSpot.y, majorSpot.width, majorSpot.height);
- info.g.fillRect(minorSpot.x, minorSpot.y, minorSpot.width, minorSpot.height);
+ clickInfo.g.setColor(Color.green);
+ clickInfo.g.fillRect(majorSpot.x, majorSpot.y, majorSpot.width, majorSpot.height);
+ clickInfo.g.fillRect(minorSpot.x, minorSpot.y, minorSpot.width, minorSpot.height);
return;
}
}
- boolean doEditClick(ClickInfo info, int level)
+ boolean doEditClick(//ClickInfo info,
+ int level)
{
if (level == 0)
return false;
hitSomething = 0;
- if (super.doEditClick(info, level))
+ if (super.doEditClick(//info,
+ level))
{
hitSomething = 1;
return true;
}
cVector temp = LA.newVector(0, 0, minor);
LA.xformPos(temp, toParent, temp);
- Rectangle majorSpot = calcHotSpot(temp, info);
+ Rectangle majorSpot = calcHotSpot(temp); //, info);
majorSpot.translate(4, 4);
temp.x = major;
temp.y = temp.z = 0;
LA.xformPos(temp, toParent, temp);
- Rectangle minorSpot = calcHotSpot(temp, info);
+ Rectangle minorSpot = calcHotSpot(temp); //, info);
minorSpot.translate(4, 4);
- if (majorSpot.contains(info.x, info.y))
+ if (majorSpot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = 2;
startRad = major;
} else
- if (minorSpot.contains(info.x, info.y))
+ if (minorSpot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = 3;
startRad = minor;
@@ -174,23 +178,25 @@
{
return false;
}
- startX = info.x;
+ startX = clickInfo.x;
return true;
}
- void doEditDrag(ClickInfo info, boolean opposite)
+ void doEditDrag(//ClickInfo info,
+ boolean opposite)
{
if (hitSomething == 0)
return;
if (hitSomething == 1)
{
- super.doEditDrag(info, opposite);
+ super.doEditDrag(//info,
+ opposite);
return;
}
- double deltaR = info.x - startX;
+ double deltaR = clickInfo.x - startX;
//cVector delta = LA.newVector(info.x - startX, 0, 0);
//LA.xformDir(delta, info.camera.fromScreen, delta);
- deltaR /= 100 * info.camera.SCALE / info.camera.Distance();
+ deltaR /= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
double newRad = startRad + deltaR;
if (newRad < 0)
newRad = 0;
@@ -199,7 +205,7 @@
else
minor = newRad;
recalculate();
- info.pane.repaint();
+ clickInfo.pane.repaint();
}
double major;
--
Gitblit v1.6.2