[giv] Added toggle of alpha transparency. Added adjustment of caliper position.
- From: Dov Grobgeld <dov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [giv] Added toggle of alpha transparency. Added adjustment of caliper position.
- Date: Wed, 27 Apr 2011 18:36:03 +0000 (UTC)
commit d8503d08203e53c5098654180feb67b10ab2665d
Author: Dov Grobgeld <dov grobgeld gmail com>
Date: Wed Apr 27 21:35:51 2011 +0300
Added toggle of alpha transparency. Added adjustment of caliper position.
ChangeLog | 11 ++++-
TODO | 1 +
src/GivRenderer.cc | 5 ++-
src/GivRenderer.h | 6 ++-
src/dovtk-lasso.c | 110 ++++++++++++++++++++++++++++++++++++--------
src/dovtk-lasso.h | 55 ++++++++++++++++++++--
src/giv-widget.gob | 10 ++++
src/giv-win.gob | 129 ++++++++++++++++++++++++++++++++++++++++------------
8 files changed, 270 insertions(+), 57 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 388ae2b..9080dfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,19 @@
+2011-04-27 Dov Grobgeld <dov grobgeld gmail com>
+
+ * giv-win.gob, GivRenderer.h, GivRenderer.cc : Added the
+ toggle 'a' that allow toggling the alpha transparency of
+ all overlays.
+
+ * giv-win.gob : Added ability to adjust the caliper tool
+ after placement.
+
2011-04-14 Dov Grobgeld <dov grobgeld gmail com>
* giv.wine.nsi.in : Added gtkrc for more windows look.
2011-04-13 Dov Grobgeld <dov grobgeld gmail com>
- * giv-settings.gob: Created settings for only seeing files of
+ * giv-settings.gob: Created settings for only seeing files of
the same type.
* giv-settings.gob, giv-settings-editor.gob, giv-win.gob :
diff --git a/TODO b/TODO
index a0264e5..a0666dd 100644
--- a/TODO
+++ b/TODO
@@ -16,6 +16,7 @@ List of things to do.
* Support high-bit color.
* Fix annoying resize bugs on reload. Fix flickering!
* Add 3d support to npy plugin.
+* Add 3d support to tiff plugin.
* Add option for setting the number of decimals to show
* Add optional grid for high zoom in.
* Make png plugin support backgrounds.
diff --git a/src/GivRenderer.cc b/src/GivRenderer.cc
index 365393d..ff12ce5 100644
--- a/src/GivRenderer.cc
+++ b/src/GivRenderer.cc
@@ -32,7 +32,8 @@ GivRenderer::GivRenderer(GPtrArray *_datasets,
shift_x(_shift_x),
shift_y(_shift_y),
width(_width),
- height(_height)
+ height(_height),
+ do_no_transparency(false)
{
}
@@ -52,6 +53,8 @@ void GivRenderer::paint()
double gg = cs*dataset->color.green;
double bb = cs*dataset->color.blue;
double alpha = cs*dataset->color.alpha;
+ if (this->do_no_transparency)
+ alpha = 1.0;
#if 0
printf("datasets[%d]->color.pixel = %d\n",
diff --git a/src/GivRenderer.h b/src/GivRenderer.h
index e62e98b..3c86fdd 100644
--- a/src/GivRenderer.h
+++ b/src/GivRenderer.h
@@ -16,6 +16,10 @@ class GivRenderer {
double height
);
void paint();
+ void set_do_no_transparency(bool do_no_transparency)
+ {
+ this->do_no_transparency = do_no_transparency;
+ }
private:
GPtrArray *datasets;
@@ -26,7 +30,7 @@ class GivRenderer {
double shift_y;
double width;
double height;
-
+ bool do_no_transparency;
};
#endif /* GIVRENDERER */
diff --git a/src/dovtk-lasso.c b/src/dovtk-lasso.c
index 0c3533e..80a023a 100644
--- a/src/dovtk-lasso.c
+++ b/src/dovtk-lasso.c
@@ -63,6 +63,13 @@ void dovtk_lasso_destroy(DovtkLasso *lasso)
g_free(lasso);
}
+void dovtk_lasso_clear_exprects(DovtkLasso *lasso)
+{
+ DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)lasso;
+ dovtk_lasso_rectangle_list_destroy(selfp->old_rect_list);
+ selfp->old_rect_list = dovtk_lasso_rectangle_list_new(0);
+}
+
static int lasso_cb_expose(GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
@@ -83,7 +90,7 @@ static int lasso_cb_expose(GtkWidget *widget,
event->area.width, event->area.height);
cairo_clip(cr);
- selfp->drawing_cb(cr, FALSE, selfp->user_data);
+ selfp->drawing_cb(cr, DOVTK_LASSO_CONTEXT_PAINT, selfp->user_data);
cairo_destroy(cr);
@@ -92,18 +99,14 @@ static int lasso_cb_expose(GtkWidget *widget,
int a8_idx=0;
-void dovtk_lasso_update(DovtkLasso *lasso)
+static DovtkLassoRectangleList *get_exprects_from_drawing(DovtkLassoPrivate *selfp)
{
- DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)lasso;
-
// Call drawing_cb to and use it to generate the rectangle list
DovtkLassoRectangleList *rect_list = NULL;
int scale_factor = 32;
int low_res_width = (selfp->widget->allocation.width+scale_factor-1) / scale_factor;
int low_res_height = (selfp->widget->allocation.height+scale_factor-1) / scale_factor;
- int i;
-
// This should be created in the creation of DovtkLasso
cairo_t *cr = NULL;
cairo_surface_t *surf = NULL;
@@ -119,11 +122,6 @@ void dovtk_lasso_update(DovtkLasso *lasso)
cairo_scale(cr,1.0/scale_factor,1.0/scale_factor);
selfp->drawing_cb(cr, TRUE, selfp->user_data);
-#if 0
- char filename[64];
- sprintf(filename, "/tmp/a8-%04d.png", a8_idx++);
- cairo_surface_write_to_png(surf, filename);
-#endif
// Turn surf into a list of rectangles
int row_idx, col_idx;
@@ -152,20 +150,38 @@ void dovtk_lasso_update(DovtkLasso *lasso)
cairo_destroy(cr);
cairo_surface_destroy(surf);
- // printf("num_rectangles = %d\n", rect_list->num_rectangles);
+ return rect_list;
+}
+
+static DovtkLassoRectangleList *rect_cat(DovtkLassoRectangleList *rect1,
+ DovtkLassoRectangleList *rect2)
+{
+ int num_rects1 = rect1->num_rectangles;
+ int num_rects2 = rect2->num_rectangles;
+ DovtkLassoRectangleList *rect_list
+ = dovtk_lasso_rectangle_list_new(num_rects1+num_rects2);
+ int i;
+ for (i=0; i<num_rects1; i++)
+ rect_list->rectangles[i] = rect1->rectangles[i];
+ for (i=0; i<num_rects2; i++)
+ rect_list->rectangles[num_rects1 + i] = rect2->rectangles[i];
+ return rect_list;
+}
+
+void dovtk_lasso_update(DovtkLasso *lasso)
+{
+ DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)lasso;
+
+ // Call drawing_cb to and use it to generate the rectangle list
+ DovtkLassoRectangleList *rect_list = get_exprects_from_drawing(selfp);
// Build a list of expose rectangles from the old and the new lists.
// Better done as a linked list.
DovtkLassoRectangleList *expose_rect_list
- = dovtk_lasso_rectangle_list_new(selfp->old_rect_list->num_rectangles
- + rect_list->num_rectangles);
- int num_old_rects = selfp->old_rect_list->num_rectangles;
- for (i=0; i<num_old_rects; i++)
- expose_rect_list->rectangles[i] = selfp->old_rect_list->rectangles[i];
- for (i=0; i<rect_list->num_rectangles; i++)
- expose_rect_list->rectangles[num_old_rects + i] = rect_list->rectangles[i];
+ = rect_cat(selfp->old_rect_list, rect_list);
// Expose the old and the new list of rectangles!
+ int i;
for (i=0; i<expose_rect_list->num_rectangles; i++) {
// Shortcut
cairo_rectangle_t *lasso_rect = &expose_rect_list->rectangles[i];
@@ -202,3 +218,59 @@ void dovtk_lasso_rectangle_list_destroy(DovtkLassoRectangleList *rectangle_list)
g_free(rectangle_list->rectangles);
g_free(rectangle_list);
}
+
+int dovtk_lasso_get_label_for_pixel(DovtkLasso *lasso,
+ int col_idx, int row_idx)
+{
+ DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)lasso;
+ cairo_t *cr = NULL;
+ cairo_surface_t *surf = NULL;
+
+ surf=cairo_image_surface_create(CAIRO_FORMAT_RGB24,1,1);
+ cr = cairo_create(surf);
+ cairo_translate(cr,-col_idx,-row_idx);
+
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+
+ selfp->drawing_cb(cr, DOVTK_LASSO_CONTEXT_LABEL, selfp->user_data);
+
+ guint8 *buf = cairo_image_surface_get_data(surf);
+ int label = buf[2]+256*buf[1]+256*256*buf[0];
+ cairo_destroy(cr);
+ cairo_surface_destroy(surf);
+ return label;
+}
+
+/**
+ * The label is encoded in the RGB image by its color.
+ *
+ * @param lasso
+ * @param cr
+ * @param label
+ */
+void dovtk_lasso_set_color_label(DovtkLasso *lasso,
+ cairo_t *cr,
+ int label)
+{
+ double rr = 1.0*label/255;
+ double gg = (1.0*(label>>8))/255;
+ double bb = (1.0*(label>>16))/255;
+
+ cairo_set_source_rgb(cr,rr,gg,bb);
+}
+
+/**
+ * Use the drawing routine to add more rects list without exposing
+ * the drawing.
+ *
+ * @param lasso
+ */
+void dovtk_lasso_add_exprects_from_drawing_cb(DovtkLasso *lasso)
+{
+ DovtkLassoPrivate *selfp = (DovtkLassoPrivate*)lasso;
+ DovtkLassoRectangleList *rect_list = get_exprects_from_drawing(selfp);
+ DovtkLassoRectangleList *new_rect_list = rect_cat(selfp->old_rect_list,
+ rect_list);
+ dovtk_lasso_rectangle_list_destroy(selfp->old_rect_list);
+ selfp->old_rect_list = new_rect_list;
+}
diff --git a/src/dovtk-lasso.h b/src/dovtk-lasso.h
index b3b13fe..76286c5 100644
--- a/src/dovtk-lasso.h
+++ b/src/dovtk-lasso.h
@@ -13,6 +13,24 @@
#include <gtk/gtk.h>
+/**
+ * The drawing callback is used for three purposes:
+ *
+ * - Drawing a mask
+ * - Drawing a label image (mapping of pixel to label). Used for
+ * picking.
+ * - Drawing the graphics
+ *
+ * @param DovtkLassoDrawing
+ *
+ * @return
+ */
+typedef enum {
+ DOVTK_LASSO_CONTEXT_PAINT,
+ DOVTK_LASSO_CONTEXT_MASK,
+ DOVTK_LASSO_CONTEXT_LABEL
+} DovtkLassoContext;
+
/**
* Opaque handle for the lasso
*
@@ -22,17 +40,17 @@ typedef struct {
/**
* Callback function for the lasso that paints the overlap. If
- * do_mask is true, then the drawing alpha channel of the drawing
- * will be used to determine whether the redraw that patch.
- * Typically lines will be drawn thicker when mask is on in
- * order to make sure that the corresponding patch is dirty.
+ * context == DOVTK_LASSO_CONTEXT_MASK, then the drawing alpha channel
+ * of the drawing will be used to determine whether the redraw
+ * that patch. Typically lines will be drawn thicker when mask is
+ * on in order to make sure that the corresponding patch is dirty.
*
* @param DovtkLassoDrawing
*
* @return
*/
typedef void (*DovtkLassoDrawing)(cairo_t *cr,
- gboolean do_mask,
+ DovtkLassoContext Context,
gpointer user_data);
@@ -58,4 +76,31 @@ void dovtk_lasso_update(DovtkLasso *lasso);
*/
void dovtk_lasso_destroy(DovtkLasso *lasso);
+/**
+ * Discards all the exprects.
+ *
+ * @param lasso
+ */
+void dovtk_lasso_clear_exprects(DovtkLasso *lasso);
+
+/**
+ * Create exprects from the current callback
+ *
+ * @param lasso
+ */
+void dovtk_lasso_add_exprects_from_drawing_cb(DovtkLasso *lasso);
+
+/**
+ * Get label for a pixel according to the current drawing routine.
+ */
+int dovtk_lasso_get_label_for_pixel(DovtkLasso *lasso,
+ int col_idx, int row_idx);
+
+/**
+ * Set the color corresponding to a label.
+ */
+void dovtk_lasso_set_color_label(DovtkLasso *lasso,
+ cairo_t *cr,
+ int label);
+
#endif /* DOVTK */
diff --git a/src/giv-widget.gob b/src/giv-widget.gob
index 0c89c56..434bb07 100644
--- a/src/giv-widget.gob
+++ b/src/giv-widget.gob
@@ -90,6 +90,7 @@ class Giv:Widget from Gtk:Image:Viewer
private bool do_view_marks = TRUE;
private bool do_view_cross_hair = FALSE;
private bool do_show_balloon = FALSE;
+ private bool do_no_transparency = FALSE;
private gint last_cx = 0;
private gint last_cy = 0;
private gint last_move_x = 0;
@@ -334,6 +335,13 @@ class Giv:Widget from Gtk:Image:Viewer
}
public
+ void set_do_no_transparency(self,
+ bool do_no_transparency)
+ {
+ selfp->do_no_transparency = do_no_transparency;
+ }
+
+ public
void set_colormap(self,
GivPseudoColor pseudo_color)
{
@@ -542,6 +550,7 @@ cb_image_annotate(GivWidget *self,
scale_x, scale_y,
shift_x, shift_y,
width, height);
+ renderer.set_do_no_transparency(selfp->do_no_transparency);
if (!selfp->is_dragging && selfp->do_view_marks)
renderer.paint();
@@ -612,6 +621,7 @@ cb_image_annotate(GivWidget *self,
li_scale_x, li_scale_y,
li_shift_x, li_shift_y,
li_width, li_height);
+ renderer.set_do_no_transparency(selfp->do_no_transparency);
renderer.paint();
}
}
diff --git a/src/giv-win.gob b/src/giv-win.gob
index 5c1c9cd..1d53082 100644
--- a/src/giv-win.gob
+++ b/src/giv-win.gob
@@ -105,7 +105,9 @@ static void cb_view_auto_reload (GtkAction *action, gpointer data);
static void cb_menu_measure_distance (GtkAction *action, gpointer data);
static void cb_menu_calibrate (GtkAction *action, gpointer data);
static void cb_menu_quiver_zoom (GtkAction *action, gpointer data);
+#if 0
static void cb_menu_default (GtkAction *action, gpointer data);
+#endif
static void cb_menu_preferences (GtkAction *action, gpointer data);
static void cb_menu_new_window (GtkAction *action, gpointer data);
static void cb_menu_fill (GtkAction *action, gpointer data);
@@ -232,7 +234,7 @@ cb_image_annotate(GivWidget *imgv,
);
static void
my_lasso_draw(cairo_t *cr,
- gboolean do_mask,
+ DovtkLassoContext context,
gpointer user_data);
// The following tables contain all the actions for both the menubar
@@ -473,6 +475,7 @@ class Giv:Win from Gtk:Window
private bool do_square_aspect_ratio = true;
private bool do_auto_fit_marks = TRUE;
private bool do_auto_reload = FALSE;
+ private bool do_no_transparency = FALSE;
private gdouble last_move_x=-1;
private gdouble last_move_y=-1;
private double last_cx;
@@ -494,8 +497,11 @@ class Giv:Win from Gtk:Window
// private giv_backstore_t *back_store = NULL;
private DovtkLasso *lasso = NULL;
private gboolean is_measuring_distance = FALSE;
+ private int picking_mode = 0;
private gboolean is_quiver_zoom = FALSE;
private gint measure_point_index = 0;
+ private double picking_x=-1;
+ private double picking_y=-1;
private double measure_x1=-1;
private double measure_y1=-1;
private double measure_x2=-1;
@@ -693,6 +699,8 @@ class Giv:Win from Gtk:Window
G_CALLBACK(cb_image_reference), self);
g_signal_connect(selfp->w_imgv, "button-press-event",
G_CALLBACK(cb_button_press_event), self);
+ g_signal_connect(selfp->w_imgv, "button-release-event",
+ G_CALLBACK(cb_button_release_event), self);
g_signal_connect(selfp->w_imgv, "key-press-event",
G_CALLBACK(cb_key_press_event), self);
g_signal_connect(selfp->w_imgv, "motion-notify-event",
@@ -1474,14 +1482,20 @@ cb_button_press_event (GtkWidget * widget,
giv_widget_popdown_balloon(GIV_WIDGET(selfp->w_imgv));
if (event->button == 1) {
-
// check if are in measure mode ('z')
if (selfp->is_measuring_distance) {
- if (0 == selfp->measure_point_index) {
+ selfp->picking_mode = dovtk_lasso_get_label_for_pixel(selfp->lasso, event->x, event->y);
+ if (selfp->measure_point_index == 0
+ && selfp->picking_mode) {
+ selfp->picking_x = selfp->last_move_x;
+ selfp->picking_y = selfp->last_move_y;
+ }
+ else if (0 == selfp->measure_point_index) {
selfp->measure_x1 = selfp->last_move_x;
selfp->measure_y1 = selfp->last_move_y;
selfp->measure_point_index = 1;
- selfp->measure_x2 = selfp->measure_y2 = -1;
+ selfp->measure_x2 = selfp->measure_x1;
+ selfp->measure_y2 = selfp->measure_y1;
}
else {
selfp->measure_x2 = selfp->last_move_x;
@@ -1517,6 +1531,7 @@ cb_button_release_event (GtkWidget * widget,
selfp->is_dragging = FALSE;
giv_win_redraw(self);
}
+ selfp->picking_mode = 0;
return 0;
}
@@ -1528,6 +1543,13 @@ cb_key_press_event (GtkWidget * widget,
{
GivWin *self = (GivWin *)user_data;
gint k = event->keyval;
+ if (k == 'a') {
+ selfp->do_no_transparency = !selfp->do_no_transparency;
+ giv_widget_set_do_no_transparency(GIV_WIDGET(selfp->w_imgv),
+ selfp->do_no_transparency);
+ giv_win_redraw(self);
+ return 1;
+ }
if (k == 'q')
gtk_main_quit();
if (k== 'o')
@@ -1698,30 +1720,38 @@ cb_motion_event(GtkWidget *widget,
double x,y;
GString *info_label = g_string_new("");
gboolean do_update_label = true;
+ bool do_update_measure_distance = false;
gtk_image_viewer_canv_coord_to_img_coord(GTK_IMAGE_VIEWER(image_viewer),
cx, cy, &x, &y);
if (selfp->is_measuring_distance) {
- if (selfp->measure_point_index == 1) {
- // Calculate distance
- double m_dist = sqrt(sqr(selfp->measure_x1 - x) + sqr((selfp->measure_y1-y)));
- selfp->last_measure_distance_in_pixels = m_dist;
- if (selfp->w_calibrate)
- giv_calibrate_dialog_set_last_measure_distance_in_pixels(
- GIV_CALIBRATE_DIALOG(selfp->w_calibrate),
- m_dist);
-
- selfp->measure_x2 = x;
- selfp->measure_y2 = y;
+ if (selfp->picking_mode) {
+ double dx = x - selfp->picking_x;
+ double dy = y - selfp->picking_y;
+ if (selfp->picking_mode == 1 || selfp->picking_mode==2) {
+ selfp->measure_x1 += dx;
+ selfp->measure_y1 += dy;
+ }
+ if (selfp->picking_mode == 1 || selfp->picking_mode==3) {
+ selfp->measure_x2 += dx;
+ selfp->measure_y2 += dy;
+ }
+ selfp->picking_x = x;
+ selfp->picking_y = y;
+ do_update_measure_distance = true;
+ }
+
+ else if (selfp->measure_point_index == 1) {
+ selfp->measure_x2 = x;
+ selfp->measure_y2 = y;
+ do_update_measure_distance = true;
#if 0
draw_measure_line(selfp->back_store,
widget,
selfp->measure_x1, selfp->measure_y1,
x,y);
#endif
- dovtk_lasso_update(selfp->lasso);
- giv_win_update_pixelsize_info(self, info_label);
}
else
do_update_label = false;
@@ -1731,6 +1761,19 @@ cb_motion_event(GtkWidget *widget,
else
g_string_sprintf(info_label, " (%4.0f, %4.0f)", x, y);
+ if (do_update_measure_distance) {
+ double m_dist = sqrt(sqr(selfp->measure_x2 - selfp->measure_x1)
+ + sqr(selfp->measure_y2-selfp->measure_y1));
+ selfp->last_measure_distance_in_pixels = m_dist;
+
+ dovtk_lasso_update(selfp->lasso);
+ giv_win_update_pixelsize_info(self, info_label);
+ if (selfp->w_calibrate)
+ giv_calibrate_dialog_set_last_measure_distance_in_pixels(
+ GIV_CALIBRATE_DIALOG(selfp->w_calibrate),
+ m_dist);
+ }
+
if (selfp->img_org && !selfp->is_measuring_distance) {
int width = giv_image_get_width(selfp->img_org);
int height = giv_image_get_height(selfp->img_org);
@@ -2545,6 +2588,7 @@ void draw_to_cairo(cairo_t *cr,
scale_x, scale_y,
shift_x, shift_y,
cnv_width, cnv_height);
+ renderer.set_do_no_transparency(selfp->do_no_transparency);
renderer.paint();
pixbuf_to_cairo(img_scaled,
@@ -2596,6 +2640,7 @@ void draw_to_cairo(cairo_t *cr,
scale_x, scale_y,
shift_x, shift_y,
cnv_width, cnv_height);
+ renderer.set_do_no_transparency(selfp->do_no_transparency);
renderer.paint();
#endif
}
@@ -3583,16 +3628,19 @@ cb_image_annotate(GivWidget *imgv,
}
static void
-draw_caliper(cairo_t *cr,
- gboolean do_mask,
+draw_caliper(GivWin *self,
+ cairo_t *cr,
+ DovtkLassoContext lasso_context,
double x0, double y0,
double x1, double y1,
const char *caliper_text)
{
int margin = 0;
- if (do_mask)
+ if (lasso_context != DOVTK_LASSO_CONTEXT_PAINT)
margin = 5;
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+
double angle = atan2(y1-y0,x1-x0);
cairo_translate(cr,
0.5 * (x0+x1),
@@ -3600,14 +3648,19 @@ draw_caliper(cairo_t *cr,
cairo_rotate(cr, angle);
double dist = sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
- if (!do_mask)
+ if (lasso_context == DOVTK_LASSO_CONTEXT_PAINT)
cairo_set_source_rgba(cr, 10*0x4d/255.0,1.0*0xaa/255.0,0,0.5);
+ else if (lasso_context == DOVTK_LASSO_CONTEXT_LABEL)
+ dovtk_lasso_set_color_label(selfp->lasso, cr, 1);
+
cairo_rectangle(cr, -dist/2-margin, -20-margin,
dist+2*margin, 20+2*margin);
cairo_fill(cr);
- if (!do_mask)
+ if (lasso_context == DOVTK_LASSO_CONTEXT_PAINT)
cairo_set_source_rgb(cr, 0x50/255.0,0x2d/255.0,0x16/255.0);
+ else if (lasso_context == DOVTK_LASSO_CONTEXT_LABEL)
+ dovtk_lasso_set_color_label(selfp->lasso, cr, 2);
double calip_height = 50;
cairo_move_to(cr, -dist/2+margin,calip_height/2+margin);
@@ -3620,6 +3673,13 @@ draw_caliper(cairo_t *cr,
cairo_close_path(cr);
+ if (lasso_context == DOVTK_LASSO_CONTEXT_LABEL) {
+ cairo_fill_preserve(cr);
+ cairo_set_line_width(cr, 5);
+ cairo_stroke(cr);
+ dovtk_lasso_set_color_label(selfp->lasso, cr, 3);
+ }
+
cairo_move_to(cr, dist/2-margin,calip_height/2+margin);
cairo_rel_curve_to(cr,
15+2*margin,dy,
@@ -3629,14 +3689,18 @@ draw_caliper(cairo_t *cr,
cairo_close_path(cr);
- if (do_mask) {
- cairo_fill_preserve(cr);
+ if (lasso_context == DOVTK_LASSO_CONTEXT_PAINT)
+ cairo_fill(cr);
+ else {
cairo_set_line_width(cr, 5);
+ cairo_fill_preserve(cr);
cairo_stroke(cr);
}
- else
- cairo_fill(cr);
+ // No need to draw text for label context
+ if (lasso_context == DOVTK_LASSO_CONTEXT_LABEL)
+ return;
+
#if 0
// This is stil broken!
@@ -3693,7 +3757,7 @@ draw_caliper(cairo_t *cr,
pango_layout_get_size(pango_layout, &layout_width, &layout_height);
cairo_move_to(cr, -0.5*layout_width/PANGO_SCALE,-0.9*layout_height/PANGO_SCALE);
- if (!do_mask)
+ if (lasso_context==DOVTK_LASSO_CONTEXT_PAINT)
cairo_set_source_rgba(cr, 0,0,0,1); // 0x50/255.0,0x2d/255.0,0x16/255.0,1);
pango_cairo_show_layout(cr, pango_layout);
@@ -3711,7 +3775,7 @@ draw_caliper(cairo_t *cr,
*/
static void
my_lasso_draw(cairo_t *cr,
- gboolean do_mask,
+ DovtkLassoContext context,
gpointer user_data)
{
GivWin *self = GIV_WIN(user_data);
@@ -3730,6 +3794,7 @@ my_lasso_draw(cairo_t *cr,
selfp->measure_y2,
&end_x, &end_y);
+#if 0
if (!do_mask) {
cairo_set_source_rgb(cr, 1,0,0);
cairo_set_line_width(cr,1);
@@ -3738,6 +3803,7 @@ my_lasso_draw(cairo_t *cr,
cairo_set_line_width(cr, 5);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+#endif
// Draw a rectangle
// cairo_rectangle(cr, min_x, min_y, abs(end_x-start_x), abs(end_y-start_y));
@@ -3747,13 +3813,16 @@ my_lasso_draw(cairo_t *cr,
caliper_text = slipprintf("%.1f%s",
dist*selfp->pixelsize,
selfp->pixelsize_unit);
- draw_caliper(cr,
- do_mask,
+ draw_caliper(self,
+ cr,
+ context,
start_x, start_y,
end_x, end_y,
caliper_text);
+#if 0
cairo_stroke(cr);
+#endif
}
%}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]