Added dashed line between org anchor and corresponding line, and tweaked the display of all visual typesetting tools to make them more visible.

Originally committed to SVN as r1353.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-04 20:25:24 +00:00
parent 2251c79791
commit 93571ce295
3 changed files with 51 additions and 25 deletions

View File

@ -60,9 +60,9 @@
VisualTool::VisualTool(VideoDisplay *par) : eventSink(this) { VisualTool::VisualTool(VideoDisplay *par) : eventSink(this) {
// Config // Config
parent = par; parent = par;
colour[0] = wxColour(27,60,114); colour[0] = wxColour(106,32,19);
colour[1] = wxColour(166,247,177); colour[1] = wxColour(255,169,40);
colour[2] = wxColour(255,255,255); colour[2] = wxColour(255,253,185);
colour[3] = wxColour(187,0,0); colour[3] = wxColour(187,0,0);
// Holding variables // Holding variables
@ -298,8 +298,8 @@ void VisualTool::DrawAllFeatures() {
// Draw features // Draw features
for (size_t i=0;i<features.size();i++) { for (size_t i=0;i<features.size();i++) {
SetFillColour(colour[(signed)i == mouseOver ? 2 : 1],0.3f); SetFillColour(colour[(signed)i == mouseOver ? 2 : 1],0.6f);
SetLineColour(colour[0]); SetLineColour(colour[0],1.0f,2);
features[i].Draw(this); features[i].Draw(this);
} }
} }

View File

@ -143,35 +143,55 @@ void VisualToolDrag::Draw() {
// Draw arrows // Draw arrows
for (size_t i=0;i<features.size();i++) { for (size_t i=0;i<features.size();i++) {
if (features[i].brother[0] != -1 && features[i].type == DRAG_BIG_SQUARE) { if (features[i].brother[0] != -1 && (features[i].type == DRAG_BIG_CIRCLE || features[i].type == DRAG_BIG_TRIANGLE)) {
// Get features // Get features
VisualDraggableFeature *p1,*p2; VisualDraggableFeature *p1,*p2;
p1 = &features[i]; p2 = &features[i];
p2 = &features[p1->brother[0]]; p1 = &features[p2->brother[0]];
// See if the distance between them is at least 30 pixels // Has arrow?
bool hasArrow = p2->type == DRAG_BIG_CIRCLE;
int arrowLen = hasArrow ? 10 : 0;
// See if the distance between them is enough
int dx = p2->x - p1->x; int dx = p2->x - p1->x;
int dy = p2->y - p1->y; int dy = p2->y - p1->y;
int dist = (int)sqrt(double(dx*dx + dy*dy)); int dist = (int)sqrt(double(dx*dx + dy*dy));
if (dist < 30) continue; if (dist < 20+arrowLen) continue;
// Get end points // Get end points
int x1 = p1->x + dx*10/dist; int x1 = p1->x + dx*10/dist;
int x2 = p2->x - dx*20/dist; int x2 = p2->x - dx*(10+arrowLen)/dist;
int y1 = p1->y + dy*10/dist; int y1 = p1->y + dy*10/dist;
int y2 = p2->y - dy*20/dist; int y2 = p2->y - dy*(10+arrowLen)/dist;
// Draw line
SetLineColour(colour[3],0.8f,2);
DrawLine(x1,y1,x2,y2);
// Draw arrow // Draw arrow
double angle = atan2(double(y2-y1),double(x2-x1))+1.570796; if (hasArrow) {
int sx = int(cos(angle)*4); // Calculate angle
int sy = int(-sin(angle)*4); double angle = atan2(double(y2-y1),double(x2-x1))+1.570796;
DrawLine(x2+sx,y2-sy,x2-sx,y2+sy); int sx = int(cos(angle)*4);
DrawLine(x2+sx,y2-sy,x2+dx*10/dist,y2+dy*10/dist); int sy = int(-sin(angle)*4);
DrawLine(x2-sx,y2+sy,x2+dx*10/dist,y2+dy*10/dist);
// Arrow line
SetLineColour(colour[3],0.8f,2);
DrawLine(x1,y1,x2,y2);
// Arrow head
DrawLine(x2+sx,y2-sy,x2-sx,y2+sy);
DrawLine(x2+sx,y2-sy,x2+dx*10/dist,y2+dy*10/dist);
DrawLine(x2-sx,y2+sy,x2+dx*10/dist,y2+dy*10/dist);
}
// Draw dashed line
else {
SetLineColour(colour[3],0.5f,2);
int steps = (dist-20)/6;
double stepx = double(x2-x1)/steps;
double stepy = double(y2-y1)/steps;
for (int i=0;i<steps;i++) {
if (i % 2 == 0) DrawLine(x1+int(i*stepx),y1+int(i*stepy),x1+int((i+1)*stepx),y1+int((i+1)*stepy));
}
}
} }
} }
} }
@ -215,6 +235,7 @@ void VisualToolDrag::PopulateFeatureList() {
feat.line = diag; feat.line = diag;
feat.lineN = i; feat.lineN = i;
features.push_back(feat); features.push_back(feat);
int parentN = features.size()-1;
// Create move destination feature // Create move destination feature
if (hasMove) { if (hasMove) {
@ -229,8 +250,8 @@ void VisualToolDrag::PopulateFeatureList() {
// Add each other as brothers. // Add each other as brothers.
int n = features.size(); int n = features.size();
features[n-1].brother[0] = n-2; features[n-1].brother[0] = parentN;
features[n-2].brother[0] = n-1; features[parentN].brother[0] = n-1;
} }
// Create org feature // Create org feature
@ -243,6 +264,11 @@ void VisualToolDrag::PopulateFeatureList() {
feat.line = diag; feat.line = diag;
feat.lineN = i; feat.lineN = i;
features.push_back(feat); features.push_back(feat);
// Add each other as brothers.
int n = features.size();
features[n-1].brother[0] = parentN;
features[parentN].brother[1] = n-1;
} }
} }
} }

View File

@ -108,7 +108,7 @@ void VisualToolRotateXY::Draw() {
// Draw grid // Draw grid
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
SetLineColour(colour[0],0.5f,1); SetLineColour(colour[0],0.5f,2);
SetModeLine(); SetModeLine();
float r = colour[0].Red()/255.0f; float r = colour[0].Red()/255.0f;
float g = colour[0].Green()/255.0f; float g = colour[0].Green()/255.0f;