00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "gxsm_app.h"
00030
00031 #include "unit.h"
00032 #include "pcs.h"
00033 #include "xsmtypes.h"
00034 #include "action_id.h"
00035 #include "glbvars.h"
00036
00037 #include "app_profile.h"
00038 #include "app_vobj.h"
00039 #include "app_view.h"
00040
00041 #include "clip.h"
00042
00043 #define SETUP_ITEM(X) gnome_canvas_item_raise_to_top(X)
00044
00045 #define UTF8_DEGREE "\302\260"
00046
00047 #define MAXHANDLECOLORS 4
00048
00049 #define OBJECT_LINE_WIDTH xsmres.ObjectLineWidth
00050 #define SQR_HANDLE_SIZE 5
00051 #define SQR_HANDLE_LINE_WIDTH xsmres.HandleLineWidth
00052 #define TRI_HANDLE_SIZE 15
00053 #define TRI_HANDLE_LINE_WIDTH xsmres.HandleLineWidth
00054
00055 #define HANDLE_FILL_COLOR RGBAColor (xsmres.HandleActBgColor)
00056 #define HANDLE_FILL_COLOR_INACTIVE RGBAColor (xsmres.HandleInActBgColor)
00057
00058 #define LABEL_XOFF 0.
00059 #define LABEL_YOFF -25.
00060
00061 inline unsigned long RGBAColor (float c[4]) {
00062 if (c[3] < 0.01) return 0;
00063 return WORDS_BIGENDIAN ?
00064 (unsigned long)(c[0]*0xff)
00065 | ((unsigned long)(c[1]*0xff)<<8)
00066 | ((unsigned long)(c[2]*0xff)<<16)
00067 | ((unsigned long) (c[3]*0xff)<<24)
00068 :
00069 (unsigned long)(c[3]*0xff)
00070 | ((unsigned long)(c[2]*0xff)<<8)
00071 | ((unsigned long)(c[1]*0xff)<<16)
00072 | ((unsigned long) (c[0]*0xff)<<24)
00073 ;
00074 }
00075
00076 VObject *current_vobject2 = NULL;
00077
00078 VObject::VObject(GtkWidget *Canvas, double *xy0, int npkt, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale){
00079 static int obj_count = 0;
00080 static int event_count = 0;
00081 int i;
00082 XSM_DEBUG(DBG_L2, "VObject::VObject");
00083
00084 scan_event=NULL;
00085 lock=0;
00086 id=0;
00087 p2d = P2d;
00088 marker_scale=Marker_scale;
00089 canvas = Canvas;
00090 statusbar = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (canvas), "statusbar");
00091 statusid = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "drag");
00092 vinfo = (ViewInfo*)gtk_object_get_data (GTK_OBJECT (canvas), "ViewInfo");
00093
00094 name = g_strdup("VObject");
00095 if (lab)
00096 text = g_strdup(lab);
00097 else
00098 text = npkt == 0
00099 ? g_strdup_printf("Ev[%d]", ++event_count)
00100 : g_strdup_printf("Object[%d]", ++obj_count);
00101
00102 np=npkt > 0 ? npkt : 1;
00103 abl = new GnomeCanvasItem* [np+4];
00104 label = NULL;
00105 arrow_head = NULL;
00106
00107 label_offset_xy[0]=LABEL_XOFF;
00108 label_offset_xy[1]=LABEL_YOFF;
00109
00110 xy = new double[2*np];
00111 memcpy(xy, xy0, 2*np*sizeof(double));
00112
00113 touched_item=NULL;
00114 touched_xy[0]=touched_xy[1]=0.;
00115
00116 SetUpPos (cmode);
00117
00118 switch (npkt){
00119 case 0: popup = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (canvas), "ObjPopupEvent"); break;
00120 case 1: popup = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (canvas), "ObjPopup1"); break;
00121 case 2: popup = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (canvas), "ObjPopup2"); break;
00122 default: popup = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (canvas), "ObjPopupN"); break;
00123 }
00124
00125 for(i=0; i<np; i++){
00126 abl[i] = node_marker (NULL, &xy[2*i], i);
00127 SETUP_ITEM(abl[i]);
00128 gtk_signal_connect(GTK_OBJECT(abl[i]), "event",
00129 (GtkSignalFunc) VObject::item_event,
00130 this);
00131 }
00132 abl[i++]=NULL;
00133 abl[i++]=NULL;
00134 abl[i++]=NULL;
00135
00136 if(pflg){
00137 gchar *proftit = g_strdup_printf("%s Profile from Ch%d",
00138 np>1 ? "Path":"Layer",
00139 1+(int)gtk_object_get_data (GTK_OBJECT (canvas), "Ch"));
00140 profile = new ProfileControl(proftit);
00141 g_free(proftit);
00142 }
00143 else
00144 profile = NULL;
00145 }
00146
00147 VObject::~VObject(){
00148 XSM_DEBUG(DBG_L2, "VObject::~VObject");
00149
00150 if(profile)
00151 delete profile;
00152 profile=NULL;
00153
00154 for(int i=0; abl[i]; i++)
00155 gtk_object_destroy(GTK_OBJECT(abl[i]));
00156
00157 if(label)
00158 gtk_object_destroy(GTK_OBJECT(label));
00159
00160 if (arrow_head)
00161 gtk_object_destroy(GTK_OBJECT(arrow_head));
00162
00163 delete[] xy;
00164
00165 delete[] abl;
00166
00167 g_free(name);
00168 g_free(text);
00169 }
00170
00171
00172
00173
00174
00175 GnomeCanvasItem* VObject::node_marker(GnomeCanvasItem* item, double *xy, int i){
00176 double rsz;
00177 int hand_type = xsmres.HandleType[0];
00178 gchar *HandleColors[MAXHANDLECOLORS] = { "red","green","cyan","yellow" };
00179
00180
00181 if (item)
00182 hand_type = (long)gtk_object_get_data (GTK_OBJECT (item), "HAND_TYPE");
00183
00184 switch (hand_type){
00185 case 'T':
00186 rsz = TRI_HANDLE_SIZE * marker_scale;
00187 {
00188 GnomeCanvasPoints* poly_tri = gnome_canvas_points_new (3);
00189 poly_tri->coords[0] = xy[0];
00190 poly_tri->coords[1] = xy[1];
00191 poly_tri->coords[2] = xy[0]-rsz/3;
00192 poly_tri->coords[3] = xy[1]-rsz;
00193 poly_tri->coords[4] = xy[0]+rsz/3;
00194 poly_tri->coords[5] = xy[1]-rsz;
00195
00196 if (item)
00197 gnome_canvas_item_set (item, "points", poly_tri, NULL);
00198 else{
00199 item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(canvas)),
00200 gnome_canvas_polygon_get_type (),
00201 "points", poly_tri,
00202 "outline_color", HandleColors[i%MAXHANDLECOLORS],
00203 "width_pixels", TRI_HANDLE_LINE_WIDTH,
00204 NULL);
00205 gtk_object_set_data (GTK_OBJECT (item), "HAND_TYPE", (void*)'T');
00206 }
00207 gnome_canvas_points_free (poly_tri);
00208 }
00209 return item;
00210
00211 default:
00212 rsz = SQR_HANDLE_SIZE * marker_scale;
00213 if (item)
00214 gnome_canvas_item_set (item,
00215 "x1", xy[0]-rsz,
00216 "y1", xy[1]-rsz,
00217 "x2", xy[0]+rsz,
00218 "y2", xy[1]+rsz,
00219 NULL);
00220 else{
00221 item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(canvas)),
00222 gnome_canvas_rect_get_type (),
00223 "x1", xy[0]-rsz,
00224 "y1", xy[1]-rsz,
00225 "x2", xy[0]+rsz,
00226 "y2", xy[1]+rsz,
00227 "outline_color", HandleColors[i%MAXHANDLECOLORS],
00228 "width_pixels", SQR_HANDLE_LINE_WIDTH,
00229 NULL);
00230 gtk_object_set_data (GTK_OBJECT (item), "HAND_TYPE", (void*)'R');
00231 }
00232 return item;
00233 }
00234 return NULL;
00235 }
00236
00237 void VObject::SetUpPos(VOBJ_COORD_MODE cmode){
00238 switch (cmode){
00239 case VOBJ_COORD_FROM_MOUSE:
00240 {
00241 gint cx,cy, xso, yso;
00242 double wx, wy;
00243 gdk_window_get_pointer (canvas->window, &cx, &cy, NULL);
00244 gnome_canvas_get_scroll_offsets (GNOME_CANVAS(canvas), &xso, &yso);
00245 cx += xso; cy += yso;
00246 gnome_canvas_window_to_world (GNOME_CANVAS(canvas), (double)cx,(double)cy, &wx,&wy);
00247 for(int i=0; i<np; ++i){
00248 xy[2*i] += wx;
00249 xy[2*i+1] += wy;
00250 }
00251 }
00252 break;
00253
00254 case VOBJ_COORD_ABSOLUT:
00255 for(int i=0; i<np; ++i)
00256 vinfo->Angstroem2W (xy[2*i], xy[2*i+1]);
00257 break;
00258 case VOBJ_COORD_RELATIV:
00259 ;
00260 break;
00261 }
00262
00263 }
00264
00265 void VObject::set_color_to_active (){
00266 gchar *HandleColors[MAXHANDLECOLORS] = { "red","green","cyan","yellow" };
00267 for(int i=0; i<np; i++)
00268 if (HANDLE_FILL_COLOR)
00269 gnome_canvas_item_set(abl[i],
00270 "fill_color_rgba", HANDLE_FILL_COLOR,
00271 "outline_color", !strcmp (name, "Event") ? "yellow" : HandleColors[i%MAXHANDLECOLORS],
00272 NULL);
00273 else
00274 gnome_canvas_item_set(abl[i],
00275 "fill_color", NULL,
00276 "outline_color", !strcmp (name, "Event") ? "yellow" : HandleColors[i%MAXHANDLECOLORS],
00277 NULL);
00278
00279 }
00280
00281 void VObject::set_color_to_inactive (){
00282 for(int i=0; i<np; i++)
00283 if (HANDLE_FILL_COLOR_INACTIVE)
00284 gnome_canvas_item_set(abl[i],
00285 "fill_color_rgba", HANDLE_FILL_COLOR_INACTIVE,
00286 "outline_color", !strcmp (name, "Event") ? "green" : "grey",
00287 NULL);
00288 else
00289 gnome_canvas_item_set(abl[i],
00290 "fill_color", NULL,
00291 "outline_color", !strcmp (name, "Event") ? "green" : "grey",
00292 NULL);
00293 }
00294
00295 void VObject::set_color_to_hilit (){
00296 for(int i=0; i<np; i++)
00297 if (HANDLE_FILL_COLOR_INACTIVE)
00298 gnome_canvas_item_set(abl[i],
00299 "fill_color_rgba", HANDLE_FILL_COLOR_INACTIVE,
00300 "outline_color", "yellow",
00301 NULL);
00302 else
00303 gnome_canvas_item_set(abl[i],
00304 "fill_color", NULL,
00305 "outline_color", "yellow",
00306 NULL);
00307 }
00308 void get_obj_coords_wrapper2(int i, double &x, double &y){
00309 if (current_vobject2)
00310 current_vobject2->obj_get_xy_i (i,x,y);
00311 }
00312
00313 void VObject::Activate (){
00314 ((ViewControl*)gtk_object_get_data (GTK_OBJECT (canvas), "ViewControl"))->PaintAllRegionsInactive();
00315 set_color_to_active();
00316
00317 if (current_vobject2){
00318 XSM_DEBUG(DBG_L2, "VObjetc::Activate ERROR, recursive call occured!!" );
00319 return;
00320 }
00321 if (id){
00322 current_vobject2 = this;
00323 Scan *sc = ((Scan*)gtk_object_get_data (GTK_OBJECT (canvas), "Scan"));
00324 if (sc) sc->update_object (id, name, text, get_obj_coords_wrapper2);
00325 current_vobject2 = NULL;
00326 }
00327
00328 }
00329
00330 static void label_changed_cb (GtkEditable *e, gchar **text){
00331 g_free (*text);
00332 *text = gtk_editable_get_chars (GTK_EDITABLE (e), 0, -1);
00333 }
00334
00335 void VObject::properties(){
00336 GtkWidget *dialog;
00337 GtkWidget *vbox;
00338 GtkWidget *hbox;
00339 GtkWidget *info;
00340 GtkWidget *input, *textinput = NULL;
00341 Gtk_EntryControl **ec = new Gtk_EntryControl*[2*np];
00342
00343 dialog = gtk_dialog_new_with_buttons (_("Object Properties"),
00344 NULL,
00345 (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
00346 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
00347 NULL);
00348
00349 vbox = gtk_vbox_new (FALSE, 0);
00350 gtk_widget_show (vbox);
00351
00352 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
00353 vbox, TRUE, TRUE, GNOME_PAD);
00354
00355 gchar *objident = g_strdup_printf ("Edit Object \"%s\"", name);
00356 info = gtk_label_new (objident);
00357 g_free (objident);
00358 gtk_widget_show (info);
00359 gtk_box_pack_start(GTK_BOX(vbox), info, TRUE, TRUE, GNOME_PAD);
00360
00361 UnitObj *Pixel = new UnitObj("Pix","Pix");
00362
00363 if (text){
00364 textinput = gapp->mygtk_create_input("Text", vbox, hbox);
00365 gtk_entry_set_text (GTK_ENTRY (textinput), text);
00366 }
00367 for(int n=0; n<np; ++n){
00368 int i=2*n;
00369
00370 gchar *label = g_strdup_printf ("P%d:", n);
00371 input = gapp->mygtk_create_input(label, vbox, hbox);
00372 g_free (label);
00373
00374 ec[i] = new Gtk_EntryControl (Pixel, "Value out of range !", &xy[i],
00375 -32767, 32767, ".0f", input);
00376 input = gapp->mygtk_add_input(hbox);
00377 ec[i+1] = new Gtk_EntryControl (Pixel, "Value out of range !", &xy[i+1],
00378 -32767, 32767, ".0f", input);
00379 }
00380 if (textinput)
00381 gtk_signal_connect (GTK_OBJECT (textinput), "changed", GTK_SIGNAL_FUNC (label_changed_cb), &text);
00382 gtk_widget_show(dialog);
00383 gtk_dialog_run (GTK_DIALOG(dialog));
00384 gtk_widget_destroy (dialog);
00385
00386 for(int i=0; i<np; i++){
00387 node_marker (abl[i], &xy[2*i], i);
00388 delete ec[2*i];
00389 delete ec[2*i+1];
00390 }
00391 delete[] ec;
00392
00393 Update ();
00394 show_label ();
00395 }
00396
00397 void VObject::set_offset(){
00398 double x,y;
00399 x = xy[0]*vinfo->GetQfac();
00400 y = xy[1]*vinfo->GetQfac();
00401
00402 if (x < 0. || x >= vinfo->sc->mem2d->GetNx())
00403 return;
00404 if (y < 0. || y >= vinfo->sc->mem2d->GetNy())
00405 return;
00406
00407 vinfo->sc->Pixel2World (R2INT (x), R2INT (y),
00408 gapp->xsm->data.s.x0, gapp->xsm->data.s.y0,
00409 SCAN_COORD_ABSOLUTE);
00410
00411 gapp->spm_update_all();
00412 }
00413
00414 void VObject::SetUpScan(){
00415 double x0,y0,x1,y1,dx,dy;
00416 double xyq[4];
00417
00418 xyq[0] = xy[0]*vinfo->GetQfac();
00419 xyq[1] = xy[1]*vinfo->GetQfac();
00420 xyq[2] = xy[2*(np-1)]*vinfo->GetQfac();
00421 xyq[3] = xy[2*(np-1)+1]*vinfo->GetQfac();
00422
00423 if(xyq[0]<0. || xyq[0] >= vinfo->sc->mem2d->GetNx() ||
00424 xyq[2]<0. || xyq[2] >= vinfo->sc->mem2d->GetNx())
00425 return;
00426 if(xyq[1]<0. || xyq[1] >= vinfo->sc->mem2d->GetNy() ||
00427 xyq[3]<0. || xyq[3] >= vinfo->sc->mem2d->GetNy())
00428 return;
00429
00430
00431 vinfo->sc->Pixel2World (R2INT((xyq[0] + xyq[2])/2.), R2INT((xyq[1] + xyq[3])/2.),
00432 gapp->xsm->data.s.x0, gapp->xsm->data.s.y0,
00433 SCAN_COORD_ABSOLUTE);
00434
00435
00436 vinfo->sc->Pixel2World (R2INT(xyq[0]), R2INT(xyq[1]),
00437 x0, y0,
00438 SCAN_COORD_RELATIVE);
00439
00440 vinfo->sc->Pixel2World (R2INT(xyq[2]), R2INT(xyq[3]),
00441 x1, y1,
00442 SCAN_COORD_RELATIVE);
00443
00444 XSM_DEBUG ( DBG_L3, "SetUpScan:" << np << ":" << x0 << "," << y0 << ", " << x1 << "," << y1 );
00445 dx = x1-x0;
00446 dy = y1-y0;
00447 XSM_DEBUG (DBG_L3, "SetUpScan:" << dx << "," << dy );
00448 gapp->xsm->data.s.rx = sqrt(dx*dx+dy*dy);
00449
00450 gapp->xsm->data.s.nx = R2INT(Dist(0,np-1));
00451 gapp->xsm->data.s.ny = 1;
00452 gapp->xsm->data.s.dx = gapp->xsm->data.s.rx/(gapp->xsm->data.s.nx-1);
00453 gapp->xsm->data.s.dy = gapp->xsm->data.s.dx;
00454 gapp->xsm->data.s.ry = gapp->xsm->data.s.dx;
00455 gapp->xsm->data.s.alpha = -Phi(dx,dy);
00456 gapp->spm_update_all();
00457 }
00458
00459 void VObject::show_label(int flg){
00460 switch (flg){
00461 case 1:
00462 if (!label){
00463 label = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
00464 gnome_canvas_text_get_type(),
00465 "text", text,
00466 "x", xy[0] + label_offset_xy[0]*marker_scale,
00467 "y", xy[1] + label_offset_xy[1]*marker_scale,
00468 "font", xsmres.ObjectLabFont,
00469 "anchor", GTK_ANCHOR_CENTER,
00470 "fill_color_rgba", RGBAColor (xsmres.ObjectLabColor),
00471 NULL);
00472 gtk_signal_connect (GTK_OBJECT (label), "event",
00473 (GtkSignalFunc) VObject::item_event,
00474 this);
00475
00476 }
00477 return;
00478 case 0:
00479 if (label){
00480 gtk_object_destroy (GTK_OBJECT (label));
00481 label = NULL;
00482 }
00483 return;
00484 case -1:
00485 if (label)
00486 gnome_canvas_item_set (label,
00487 "text", text,
00488 "x", xy[0] + label_offset_xy[0]*marker_scale,
00489 "y", xy[1] + label_offset_xy[1]*marker_scale,
00490 NULL);
00491 return;
00492 }
00493 }
00494
00495 void VObject::GoLocMax(int r){
00496 for(int n=0; n<np; ++n){
00497 int i=2*n;
00498
00499 if(xy[i] > r && xy[i] < (vinfo->sc->mem2d->GetNx()-r) &&
00500 xy[i+1] > r && xy[i+1] < (vinfo->sc->mem2d->GetNy()-r)){
00501 int lmx, lmy;
00502 double val=vinfo->sc->mem2d->GetDataPkt(lmx=R2INT(xy[i]),
00503 lmy=R2INT(xy[i+1]));
00504
00505 for(int x=R2INT(xy[i])-r; x<(R2INT(xy[i])+r); ++x)
00506 for(int y=R2INT(xy[i+1])-r; y<(R2INT(xy[i+1])+r); ++y){
00507 double z=vinfo->sc->mem2d->GetDataPkt(x,y);
00508 if(z > val) lmx=x, lmy=y, val=z;
00509 }
00510
00511 xy[i]=lmx, xy[i+1]=lmy;
00512 node_marker (abl[i], &xy[i], i);
00513 Update();
00514 }
00515 break;
00516 }
00517 }
00518
00519 gint VObject::item_event(GnomeCanvasItem *item, GdkEvent *event, VObject *vo){
00520 static double x, y;
00521 double new_x, new_y;
00522 GdkCursor *cursor;
00523 static int dragging;
00524 double item_x=0., item_y=0.;
00525
00526 if (vo->lock && !(event->type == GDK_BUTTON_PRESS && event->button.button == 2)){
00527 vo->Update();
00528 return FALSE;
00529 }
00530
00531 item_x = event->button.x;
00532 item_y = event->button.y;
00533 gnome_canvas_item_w2i(item->parent, &item_x, &item_y);
00534
00535 switch (event->type)
00536 {
00537 case GDK_BUTTON_PRESS:
00538 switch(event->button.button)
00539 {
00540 case 1:
00541
00542
00543
00544
00545
00546 {
00547 x = item_x;
00548 y = item_y;
00549
00550 vo->touched_item = item;
00551 vo->touched_xy[0] = item_x;
00552 vo->touched_xy[1] = item_y;
00553
00554 cursor = gdk_cursor_new(GDK_FLEUR);
00555 gnome_canvas_item_grab(item,
00556 GDK_POINTER_MOTION_MASK |
00557 GDK_BUTTON_RELEASE_MASK,
00558 cursor,
00559 event->button.time);
00560
00561 dragging = TRUE;
00562 }
00563 vo->Update();
00564 break;
00565
00566 case 2:
00567 vo->touched_item = item;
00568 vo->touched_xy[0] = item_x;
00569 vo->touched_xy[1] = item_y;
00570
00571 gnome_popup_menu_do_popup (vo->popup, NULL, NULL, NULL, vo, NULL);
00572 break;
00573
00574 default:
00575 break;
00576 }
00577 break;
00578
00579 case GDK_MOTION_NOTIFY:
00580 if(gtk_events_pending() < 1)
00581 if (dragging && (event->motion.state & GDK_BUTTON1_MASK))
00582 {
00583 new_x = item_x;
00584 new_y = item_y;
00585
00586 if(item == vo->abl[vo->np] || item == vo->label || item == vo->arrow_head){
00587 for(int i=0; i<vo->np; i++){
00588 vo->xy[2*i]+=new_x-x;
00589 vo->xy[2*i+1]+=new_y-y;
00590 vo->node_marker (vo->abl[i], &vo->xy[2*i], i);
00591 }
00592 }else{
00593
00594 for(int i=0; i<vo->np; i++)
00595 if(item == vo->abl[i]){
00596 vo->xy[2*i]+=new_x-x;
00597 vo->xy[2*i+1]+=new_y-y;
00598 vo->node_marker (item, &vo->xy[2*i], i);
00599 }
00600 }
00601
00602 vo->Update();
00603 vo->show_label();
00604 x = new_x;
00605 y = new_y;
00606 }
00607 break;
00608
00609 case GDK_BUTTON_RELEASE:
00610 gnome_canvas_item_ungrab(item, event->button.time);
00611 dragging = FALSE;
00612 break;
00613
00614 #if 0
00615 case GDK_ENTER_NOTIFY:
00616 vo->set_color_to_hilit ();
00617 break;
00618 case GDK_LEAVE_NOTIFY:
00619 vo->set_color_to_inactive ();
00620 break;
00621 #endif
00622
00623 default:
00624 break;
00625 }
00626
00627 return FALSE;
00628 }
00629
00630 VObPoint::VObPoint(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
00631 : VObject(canvas, xy0, 1, P2d, pflg, cmode, lab, Marker_scale){
00632 if(name) g_free(name);
00633 name = g_strdup("Point");
00634 follow = FALSE;
00635 }
00636
00637 void VObPoint::Update(){
00638 gchar *s1;
00639 gchar *mld = g_strconcat("Point: ",
00640 s1=vinfo->makeXYZinfo(xy[0],xy[1], &p2d[0]),
00641 NULL);
00642 g_free(s1);
00643 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
00644 vinfo->sc->PktVal=1;
00645 vinfo->sc->set_data (MPOINT);
00646
00647 if (follow)
00648 update_offset ();
00649
00650 if (profile){
00651 profile->show();
00652 profile->NewData(vinfo->sc);
00653 }
00654 else
00655 gapp->xsm->MausMode(MPOINT);
00656
00657 Activate ();
00658 g_free(mld);
00659 }
00660
00661 VObPoint::~VObPoint(){};
00662
00663 void VObPoint::follow_on(){
00664 follow = TRUE;
00665 };
00666
00667 void VObPoint::follow_off(){
00668 follow = FALSE;
00669 };
00670
00671 void VObPoint::update_offset(){
00672 double x,y;
00673 x = (double)xy[0]*vinfo->GetQfac ();
00674 y = (double)xy[1]*vinfo->GetQfac ();
00675
00676 if (x < 0. || x >= vinfo->sc->mem2d->GetNx ())
00677 return;
00678 if (y < 0. || y >= vinfo->sc->mem2d->GetNy ())
00679 return;
00680
00681 vinfo->sc->Pixel2World (R2INT (x), R2INT (y),
00682 gapp->xsm->data.s.x0, gapp->xsm->data.s.y0,
00683 SCAN_COORD_ABSOLUTE);
00684
00685 gapp->xsm->hardware->SetOffset
00686 (R2INT (gapp->xsm->Inst->X0A2Dig (gapp->xsm->data.s.x0)),
00687 R2INT (gapp->xsm->Inst->Y0A2Dig (gapp->xsm->data.s.y0)));
00688
00689 gapp->spm_update_all ();
00690 }
00691
00692 VObLine::VObLine(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
00693 : VObject(canvas, xy0, 2, P2d, pflg, cmode, lab, Marker_scale){
00694 if(name) g_free(name);
00695 name = g_strdup("Line");
00696 XSM_DEBUG (DBG_L3, "VObLine::VObLine - adding line" );
00697 GnomeCanvasPoints *pn = gnome_canvas_points_new (2);
00698
00699 pn->coords[0] = xy[0]; pn->coords[1] = xy[1];
00700 pn->coords[2] = xy[2]; pn->coords[3] = xy[3];
00701
00702 abl[2] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
00703 gnome_canvas_line_get_type (),
00704 "points", pn,
00705 "fill_color","blue",
00706 "width_pixels", OBJECT_LINE_WIDTH,
00707 NULL);
00708
00709 arrow_head = NULL;
00710
00711 gnome_canvas_points_free (pn);
00712 SETUP_ITEM(abl[2]);
00713 gnome_canvas_item_lower(abl[2], 2);
00714
00715 gtk_signal_connect(GTK_OBJECT(abl[2]), "event",
00716 (GtkSignalFunc) VObject::item_event,
00717 this);
00718 Update();
00719 }
00720
00721 VObLine::~VObLine(){
00722 XSM_DEBUG(DBG_L2, "VObLine::~VObLine");
00723 }
00724
00725 void VObLine::Update(){
00726 gchar *s1, *s2, *s3;
00727 gchar *phitxt = g_strdup_printf("phi=%g"UTF8_DEGREE, Phi());
00728 gchar *mld = g_strconcat("Line: |",
00729 s1=vinfo->makeXYinfo(xy[0],xy[1]),
00730 ": ",
00731 s2=vinfo->makedXdYinfo(xy,xy+2),
00732 "|=",
00733 s3=vinfo->makeDXYinfo(xy,xy+2, &p2d[0], &p2d[1]), ", ", phitxt,
00734 NULL);
00735 g_free(s3); g_free(s2); g_free(s1);
00736
00737 GnomeCanvasPoints *pn = gnome_canvas_points_new (2);
00738 double phi;
00739 double l = 12. * marker_scale;
00740 double M[4];
00741
00742 phi = M_PI*(Phi()+45)/180.;
00743 M[0] = M[3] = cos(phi);
00744 M[2] = -(M[1] = sin(phi));
00745
00746
00747 pn->coords[0] = xy[0]; pn->coords[1] = xy[1];
00748 pn->coords[2] = xy[2]-(l*M[0] + l*M[1]); pn->coords[3] = xy[3]+(l*M[2] + l*M[3]);
00749
00750 gnome_canvas_item_set(abl[np], "points", pn, NULL);
00751 gnome_canvas_points_free (pn);
00752
00753 pn = gnome_canvas_points_new (3);
00754
00755
00756 phi = M_PI*(Phi()+30.)/180.;
00757 M[0] = M[3] = cos(phi);
00758 M[2] = -(M[1] = sin(phi));
00759
00760 pn->coords[0] = xy[2]-(l*M[0] + l*M[1]);
00761 pn->coords[1] = xy[3]+(l*M[2] + l*M[3]);
00762
00763 phi = M_PI*(Phi()+60.)/180.;
00764 M[0] = M[3] = cos(phi);
00765 M[2] = -(M[1] = sin(phi));
00766 pn->coords[2] = xy[2]-(l*M[0] + l*M[1]);
00767 pn->coords[3] = xy[3]+(l*M[2] + l*M[3]);
00768
00769 pn->coords[4] = xy[2];
00770 pn->coords[5] = xy[3];
00771
00772 if (arrow_head)
00773 gnome_canvas_item_set(arrow_head, "points", pn, NULL);
00774 else{
00775 arrow_head = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS(canvas)),
00776 gnome_canvas_polygon_get_type (),
00777 "points", pn,
00778 "outline_color", "blue",
00779 "fill_color_rgba", 0x00000050,
00780 "width_pixels", OBJECT_LINE_WIDTH,
00781 NULL);
00782 SETUP_ITEM(arrow_head);
00783 gtk_signal_connect (GTK_OBJECT (arrow_head), "event",
00784 (GtkSignalFunc) VObject::item_event,
00785 this);
00786 }
00787 gnome_canvas_points_free (pn);
00788
00789 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
00790 vinfo->sc->PktVal=2;
00791 vinfo->sc->set_data (MLINE);
00792
00793 if(profile){
00794 profile->show();
00795 profile->NewData(vinfo->sc);
00796 }
00797 else
00798 gapp->xsm->MausMode(MLINE);
00799 g_free(mld);
00800 g_free(phitxt);
00801 Activate ();
00802 }
00803
00804 VObPolyLine::VObPolyLine(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
00805 : VObject(canvas, &xy0[1], (int) xy0[0], P2d, pflg, cmode, lab, Marker_scale){
00806 if(name) g_free(name);
00807 name = g_strdup("PolyLine");
00808 XSM_DEBUG (DBG_L3, "VObPolyLine::VObPolyLine - adding poly line, np=" << np );
00809
00810 GnomeCanvasPoints *pn = gnome_canvas_points_new (np);
00811 double *pxy = pn->coords;
00812 for( int i=0; i<np; ++i){
00813 *pxy++ = xy[2*i];
00814 *pxy++ = xy[1+2*i];
00815 }
00816
00817 if(xsmres.antialiascanvas)
00818 abl[np] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
00819 GNOME_TYPE_CANVAS_LINE,
00820 "points", pn,
00821 "fill_color","blue",
00822 "fill_color_rgba", 0x00000030,
00823 "width_pixels", OBJECT_LINE_WIDTH,
00824 NULL);
00825 else
00826 abl[np] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
00827 GNOME_TYPE_CANVAS_LINE,
00828 "points", pn,
00829 "fill_color","blue",
00830 "width_pixels", OBJECT_LINE_WIDTH,
00831 NULL);
00832
00833 gnome_canvas_points_unref(pn);
00834
00835 SETUP_ITEM(abl[np]);
00836 gnome_canvas_item_lower(abl[np], 2);
00837
00838 gtk_signal_connect(GTK_OBJECT(abl[np]), "event",
00839 (GtkSignalFunc) VObject::item_event,
00840 this);
00841 Update();
00842 }
00843
00844 VObPolyLine::~VObPolyLine(){
00845 XSM_DEBUG(DBG_L2, "VObPolyLine::~VObPolyLine");
00846 }
00847
00848 void VObPolyLine::AddNode(){
00849 XSM_DEBUG(DBG_L2, "Add Node, Item: " << touched_item
00850 << " XY: " << touched_xy[0] << "," << touched_xy[1] );
00851 XSM_DEBUG(DBG_L2, "-- not jet implemented, have to change xy and abl to G_SLIST --" );
00852 }
00853
00854 void VObPolyLine::DelNode(){
00855 XSM_DEBUG(DBG_L2, "Del Node, Item: " << touched_item
00856 << " XY: " << touched_xy[0] << "," << touched_xy[1] );
00857 XSM_DEBUG(DBG_L2, "-- not jet implemented, have to change xy and abl to G_SLIST --" );
00858 }
00859
00860 void VObPolyLine::Update(){
00861 gchar *s1, *s2, *s3;
00862 gchar *mld = g_strconcat("PolyLine: |",
00863 s1=vinfo->makeXYinfo(xy[0],xy[1], &p2d[0]),
00864 ":..: ",
00865 s2=vinfo->makedXdYinfo(xy,xy+2*(np-1)),
00866 "|=",
00867 s3=vinfo->makeDnXYinfo(xy,np),
00868 NULL);
00869 g_free(s3); g_free(s2); g_free(s1);
00870
00871 GnomeCanvasPoints *pn = gnome_canvas_points_new (np);
00872 double *pxy = pn->coords;
00873 for( int i=0; i<np; ++i){
00874 g_free (vinfo->makeXYinfo (xy[2*i],xy[1+2*i], &p2d[i]));
00875 *pxy++ = xy[2*i];
00876 *pxy++ = xy[1+2*i];
00877 }
00878 gnome_canvas_item_set(abl[np], "points", pn, NULL);
00879 gnome_canvas_points_unref(pn);
00880
00881 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
00882 vinfo->sc->PktVal=np;
00883 g_free(mld);
00884
00885 Activate ();
00886 }
00887
00888 VObTrace::VObTrace(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
00889 : VObject(canvas, &xy0[1], 1, P2d, pflg, cmode, lab, Marker_scale){
00890 if(name) g_free(name);
00891 name = g_strdup("Trace");
00892 XSM_DEBUG (DBG_L3, "VObTrace::VObTrace - adding poly line, np=" << np );
00893
00894 trlen = (int)xy0[0];
00895 pn = gnome_canvas_points_new (trlen);
00896 double *pxy = pn->coords;
00897 for( int i=0; i<trlen; ++i, pxy+=2){
00898 pxy[0] = xy0[1+2*i];
00899 pxy[1] = xy0[1+2*i+1];
00900 vinfo->Angstroem2W (pxy[0], pxy[1]);
00901 }
00902 abl[np] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
00903 GNOME_TYPE_CANVAS_LINE,
00904 "points", pn,
00905 "fill_color","blue",
00906 "width_pixels", OBJECT_LINE_WIDTH,
00907 NULL);
00908
00909 SETUP_ITEM(abl[np]);
00910 gnome_canvas_item_lower(abl[np], 2);
00911
00912 gtk_signal_connect(GTK_OBJECT(abl[np]), "event",
00913 (GtkSignalFunc) VObject::item_event,
00914 this);
00915 Update();
00916 }
00917
00918 VObTrace::~VObTrace(){
00919 gnome_canvas_points_unref(pn);
00920 XSM_DEBUG(DBG_L2, "VObTrace::~VObTrace");
00921 }
00922
00923 void VObTrace::Change(double *xy0){
00924 gnome_canvas_points_unref(pn);
00925 trlen = (int)xy0[0];
00926 pn = gnome_canvas_points_new (trlen);
00927 double *pxy = pn->coords;
00928 for( int i=0; i<trlen; ++i, pxy+=2){
00929 pxy[0] = xy0[1+2*i];
00930 pxy[1] = xy0[1+2*i+1];
00931 vinfo->Angstroem2W (pxy[0], pxy[1]);
00932 }
00933 gnome_canvas_item_set(abl[np], "points", pn, NULL);
00934 }
00935
00936 void VObTrace::Update(){
00937 gchar *s1;
00938 gchar *mld = g_strconcat("Tracehead: ",
00939 s1=vinfo->makeXYinfo(xy[0],xy[1], &p2d[0]),
00940 NULL);
00941 g_free(s1);
00942
00943 double *pxy = pn->coords;
00944 for( int i=0; i<np; ++i){
00945 *pxy++ = xy[2*i];
00946 *pxy++ = xy[1+2*i];
00947 }
00948 gnome_canvas_item_set(abl[np], "points", pn, NULL);
00949
00950 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
00951 vinfo->sc->PktVal=np;
00952 g_free(mld);
00953
00954 Activate ();
00955 }
00956
00957
00958
00959 VObKsys::VObKsys(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
00960 : VObject(canvas, xy0, 3, P2d, pflg, cmode, lab, Marker_scale){
00961 XSM_DEBUG (DBG_L3, "VObKsys::VObKsys - adding Ksys" );
00962 GnomeCanvasPoints *pn = gnome_canvas_points_new (3);
00963 pn->coords[0] = xy[0]; pn->coords[1] = xy[1];
00964 pn->coords[2] = xy[2]; pn->coords[3] = xy[3];
00965 pn->coords[4] = xy[4]; pn->coords[5] = xy[5];
00966 abl[3] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
00967 GNOME_TYPE_CANVAS_LINE,
00968 "points", pn,
00969 "fill_color","blue",
00970 "width_pixels", OBJECT_LINE_WIDTH,
00971 NULL);
00972
00973 gnome_canvas_points_free (pn);
00974 SETUP_ITEM(abl[3]);
00975 gnome_canvas_item_lower(abl[3], 3);
00976
00977 abl[4] = NULL;
00978 calc_grid ();
00979 SETUP_ITEM(abl[4]);
00980 gnome_canvas_item_lower(abl[4], 4);
00981
00982 gtk_signal_connect(GTK_OBJECT(abl[3]), "event",
00983 (GtkSignalFunc) VObject::item_event,
00984 this);
00985 Update();
00986 }
00987
00988 VObKsys::~VObKsys(){
00989 XSM_DEBUG(DBG_L2, "VObKsys::~VObKsys");
00990 }
00991
00992 void VObKsys::calc_grid(){
00993 const int num_grid_lines = 11;
00994 int nl = 4*num_grid_lines;
00995 int i,j,k,l;
00996 double rx[2], ry[2];
00997 rx[0] = xy[2]-xy[0];
00998 rx[1] = xy[3]-xy[1];
00999 ry[0] = xy[2]-xy[4];
01000 ry[1] = xy[3]-xy[5];
01001 j = 0;
01002 l = num_grid_lines/2;
01003 GnomeCanvasPoints *pngrid = gnome_canvas_points_new (nl);
01004
01005 for (i=-num_grid_lines/2; i<=num_grid_lines/2; ++i){
01006 k = i;
01007 pngrid->coords[j++] = xy[2] + k*rx[0] + l*ry[0];
01008 pngrid->coords[j++] = xy[3] + k*rx[1] + l*ry[1];
01009 l = -l;
01010 pngrid->coords[j++] = xy[2] + k*rx[0] + l*ry[0];
01011 pngrid->coords[j++] = xy[3] + k*rx[1] + l*ry[1];
01012 }
01013 k = num_grid_lines/2;
01014 for (i=-num_grid_lines/2; i<=num_grid_lines/2; ++i){
01015 l = i;
01016 pngrid->coords[j++] = xy[2] + k*rx[0] + l*ry[0];
01017 pngrid->coords[j++] = xy[3] + k*rx[1] + l*ry[1];
01018 k = -k;
01019 pngrid->coords[j++] = xy[2] + k*rx[0] + l*ry[0];
01020 pngrid->coords[j++] = xy[3] + k*rx[1] + l*ry[1];
01021 }
01022
01023 if (abl[4])
01024 gnome_canvas_item_set( abl[4],
01025 "points", pngrid,
01026 NULL);
01027 else
01028 abl[4] = gnome_canvas_item_new (gnome_canvas_root( GNOME_CANVAS(canvas)),
01029 GNOME_TYPE_CANVAS_LINE,
01030 "points", pngrid,
01031 "fill_color", "green",
01032 "width_pixels", 1,
01033 NULL);
01034 gnome_canvas_points_free (pngrid);
01035 }
01036
01037 void VObKsys::update_grid(){
01038 calc_grid ();
01039 }
01040
01041 void VObKsys::Update(){
01042 gchar *s1;
01043 gchar *phi = g_strdup_printf("phi=%g"UTF8_DEGREE, Phi()-Phi(xy[2]-xy[4], xy[3]-xy[5]));
01044 gchar *mld = g_strconcat("Line: o:",
01045 s1=vinfo->makeXYinfo(xy[2],xy[3], &p2d[1]),
01046 ", ", phi,
01047 NULL);
01048 g_free(s1);
01049 g_free(vinfo->makeXYinfo(xy[0],xy[1], &p2d[0]));
01050 g_free(vinfo->makeXYinfo(xy[4],xy[5], &p2d[2]));
01051 GnomeCanvasPoints *pn = gnome_canvas_points_new (3);
01052 pn->coords[0] = xy[0]; pn->coords[1] = xy[1];
01053 pn->coords[2] = xy[2]; pn->coords[3] = xy[3];
01054 pn->coords[4] = xy[4]; pn->coords[5] = xy[5];
01055 gnome_canvas_item_set (abl[np], "points", pn, NULL);
01056 gnome_canvas_points_free (pn);
01057 calc_grid ();
01058 update_grid ();
01059
01060 vinfo->sc->PktVal=3;
01061 vinfo->sc->set_data (MPOLY);
01062
01063 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
01064 if(profile){
01065 profile->show();
01066 profile->NewData(vinfo->sc);
01067 }
01068 else
01069 gapp->xsm->MausMode(MPOLY);
01070 g_free(mld);
01071 g_free(phi);
01072
01073 Activate ();
01074 }
01075
01076 VObParabel::VObParabel(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
01077 : VObject(canvas, xy0, 3, P2d, pflg, cmode, lab, Marker_scale){
01078 if(name) g_free(name);
01079 name = g_strdup("Parabel");
01080 GnomeCanvasPoints *pn = gnome_canvas_points_new (3);
01081 pn->coords[0] = xy[0]; pn->coords[1] = xy[1];
01082 pn->coords[2] = xy[2]; pn->coords[3] = xy[3];
01083 pn->coords[4] = xy[4]; pn->coords[5] = xy[5];
01084 abl[3] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
01085 GNOME_TYPE_CANVAS_LINE,
01086 "points", pn,
01087 "fill_color","blue",
01088 "width_pixels", OBJECT_LINE_WIDTH,
01089 NULL);
01090
01091 gnome_canvas_points_free (pn);
01092 SETUP_ITEM(abl[3]);
01093 gnome_canvas_item_lower(abl[3], 3);
01094
01095 gtk_signal_connect(GTK_OBJECT(abl[3]), "event",
01096 (GtkSignalFunc) VObject::item_event,
01097 this);
01098 Update();
01099 }
01100
01101 VObParabel::~VObParabel(){
01102 XSM_DEBUG(DBG_L2, "VObParabel::~VObParabel");
01103 }
01104
01105
01106 void VObParabel::Update(){
01107 double phi;
01108 gchar *s1, *s2, *s3, *s4;
01109 gchar *sphi = g_strdup_printf("phi=%g"UTF8_DEGREE, phi=Phi());
01110 gchar *mld = g_strconcat("Line: |",
01111 s1=vinfo->makeXYinfo(xy[0],xy[1], &p2d[0]),
01112 ",",
01113 s2=vinfo->makeXYinfo(xy[2],xy[3], &p2d[1]),
01114 ",",
01115 s3=vinfo->makeXYinfo(xy[4],xy[5], &p2d[2]),
01116 "|=",
01117 s4=vinfo->makeXinfo(Dist()), ", ", sphi,
01118 NULL);
01119 g_free(s4); g_free(s3); g_free(s2); g_free(s1); g_free(sphi);
01120
01121 #define NSEGS 20
01122 GnomeCanvasPoints *pn = gnome_canvas_points_new(NSEGS);
01123 double dx,x;
01124 double c = cos(phi/180.*M_PI);
01125 double s = sin(phi/180.*M_PI);
01126 double *pxy = pn->coords;
01127 double p2[2], pt2[2];
01128 double skl;
01129 p2[0] = xy[4]-xy[2];
01130 p2[1] = xy[5]-xy[3];
01131 pt2[0] = c*p2[0] + s*p2[1];
01132 pt2[1] = -s*p2[0] + c*p2[1];
01133 x = c*(xy[0]-xy[2]) + s*(xy[1]-xy[3]);
01134 dx = (pt2[0]-x)/(NSEGS-1);
01135 skl= pt2[1]/pt2[0]/pt2[0];
01136 c = cos(-phi/180.*M_PI);
01137 s = sin(-phi/180.*M_PI);
01138 for( int i=0; i<NSEGS; ++i, x+=dx){
01139 *pxy++ = xy[2] + c*x + s*x*x*skl;
01140 *pxy++ = xy[3] - s*x + c*x*x*skl;
01141 }
01142
01143 gnome_canvas_item_set(abl[np], "points", pn, NULL);
01144 gnome_canvas_points_unref(pn);
01145
01146 vinfo->sc->PktVal=3;
01147 vinfo->sc->set_data (MPARABEL);
01148 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
01149
01150 if(profile){
01151 profile->show();
01152 profile->NewData(vinfo->sc);
01153 }
01154 else
01155 gapp->xsm->MausMode (MPARABEL);
01156 g_free(mld);
01157
01158
01159 Activate ();
01160 }
01161
01162 VObRectangle::VObRectangle(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
01163 : VObject(canvas, xy0, 2, P2d, pflg, cmode, lab, Marker_scale){
01164 if(name) g_free(name);
01165 name = g_strdup("Rectangle");
01166
01167 if(xsmres.antialiascanvas)
01168 abl[2] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
01169 gnome_canvas_rect_get_type(),
01170 "x1",xy[0],
01171 "y1",xy[1],
01172 "x2",xy[2],
01173 "y2",xy[3],
01174 "outline_color","blue",
01175 "fill_color_rgba", 0x00000030,
01176 "width_pixels", OBJECT_LINE_WIDTH,
01177 NULL);
01178 else
01179 abl[2] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
01180 gnome_canvas_rect_get_type(),
01181 "x1",xy[0],
01182 "y1",xy[1],
01183 "x2",xy[2],
01184 "y2",xy[3],
01185 "outline_color","blue",
01186 "width_pixels", OBJECT_LINE_WIDTH,
01187 NULL);
01188
01189 gnome_canvas_item_lower(abl[2], 2);
01190
01191 gtk_signal_connect(GTK_OBJECT(abl[2]), "event",
01192 (GtkSignalFunc) VObject::item_event,
01193 this);
01194 }
01195
01196 VObRectangle::~VObRectangle(){};
01197
01198 void VObRectangle::Update(){
01199 gchar *s1, *s2, *s3;
01200 gchar *mld = g_strconcat("Rect: ",
01201 s1=vinfo->makeXYinfo(xy[0],xy[1], &p2d[0]),
01202 "-",
01203 s2=vinfo->makedXdYinfo(xy,xy+2),
01204 " A=",
01205 s3=vinfo->makeA2info(xy,xy+2),
01206 NULL);
01207 g_free(s3); g_free(s2); g_free(s1);
01208 g_free(vinfo->makeXYinfo(xy[2],xy[3], &p2d[1]));
01209 gnome_canvas_item_set(abl[np],
01210 "x1",xy[0], "y1",xy[1],
01211 "x2",xy[2], "y2",xy[3],
01212 NULL);
01213 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
01214 vinfo->sc->PktVal=2;
01215
01216 gapp->xsm->MausMode(MRECT);
01217 g_free(mld);
01218
01219 Activate ();
01220 }
01221
01222 VObCircle::VObCircle(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double Marker_scale)
01223 : VObject(canvas, xy0, 2, P2d, pflg, cmode, lab, Marker_scale){
01224 if(name) g_free(name);
01225 name = g_strdup("Circle");
01226 Calc();
01227 abl[2] = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(canvas)),
01228 gnome_canvas_ellipse_get_type(),
01229 "x1",xyrec[0],
01230 "y1",xyrec[1],
01231 "x2",xyrec[2],
01232 "y2",xyrec[3],
01233 "outline_color","blue",
01234 "width_pixels", OBJECT_LINE_WIDTH,
01235 NULL);
01236
01237 gnome_canvas_item_lower(abl[2],2);
01238
01239 gtk_signal_connect(GTK_OBJECT(abl[2]), "event",
01240 (GtkSignalFunc) VObject::item_event,
01241 this);
01242 }
01243
01244 VObCircle::~VObCircle(){};
01245
01246 void VObCircle::Update(){
01247 Calc();
01248 gchar *s1, *s2;
01249 gchar *mld = g_strconcat("Circle: ",
01250 s1=vinfo->makeXYinfo(xy[0],xy[1], &p2d[0]),
01251 ", r=",
01252 s2=vinfo->makeDXYinfo(xy, xy+2),
01253 NULL);
01254 g_free(s2); g_free(s1);
01255 g_free(vinfo->makeXYinfo(xy[2],xy[3], &p2d[1]));
01256 gnome_canvas_item_set(abl[np],
01257 "x1",xyrec[0], "y1",xyrec[1],
01258 "x2",xyrec[2], "y2",xyrec[3],
01259 NULL);
01260
01261 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
01262 vinfo->sc->PktVal=2;
01263 vinfo->sc->set_data (MCIRC);
01264
01265 if (profile){
01266 profile->show();
01267 profile->NewData(vinfo->sc);
01268 }
01269 else
01270 gapp->xsm->MausMode (MCIRC);
01271
01272 g_free(mld);
01273 Activate ();
01274 }
01275
01276
01277 VObEvent::VObEvent(GtkWidget *canvas, double *xy0, Point2D *P2d, int pflg, VOBJ_COORD_MODE cmode, gchar *lab, double marker_scale)
01278 : VObject(canvas, xy0, 0, P2d, pflg, cmode, lab, marker_scale){
01279 if(name) g_free(name);
01280 name = g_strdup("Event");
01281 lock_object (TRUE);
01282 Update();
01283 }
01284
01285 void VObEvent::Update(){
01286 gchar *s1;
01287 gchar *mld = g_strconcat("Event: ",
01288 s1=vinfo->makeXYZinfo(xy[0],xy[1], &p2d[0]),
01289 NULL);
01290 g_free(s1);
01291 gtk_statusbar_push(GTK_STATUSBAR(statusbar), statusid, mld);
01292 vinfo->sc->PktVal=1;
01293 vinfo->sc->set_data (MPOINT);
01294
01295 if (vinfo->sc->view)
01296 vinfo->sc->view->update_event_info (scan_event);
01297
01298 Activate ();
01299
01300 g_free(mld);
01301 }
01302
01303 VObEvent::~VObEvent(){};