|
From: <joh...@ie...> - 2000-05-19 05:30:37
|
Patch: vhclmaps-000519-johnston-028
For: vhclmaps-0.7.4
Author: joh...@us...
Subject: changeview utmviewer command slips in a new composite graphic
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:
- "changeview" is a new utmviewer command for replacing the composite
graphic (the OverlaysComp/Picture) associated with a variable in the
interpreter:
compview=changeview(compview drawtoolstr) -- change composite graphic associated with a vehicle"; }
Index: UtmUnidraw/utmeditor.c
diff -c UtmUnidraw/utmeditor.c:1.5 UtmUnidraw/utmeditor.c:1.6
*** UtmUnidraw/utmeditor.c:1.5 Fri Apr 7 04:24:56 2000
--- src/UtmUnidraw/utmeditor.c Fri May 19 11:36:02 2000
***************
*** 126,131 ****
--- 126,132 ----
comterp->add_command("vhclview", new VhclViewFunc(comterp, this));
comterp->add_command("moveview", new VhclMoveToFunc(comterp, this));
+ comterp->add_command("changeview", new VhclChangeViewFunc(comterp, this));
comterp->add_command("rteview", new RteViewFunc(comterp, this));
comterp->add_command("paste", new PasteFunc(comterp, this));
Index: UtmUnidraw/utmfunc.c
diff -c UtmUnidraw/utmfunc.c:1.5 UtmUnidraw/utmfunc.c:1.6
*** UtmUnidraw/utmfunc.c:1.5 Wed May 10 03:25:10 2000
--- src/UtmUnidraw/utmfunc.c Fri May 19 11:36:02 2000
***************
*** 40,48 ****
#include <Unidraw/Graphic/graphic.h>
#include <Unidraw/Components/component.h>
#include <Unidraw/Components/compview.h>
! #include <Unidraw/Graphic/graphic.h>
#include <Unidraw/clipboard.h>
#include <Unidraw/selection.h>
#include <Unidraw/unidraw.h>
#include <Unidraw/viewer.h>
#include <ComTerp/comvalue.h>
--- 40,49 ----
#include <Unidraw/Graphic/graphic.h>
#include <Unidraw/Components/component.h>
#include <Unidraw/Components/compview.h>
! #include <Unidraw/Graphic/picture.h>
#include <Unidraw/clipboard.h>
#include <Unidraw/selection.h>
+ #include <Unidraw/ulist.h>
#include <Unidraw/unidraw.h>
#include <Unidraw/viewer.h>
#include <ComTerp/comvalue.h>
***************
*** 223,228 ****
--- 224,295 ----
#endif
}
push_stack(compval);
+ } else
+ push_stack(ComValue::nullval());
+ return;
+ }
+
+
+ /*****************************************************************************/
+
+ VhclChangeViewFunc::VhclChangeViewFunc(ComTerp* comterp, Editor* ed) : UtmFunc(comterp, ed) {
+ }
+
+ void VhclChangeViewFunc::execute() {
+ ComValue compsym(stack_arg(0, true));
+ ComValue compval(lookup_symval(compsym));
+ ComValue grstr(stack_arg(1));
+ reset_stack();
+
+ istrstream in(grstr.string_ptr());
+ const char* first_token = "drawtool";
+ int len = strlen(first_token)+1;
+ char buf[len];
+
+ char ch;
+ while (isspace(ch = in.get())); in.putback(ch);
+ ParamList::parse_token(in, buf, len);
+ if (strcmp(buf, first_token)!=0) {
+ push_stack(ComValue::nullval());
+ return;
+ }
+
+ OverlaysComp* newvhclpict = new OverlaysComp(in, nil);
+
+ OverlaysComp* oldvhclpict =
+ (OverlaysComp*)compval.geta(OverlaysComp::class_symid());
+
+ if (newvhclpict && oldvhclpict) {
+ MacroCmd* macrocmd = new MacroCmd();
+
+ Clipboard* delcb = new Clipboard;
+ delcb->Append(oldvhclpict);
+ macrocmd->Append(new DeleteCmd(GetEditor(), delcb));
+
+ Graphic* newgr = newvhclpict->GetGraphic();
+ Graphic* oldgr = oldvhclpict->GetGraphic();
+ if (oldgr && newgr) newgr->SetTransformer(oldgr->GetTransformer());
+
+ Clipboard* pastecb = new Clipboard();
+ pastecb->Append(newvhclpict);
+ macrocmd->Append(new PasteCmd(GetEditor(), pastecb));
+
+ macrocmd->Execute();
+ unidraw->Update();
+ newvhclpict->SetAttributeList(oldvhclpict->attrlist());
+ UList* vl = oldvhclpict->ViewList();
+ for (UList* u = vl->First(); u != vl->End(); ) {
+ ComponentView* oldview = oldvhclpict->View(u);
+ u = u->Next();
+ if (oldview && oldview->IsA(COMPONENT_VIEW) && !oldview->IsA(OVERLAY_VIEW)) {
+ /* this must be a variable, transfer the new value over */
+ oldvhclpict->Detach(oldview);
+ oldview->SetSubject(newvhclpict);
+ newvhclpict->Attach(oldview);
+ }
+ }
+ delete macrocmd;
+
} else
push_stack(ComValue::nullval());
return;
Index: UtmUnidraw/utmfunc.h
diff -c UtmUnidraw/utmfunc.h:1.5 UtmUnidraw/utmfunc.h:1.6
*** UtmUnidraw/utmfunc.h:1.5 Sat May 6 05:53:49 2000
--- src/UtmUnidraw/utmfunc.h Fri May 19 11:36:02 2000
***************
*** 61,66 ****
--- 61,75 ----
int _heading_symid;
};
+ class VhclChangeViewFunc : public UtmFunc {
+ public:
+ VhclChangeViewFunc(ComTerp*, Editor*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "compview=%s(compview drawtoolstr) -- change composite graphic associated with a vehicle"; }
+
+ };
+
class RteViewFunc : public UtmFunc {
public:
RteViewFunc(ComTerp*, Editor*);
*** /dev/null Fri May 19 11:36:12 PDT 2000
--- patches/vhclmaps-000519-johnston-028
*************** patches/vhclmaps-000519-johnston-028
*** 0 ****
--- 1 ----
+ vhclmaps-000519-johnston-028
|