| 1 | /**************************************************************************** |
| 2 | * VCGLib o o * |
| 3 | * Visual and Computer Graphics Library o o * |
| 4 | * _ O _ * |
| 5 | * Copyright(C) 2004 \/)\/ * |
| 6 | * Visual Computing Lab /\/| * |
| 7 | * ISTI - Italian National Research Council | * |
| 8 | * \ * |
| 9 | * All rights reserved. * |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | * This program is distributed in the hope that it will be useful, * |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 19 | * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * |
| 20 | * for more details. * |
| 21 | * * |
| 22 | ****************************************************************************/ |
| 23 | /**************************************************************************** |
| 24 | History |
| 25 | |
| 26 | $Log: trackball.cpp,v $ |
| 27 | Revision 1.27 2008/02/24 18:05:08 ponchio |
| 28 | Should work as before. I didn't test cylinder and other exotic modes. |
| 29 | |
| 30 | Revision 1.26 2008/02/24 14:37:00 ponchio |
| 31 | Restored trackball functionality. Not very much tested, and code will need some |
| 32 | cleanup. |
| 33 | |
| 34 | Revision 1.25 2008/02/22 18:57:46 benedetti |
| 35 | first attempt to correct after quaternion ToMatrix() inversion (does not work yet) |
| 36 | |
| 37 | Revision 1.24 2007/12/21 12:29:34 tarini |
| 38 | *** empty log message *** |
| 39 | |
| 40 | Revision 1.23 2007/10/12 14:02:39 corsini |
| 41 | solve memory leak in dtor |
| 42 | |
| 43 | Revision 1.22 2007/07/09 22:47:18 benedetti |
| 44 | Removed using namespace std and modified accordingly. |
| 45 | |
| 46 | Revision 1.21 2007/06/20 12:59:43 corsini |
| 47 | adjust wheel back-compatibility |
| 48 | |
| 49 | Revision 1.20 2007/06/13 17:15:08 benedetti |
| 50 | Added one-level undo system and sticky trackmodes. |
| 51 | |
| 52 | Revision 1.19 2007/05/15 15:00:27 benedetti |
| 53 | Moved the drawing code to trackmodes, some other minor changes |
| 54 | |
| 55 | Revision 1.18 2007/02/26 01:30:02 cignoni |
| 56 | Added reflection Name |
| 57 | |
| 58 | Revision 1.17 2007/01/15 15:04:15 tarini |
| 59 | added "ToAscii" and "SetFromAscii" methods to load/store current trackball status from/to ascii strings |
| 60 | (intended uses: clipboard operations and comments inside png snapshots!) |
| 61 | |
| 62 | Revision 1.16 2006/07/26 13:54:45 cignoni |
| 63 | Reversed the direction of wheel scaling and added middle mouse panning |
| 64 | |
| 65 | Revision 1.15 2006/02/13 13:15:52 cignoni |
| 66 | Added Scale and Translate methods. |
| 67 | Added many drawing hints and raised the default num. of steps when drawing circles. |
| 68 | Added MouseDown without coords (for remembering changes of keys modifiers) |
| 69 | Added ZMode to the default modes under Alt+left |
| 70 | Added DrawPostApply (to be completed) |
| 71 | |
| 72 | Revision 1.14 2005/10/17 01:29:46 cignoni |
| 73 | Main restructuring. Removed the Draw function and slightly changed the meaning of the trackball itself. |
| 74 | See the notes at the beginning of trackball.h |
| 75 | |
| 76 | Revision 1.13 2005/04/17 17:48:24 ganovelli |
| 77 | modes deallocation commented (quick and dirty solution..to debug) |
| 78 | |
| 79 | Revision 1.12 2004/12/17 10:28:10 ricciodimare |
| 80 | *** empty log message *** |
| 81 | |
| 82 | Revision 1.11 2004/09/28 15:30:12 ponchio |
| 83 | Added a 'else'. |
| 84 | |
| 85 | Revision 1.10 2004/09/09 14:38:52 ponchio |
| 86 | #include <gl... -> #include <GL... |
| 87 | |
| 88 | Revision 1.9 2004/07/11 22:06:55 cignoni |
| 89 | Added scaling by wheel |
| 90 | |
| 91 | Revision 1.8 2004/06/09 14:01:13 cignoni |
| 92 | Heavily restructured. To be completed only rotation works... |
| 93 | |
| 94 | Revision 1.7 2004/05/14 03:15:09 ponchio |
| 95 | Redesigned partial version. |
| 96 | |
| 97 | Revision 1.6 2004/05/12 20:55:18 ponchio |
| 98 | *** empty log message *** |
| 99 | |
| 100 | Revision 1.5 2004/05/07 12:46:08 cignoni |
| 101 | Restructured and adapted in a better way to opengl |
| 102 | |
| 103 | Revision 1.4 2004/04/07 10:54:10 cignoni |
| 104 | Commented out unused parameter names and other minor warning related issues |
| 105 | |
| 106 | Revision 1.3 2004/03/31 15:08:03 ponchio |
| 107 | Fixed current_action initialization. |
| 108 | |
| 109 | Revision 1.2 2004/03/25 14:55:25 ponchio |
| 110 | Adding copyright. |
| 111 | |
| 112 | |
| 113 | ****************************************************************************/ |
| 114 | |
| 115 | #include <GL/glew.h> |
| 116 | #include "trackball.h"cxx . . $ `<file>/vcg/wrap/gui/trackball.h`/ |
| 117 | |
| 118 | #include <wrap/gl/math.h>cxx . . $ `<file>/vcg/wrap/gl/math.h`/ |
| 119 | #include <wrap/gl/space.h>cxx . . $ `<file>/vcg/wrap/gl/space.h`/ |
| 120 | |
| 121 | using namespace vcg; |
| 122 | |
| 123 | Transformcxx . . $ vcg/Transform#::Transformcxx . . $ vcg/Transform#Transform(49f6e7a06ebc5aa8).() { |
| 124 | trackcxx . . $ vcg/Transform#track..SetIdentitycxx . . $ vcg/Similarity#SetIdentity(6e6672ce44b14785).(); |
| 125 | radiuscxx . . $ vcg/Transform#radius.=1.0f; |
| 126 | centercxx . . $ vcg/Transform#center.=cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e).Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(0,0,0); |
| 127 | } |
| 128 | |
| 129 | Trackballcxx . . $ vcg/Trackball#::Trackballcxx . . $ vcg/Trackball#Trackball(49f6e7a06ebc5aa8).(): current_buttoncxx . . $ vcg/Trackball#current_button.(0), current_modecxx . . $ vcg/Trackball#current_mode.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!), inactive_modecxx . . $ vcg/Trackball#inactive_mode.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!), |
| 130 | draggingcxx . . $ vcg/Trackball#dragging.(false), spinnablecxx . . $ vcg/Trackball#spinnable.(true), spinningcxx . . $ vcg/Trackball#spinning.(false), |
| 131 | history_sizecxx . . $ vcg/Trackball#history_size.(10){ |
| 132 | setDefaultMappingcxx . . $ vcg/Trackball#setDefaultMapping(49f6e7a06ebc5aa8). (); |
| 133 | } |
| 134 | |
| 135 | Trackballcxx . . $ vcg/Trackball#::~cxx . . $ vcg/Trackball#`~Trackball`(ced63f7c635d850d).Trackballcxx . . $ vcg/Trackball#() |
| 136 | { |
| 137 | stdcxx . . $ std/::mapcxx . . $ std/map#<int, TrackMode *>::iteratorcxx . . $ std/map#iterator# itcxx . . $ std/_Rb_tree_iterator#_Rb_tree_iterator(ced63f7c635d850d).; |
| 138 | for(it =cxx . . $ std/_Rb_tree_iterator#`operator=`(3aa99e3e3f44eabe). modescxx . . $ vcg/Trackball#modes..begincxx . . $ std/map#begin(7e4de33083b6e738).(); it !=cxx . . $ std/`operator!=`(be6a71a859368080). modescxx . . $ vcg/Trackball#modes..endcxx . . $ std/map#end(7e4de33083b6e738).(); it++cxx . . $ std/_Rb_tree_iterator#operator++(2987e7ff93f61dc1).) |
| 139 | { |
| 140 | if ((*cxx . . $ std/_Rb_tree_iterator#`operator*`(d426bc7b625886b7).it).second) |
| 141 | delete (*cxx . . $ std/_Rb_tree_iterator#`operator*`(d426bc7b625886b7).it).second; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | |
| 146 | void Trackballcxx . . $ vcg/Trackball#::setDefaultMappingcxx . . $ vcg/Trackball#setDefaultMapping(49f6e7a06ebc5aa8). () { |
| 147 | inactive_modecxx . . $ vcg/Trackball#inactive_mode. = new InactiveModecxx . . $ vcg/InactiveMode# (); |
| 148 | modescxx . . $ vcg/Trackball#modes..clearcxx . . $ std/map#clear(ced63f7c635d850d). (); |
| 149 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).0] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 150 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).BUTTON_LEFTcxx . . $ vcg/Trackball#BUTTON_LEFT.] = new SphereModecxx . . $ vcg/SphereMode# (); |
| 151 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).BUTTON_LEFTcxx . . $ vcg/Trackball#BUTTON_LEFT. | KEY_CTRLcxx . . $ vcg/Trackball#KEY_CTRL.] = new PanModecxx . . $ vcg/PanMode# (); |
| 152 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).BUTTON_MIDDLEcxx . . $ vcg/Trackball#BUTTON_MIDDLE.] = new PanModecxx . . $ vcg/PanMode# (); |
| 153 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).BUTTON_LEFTcxx . . $ vcg/Trackball#BUTTON_LEFT. | KEY_SHIFTcxx . . $ vcg/Trackball#KEY_SHIFT.] = new ScaleModecxx . . $ vcg/ScaleMode# (); |
| 154 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).BUTTON_LEFTcxx . . $ vcg/Trackball#BUTTON_LEFT. | KEY_ALTcxx . . $ vcg/Trackball#KEY_ALT.] = new ZModecxx . . $ vcg/ZMode# (); |
| 155 | modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).WHEELcxx . . $ vcg/Trackball#WHEEL.] = new ScaleModecxx . . $ vcg/ScaleMode# (); |
| 156 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8). (); |
| 157 | } |
| 158 | |
| 159 | void Trackballcxx . . $ vcg/Trackball#::SetIdentitycxx . . $ vcg/Trackball#SetIdentity(49f6e7a06ebc5aa8).() { |
| 160 | trackcxx . . $ vcg/Transform#track..SetIdentitycxx . . $ vcg/Similarity#SetIdentity(6e6672ce44b14785).(); |
| 161 | Resetcxx . . $ vcg/Trackball#Reset(49f6e7a06ebc5aa8).(); |
| 162 | } |
| 163 | void Trackballcxx . . $ vcg/Trackball#::SetPositioncxx . . $ vcg/Trackball#SetPosition(c0b2a1bb3b4e9f55).(const Point3fcxx . . $ vcg/Point3f# &c, int /* millisec */) { |
| 164 | centercxx . . $ vcg/Transform#center. =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). c; |
| 165 | } |
| 166 | |
| 167 | void Trackballcxx . . $ vcg/Trackball#::GetViewcxx . . $ vcg/Trackball#GetView(49f6e7a06ebc5aa8).() { |
| 168 | cameracxx . . $ vcg/Trackball#camera..GetViewcxx . . $ vcg/View#GetView(49f6e7a06ebc5aa8).(); |
| 169 | } |
| 170 | |
| 171 | // the drawing code has been moved to the trackmodes |
| 172 | void Trackballcxx . . $ vcg/Trackball#::DrawPostApplycxx . . $ vcg/Trackball#DrawPostApply(49f6e7a06ebc5aa8).() { |
| 173 | if(current_modecxx . . $ vcg/Trackball#current_mode. !=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!){ |
| 174 | current_modecxx . . $ vcg/Trackball#current_mode.->Drawcxx . . $ vcg/TrackMode#Draw(3c6e6be657895f3d).(this); |
| 175 | }else{ |
| 176 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(inactive_mode != NULL); |
| 177 | inactive_modecxx . . $ vcg/Trackball#inactive_mode.->Drawcxx . . $ vcg/TrackMode#Draw(3c6e6be657895f3d).(this); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | void Trackballcxx . . $ vcg/Trackball#::Applycxx . . $ vcg/Trackball#Apply(49f6e7a06ebc5aa8). () { |
| 182 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (centercxx . . $ vcg/Transform#center.); |
| 183 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f). (trackcxx . . $ vcg/Transform#track..Matrixcxx . . $ vcg/Similarity#Matrix(7c114f2e28b188e1).()); |
| 184 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6). (-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).centercxx . . $ vcg/Transform#center.); |
| 185 | } |
| 186 | |
| 187 | void Trackballcxx . . $ vcg/Trackball#::Applycxx . . $ vcg/Trackball#Apply(b45ddcbc8423892c).(bool ToDraw) { |
| 188 | Applycxx . . $ vcg/Trackball#Apply(49f6e7a06ebc5aa8).(); |
| 189 | if(ToDraw){ |
| 190 | DrawPostApplycxx . . $ vcg/Trackball#DrawPostApply(49f6e7a06ebc5aa8).(); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | |
| 195 | void Trackballcxx . . $ vcg/Trackball#::ApplyInversecxx . . $ vcg/Trackball#ApplyInverse(49f6e7a06ebc5aa8).() { |
| 196 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6).(centercxx . . $ vcg/Transform#center.); |
| 197 | glMultMatrixcxx . . $ vcg/glMultMatrix(d6fcb610a9d9294f).(trackcxx . . $ vcg/Transform#track..InverseMatrixcxx . . $ vcg/Similarity#InverseMatrix(7c114f2e28b188e1).()); |
| 198 | glTranslatecxx . . $ vcg/glTranslate(fc87840241e07ad6).(-cxx . . $ vcg/Point3#operator-(6f246fd4bb5f10ad).centercxx . . $ vcg/Transform#center.); |
| 199 | } |
| 200 | |
| 201 | void Trackballcxx . . $ vcg/Trackball#::Scalecxx . . $ vcg/Trackball#Scale(9364e6e7bff7660).(const float s) |
| 202 | { |
| 203 | trackcxx . . $ vcg/Transform#track..scacxx . . $ vcg/Similarity#sca.*=s; |
| 204 | } |
| 205 | |
| 206 | void Trackballcxx . . $ vcg/Trackball#::Translatecxx . . $ vcg/Trackball#Translate(8c9d966b9d6d20d).(Point3fcxx . . $ vcg/Point3f# tr) |
| 207 | { |
| 208 | Quaternionfcxx . . $ vcg/Quaternionf# irot = trackcxx . . $ vcg/Transform#track..rotcxx . . $ vcg/Similarity#rot.; |
| 209 | irot.Invertcxx . . $ vcg/Quaternion#Invert(49f6e7a06ebc5aa8).(); |
| 210 | trackcxx . . $ vcg/Transform#track..tracxx . . $ vcg/Similarity#tra. =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). last_trackcxx . . $ vcg/Trackball#last_track..tracxx . . $ vcg/Similarity#tra. +cxx . . $ vcg/Point3#operator+(df3b8fd47e21bd0c). irot.Rotatecxx . . $ vcg/Quaternion#Rotate(5903a07d8f3d5a70).(trcxx . . $ vcg/Point3#Point3(5401f57a7bce03f4).)/cxx . . $ vcg/Point3#`operator/`(19a42edf8b0c4f9d).trackcxx . . $ vcg/Transform#track..scacxx . . $ vcg/Similarity#sca.; |
| 211 | } |
| 212 | |
| 213 | /***************************************************************/ |
| 214 | // DrawCircle () e DrawPlane() have been moved to trackutils.h |
| 215 | // the drawing code has been moved to the trackmodes |
| 216 | /* |
| 217 | void Trackball::DrawCircle() { |
| 218 | int nside=DH.CircleStep; |
| 219 | const double pi2=3.14159265*2.0; |
| 220 | glBegin(GL_LINE_LOOP); |
| 221 | for(double i=0;i<nside;i++){ |
| 222 | glNormal3d(cos(i*pi2/nside), sin(i*pi2/nside), 0.0); |
| 223 | glVertex3d(cos(i*pi2/nside), sin(i*pi2/nside), 0.0); |
| 224 | } |
| 225 | glEnd(); |
| 226 | DrawPlaneHandle(); |
| 227 | } |
| 228 | |
| 229 | void Trackball::DrawPlane() { |
| 230 | const int nl=10; |
| 231 | float w=5.0f/3.0f; |
| 232 | float u; |
| 233 | glBegin(GL_LINES); |
| 234 | glNormal3f(0.0,0.0,1.0); |
| 235 | for( u=-w; u<=w+0.01f; u+=2*w/nl){ |
| 236 | glVertex3f(-w, +u, 0); |
| 237 | glVertex3f(+w, +u, 0); |
| 238 | glVertex3f(+u, -w, 0); |
| 239 | glVertex3f(+u, +w, 0); |
| 240 | } |
| 241 | glEnd(); |
| 242 | } |
| 243 | */ |
| 244 | |
| 245 | void Trackballcxx . . $ vcg/Trackball#::ToAsciicxx . . $ vcg/Trackball#ToAscii(fda57c8427c60377).(char* result){ |
| 246 | float * f = (float*) &trackcxx . . $ vcg/Transform#track.; |
| 247 | sprintf(result, "trackball(%f,%f,%f,%f,%f,%f,%f,%f,%f)", |
| 248 | f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8] ); |
| 249 | } |
| 250 | |
| 251 | bool Trackballcxx . . $ vcg/Trackball#::SetFromAsciicxx . . $ vcg/Trackball#SetFromAscii(c5f7da30cbc0f4e9).(const char * st){ |
| 252 | float * f = (float*) &trackcxx . . $ vcg/Transform#track.; |
| 253 | int res= sscanf(st, "trackball(%f,%f,%f,%f,%f,%f,%f,%f,%f)", |
| 254 | f+0,f+1,f+2,f+3,f+4,f+5,f+6,f+7,f+8 ); |
| 255 | |
| 256 | return (res==9); |
| 257 | |
| 258 | } |
| 259 | |
| 260 | // DrawPlaneHandle() e DrawIcon() have been moved to trackutils.h |
| 261 | // the drawing code has been moved to the trackmodes |
| 262 | /* |
| 263 | void Trackball::DrawPlaneHandle() { |
| 264 | float r=1.0; |
| 265 | float dr=r/10.0f; |
| 266 | glBegin(GL_LINE_STRIP); |
| 267 | glVertex3f(+r+dr, +r, 0.0); |
| 268 | glVertex3f(+r , +r+dr,0.0); |
| 269 | glVertex3f(+r-dr, +r, 0.0); |
| 270 | glVertex3f(+r , +r-dr,0.0); |
| 271 | glVertex3f(+r+dr, +r, 0.0); |
| 272 | glEnd(); |
| 273 | glBegin(GL_LINE_STRIP); |
| 274 | glVertex3f(-r+dr, -r, 0.0); |
| 275 | glVertex3f(-r , -r+dr,0.0); |
| 276 | glVertex3f(-r-dr, -r, 0.0); |
| 277 | glVertex3f(-r , -r-dr,0.0); |
| 278 | glVertex3f(-r+dr, -r, 0.0); |
| 279 | glEnd(); |
| 280 | } |
| 281 | |
| 282 | void Trackball::DrawIcon() { |
| 283 | glPushMatrix(); |
| 284 | |
| 285 | glScale(radius); |
| 286 | /// Here start the real drawing stuff |
| 287 | float amb[4] ={.3f,.3f,.3f,1.0f}; |
| 288 | float col[4] ={.5f,.5f,.8f,1.0f}; |
| 289 | //float col2[4]={.9f,.9f,1.0f,1.0f}; |
| 290 | glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT); |
| 291 | |
| 292 | |
| 293 | if(current_mode == NULL ) glLineWidth(DH.LineWidthStill); |
| 294 | else glLineWidth(DH.LineWidthMoving); |
| 295 | |
| 296 | glEnable(GL_LIGHTING); |
| 297 | glEnable(GL_LIGHT0); |
| 298 | glEnable(GL_LINE_SMOOTH); |
| 299 | glEnable(GL_BLEND); |
| 300 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 301 | glColor(DH.color); |
| 302 | |
| 303 | glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,amb); |
| 304 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,col); |
| 305 | glPushMatrix(); |
| 306 | DrawCircle(); |
| 307 | glPushMatrix(); |
| 308 | |
| 309 | glRotatef(90,1,0,0); |
| 310 | DrawCircle(); |
| 311 | glRotatef(90,0,1,0); |
| 312 | DrawCircle(); |
| 313 | |
| 314 | glPopMatrix(); |
| 315 | glPopMatrix(); |
| 316 | |
| 317 | //glColor4f(1.0,.8f,.8f,1.0f); |
| 318 | |
| 319 | glPopAttrib(); |
| 320 | |
| 321 | glPopMatrix(); |
| 322 | } |
| 323 | */ |
| 324 | |
| 325 | void Trackballcxx . . $ vcg/Trackball#::Resetcxx . . $ vcg/Trackball#Reset(49f6e7a06ebc5aa8).() { |
| 326 | trackcxx . . $ vcg/Transform#track..SetIdentitycxx . . $ vcg/Similarity#SetIdentity(6e6672ce44b14785).(); |
| 327 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 328 | stdcxx . . $ std/::mapcxx . . $ std/map#<int, TrackMode *>::iteratorcxx . . $ std/map#iterator# icxx . . $ std/_Rb_tree_iterator#_Rb_tree_iterator(ced63f7c635d850d).; |
| 329 | for(i =cxx . . $ std/_Rb_tree_iterator#`operator=`(3aa99e3e3f44eabe). modescxx . . $ vcg/Trackball#modes..begincxx . . $ std/map#begin(7e4de33083b6e738).(); i !=cxx . . $ std/`operator!=`(be6a71a859368080). modescxx . . $ vcg/Trackball#modes..endcxx . . $ std/map#end(7e4de33083b6e738).(); i++cxx . . $ std/_Rb_tree_iterator#operator++(2987e7ff93f61dc1).){ |
| 330 | TrackModecxx . . $ vcg/TrackMode# * mode=(*cxx . . $ std/_Rb_tree_iterator#`operator*`(d426bc7b625886b7).i).second; |
| 331 | if(mode!=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 332 | mode->Resetcxx . . $ vcg/TrackMode#Reset(49f6e7a06ebc5aa8).(); |
| 333 | } |
| 334 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(inactive_mode != NULL); |
| 335 | inactive_modecxx . . $ vcg/Trackball#inactive_mode.->Resetcxx . . $ vcg/TrackMode#Reset(49f6e7a06ebc5aa8).(); |
| 336 | } |
| 337 | |
| 338 | //interface |
| 339 | void Trackballcxx . . $ vcg/Trackball#::MouseDowncxx . . $ vcg/Trackball#MouseDown(d4f767463ce0a6b3).(int button) { |
| 340 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 341 | current_buttoncxx . . $ vcg/Trackball#current_button. |= button; |
| 342 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 343 | Hitscxx . . $ vcg/Trackball#Hits..clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 344 | } |
| 345 | void Trackballcxx . . $ vcg/Trackball#::MouseDowncxx . . $ vcg/Trackball#MouseDown(b1146eedae1e1d0b).(int x, int y, int button) { |
| 346 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 347 | current_buttoncxx . . $ vcg/Trackball#current_button. |= button; |
| 348 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 349 | last_pointcxx . . $ vcg/Trackball#last_point. =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).((float)x, (float)y, 0); |
| 350 | Hitscxx . . $ vcg/Trackball#Hits..clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 351 | } |
| 352 | |
| 353 | void Trackballcxx . . $ vcg/Trackball#::MouseMovecxx . . $ vcg/Trackball#MouseMove(3e454b8ccf442868).(int x, int y) { |
| 354 | if(current_modecxx . . $ vcg/Trackball#current_mode. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) return; |
| 355 | if(last_pointcxx . . $ vcg/Trackball#last_point.[cxx . . $ vcg/Point3#`operator[]`(7a0ef1c7079e8533).2] == -1) { //changed mode in the middle of moving |
| 356 | last_pointcxx . . $ vcg/Trackball#last_point. =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).((float)x, (float)y, 0); |
| 357 | return; |
| 358 | } |
| 359 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 360 | current_modecxx . . $ vcg/Trackball#current_mode.->Applycxx . . $ vcg/TrackMode#Apply(dd961599e018a09).(this, Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2).(float(x), float(y), 0)); |
| 361 | } |
| 362 | |
| 363 | void Trackballcxx . . $ vcg/Trackball#::MouseUpcxx . . $ vcg/Trackball#MouseUp(b1146eedae1e1d0b).(int /* x */, int /* y */, int button) { |
| 364 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 365 | current_buttoncxx . . $ vcg/Trackball#current_button. &= (~button); |
| 366 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 367 | } |
| 368 | |
| 369 | // it assumes that a notch of 1.0 is a single step of the wheel |
| 370 | void Trackballcxx . . $ vcg/Trackball#::MouseWheelcxx . . $ vcg/Trackball#MouseWheel(9364e6e7bff7660).(float notch) |
| 371 | { |
| 372 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 373 | int buttons = current_buttoncxx . . $ vcg/Trackball#current_button.; |
| 374 | current_buttoncxx . . $ vcg/Trackball#current_button. = WHEELcxx . . $ vcg/Trackball#WHEEL. | (buttons&(KEY_SHIFTcxx . . $ vcg/Trackball#KEY_SHIFT.|KEY_CTRLcxx . . $ vcg/Trackball#KEY_CTRL.|KEY_ALTcxx . . $ vcg/Trackball#KEY_ALT.)); |
| 375 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 376 | if (current_modecxx . . $ vcg/Trackball#current_mode. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 377 | { |
| 378 | ScaleModecxx . . $ vcg/ScaleMode# scalemode; |
| 379 | scalemode.Applycxx . . $ vcg/ScaleMode#Apply(727d76963269bc9a). (this, notch); |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | current_modecxx . . $ vcg/Trackball#current_mode.->Applycxx . . $ vcg/TrackMode#Apply(727d76963269bc9a).(this, notch); |
| 384 | } |
| 385 | current_buttoncxx . . $ vcg/Trackball#current_button. = buttons; |
| 386 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 387 | } |
| 388 | |
| 389 | void Trackballcxx . . $ vcg/Trackball#::MouseWheelcxx . . $ vcg/Trackball#MouseWheel(1746e8aa98ca1bc0).(float notch, int button) |
| 390 | { |
| 391 | undo_trackcxx . . $ vcg/Trackball#undo_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 392 | current_buttoncxx . . $ vcg/Trackball#current_button. |= button; |
| 393 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 394 | if (current_modecxx . . $ vcg/Trackball#current_mode. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 395 | ScaleModecxx . . $ vcg/ScaleMode# scalemode; |
| 396 | scalemode.Applycxx . . $ vcg/ScaleMode#Apply(727d76963269bc9a). (this, notch); |
| 397 | } else { |
| 398 | current_modecxx . . $ vcg/Trackball#current_mode.->Applycxx . . $ vcg/TrackMode#Apply(727d76963269bc9a). (this, notch); |
| 399 | } |
| 400 | current_buttoncxx . . $ vcg/Trackball#current_button. &= (~button); |
| 401 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8). (); |
| 402 | } |
| 403 | |
| 404 | void Trackballcxx . . $ vcg/Trackball#::ButtonDowncxx . . $ vcg/Trackball#ButtonDown(8a427f6384c0f7e5).(Trackballcxx . . $ vcg/Trackball#::Buttoncxx . . $ vcg/Trackball#Button# button) { |
| 405 | bool old_sticky=false, new_sticky=false; |
| 406 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`! (modes.count (0)); |
| 407 | if ( ( modescxx . . $ vcg/Trackball#modes..countcxx . . $ std/map#count(ea780b5adf43227). (current_buttoncxx . . $ vcg/Trackball#current_button.) ) && ( modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! ) ) { |
| 408 | old_sticky = modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.]->isStickycxx . . $ vcg/TrackMode#isSticky(c9857a73d68e59ba).(); |
| 409 | } |
| 410 | current_buttoncxx . . $ vcg/Trackball#current_button. |= button; |
| 411 | if ( ( modescxx . . $ vcg/Trackball#modes..countcxx . . $ std/map#count(ea780b5adf43227). (current_buttoncxx . . $ vcg/Trackball#current_button.) ) && ( modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! ) ) { |
| 412 | new_sticky = modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.]->isStickycxx . . $ vcg/TrackMode#isSticky(c9857a73d68e59ba).(); |
| 413 | } |
| 414 | if ( old_sticky || new_sticky) |
| 415 | return; |
| 416 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 417 | } |
| 418 | |
| 419 | void Trackballcxx . . $ vcg/Trackball#::ButtonUpcxx . . $ vcg/Trackball#ButtonUp(8a427f6384c0f7e5).(Trackballcxx . . $ vcg/Trackball#::Buttoncxx . . $ vcg/Trackball#Button# button) { |
| 420 | bool old_sticky=false, new_sticky=false; |
| 421 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`! ( modes.count (0) ); |
| 422 | if ( ( modescxx . . $ vcg/Trackball#modes..countcxx . . $ std/map#count(ea780b5adf43227). (current_buttoncxx . . $ vcg/Trackball#current_button.) ) && ( modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! ) ) { |
| 423 | old_sticky = modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.]->isStickycxx . . $ vcg/TrackMode#isSticky(c9857a73d68e59ba).(); |
| 424 | } |
| 425 | current_buttoncxx . . $ vcg/Trackball#current_button. &= (~button); |
| 426 | if ( ( modescxx . . $ vcg/Trackball#modes..countcxx . . $ std/map#count(ea780b5adf43227). (current_buttoncxx . . $ vcg/Trackball#current_button.) ) && ( modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.] != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! ) ) { |
| 427 | new_sticky = modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.]->isStickycxx . . $ vcg/TrackMode#isSticky(c9857a73d68e59ba).(); |
| 428 | } |
| 429 | if ( old_sticky || new_sticky) |
| 430 | return; |
| 431 | SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8).(); |
| 432 | } |
| 433 | |
| 434 | void Trackballcxx . . $ vcg/Trackball#::Undocxx . . $ vcg/Trackball#Undo(49f6e7a06ebc5aa8).(){ |
| 435 | trackcxx . . $ vcg/Transform#track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). undo_trackcxx . . $ vcg/Trackball#undo_track.; |
| 436 | if(current_modecxx . . $ vcg/Trackball#current_mode. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 437 | current_modecxx . . $ vcg/Trackball#current_mode.->Undocxx . . $ vcg/TrackMode#Undo(49f6e7a06ebc5aa8).(); |
| 438 | } |
| 439 | |
| 440 | |
| 441 | //spinning interface |
| 442 | void Trackballcxx . . $ vcg/Trackball#::SetSpinnablecxx . . $ vcg/Trackball#SetSpinnable(b45ddcbc8423892c).(bool /* on*/ ){} |
| 443 | bool Trackballcxx . . $ vcg/Trackball#::IsSpinnablecxx . . $ vcg/Trackball#IsSpinnable(c9857a73d68e59ba).() { |
| 444 | return spinnablecxx . . $ vcg/Trackball#spinnable.; |
| 445 | } |
| 446 | void Trackballcxx . . $ vcg/Trackball#::SetSpinningcxx . . $ vcg/Trackball#SetSpinning(5feed1d272678cca).(Quaternionfcxx . . $ vcg/Quaternionf# &/* spin*/){} |
| 447 | void Trackballcxx . . $ vcg/Trackball#::StopSpinningcxx . . $ vcg/Trackball#StopSpinning(49f6e7a06ebc5aa8).(){} |
| 448 | bool Trackballcxx . . $ vcg/Trackball#::IsSpinningcxx . . $ vcg/Trackball#IsSpinning(c9857a73d68e59ba).() { |
| 449 | return spinningcxx . . $ vcg/Trackball#spinning.; |
| 450 | } |
| 451 | |
| 452 | //navigation interface: |
| 453 | void Trackballcxx . . $ vcg/Trackball#::Backcxx . . $ vcg/Trackball#Back(49f6e7a06ebc5aa8).(){} |
| 454 | void Trackballcxx . . $ vcg/Trackball#::Forwardcxx . . $ vcg/Trackball#Forward(49f6e7a06ebc5aa8).(){} |
| 455 | void Trackballcxx . . $ vcg/Trackball#::Homecxx . . $ vcg/Trackball#Home(49f6e7a06ebc5aa8).(){} |
| 456 | void Trackballcxx . . $ vcg/Trackball#::HistorySizecxx . . $ vcg/Trackball#HistorySize(d4f767463ce0a6b3).(int /* length */){} |
| 457 | |
| 458 | void Trackballcxx . . $ vcg/Trackball#::SetCurrentActioncxx . . $ vcg/Trackball#SetCurrentAction(49f6e7a06ebc5aa8). () |
| 459 | { |
| 460 | //I use strict matching. |
| 461 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`! (modes.count (0)); |
| 462 | if (!modescxx . . $ vcg/Trackball#modes..countcxx . . $ std/map#count(ea780b5adf43227). (current_buttoncxx . . $ vcg/Trackball#current_button.)) { |
| 463 | current_modecxx . . $ vcg/Trackball#current_mode. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 464 | } else { |
| 465 | current_modecxx . . $ vcg/Trackball#current_mode. = modescxx . . $ vcg/Trackball#modes.[cxx . . $ std/map#`operator[]`(bbd415b616967878).current_buttoncxx . . $ vcg/Trackball#current_button.]; |
| 466 | if(current_modecxx . . $ vcg/Trackball#current_mode. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 467 | current_modecxx . . $ vcg/Trackball#current_mode.->SetActioncxx . . $ vcg/TrackMode#SetAction(49f6e7a06ebc5aa8).(); |
| 468 | } |
| 469 | last_pointcxx . . $ vcg/Trackball#last_point. =cxx . . $ vcg/Point3#`operator=`(4233705dd3c5533e). Point3fcxx . . $ vcg/Point3#Point3(ca6b6cb9f73ddfb2). (0, 0, -1); |
| 470 | last_trackcxx . . $ vcg/Trackball#last_track. =cxx . . $ vcg/Similarityf#`operator=`(c6bef3d1d0ae03). trackcxx . . $ vcg/Transform#track.; |
| 471 | } |
| 472 | |
| 473 | ////return center of trackball in Window coordinates. |
| 474 | //Point3f Trackball::ScreenOrigin() { |
| 475 | // return camera.Project(ModelOrigin()); |
| 476 | //} |
| 477 | |
| 478 | |
| 479 | //return center of trackball in Model coordinates |
| 480 | //Point3f Trackball::ModelOrigin() { |
| 481 | // return center; |
| 482 | //} |
| 483 | |
| 484 | //Matrix44f Trackball::ScreenToModel() { |
| 485 | // return camera.inverse; |
| 486 | //} |
| 487 | // |
| 488 | //Similarityf Trackball::ModelToLocal() { |
| 489 | // Similarityf m = local * last_track; |
| 490 | // return m; |
| 491 | //} |
| 492 |