3 This file is part of R²C²
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
11 #include "3d/layout.h"
18 Measure::Measure(Designer &d):
28 void Measure::snap_to_tracks(Vector &pt, float &dir)
30 const set<Track *> <racks = designer.get_layout().get_tracks();
31 for(set<Track *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
32 if((*i)->snap(pt, dir))
36 void Measure::button_press(int, int, float gx, float gy, unsigned btn)
43 spoint = Vector(gx, gy, 0);
45 snap_to_tracks(spoint, sdir);
61 void Measure::pointer_motion(int, int, float gx, float gy)
66 pointer = Vector(gx, gy, 0);
68 snap_to_tracks(pointer, dir);
72 Vector delta(pointer.x-spoint.x, pointer.y-spoint.y, 0);
76 par_dist = delta.x*c+delta.y*s;
77 perp_dist = delta.x*s-delta.y*c;
79 adiff = dir-sdir+M_PI;
85 signal_changed.emit();
89 void Measure::render()
93 glTranslatef(spoint.x, spoint.y, spoint.z);
94 else if(state==STARTING)
95 glTranslatef(pointer.x, pointer.y, pointer.z);
97 glDisable(GL_CULL_FACE);
98 glColor4f(1, 1, 1, 1);
99 glBegin(GL_QUAD_STRIP);
100 for(unsigned i=0; i<=16; ++i)
102 float x = cos(i*M_PI/8)*0.005;
103 float y = sin(i*M_PI/8)*0.005;
105 glVertex3f(x, y, 0.01);
113 glBegin(GL_QUAD_STRIP);
115 glVertex3f(0, 0, 0.01);
116 glVertex3f(c*par_dist, s*par_dist, 0);
117 glVertex3f(c*par_dist, s*par_dist, 0.01);
118 glVertex3f(pointer.x-spoint.x, pointer.y-spoint.y, 0);
119 glVertex3f(pointer.x-spoint.x, pointer.y-spoint.y, 0.01);
120 /*glVertex3f(s*perp_dist, -c*perp_dist, 0);
121 glVertex3f(s*perp_dist, -c*perp_dist, 0.01);*/
123 glVertex3f(0, 0, 0.01);