|
From: <joh...@ie...> - 2000-04-14 21:53:42
|
Patch: vhclmaps-000410-johnston-020
For: vhclmaps-0.7.4
Author: joh...@us...
Subject: remove Edit and Struct menus from map viewers, further composite vehicle improvements, routedist command.
Requires:
This is an intermediate patch to vhclmaps-0.7.4. To apply, cd to the
top-level directory of the vhclmaps source tree (the directory with src
and config subdirs), and apply like this:
patch -p0 <ThisFile
Summary of Changes:
- remove Edit and Struct menu from utmviewer and all derivatives.
There is a fundamental limitation with the implementation of
MapFeatureComp that disables commands like Duplicate and Group.
Originally for reasons of efficiency, the map feature component did
not have a graphic, but a MapFeature object instead. This problem
could be fixed by introducing a mostly empty Graphic placeholder in
the map feature component.
- improve the composite vehicle object to rotate them as needed when
the direction vector changes.
- add a routedist command to compute the total distance of a set of
waypoints.
Index: UtmUnidraw/utmkit.h
diff -c UtmUnidraw/utmkit.h:1.2 UtmUnidraw/utmkit.h:1.3
*** UtmUnidraw/utmkit.h:1.2 Fri Apr 7 04:24:56 2000
--- src/UtmUnidraw/utmkit.h Mon Apr 10 22:40:51 2000
***************
*** 48,53 ****
--- 48,54 ----
virtual Glyph* MakeToolbar();
virtual Glyph* MakeStates();
virtual MenuItem* MakeFileMenu();
+ virtual MenuItem* MakeEditMenu() { return nil; }
virtual MenuItem* MakeStructureMenu() { return nil; }
virtual MenuItem* MakeRouteMenu();
virtual MenuItem* MakeMapMenu();
Index: Vehicle/compositevhcl.c
diff -c Vehicle/compositevhcl.c:1.4 Vehicle/compositevhcl.c:1.5
*** Vehicle/compositevhcl.c:1.4 Fri Apr 7 04:25:03 2000
--- src/Vehicle/compositevhcl.c Mon Apr 10 22:40:59 2000
***************
*** 239,317 ****
void CompositeVehicle::jumpturn(float x, float y, float z,
float dx, float dy) {
! float angle =
! (asin(dy/sqrt(dx*dx+dy*dy)) - asin(ydir()/sqrt(xdir()*xdir()+ydir()*ydir())))*RAD_TO_DEG;
! rotate2d(angle);
!
! float cx = xloc();
! float cy = yloc();
! float cz = zloc();
! defer_composite_update()=true;
! int nvhcls = nsubvhcls();
! for(int i=0; i<nvhcls; i++) {
! Vehicle* subv = subvhcl(i);
! float xoff = subv->xloc()-cx;
! float yoff = subv->yloc()-cy;
! float zoff = subv->zloc()-cz;
! if (subv) subv->jumpturn(x+xoff, y+yoff, z+zoff, dx, dy);
}
- xdir() = dx;
- ydir() = dy;
- defer_composite_update()=false;
- recompute();notify();
}
void CompositeVehicle::jumpturn(float x, float y, float z,
float dx, float dy, float dz) {
! float angle =
! (asin(dy/sqrt(dx*dx+dy*dy)) - asin(ydir()/sqrt(xdir()*xdir()+ydir()*ydir())))*RAD_TO_DEG;
! rotate2d(angle);
!
! float cx = xloc();
! float cy = yloc();
! float cz = zloc();
! defer_composite_update()=true;
! int nvhcls = nsubvhcls();
! for(int i=0; i<nvhcls; i++) {
! Vehicle* subv = subvhcl(i);
! float xoff = subv->xloc()-cx;
! float yoff = subv->yloc()-cy;
! float zoff = subv->zloc()-cz;
! if (subv) subv->jumpturn(x+xoff, y+yoff, z+zoff, dx, dy);
}
- xdir() = dx;
- ydir() = dy;
- zdir() = dz;
- defer_composite_update()=false;
- recompute();notify();
}
void CompositeVehicle::jumpturn(float* loc, float* dir, int n) {
! float angle =
! (asin(dir[1]/sqrt(dir[0]*dir[0]+dir[1]*dir[1])) - asin(ydir()/sqrt(xdir()*xdir()+ydir()*ydir())))*RAD_TO_DEG;
! rotate2d(angle);
!
! defer_composite_update()=true;
! int nvhcls = nsubvhcls();
! float cs[n];
! if(n>0) cs[0] = xloc();
! if(n>1) cs[1] = yloc();
! if(n>2) cs[2] = zloc();
! for(int i=0; i<nvhcls; i++) {
! Vehicle* subv = subvhcl(i);
! float locoffs[n];
! if(n>0) locoffs[0] = loc[0] - (subv->xloc()-cs[0]);
! if(n>1) locoffs[1] = loc[1] - (subv->yloc()-cs[1]);
! if(n>2) locoffs[2] = loc[2] - (subv->zloc()-cs[2]);
!
! if (subv) subv->jumpturn(locoffs, dir, n);
}
- if(n>0) xdir() = dir[0];
- if(n>1) ydir() = dir[1];
- if(n>2) ydir() = dir[2];
- defer_composite_update()=false;
- recompute();notify();
}
void CompositeVehicle::forward2d(float dist) {
--- 239,326 ----
void CompositeVehicle::jumpturn(float x, float y, float z,
float dx, float dy) {
! if (dx||dy) {
! float angle =
! (asin(dy/sqrt(dx*dx+dy*dy)) - asin(ydir()/sqrt(xdir()*xdir()+ydir()*ydir())))*RAD_TO_DEG;
! rotate2d(angle);
!
! float cx = xloc();
! float cy = yloc();
! float cz = zloc();
! defer_composite_update()=true;
! int nvhcls = nsubvhcls();
! for(int i=0; i<nvhcls; i++) {
! Vehicle* subv = subvhcl(i);
! float xoff = subv->xloc()-cx;
! float yoff = subv->yloc()-cy;
! float zoff = subv->zloc()-cz;
! if (subv) subv->jumpturn(x+xoff, y+yoff, z+zoff, dx, dy);
! }
! xdir() = dx;
! ydir() = dy;
! defer_composite_update()=false;
! recompute();notify();
}
}
void CompositeVehicle::jumpturn(float x, float y, float z,
float dx, float dy, float dz) {
! if (dx||dy||dz) {
! float angle =
! (asin(dy/sqrt(dx*dx+dy*dy)) - asin(ydir()/sqrt(xdir()*xdir()+ydir()*ydir())))*RAD_TO_DEG;
! rotate2d(angle);
!
! float cx = xloc();
! float cy = yloc();
! float cz = zloc();
! defer_composite_update()=true;
! int nvhcls = nsubvhcls();
! for(int i=0; i<nvhcls; i++) {
! Vehicle* subv = subvhcl(i);
! float xoff = subv->xloc()-cx;
! float yoff = subv->yloc()-cy;
! float zoff = subv->zloc()-cz;
! if (subv) subv->jumpturn(x+xoff, y+yoff, z+zoff, dx, dy);
! }
! xdir() = dx;
! ydir() = dy;
! zdir() = dz;
! defer_composite_update()=false;
! recompute();notify();
}
}
void CompositeVehicle::jumpturn(float* loc, float* dir, int n) {
! boolean dirset = dir[0]!=0.0;
! if (n>1) dirset = dirset || dir[1]!=0.0;
! if (n>2) dirset = dirset || dir[2]!=0.0;
! if (dirset) {
! float angle =
! (asin(dir[1]/sqrt(dir[0]*dir[0]+dir[1]*dir[1])) - asin(ydir()/sqrt(xdir()*xdir()+ydir()*ydir())))*RAD_TO_DEG;
! rotate2d(angle);
! defer_composite_update()=true;
! int nvhcls = nsubvhcls();
! float cs[n];
! if(n>0) cs[0] = xloc();
! if(n>1) cs[1] = yloc();
! if(n>2) cs[2] = zloc();
! for(int i=0; i<nvhcls; i++) {
! Vehicle* subv = subvhcl(i);
!
! float locoffs[n];
! if(n>0) locoffs[0] = loc[0] - (subv->xloc()-cs[0]);
! if(n>1) locoffs[1] = loc[1] - (subv->yloc()-cs[1]);
! if(n>2) locoffs[2] = loc[2] - (subv->zloc()-cs[2]);
!
! if (subv) subv->jumpturn(locoffs, dir, n);
! }
! if(n>0) xdir() = dir[0];
! if(n>1) ydir() = dir[1];
! if(n>2) ydir() = dir[2];
! defer_composite_update()=false;
! recompute();notify();
}
}
void CompositeVehicle::forward2d(float dist) {
Index: Vehicle/route.c
diff -c Vehicle/route.c:1.1 Vehicle/route.c:1.2
*** Vehicle/route.c:1.1 Mon Aug 2 13:53:47 1999
--- src/Vehicle/route.c Mon Apr 10 22:40:59 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1997 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 161,164 ****
--- 162,176 ----
if (_curdir==0)
_vhcl->xdelta() = _vhcl->ydelta() = _vhcl->zdelta() = 0.0;
return _curdir == 0;
+ }
+
+ double Route::length() {
+ double alldist=0.0;
+ for(int i=0; i<npts()-1; i++) {
+ double xdist = x()[i+1]-x()[i];
+ double ydist = x()[i+1]-x()[i];
+ double zdist = x()[i+1]-x()[i];
+ alldist += sqrt(xdist*xdist+ydist*ydist+zdist*zdist);
+ }
+ return alldist;
}
Index: Vehicle/route.h
diff -c Vehicle/route.h:1.1 Vehicle/route.h:1.2
*** Vehicle/route.h:1.1 Mon Aug 2 13:53:47 1999
--- src/Vehicle/route.h Mon Apr 10 22:40:59 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1997 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 50,57 ****
--- 51,62 ----
void step(float meters);
boolean finished();
+ double length();
+
Vehicle* vehicle() { return _vhcl; }
void vehicle(Vehicle* vhcl) { _vhcl = vhcl; }
+
+
protected:
char* _name;
Index: VhclServ/vhclfunc.c
diff -c VhclServ/vhclfunc.c:1.5 VhclServ/vhclfunc.c:1.6
*** VhclServ/vhclfunc.c:1.5 Fri Mar 24 23:21:09 2000
--- src/VhclServ/vhclfunc.c Mon Apr 10 22:41:01 2000
***************
*** 844,846 ****
--- 844,864 ----
return;
}
+ /*****************************************************************************/
+
+ RouteDistFunc::RouteDistFunc(ComTerp* comterp) : VhclFunc(comterp) {
+ }
+
+ void RouteDistFunc::execute() {
+ ComValue rtesym(stack_arg(0, true));
+ RouteComp* rtecomp = VhclFunc::findrte(rtesym.symbol_val());
+ reset_stack();
+ if (!rtecomp) {
+ push_stack(ComValue::nullval());
+ return;
+ }
+ ComValue retval(rtecomp->route()->length());
+ push_stack(retval);
+ return;
+ }
+
Index: VhclServ/vhclfunc.h
diff -c VhclServ/vhclfunc.h:1.4 VhclServ/vhclfunc.h:1.5
*** VhclServ/vhclfunc.h:1.4 Wed Mar 29 23:08:51 2000
--- src/VhclServ/vhclfunc.h Mon Apr 10 22:41:01 2000
***************
*** 243,246 ****
--- 243,254 ----
int _speed_symid;
};
+ class RouteDistFunc : public VhclFunc {
+ public:
+ RouteDistFunc(ComTerp*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(rte) -- return total route distance"; }
+ };
+
#endif
Index: VhclServ/vhclhandler.c
diff -c VhclServ/vhclhandler.c:1.2 VhclServ/vhclhandler.c:1.3
*** VhclServ/vhclhandler.c:1.2 Sat Mar 18 02:24:17 2000
--- src/VhclServ/vhclhandler.c Mon Apr 10 22:41:01 2000
***************
*** 56,61 ****
--- 56,62 ----
comterp->add_command("vhcldelta", new VhclDeltaFunc(comterp));
comterp->add_command("simroute", new SimRouteFunc(comterp));
comterp->add_command("printroute", new PrintRouteFunc(comterp));
+ comterp->add_command("routedist", new RouteDistFunc(comterp));
MapservHandler::AddCommands(comterp);
comterp->add_command("load100kdlgfc", new Load100KDLGFCFunc(comterp));
*** /dev/null Mon Apr 10 22:41:07 PDT 2000
--- patches/vhclmaps-000410-johnston-020
*************** patches/vhclmaps-000410-johnston-020
*** 0 ****
--- 1 ----
+ vhclmaps-000410-johnston-020
|