1 /*****************************************************************************
2 * Virtual Mockup for Machine Vision
3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr.,
4 * Carlos S. Santos.
5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP
6 *
7 * Permission is granted to redistribute and/or modify this
8 * software under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html)
16 * for more details.
17 *
18 *****************************************************************************/
19
20 package camera3d.manipulation;
21
22 /*
23 * Title: Câmera Virtual - LIVES
24 * Description: Câmera Virtual para Controle via LabVIEW
25 * Copyright: Copyright (c) 2001
26 * Company: Centro de Educação em Informática - SENAC - SP
27 */
28
29 import camera3d.TransformMode;
30 import camera3d.TransformScope;
31
32 /***
33 * A manipulator to perform changes in the scale of objects. Dragging the mouse upward
34 * will increase the selected object's scale. Dragging the mouse downward will decrease
35 * the selected object's scale.
36 *
37 * @author Fábio Roberto de Miranda, Carlos da Silva dos Santos
38 * @version 1.0
39 */
40 public class ScalingManipulator extends TransformationManipulator {
41
42 private double deltaX;
43 private double deltaY;
44 private double lastX;
45 private double lastY;
46 private double beginX;
47 private double beginY;
48
49 private double coefficient = -1.0;
50 private double xyzCoeff = -1.0;
51
52 private double totalY;
53
54 ScalableObject scalableObject;
55
56 public ScalingManipulator(){
57 super();
58 }
59
60 public void setScalableObject(ScalableObject scalableObject){
61 this.scalableObject = scalableObject;
62 setTransformationMode(this.mode);
63 setTransformationScope(this.scope);
64 }
65
66 public void clearSelection(){
67 this.scalableObject = null;
68 }
69
70 public void setBeginPoint(int x, int y){
71 lastX = x;
72 lastY = y;
73 // debugln("Scaling manip. begin:("+x+","+y+")");
74 }
75
76 /***
77 * Calculates and sets the new object's scale.
78 * @param x x coordinate of current mouse position.
79 * @param y y coordinate of current mouse position.
80 */
81 void transform(int x, int y){
82 double h = canvas3d.getHeight();
83 double w = canvas3d.getWidth();
84
85 deltaX = (x - lastX)/w;
86 deltaY = (y - lastY)/h;
87
88 coefficient = -1.0;
89
90 totalY = coefficient*deltaY;
91 if(scope == TransformScope.XYZ){
92 double temp = (1 + deltaY * xyzCoeff);
93 scalableObject.scaleRelative(scope, temp);
94 }
95 scalableObject.scaleRelative(scope, 1 + totalY);
96 /*
97 if(scope == TransformScope.X){
98 selectedObject.scaleXRelative(1 + totalY);
99 }
100 else if(scope == TransformScope.Y){
101 selectedObject.scaleYRelative(1 + totalY);
102 }
103 else if(scope == TransformScope.Z){
104 selectedObject.scaleZRelative(1 + totalY);
105 }
106 else if(scope == TransformScope.XYZ){
107 double temp = (1 + deltaY * xyzCoeff);
108 selectedObject.setRelativeScale(temp,temp,temp);
109 }*/
110
111 lastX = x;
112 lastY = y;
113 }
114
115 }
This page was automatically generated by Maven