summaryrefslogtreecommitdiffstats
path: root/tksao
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-08-07 18:45:09 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-08-07 18:45:09 (GMT)
commit65e1b37de89e1bd6994096ed8647024f1ddb04c0 (patch)
tree091ff5618893c22018865722ab560cd801d8df58 /tksao
parent9a0df8d5b9819a02744d8254ca475e1acdae8b8e (diff)
parentde2c859f0fc52f7efa02a4076ae25597ee75b1c7 (diff)
downloadblt-65e1b37de89e1bd6994096ed8647024f1ddb04c0.zip
blt-65e1b37de89e1bd6994096ed8647024f1ddb04c0.tar.gz
blt-65e1b37de89e1bd6994096ed8647024f1ddb04c0.tar.bz2
Merge branch 'xor' into devel
Diffstat (limited to 'tksao')
-rw-r--r--tksao/frame/base.C27
-rw-r--r--tksao/frame/base.h4
-rw-r--r--tksao/frame/basecommand.C56
-rw-r--r--tksao/frame/fr3dcommand.C75
-rw-r--r--tksao/frame/frame3dbase.C25
-rw-r--r--tksao/frame/frame3dbase.h1
6 files changed, 70 insertions, 118 deletions
diff --git a/tksao/frame/base.C b/tksao/frame/base.C
index 66ebec5..92fc64b 100644
--- a/tksao/frame/base.C
+++ b/tksao/frame/base.C
@@ -99,6 +99,9 @@ Base::Base(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item)
useMagnifierCursor = 1;
magnifierColorName = dupstr("white");
+ useCrop =0;
+ useCrop3d =0;
+
wcsSystem_ = Coord::WCS;
wcsSkyFrame_ = Coord::FK5;
wcsSkyFormat_ = Coord::DEGREES;
@@ -1706,6 +1709,12 @@ void Base::updatePM(const BBox& bbox)
if (useCrosshair)
x11Crosshair(pixmap, Coord::WIDGET, options->width, options->height);
+ // crop
+ if (useCrop)
+ x11Crop();
+ if (useCrop3d)
+ x11Crop3d();
+
// highlite bbox/compass
x11Graphics();
@@ -1723,6 +1732,24 @@ char* Base::varcat(char* buf, char* base, char id, char* mod)
return buf;
}
+void Base::x11Crop()
+{
+ if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
+ Vector ss = mapToRef(cropBegin, Coord::CANVAS);
+ Vector tt = mapToRef(cropEnd, Coord::CANVAS);
+
+ Vector ll = mapFromRef(ss, Coord::CANVAS);
+ Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::CANVAS);
+ Vector ur = mapFromRef(tt, Coord::CANVAS);
+ Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::CANVAS);
+
+ XDrawLine(display,pixmap,selectGCXOR,ll[0],ll[1],lr[0],lr[1]);
+ XDrawLine(display,pixmap,selectGCXOR,lr[0],lr[1],ur[0],ur[1]);
+ XDrawLine(display,pixmap,selectGCXOR,ur[0],ur[1],ul[0],ul[1]);
+ XDrawLine(display,pixmap,selectGCXOR,ul[0],ul[1],ll[0],ll[1]);
+ }
+}
+
void Base::x11Crosshair(Pixmap pm, Coord::InternalSystem sys,
int width, int height)
{
diff --git a/tksao/frame/base.h b/tksao/frame/base.h
index 02f9bd4..f2c2786 100644
--- a/tksao/frame/base.h
+++ b/tksao/frame/base.h
@@ -205,6 +205,8 @@ public:
Vector magnifierCursor; // we need to save the last cursor used
char* magnifierColorName;
+ int useCrop;
+ int useCrop3d;
Vector cropBegin;
Vector cropEnd;
@@ -482,6 +484,8 @@ public:
char* varcat(char*, char*, char, char*);
virtual int validColorScale() =0;
+ void x11Crop();
+ virtual void x11Crop3d() {}
void x11Crosshair(Pixmap, Coord::InternalSystem, int, int);
void x11Dash(GC, int);
virtual void x11Graphics();
diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C
index 81872ff..7c6186c 100644
--- a/tksao/frame/basecommand.C
+++ b/tksao/frame/basecommand.C
@@ -452,72 +452,24 @@ void Base::cropCenterCmd(const Vector& vv,
void Base::cropBeginCmd(const Vector& vv)
{
+ useCrop = 1;
cropBegin = vv;
cropEnd = vv;
}
void Base::cropMotionCmd(const Vector& vv)
{
- Vector ss = mapToRef(cropBegin, Coord::CANVAS);
-
- // erase
- if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
- Vector tt = mapToRef(cropEnd, Coord::CANVAS);
-
- Vector ll = mapFromRef(ss, Coord::CANVAS);
- Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::CANVAS);
- Vector ur = mapFromRef(tt, Coord::CANVAS);
- Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::CANVAS);
-
- BBox bb(ll);
- bb.bound(lr);
- bb.bound(ur);
- bb.bound(ul);
-
- redrawNow(bb.expand(2));
- }
-
cropEnd = vv;
- // and draw to window
- {
- Vector tt = mapToRef(cropEnd, Coord::CANVAS);
-
- Vector ll = mapFromRef(ss, Coord::WINDOW);
- Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::WINDOW);
- Vector ur = mapFromRef(tt, Coord::WINDOW);
- Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::WINDOW);
-
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ll[0],ll[1],lr[0],lr[1]);
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,lr[0],lr[1],ur[0],ur[1]);
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ur[0],ur[1],ul[0],ul[1]);
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ul[0],ul[1],ll[0],ll[1]);
- }
+ update(PIXMAP);
}
void Base::cropEndCmd(const Vector& vv)
{
- Vector ss = mapToRef(cropBegin, Coord::CANVAS);
-
- // erase
- if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
- Vector tt = mapToRef(cropEnd, Coord::CANVAS);
-
- Vector ll = mapFromRef(ss, Coord::CANVAS);
- Vector lr = mapFromRef(Vector(tt[0],ss[1]), Coord::CANVAS);
- Vector ur = mapFromRef(tt, Coord::CANVAS);
- Vector ul = mapFromRef(Vector(ss[0],tt[1]), Coord::CANVAS);
-
- BBox bb(ll);
- bb.bound(lr);
- bb.bound(ur);
- bb.bound(ul);
- redrawNow(bb.expand(2));
- }
-
- // and crop
+ useCrop = 0;
cropEnd = vv;
if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
+ Vector ss = mapToRef(cropBegin, Coord::CANVAS);
Vector tt = mapToRef(cropEnd, Coord::CANVAS);
if (!isMosaic()) {
diff --git a/tksao/frame/fr3dcommand.C b/tksao/frame/fr3dcommand.C
index b91e663..5dc739e 100644
--- a/tksao/frame/fr3dcommand.C
+++ b/tksao/frame/fr3dcommand.C
@@ -57,52 +57,23 @@ void Frame3dBase::blockToFitCmd()
void Frame3dBase::crop3dBeginCmd(const Vector& vv, int which)
{
- // which =0 (zmin) which =1 (zmax)
- if (!keyContext->fits)
- return;
-
+ useCrop3d =1;
cropBegin = vv * Scale(zoom_).invert();
cropEnd = vv * Scale(zoom_).invert();
-
- // params is a BBOX in DATA coords 0-n
- FitsZBound* zparams =
- keyContext->getDataParams(keyContext->secMode());
- if (!which)
- cropsl_ = zparams->zmin;
- else
- cropsl_ = zparams->zmax;
}
void Frame3dBase::crop3dMotionCmd(const Vector& vv, int which)
{
- // which =0 (zmin) which =1 (zmax)
+ cropEnd = vv * Scale(zoom_).invert();
+
+ // just in case
if (!keyContext->fits)
return;
// params is a BBOX in DATA coords 0-n
- FitsBound* params =
- keyContext->fits->getDataParams(keyContext->secMode());
FitsZBound* zparams =
keyContext->getDataParams(keyContext->secMode());
- Vector ss(params->xmin,params->ymin);
- Vector tt(params->xmax,params->ymax);
-
- // erase
- if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
- Vector ll = mapFromRef3d(ss,Coord::CANVAS,cropsl_);
- Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::CANVAS,cropsl_);
- Vector ur = mapFromRef3d(tt,Coord::CANVAS,cropsl_);
- Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::CANVAS,cropsl_);
-
- BBox bb(ll);
- bb.bound(lr);
- bb.bound(ur);
- bb.bound(ul);
- redrawNow(bb.expand(2));
- }
-
- cropEnd = vv * Scale(zoom_).invert();
Vector diff = cropEnd-cropBegin;
if (!which)
cropsl_ = diff[0]+zparams->zmin;
@@ -124,50 +95,22 @@ void Frame3dBase::crop3dMotionCmd(const Vector& vv, int which)
cropsl_ = depth;
}
- // and draw to window
- {
- Vector ll = mapFromRef3d(ss,Coord::WINDOW,cropsl_);
- Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::WINDOW,cropsl_);
- Vector ur = mapFromRef3d(tt,Coord::WINDOW,cropsl_);
- Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::WINDOW,cropsl_);
-
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ll[0],ll[1],lr[0],lr[1]);
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,lr[0],lr[1],ur[0],ur[1]);
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ur[0],ur[1],ul[0],ul[1]);
- XDrawLine(display,Tk_WindowId(tkwin),selectGCXOR,ul[0],ul[1],ll[0],ll[1]);
- }
+ update(PIXMAP);
}
void Frame3dBase::crop3dEndCmd(const Vector& vv, int which)
{
- // which =0 (zmin) which =1 (zmax)
+ useCrop3d =0;
+ cropEnd = vv * Scale(zoom_).invert();
+
+ // just in case
if (!keyContext->fits)
return;
// params is a BBOX in DATA coords 0-n
- FitsBound* params =
- keyContext->fits->getDataParams(keyContext->secMode());
FitsZBound* zparams =
keyContext->getDataParams(keyContext->secMode());
- Vector ss(params->xmin,params->ymin);
- Vector tt(params->xmax,params->ymax);
- // erase
- if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
- Vector ll = mapFromRef3d(ss,Coord::CANVAS,cropsl_);
- Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::CANVAS,cropsl_);
- Vector ur = mapFromRef3d(tt,Coord::CANVAS,cropsl_);
- Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::CANVAS,cropsl_);
-
- BBox bb(ll);
- bb.bound(lr);
- bb.bound(ur);
- bb.bound(ul);
-
- redrawNow(bb.expand(2));
- }
-
- cropEnd = vv * Scale(zoom_).invert();
Vector diff = cropEnd-cropBegin;
if (!which)
cropsl_ = diff[0]+zparams->zmin;
diff --git a/tksao/frame/frame3dbase.C b/tksao/frame/frame3dbase.C
index d993b50..098abd8 100644
--- a/tksao/frame/frame3dbase.C
+++ b/tksao/frame/frame3dbase.C
@@ -1016,6 +1016,31 @@ void Frame3dBase::updatePanner()
}
}
+void Frame3dBase::x11Crop3d()
+{
+ // just in case
+ if (!keyContext->fits)
+ return;
+
+ if (cropBegin[0]!=cropEnd[0] || cropBegin[1]!=cropEnd[1]) {
+ // params is a BBOX in DATA coords 0-n
+ FitsBound* params =
+ keyContext->fits->getDataParams(keyContext->secMode());
+ Vector ss(params->xmin,params->ymin);
+ Vector tt(params->xmax,params->ymax);
+
+ Vector ll = mapFromRef3d(ss,Coord::CANVAS,cropsl_);
+ Vector lr = mapFromRef3d(Vector(tt[0],ss[1]),Coord::CANVAS,cropsl_);
+ Vector ur = mapFromRef3d(tt,Coord::CANVAS,cropsl_);
+ Vector ul = mapFromRef3d(Vector(ss[0],tt[1]),Coord::CANVAS,cropsl_);
+
+ XDrawLine(display,pixmap,selectGCXOR,ll[0],ll[1],lr[0],lr[1]);
+ XDrawLine(display,pixmap,selectGCXOR,lr[0],lr[1],ur[0],ur[1]);
+ XDrawLine(display,pixmap,selectGCXOR,ur[0],ur[1],ul[0],ul[1]);
+ XDrawLine(display,pixmap,selectGCXOR,ul[0],ul[1],ll[0],ll[1]);
+ }
+}
+
void Frame3dBase::x11Graphics()
{
Base::x11Graphics();
diff --git a/tksao/frame/frame3dbase.h b/tksao/frame/frame3dbase.h
index 0489718..988cd26 100644
--- a/tksao/frame/frame3dbase.h
+++ b/tksao/frame/frame3dbase.h
@@ -123,6 +123,7 @@ class Frame3dBase : public Base {
void updateMatrices();
void updatePanner();
+ void x11Crop3d();
void x11Line(Vector, Vector, int, GC, Pixmap);
void x11Graphics();
void x11Border(Coord::InternalSystem, FrScale::SecMode, GC, Pixmap);