Split curve and spiral widgets
This commit is contained in:
committed by
Stéphane Lesimple
parent
9effa298cd
commit
73218aebd2
@@ -413,7 +413,7 @@ typedef struct _GlobalClosure
|
|||||||
/*** Widgets for the linear reading/scanning action */
|
/*** Widgets for the linear reading/scanning action */
|
||||||
|
|
||||||
GtkWidget *readLinearHeadline;
|
GtkWidget *readLinearHeadline;
|
||||||
GtkWidget *readLinearDrawingArea;
|
GtkWidget *readLinearCurveArea;
|
||||||
struct _Curve *readLinearCurve;
|
struct _Curve *readLinearCurve;
|
||||||
struct _Spiral *readLinearSpiral;
|
struct _Spiral *readLinearSpiral;
|
||||||
GtkWidget *readLinearNotebook;
|
GtkWidget *readLinearNotebook;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static void update_geometry(void);
|
|||||||
|
|
||||||
static gboolean max_speed_idle_func(gpointer data)
|
static gboolean max_speed_idle_func(gpointer data)
|
||||||
{
|
{
|
||||||
gdk_window_clear(gtk_widget_get_window(Closure->readLinearDrawingArea));
|
gdk_window_clear(gtk_widget_get_window(Closure->readLinearCurveArea));
|
||||||
update_geometry();
|
update_geometry();
|
||||||
redraw_curve();
|
redraw_curve();
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ static gboolean curve_idle_func(gpointer data)
|
|||||||
{ Closure->readLinearCurve->maxY = Closure->readLinearCurve->fvalue[ci->percent] + 1;
|
{ Closure->readLinearCurve->maxY = Closure->readLinearCurve->fvalue[ci->percent] + 1;
|
||||||
|
|
||||||
update_geometry();
|
update_geometry();
|
||||||
gdk_window_clear(gtk_widget_get_window(Closure->readLinearDrawingArea));
|
gdk_window_clear(gtk_widget_get_window(Closure->readLinearCurveArea));
|
||||||
redraw_curve();
|
redraw_curve();
|
||||||
rc->lastPlotted = ci->percent;
|
rc->lastPlotted = ci->percent;
|
||||||
rc->lastPlottedY = GuiCurveY(Closure->readLinearCurve, Closure->readLinearCurve->fvalue[ci->percent]);
|
rc->lastPlottedY = GuiCurveY(Closure->readLinearCurve, Closure->readLinearCurve->fvalue[ci->percent]);
|
||||||
@@ -168,14 +168,14 @@ static gboolean curve_idle_func(gpointer data)
|
|||||||
if(Closure->readLinearCurve->lvalue[i])
|
if(Closure->readLinearCurve->lvalue[i])
|
||||||
{ gdk_gc_set_rgb_fg_color(Closure->drawGC, Closure->logColor);
|
{ gdk_gc_set_rgb_fg_color(Closure->drawGC, Closure->logColor);
|
||||||
|
|
||||||
gdk_draw_rectangle(Closure->readLinearDrawingArea->window,
|
gdk_draw_rectangle(Closure->readLinearCurveArea->window,
|
||||||
Closure->drawGC, TRUE,
|
Closure->drawGC, TRUE,
|
||||||
x0, l1,
|
x0, l1,
|
||||||
x0==x1 ? 1 : x1-x0, Closure->readLinearCurve->bottomLY-l1);
|
x0==x1 ? 1 : x1-x0, Closure->readLinearCurve->bottomLY-l1);
|
||||||
}
|
}
|
||||||
if(x0<x1)
|
if(x0<x1)
|
||||||
{ gdk_gc_set_rgb_fg_color(Closure->drawGC, Closure->curveColor);
|
{ gdk_gc_set_rgb_fg_color(Closure->drawGC, Closure->curveColor);
|
||||||
gdk_draw_line(Closure->readLinearDrawingArea->window,
|
gdk_draw_line(Closure->readLinearCurveArea->window,
|
||||||
Closure->drawGC,
|
Closure->drawGC,
|
||||||
x0, y0, x1, y1);
|
x0, y0, x1, y1);
|
||||||
|
|
||||||
@@ -276,30 +276,17 @@ void GuiMarkExistingSectors(void)
|
|||||||
* Redraw the whole curve
|
* Redraw the whole curve
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Calculate the geometry of the curve and spiral */
|
static void redraw_curve(void)
|
||||||
|
{
|
||||||
|
GuiRedrawAxes(Closure->readLinearCurve);
|
||||||
|
GuiRedrawCurve(Closure->readLinearCurve, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate the geometry of the curve */
|
||||||
|
|
||||||
static void update_geometry(void)
|
static void update_geometry(void)
|
||||||
{ GtkWidget *widget = Closure->readLinearDrawingArea;
|
{
|
||||||
GtkAllocation a = {0};
|
GuiUpdateCurveGeometry(Closure->readLinearCurve, "99x", 10);
|
||||||
gtk_widget_get_allocation(widget, &a);
|
|
||||||
|
|
||||||
/* Curve geometry */
|
|
||||||
|
|
||||||
GuiUpdateCurveGeometry(Closure->readLinearCurve, "99x",
|
|
||||||
Closure->readLinearSpiral->diameter + 30);
|
|
||||||
|
|
||||||
/* Spiral center */
|
|
||||||
|
|
||||||
Closure->readLinearSpiral->mx = a.width - 15 - Closure->readLinearSpiral->diameter / 2;
|
|
||||||
Closure->readLinearSpiral->my = a.height / 2;
|
|
||||||
|
|
||||||
if(Closure->crcBuf && Closure->crcBuf->crcCached)
|
|
||||||
{ int w,h;
|
|
||||||
|
|
||||||
GuiSetText(Closure->readLinearCurve->layout, _("Sectors with CRC errors"), &w, &h);
|
|
||||||
|
|
||||||
Closure->readLinearSpiral->my -= h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Label positions in the foot line */
|
/* Label positions in the foot line */
|
||||||
|
|
||||||
@@ -310,14 +297,14 @@ static void update_geometry(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redraw_curve(void)
|
static void redraw_spiral_labels(void)
|
||||||
{ GdkWindow *d = gtk_widget_get_window(Closure->readLinearDrawingArea);
|
{ GdkWindow *d = gtk_widget_get_window(Closure->readLinearSpiral->widget);
|
||||||
int x,w,h;
|
int x,w,h;
|
||||||
int pos = 1;
|
int pos = 1;
|
||||||
|
|
||||||
/* Draw and label the spiral */
|
/* Draw and label the spiral */
|
||||||
|
|
||||||
x = Closure->readLinearCurve->rightX + 20;
|
x = 10;
|
||||||
gdk_gc_set_rgb_fg_color(Closure->drawGC, Closure->curveColor);
|
gdk_gc_set_rgb_fg_color(Closure->drawGC, Closure->curveColor);
|
||||||
GuiSetText(Closure->readLinearCurve->layout, _("Medium state"), &w, &h);
|
GuiSetText(Closure->readLinearCurve->layout, _("Medium state"), &w, &h);
|
||||||
gdk_draw_layout(d, Closure->drawGC,
|
gdk_draw_layout(d, Closure->drawGC,
|
||||||
@@ -344,26 +331,37 @@ static void redraw_curve(void)
|
|||||||
_("Unreadable / skipped"), Closure->redSector, x, pos++);
|
_("Unreadable / skipped"), Closure->redSector, x, pos++);
|
||||||
|
|
||||||
GuiDrawSpiral(Closure->readLinearSpiral);
|
GuiDrawSpiral(Closure->readLinearSpiral);
|
||||||
|
|
||||||
/* Redraw the curve */
|
|
||||||
|
|
||||||
GuiRedrawAxes(Closure->readLinearCurve);
|
|
||||||
GuiRedrawCurve(Closure->readLinearCurve, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
static gboolean expose_curve_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||||
{
|
{
|
||||||
GuiSetSpiralWidget(Closure->readLinearSpiral, widget);
|
|
||||||
|
|
||||||
if(event->count) /* Exposure compression */
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
update_geometry();
|
update_geometry();
|
||||||
redraw_curve();
|
redraw_curve();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean expose_spiral_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||||
|
{ GtkAllocation a = {0};
|
||||||
|
gtk_widget_get_allocation(widget, &a);
|
||||||
|
|
||||||
|
GuiSetSpiralWidget(Closure->readLinearSpiral, widget);
|
||||||
|
|
||||||
|
/* Override spiral center */
|
||||||
|
Closure->readLinearSpiral->mx = a.width - 15 - Closure->readLinearSpiral->diameter / 2;
|
||||||
|
if(Closure->crcBuf && Closure->crcBuf->crcCached)
|
||||||
|
{ int w,h;
|
||||||
|
|
||||||
|
GuiSetText(Closure->readLinearCurve->layout, _("Sectors with CRC errors"), &w, &h);
|
||||||
|
|
||||||
|
Closure->readLinearSpiral->my = a.height/2 - h;
|
||||||
|
}
|
||||||
|
|
||||||
|
redraw_spiral_labels();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*** Reset the notebook contents for new scan/read action
|
*** Reset the notebook contents for new scan/read action
|
||||||
***/
|
***/
|
||||||
@@ -391,7 +389,7 @@ static gboolean redraw_idle_func(gpointer data)
|
|||||||
|
|
||||||
/* Trigger an expose event for the drawing area. */
|
/* Trigger an expose event for the drawing area. */
|
||||||
|
|
||||||
window = gtk_widget_get_parent_window(Closure->readLinearDrawingArea);
|
window = gtk_widget_get_parent_window(Closure->readLinearCurveArea);
|
||||||
if(window)
|
if(window)
|
||||||
{ gdk_window_get_geometry(window, &rect.x, &rect.y, &rect.width, &rect.height, &ignore);
|
{ gdk_window_get_geometry(window, &rect.x, &rect.y, &rect.width, &rect.height, &ignore);
|
||||||
|
|
||||||
@@ -411,7 +409,7 @@ void GuiRedrawReadLinearWindow(void)
|
|||||||
***/
|
***/
|
||||||
|
|
||||||
void GuiCreateLinearReadWindow(GtkWidget *parent)
|
void GuiCreateLinearReadWindow(GtkWidget *parent)
|
||||||
{ GtkWidget *sep,*ignore,*d_area,*notebook,*hbox;
|
{ GtkWidget *sep,*ignore,*curve,*spiral,*notebook,*hbox;
|
||||||
|
|
||||||
Closure->readLinearHeadline = gtk_label_new(NULL);
|
Closure->readLinearHeadline = gtk_label_new(NULL);
|
||||||
gtk_misc_set_alignment(GTK_MISC(Closure->readLinearHeadline), 0.0, 0.0);
|
gtk_misc_set_alignment(GTK_MISC(Closure->readLinearHeadline), 0.0, 0.0);
|
||||||
@@ -425,9 +423,18 @@ void GuiCreateLinearReadWindow(GtkWidget *parent)
|
|||||||
sep = gtk_hseparator_new();
|
sep = gtk_hseparator_new();
|
||||||
gtk_box_pack_start(GTK_BOX(parent), sep, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(parent), sep, FALSE, FALSE, 0);
|
||||||
|
|
||||||
d_area = Closure->readLinearDrawingArea = gtk_drawing_area_new();
|
hbox = gtk_hbox_new(FALSE, 0);
|
||||||
gtk_box_pack_start(GTK_BOX(parent), d_area, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(parent), hbox, TRUE, TRUE, 0);
|
||||||
g_signal_connect(G_OBJECT(d_area), "expose_event", G_CALLBACK(expose_cb), NULL);
|
|
||||||
|
curve = Closure->readLinearCurveArea = gtk_drawing_area_new();
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), curve, TRUE, TRUE, 0);
|
||||||
|
g_signal_connect(G_OBJECT(curve), "expose_event", G_CALLBACK(expose_curve_cb), NULL);
|
||||||
|
|
||||||
|
Closure->readLinearSpiral = GuiCreateSpiral(Closure->grid, Closure->background, 10, 5, 1000);
|
||||||
|
spiral = gtk_drawing_area_new();
|
||||||
|
gtk_widget_set_size_request(spiral, Closure->readLinearSpiral->diameter + 20, -1);
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), spiral, FALSE, FALSE, 0);
|
||||||
|
g_signal_connect(G_OBJECT(spiral), "expose_event", G_CALLBACK(expose_spiral_cb), NULL);
|
||||||
|
|
||||||
notebook = Closure->readLinearNotebook = gtk_notebook_new();
|
notebook = Closure->readLinearNotebook = gtk_notebook_new();
|
||||||
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
|
||||||
@@ -452,8 +459,7 @@ void GuiCreateLinearReadWindow(GtkWidget *parent)
|
|||||||
ignore = gtk_label_new("footer_tab");
|
ignore = gtk_label_new("footer_tab");
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), Closure->readLinearFootline, ignore);
|
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), Closure->readLinearFootline, ignore);
|
||||||
|
|
||||||
Closure->readLinearCurve = GuiCreateCurve(d_area, _("Speed"), "%dx", 1000, CURVE_MEGABYTES);
|
Closure->readLinearCurve = GuiCreateCurve(curve, _("Speed"), "%dx", 1000, CURVE_MEGABYTES);
|
||||||
Closure->readLinearCurve->leftLogLabel = g_strdup(_("C2 errors"));
|
Closure->readLinearCurve->leftLogLabel = g_strdup(_("C2 errors"));
|
||||||
Closure->readLinearSpiral = GuiCreateSpiral(Closure->grid, Closure->background, 10, 5, 1000);
|
|
||||||
}
|
}
|
||||||
#endif /* WITH_GUI_YES */
|
#endif /* WITH_GUI_YES */
|
||||||
|
|||||||
Reference in New Issue
Block a user