Commit f78a435e authored by Christoffer Ackelman's avatar Christoffer Ackelman

Refactored GlowDraw: Combined similar drawing methods.

Instead of calling ctx->redraw() to redraw the window, call ctx->set_dirty().
The GlowCtx will redraw the window at the end of the event_handler if any event has marked it as dirty.
If you really need to redraw the window NOW (ex. after a timer triggered event),
call ctx->set_dirty followed by ctx->redraw_if_dirty().
parent 90bde1fd
......@@ -80,9 +80,6 @@ int main(int argc, char* argv[])
setlocale(LC_TIME, "en_US");
toplevel = new QWidget();
toplevel->setMinimumSize(100, 100);
toplevel->setWindowTitle("Pwr wb_ge");
toplevel->setAttribute(Qt::WA_DeleteOnClose);
// Create help window
CoXHelpQt* xhelp = new CoXHelpQt(0, xhelp_eUtility_Wtt, &sts);
......@@ -129,8 +126,6 @@ int main(int argc, char* argv[])
}
fprintf(stderr, "\n");
toplevel->show();
new wb_log_qt(toplevel);
// Create message window
......@@ -139,4 +134,4 @@ int main(int argc, char* argv[])
MsgWindow::set_default(msg_window);
return app.exec();
}
\ No newline at end of file
}
......@@ -2039,8 +2039,6 @@ static int attrnav_brow_cb(FlowCtx* ctx, flow_tEvent event)
grow_OrderGroupObject(
parent_item->id, sel_item->id, dest_item->id, glow_eDest_Before);
}
grow_DrawObject(sel_item->id);
grow_DrawObject(dest_item->id);
attrnav->refresh_objects(attr_mRefresh_Objects);
break;
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -249,7 +249,7 @@ void QtScrollWidgetGlow::handleEvent(QEvent* event)
GlowCtx* ctx = (GlowCtx*)parent_ctx;
GlowDrawQt* drawer = ((GlowDrawQt*)ctx->gdraw);
if (event->type() == QEvent::MouseMove) {
drawer->m_wind->window->update();
drawer->m_wind.window->update();
}
drawer->event_handler(event, this);
}
......
......@@ -133,7 +133,7 @@ void glow_measure_annot_text(GrowCtx* ctx, char* text, glow_eDrawType draw_type,
case glow_eAnnotType_OneLine:
ctx->gdraw->get_text_extent(text, strlen(text), draw_type, text_size, font,
&z_width, &z_height, &z_descent,
ctx->mw.zoom_factor_y / ctx->mw.base_zoom_factor * (8 + 2 * text_size),
ctx->mw->zoom_factor_y / ctx->mw->base_zoom_factor * (8 + 2 * text_size),
0);
*rows = 1;
break;
......@@ -148,8 +148,8 @@ void glow_measure_annot_text(GrowCtx* ctx, char* text, glow_eDrawType draw_type,
if (*s == 10) {
if (len) {
ctx->gdraw->get_text_extent(line, len, draw_type, text_size, font,
&l_width, &l_height, &l_descent, ctx->mw.zoom_factor_y
/ ctx->mw.base_zoom_factor * (8 + 2 * text_size),
&l_width, &l_height, &l_descent, ctx->mw->zoom_factor_y
/ ctx->mw->base_zoom_factor * (8 + 2 * text_size),
0);
z_width = MAX(z_width, l_width);
}
......@@ -161,8 +161,8 @@ void glow_measure_annot_text(GrowCtx* ctx, char* text, glow_eDrawType draw_type,
}
if (len) {
ctx->gdraw->get_text_extent(line, len, draw_type, text_size, font,
&l_width, &l_height, &l_descent, ctx->mw.zoom_factor_y
/ ctx->mw.base_zoom_factor * (8 + 2 * text_size),
&l_width, &l_height, &l_descent, ctx->mw->zoom_factor_y
/ ctx->mw->base_zoom_factor * (8 + 2 * text_size),
0);
z_width = MAX(z_width, l_width);
line_cnt++;
......@@ -172,6 +172,6 @@ void glow_measure_annot_text(GrowCtx* ctx, char* text, glow_eDrawType draw_type,
break;
}
}
*width = 1.0 * z_width / ctx->mw.base_zoom_factor;
*height = 1.0 * z_height / ctx->mw.base_zoom_factor;
*width = 1.0 * z_width / ctx->mw->base_zoom_factor;
*height = 1.0 * z_height / ctx->mw->base_zoom_factor;
}
......@@ -52,10 +52,6 @@ public:
font(glow_eFont_Helvetica), protect(0){}
void save(std::ofstream& fp, glow_eSaveMode mode);
void open(std::ifstream& fp);
void traverse(int x, int y)
{
p.traverse(x, y);
}
GrowCtx* ctx;
int number;
......
This diff is collapsed.
......@@ -93,8 +93,6 @@ public:
//! Adjust pixel coordinates for navigaion window to current zoom factor.
void nav_zoom();
void traverse(int x, int y); //!< Not used.
//! Event handler
/*!
\param pos Position of object. Should be zero.
......@@ -106,8 +104,7 @@ public:
Detects if the object is hit by the event.
*/
int event_handler(
GlowWind* w, void* pos, glow_eEvent event, int x, int y, void* node);
int event_handler(void* pos, glow_eEvent event, int x, int y, void* node);
//! Not implemented
void conpoint_select(void* pos, int x, int y, double* distance, void** cp){}
......@@ -134,7 +131,7 @@ public:
Draw the object, without borders or shadow.
*/
void draw(GlowWind* w, void* pos, int highlight, int hot, void* node);
void draw(DrawWind *w, void* pos, int highlight, int hot, void* node);
//! Draw border and shadow of the arc.
/*!
......@@ -147,7 +144,7 @@ public:
linewidth 1 pixel.
The shadow also always has linewith 1 pixel.
*/
void draw_shadow(GlowWind* w, int border, int shadow, int highlight, int hot);
void draw_shadow(DrawWind *w, int border, int shadow, int highlight, int hot);
//! Erase the object.
/*!
......@@ -155,7 +152,7 @@ public:
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase(GlowWind* w, void* pos, int hot, void* node);
void erase(DrawWind *w, void* pos, int hot, void* node);
//! Calculate the border for a set of objects or for a parent node.
/*!
......
This diff is collapsed.
......@@ -148,31 +148,23 @@ public:
void print(void* pos, void* node);
void save(std::ofstream& fp, glow_eSaveMode mode);
void open(GrowCtx* ctx, std::ifstream& fp);
void draw(GlowWind* w, void* pos, int highlight, int hot, void* node);
void erase(GlowWind* w, void* pos, int hot, void* node);
void draw(GlowWind* w, GlowTransform* t, int highlight, int hot, void* node,
void draw(DrawWind *w, void* pos, int highlight, int hot, void* node);
void erase(DrawWind *w, void* pos, int hot, void* node);
void draw(DrawWind *w, GlowTransform* t, int highlight, int hot, void* node,
void* colornode);
void erase(GlowWind* w, GlowTransform* t, int hot, void* node);
void erase(DrawWind *w, GlowTransform* t, int hot, void* node);
void draw_inverse(void* pos, int hot, void* node);
void nav_draw(void* pos, int highlight, void* node);
void nav_draw(GlowTransform* t, int highlight, void* node, void* colornode);
void nav_erase(void* pos, void* node);
void nav_erase(GlowTransform* t, void* node);
void traverse(int x, int y);
void get_borders(
double* x_right, double* x_left, double* y_high, double* y_low);
void get_borders(double pos_x, double pos_y, double* x_right, double* x_left,
double* y_high, double* y_low, void* node);
void get_borders(GlowTransform* t, double* x_right, double* x_left,
double* y_high, double* y_low);
int event_handler(GlowWind* w, glow_eEvent event, int x, int y);
int event_handler(
GlowWind* w, glow_eEvent event, int x, int y, double fx, double fy);
int event_handler(GlowWind* w, glow_eEvent event, double fx, double fy);
int event_handler(
GlowWind* w, void* pos, glow_eEvent event, int x, int y, void* node);
int event_handler(
GlowWind* w, void* pos, glow_eEvent event, int x, int y, int num);
int event_handler(glow_eEvent event, int x, int y);
int event_handler(glow_eEvent event, int x, int y, double fx, double fy);
int event_handler(glow_eEvent event, double fx, double fy);
int event_handler(void* pos, glow_eEvent event, int x, int y, void* node);
int event_handler(void* pos, glow_eEvent event, int x, int y, int num);
void conpoint_select(void* pos, int x, int y, double* distance, void** cp);
void conpoint_select(GlowTransform* t, int x, int y, double* distance,
void** cp, int* pix_x, int* pix_y);
......
......@@ -45,7 +45,7 @@
/*! \addtogroup Glow */
/*@{*/
class GlowWind;
class DrawWind;
class GlowExportFlow;
//! Base class for all drawing objects and components.
......@@ -74,29 +74,27 @@ public:
virtual void zoom(){}
virtual void nav_zoom(){}
virtual void print_zoom(){}
virtual void traverse(int x, int y){}
virtual void get_borders(
double* x_right, double* x_left, double* y_high, double* y_low){}
virtual void get_borders(GlowTransform* t, double* x_right, double* x_left,
double* y_high, double* y_low){}
virtual void get_borders(double pos_x, double pos_y, double* x_right,
double* x_left, double* y_high, double* y_low, void* node){}
virtual int event_handler(GlowWind* w, glow_eEvent event, int x, int y)
virtual int event_handler(glow_eEvent event, int x, int y)
{
return 0;
}
virtual int event_handler(
GlowWind* w, glow_eEvent event, int x, int y, double fx, double fy)
virtual int event_handler(glow_eEvent event, int x, int y, double fx,
double fy)
{
return 0;
}
virtual int event_handler(
GlowWind* w, glow_eEvent event, double fx, double fy)
virtual int event_handler(glow_eEvent event, double fx, double fy)
{
return 0;
}
virtual int event_handler(
GlowWind* w, void* pos, glow_eEvent event, int x, int y, void* node)
virtual int event_handler(void* pos, glow_eEvent event, int x, int y,
void* node)
{
return 0;
}
......@@ -105,28 +103,19 @@ public:
virtual void open(std::ifstream& fp){}
virtual void print(void* pos, void* node){}
virtual void draw(){}
virtual void draw(GlowWind* w, int ll_x, int ll_y, int ur_x, int ur_y){}
virtual void draw(GlowWind* w, int* ll_x, int* ll_y, int* ur_x, int* ur_y){}
virtual void draw(
GlowWind* w, void* pos, int highlight, int hot, void* node){}
virtual void draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
virtual void draw(DrawWind *w, int ll_x, int ll_y, int ur_x, int ur_y){}
virtual void draw(DrawWind *w, int* ll_x, int* ll_y, int* ur_x, int* ur_y){}
virtual void draw(DrawWind *w, void* pos, int highlight, int hot, void* node){}
virtual void draw(DrawWind *w, GlowTransform* t, int highlight, int hot,
void* node, void* colornode){}
virtual void erase(){}
virtual void erase(GlowWind* w, void* pos, int hot, void* node){}
virtual void erase(GlowWind* w, GlowTransform* t, int hot, void* node){}
virtual void erase(DrawWind *w, void* pos, int hot, void* node){}
virtual void erase(DrawWind *w, GlowTransform* t, int hot, void* node){}
virtual void draw_inverse(void* pos, int hot, void* node){}
virtual void move(double delta_x, double delta_y, int grid){}
virtual void move_noerase(int delta_x, int delta_y, int grid){}
virtual void shift(
void* pos, double delta_x, double delta_y, int highlight, int hot){}
virtual void nav_draw(int ll_x, int ll_y, int ur_x, int ur_y){}
virtual void nav_draw(int* ll_x, int* ll_y, int* ur_x, int* ur_y){}
virtual void nav_draw(void* pos, int highlight, void* node){}
virtual void nav_draw(
GlowTransform* t, int highlight, void* node, void* colornode){}
virtual void nav_erase(){}
virtual void nav_erase(void* pos, void* node){}
virtual void nav_erase(GlowTransform* t, void* node){}
virtual void conpoint_select(
void* pos, int x, int y, double* distance, void** cp){}
virtual void conpoint_select(GlowTransform* t, int x, int y, double* distance,
......
......@@ -160,12 +160,10 @@ void GlowArrow::open(std::ifstream& fp)
}
}
void GlowArrow::draw(GlowWind* w, void* pos, int highlight, int hot, void* node)
void GlowArrow::draw(DrawWind *w, void* pos, int highlight, int hot, void* node)
{
int p1_x, p1_y, p2_x, p2_y, p_dest_x, p_dest_y;
if (w == &ctx->navw) {
if (ctx->no_nav)
return;
if (w == ctx->navw) {
hot = 0;
p1_x = p1.nav_z_x;
p1_y = p1.nav_z_y;
......@@ -185,7 +183,7 @@ void GlowArrow::draw(GlowWind* w, void* pos, int highlight, int hot, void* node)
idx += hot;
idx = MAX(0, idx);
idx = MIN(idx, DRAW_TYPE_SIZE - 1);
ctx->gdraw->arrow(w, p_dest_x + ((GlowPoint*)pos)->z_x - w->offset_x,
ctx->gdraw->arrow(p_dest_x + ((GlowPoint*)pos)->z_x - w->offset_x,
p_dest_y + ((GlowPoint*)pos)->z_y - w->offset_y,
p1_x + ((GlowPoint*)pos)->z_x - w->offset_x,
p1_y + ((GlowPoint*)pos)->z_y - w->offset_y,
......@@ -193,12 +191,10 @@ void GlowArrow::draw(GlowWind* w, void* pos, int highlight, int hot, void* node)
p2_y + ((GlowPoint*)pos)->z_y - w->offset_y, draw_type, idx, highlight);
}
void GlowArrow::erase(GlowWind* w, void* pos, int hot, void* node)
void GlowArrow::erase(DrawWind *w, void* pos, int hot, void* node)
{
int p1_x, p1_y, p2_x, p2_y, p_dest_x, p_dest_y;
if (w == &ctx->navw) {
if (ctx->no_nav)
return;
if (w == ctx->navw) {
hot = 0;
p1_x = p1.nav_z_x;
p1_y = p1.nav_z_y;
......@@ -218,30 +214,25 @@ void GlowArrow::erase(GlowWind* w, void* pos, int hot, void* node)
idx += hot;
idx = MAX(0, idx);
idx = MIN(idx, DRAW_TYPE_SIZE - 1);
ctx->gdraw->arrow_erase(w, p_dest_x + ((GlowPoint*)pos)->z_x - w->offset_x,
ctx->gdraw->arrow(p_dest_x + ((GlowPoint*)pos)->z_x - w->offset_x,
p_dest_y + ((GlowPoint*)pos)->z_y - w->offset_y,
p1_x + ((GlowPoint*)pos)->z_x - w->offset_x,
p1_y + ((GlowPoint*)pos)->z_y - w->offset_y,
p2_x + ((GlowPoint*)pos)->z_x - w->offset_x,
p2_y + ((GlowPoint*)pos)->z_y - w->offset_y, idx);
p2_y + ((GlowPoint*)pos)->z_y - w->offset_y, glow_eDrawType_LineErase, idx);
}
void GlowArrow::move(void* pos, double x1, double y1, double x2, double y2,
int highlight, int hot)
{
erase(&ctx->mw, pos, hot, NULL);
erase(&ctx->navw, pos, 0, NULL);
if (fabs(x2 - x1) < DBL_EPSILON) {
p1.x = x2 + arrow_width / 2;
p2.x = x2 - arrow_width / 2;
if (y1 > y2) {
p1.x = x2 + arrow_width / 2;
p1.y = y2 + arrow_length;
p2.x = x2 - arrow_width / 2;
p2.y = y2 + arrow_length;
} else {
p1.x = x2 + arrow_width / 2;
p1.y = y2 - arrow_length;
p2.x = x2 - arrow_width / 2;
p2.y = y2 - arrow_length;
}
} else if (fabs(y2 - y1) < DBL_EPSILON) {
......@@ -267,15 +258,13 @@ void GlowArrow::move(void* pos, double x1, double y1, double x2, double y2,
p_dest.y = y2;
zoom();
nav_zoom();
draw(&ctx->mw, pos, highlight, hot, NULL);
draw(&ctx->navw, pos, highlight, 0, NULL);
ctx->set_dirty();
}
void GlowArrow::shift(
void* pos, double delta_x, double delta_y, int highlight, int hot)
{
erase(&ctx->mw, pos, hot, NULL);
erase(&ctx->navw, pos, 0, NULL);
p_dest.x += delta_x;
p_dest.y += delta_y;
p1.x += delta_x;
......@@ -285,12 +274,11 @@ void GlowArrow::shift(
zoom();
nav_zoom();
draw(&ctx->mw, pos, highlight, hot, NULL);
draw(&ctx->navw, pos, highlight, 0, NULL);
ctx->set_dirty();
}
int GlowArrow::event_handler(
GlowWind* w, void* pos, glow_eEvent event, int x, int y, void* node)
void* pos, glow_eEvent event, int x, int y, void* node)
{
return 0;
}
......@@ -81,8 +81,7 @@ public:
Detects if the object is hit by the event.
*/
int event_handler(
GlowWind* w, void* pos, glow_eEvent event, int x, int y, void* node);
int event_handler(void* pos, glow_eEvent event, int x, int y, void* node);
//! Not implemented
void conpoint_select(void* pos, int x, int y, double* distance, void** cp){}
......@@ -109,7 +108,7 @@ public:
Draw the object, without borders or shadow.
*/
void draw(GlowWind* w, void* pos, int highlight, int hot, void* node);
void draw(DrawWind *w, void* pos, int highlight, int hot, void* node);
//! Erase the object.
/*!
......@@ -117,7 +116,7 @@ public:
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase(GlowWind* w, void* pos, int hot, void* node);
void erase(DrawWind *w, void* pos, int hot, void* node);
//! Calculate the border for a set of objects or for a parent node.
/*!
......
......@@ -77,7 +77,7 @@ void BrowCtx::configure()
a.configure();
get_borders();
frame_x_right
= MAX(x_right, 1.0 * (mw.window_width + mw.offset_x) / mw.zoom_factor_x);
= MAX(x_right, 1.0 * (mw->window_width + mw->offset_x) / mw->zoom_factor_x);
a.zoom();
change_scrollbar();
}
......@@ -93,56 +93,53 @@ void BrowCtx::change_scrollbar()
if (a.size() == 0)
return;
((GlowNode*)a[0])->measure(&ll_x, &ll_y, &ur_x, &ur_y);
scroll_size = ur_y - ll_y + 1.0 / mw.zoom_factor_y;
scroll_size = ur_y - ll_y + 1.0 / mw->zoom_factor_y;
}
data.scroll_data = scroll_data;
data.total_width = int((x_right - x_left) / scroll_size);
data.total_height = int((y_high - y_low) / scroll_size);
data.window_width = int(mw.window_width / scroll_size / mw.zoom_factor_x);
data.window_width = int(mw->window_width / scroll_size / mw->zoom_factor_x);
data.window_height
= int(mw.window_height / scroll_size / mw.zoom_factor_y + 1);
= int(mw->window_height / scroll_size / mw->zoom_factor_y + 1);
data.offset_x = int(
mw.offset_x / scroll_size / mw.zoom_factor_x - x_left / scroll_size);
mw->offset_x / scroll_size / mw->zoom_factor_x - x_left / scroll_size);
data.offset_y
= int(mw.offset_y / scroll_size / mw.zoom_factor_y - y_low / scroll_size);
= int(mw->offset_y / scroll_size / mw->zoom_factor_y - y_low / scroll_size);
(scroll_callback)(&data);
}
void BrowCtx::redraw()
{
clear(&mw);
draw(&mw, 0, 0, mw.window_width, mw.window_height);
nav_zoom();
}
void BrowCtx::zoom(double factor)
{
if (fabs(factor) < DBL_EPSILON)
return;
mw.zoom_factor_x *= factor;
mw.zoom_factor_y *= factor;
if (mw.offset_x != 0)
mw.offset_x = int(
(mw.offset_x - mw.window_width / 2.0 * (1.0 / factor - 1)) * factor);
if (mw.offset_y != 0)
mw.offset_y = int(
(mw.offset_y - mw.window_height / 2.0 * (1.0 / factor - 1)) * factor);
mw.offset_x = MAX(mw.offset_x, 0);
mw.offset_y = MAX(mw.offset_y, 0);
if ((x_right - x_left) * mw.zoom_factor_x <= mw.window_width)
mw.offset_x = 0;
if ((y_high - y_low) * mw.zoom_factor_y <= mw.window_height)
mw.offset_y = 0;
mw->zoom_factor_x *= factor;
mw->zoom_factor_y *= factor;
if (mw->offset_x != 0)
mw->offset_x = int(
(mw->offset_x - mw->window_width / 2.0 * (1.0 / factor - 1)) * factor);
if (mw->offset_y != 0)
mw->offset_y = int(
(mw->offset_y - mw->window_height / 2.0 * (1.0 / factor - 1)) * factor);
mw->offset_x = MAX(mw->offset_x, 0);
mw->offset_y = MAX(mw->offset_y, 0);
if ((x_right - x_left) * mw->zoom_factor_x <= mw->window_width)
mw->offset_x = 0;
if ((y_high - y_low) * mw->zoom_factor_y <= mw->window_height)
mw->offset_y = 0;
a.zoom();
clear(&mw);
draw(&mw, 0, 0, mw.window_width, mw.window_height);
set_dirty();
nav_zoom();
change_scrollbar();
}
void BrowCtx::unzoom()
{
zoom(mw->base_zoom_factor / mw->zoom_factor_y);
}
void BrowCtx::print(char* filename)
{
int i;
......@@ -176,8 +173,8 @@ int BrowCtx::is_visible(GlowArrayElem* element)
double window_low, window_high;
((GlowNode*)element)->measure(&ll_x, &ll_y, &ur_x, &ur_y);
window_low = double(mw.offset_y) / mw.zoom_factor_y;
window_high = double(mw.offset_y + mw.window_height) / mw.zoom_factor_y;
window_low = double(mw->offset_y) / mw->zoom_factor_y;
window_high = double(mw->offset_y + mw->window_height) / mw->zoom_factor_y;
if (ll_y >= window_low && ur_y <= window_high)
return 1;
else
......@@ -191,11 +188,11 @@ void BrowCtx::center_object(GlowArrayElem* object, double factor)
int y_pix;
((GlowNode*)object)->measure(&ll_x, &ll_y, &ur_x, &ur_y);
new_offset_y = int(ll_y * mw.zoom_factor_y - factor * mw.window_height);
new_offset_y = int(ll_y * mw->zoom_factor_y - factor * mw->window_height);
if (new_offset_y <= 0)
y_pix = mw.offset_y;
y_pix = mw->offset_y;
else
y_pix = -(new_offset_y - mw.offset_y);
y_pix = -(new_offset_y - mw->offset_y);
scroll(0, y_pix);
change_scrollbar();
}
......@@ -204,8 +201,8 @@ void brow_scroll_horizontal(BrowCtx* ctx, int value, int bottom)
{
int x_pix;
x_pix = int(-value * ctx->scroll_size * ctx->mw.zoom_factor_x
+ (ctx->mw.offset_x - ctx->x_left * ctx->mw.zoom_factor_x));
x_pix = int(-value * ctx->scroll_size * ctx->mw->zoom_factor_x
+ (ctx->mw->offset_x - ctx->x_left * ctx->mw->zoom_factor_x));
ctx->scroll(x_pix, 0);
}
......@@ -213,15 +210,15 @@ void brow_scroll_vertical(BrowCtx* ctx, int value, int bottom)
{
int y_pix;
y_pix = int(-value * ctx->scroll_size * ctx->mw.zoom_factor_y
+ (ctx->mw.offset_y - ctx->y_low * ctx->mw.zoom_factor_y));
y_pix = int(-value * ctx->scroll_size * ctx->mw->zoom_factor_y
+ (ctx->mw->offset_y - ctx->y_low * ctx->mw->zoom_factor_y));
// Correction for the bottom position
if (bottom
&& (y_pix >= 0
|| ctx->mw.window_height + y_pix
< ctx->y_high * ctx->mw.zoom_factor_y - ctx->mw.offset_y))
// mw.window_height >= (y_high - y_low) * mw.zoom_factor_y)
y_pix = int(ctx->mw.window_height + ctx->mw.offset_y
- ctx->y_high * ctx->mw.zoom_factor_y);
|| ctx->mw->window_height + y_pix
< ctx->y_high * ctx->mw->zoom_factor_y - ctx->mw->offset_y))
// mw->window_height >= (y_high - y_low) * mw->zoom_factor_y)
y_pix = int(ctx->mw->window_height + ctx->mw->offset_y
- ctx->y_high * ctx->mw->zoom_factor_y);
ctx->scroll(0, y_pix);
}
......@@ -56,12 +56,8 @@ public:
void remove(GlowArrayElem* element);
void configure();
void change_scrollbar();
void redraw();
void zoom(double factor);
void unzoom()
{
zoom(mw.base_zoom_factor / mw.zoom_factor_y);
}
void unzoom();
void print(char* filename);
int get_first(GlowArrayElem** first)
{
......@@ -90,7 +86,4 @@ public:
double annotation_space;
};
// void brow_scroll_horizontal( BrowCtx *ctx, int value, int bottom);
// void brow_scroll_vertical( BrowCtx *ctx, int value, int bottom);
#endif
This diff is collapsed.
......@@ -93,19 +93,11 @@ public:
//! Update the layout of the scrollbars.
void change_scrollbar();
//! Redraw the window.
/*! Redraw all objects in the window.
*/
void redraw();
//! Adjust the pixel coordinates to the current zoomfactor.
void zoom(double factor);
//! Reset to base zoomfactor.
void unzoom()
{
zoom(mw.base_zoom_factor / mw.zoom_factor_y);
}
void unzoom();
//! Not used.
void print(char* filename);
......
This diff is collapsed.
......@@ -116,11 +116,10 @@ public:
void get_borders(
double* x1_right, double* x1_left, double* y1_high, double* y1_low){}
void get_con_borders();
int event_handler(GlowWind* w, glow_eEvent event, int x, int y);
int event_handler(
GlowWind* w, glow_eEvent event, int x, int y, double fx, double fy)
int event_handler(glow_eEvent event, int x, int y);
int event_handler(glow_eEvent event, int x, int y, double fx, double fy)
{
return event_handler(w, event, x, y);
return event_handler(event, x, y);
}
//! Save the content of the object to file.
......@@ -135,9 +134,8 @@ public:
\param fp Input file.
*/
void open(std::ifstream& fp);
void draw(GlowWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
void draw(GlowWind* w, int* ll_x, int* ll_y, int* ur_x, int* ur_y);
void draw();
void draw(DrawWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
void draw(DrawWind* w, int* ll_x, int* ll_y, int* ur_x, int* ur_y);
void erase(){}
void move(double delta_x, double delta_y, int grid);
void move_noerase(int delta_x, int delta_y, int move);
......
......@@ -76,7 +76,6 @@ public:
void zoom(){}
void nav_zoom(){}
void print_zoom(){}
void traverse(int x, int y){}
void get_borders(double pos_x, double pos_y, double* x_right, double* x_left,
double* y_high, double* y_low, void* node){}
int event_handler(void* pos, glow_eEvent event, int x, int y, void* node)
......@@ -98,7 +97,6 @@ public:
*/
void open(std::ifstream& fp);
void draw(GlowPoint* pos, int highlight, int hot, void* node){}
void nav_draw(GlowPoint* pos, int highlight, void* node){}
void erase(GlowPoint* pos, int hot, void* node){}
void nav_erase(GlowPoint* pos, void* node){}
......
......@@ -132,11 +132,6 @@ void GlowConPoint::open(std::ifstream& fp)
}
}
void GlowConPoint::traverse(int x, int y)
{
p.traverse(x, y);
}
int GlowConPoint::event_handler(
void* pos, glow_eEvent event, int x, int y, void* node)
{
......@@ -146,13 +141,10 @@ int GlowConPoint::event_handler(
void GlowConPoint::conpoint_select(
void* pos, int x, int y, double* distance, void** cp)
{
int px, py;
double dist;
int px = ((GlowPoint*)pos)->z_x - ctx->mw->offset_x + p.z_x;
int py = ((GlowPoint*)pos)->z_y - ctx->mw->offset_y + p.z_y;
px = ((GlowPoint*)pos)->z_x - ctx->mw.offset_x + p.z_x;
py = ((GlowPoint*)pos)->z_y - ctx->mw.offset_y + p.z_y;
dist = sqrt(1.0 * (x - px) * (x - px) + 1.0 * (y - py) * (y - py));
double dist = sqrt(1.0 * (x - px) * (x - px) + 1.0 * (y - py) * (y - py));
if (dist < *distance) {
*distance = dist;
*cp = (void*)this;
......@@ -162,16 +154,10 @@ void GlowConPoint::conpoint_select(
void GlowConPoint::conpoint_select(GlowTransform* t, int x, int y,
double* distance, void** cp, int* pix_x, int* pix_y)
{
int px, py;
double dist;
double x1, y1;
x1 = trf.x(t, p.x, p.y);
y1 = trf.y(t, p.x, p.y);
px = int(x1 * ctx->mw.zoom_factor_x - ctx->mw.offset_x);
py = int(y1 * ctx->mw.zoom_factor_y - ctx->mw.offset_y);
int px = int(trf.x(t, p.x, p.y) * ctx->mw->zoom_factor_x - ctx->mw->offset_x);
int py = int(trf.y(t, p.x, p.y) * ctx->mw->zoom_factor_y - ctx->mw->offset_y);
dist = sqrt(1.0 * (x - px) * (x - px) + 1.0 * (y - py) * (y - py));
double dist = sqrt(1.0 * (x - px) * (x - px) + 1.0 * (y - py) * (y - py));
if (dist < *distance) {
*distance = dist;
*cp = (void*)this;
......
......@@ -47,7 +47,6 @@ public:
void zoom();
void nav_zoom();
void print_zoom();
void traverse(int x, int y);
int event_handler(void* pos, glow_eEvent event, int x, int y, void* node);
void conpoint_select(void* pos, int x, int y, double* distance, void** cp);
void conpoint_select(GlowTransform* t, int x, int y, double* distance,
......
This diff is collapsed.
......@@ -57,53 +57,6 @@ public:
char text[100][200];
};
//! Main or navigation window
class GlowWind {
public:
DrawWind* window; //!< Window context.
double zoom_factor_x; //!< Zoom factor in x direction.
double zoom_factor_y; //!< Zoom factor in y direction.
double base_zoom_factor; //!< Original zoom factor.
int offset_x; //!< Offset in pixel between origo and displayed window in x
//! direction.
int offset_y; //!< Offset in pixel between origo and displayde window in y
//! direction.
int window_width; //!< Window width in pixel.
int window_height; //!< Window height in pixel.
int subwindow_x; //!< Subwindow x coordinate in pixel.
int subwindow_y; //!< Subwindow y coordinate in pixel.
double subwindow_scale; //!< Subwindow scale.
int defered_x_low; //!< Left border of defered redrawing area.
int defered_x_high; //!< Right border of defered redrawing area.
int defered_y_low; //!< Low border of defered redrawing area.
int defered_y_high; //!< High border of defered redrawing area.
GlowWind(double zoom_fact_x, double zoom_fact_y, double base_zoom_fact,
int offs_x, int offs_y)
: window(0), zoom_factor_x(zoom_fact_x), zoom_factor_y(zoom_fact_y),
base_zoom_factor(base_zoom_fact), offset_x(offs_x), offset_y(offs_y),
window_width(0), window_height(0), subwindow_x(0), subwindow_y(0),
subwindow_scale(1)
{
}
//! Draw in the double buffering buffer only.
/*! Increase the draw_buffer_only count. As long as this is > 0, no drawing is
* made to the screen, only in the buffer. */
void set_draw_buffer_only();
//! Reset draw in the double buffering buffer only.
/*! Decrease the draw_buffer_only count. As long as this is > 0, no drawing is
* made to the screen, only in the buffer. */
void reset_draw_buffer_only();
int draw_buffer_only();
int double_buffer_on();
int double_buffered();
void set_double_buffered(int val);
void set_double_buffer_on(int val);
};
//! Backcall data for scrollbar reconfiguration
typedef struct {
void* scroll_data; //!< Scrollbar data (growwidget_sScroll).
......@@ -145,21 +98,14 @@ public:
int offs_y = 0);
glow_eCtxType ctx_type; //!< Type of context
GlowWind mw; //!< Main window data.
GlowWind navw; //!< Navigation window data.
DrawWind* mw; //!< Main window data.
DrawWind* navw; //!< Navigation window data.
double print_zoom_factor; //!< Zoom factor when printing to postscript.
double x_right; //!< Right border of work area.
double x_left; //!< Left border of work area.
double y_high; //!< High border of work area.
double y_low; //!< Low border of work area.
int nav_rect_ll_x; //!< x coordinate for lower left corner of navigation
//! rectangle in nav window.
int nav_rect_ll_y; //!< y coordinate for lower left corner of navigation
//! rectangle in nav window.
int nav_rect_ur_x; //!< x coordinate for upper right corner of navigation
//! rectangle in nav window.
int nav_rect_ur_y; //!< y coordinate for upper right corner of navigation
//! rectangle in nav window.
int nav_rect_ll_x, nav_rect_ll_y, nav_rect_ur_x, nav_rect_ur_y;
int nav_rect_hot; //!< Cursor is in navigation rectangle in navigation window.
GlowDraw* gdraw; //!< Draw context.
......@@ -604,7 +550,7 @@ public:
\param ur_y y coordiate for upper right corner of area to draw in
pixel.
*/
void draw(GlowWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
virtual void draw(DrawWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
//! Redraw an area of the window. Arguments in double.
/*!
......@@ -617,15 +563,11 @@ public:
\param ur_y y coordiate for upper right corner of area to draw in
pixel.
*/
void draw(GlowWind* w, double ll_x, double ll_y, double ur_x, double ur_y)
void draw(DrawWind* w, double ll_x, double ll_y, double ur_x, double ur_y)
{
draw(w, (int)ll_x, (int)ll_y, (int)ur_x, (int)ur_y);
}
//! Clear the window.
/*! Draw background color. */
void clear(GlowWind* w);
//! Update zoom of navigation window.
/*! The zoomfactor of the navigation window is updated to match the extent of
* the working space. */
......@@ -634,39 +576,6 @@ public:
//! Zoom to appropriate scale for postscript output.
void print_zoom();
//! Clear the navigation window.
/*! Draw background color. */
void nav_clear();
//! Redraw an area of the navigation window.
/*!
\param ll_x x coordiate for lower left corner of area to draw in
pixel.
\param ll_y y coordiate for lower left corner of area to draw in
pixel.
\param ur_x x coordiate for upper right corner of area to draw in
pixel.
\param ur_y y coordiate for upper right corner of area to draw in
pixel.
*/
void nav_draw(GlowWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
//! Redraw an area of the navigation window. Arguments in double.
/*!
\param ll_x x coordiate for lower left corner of area to draw in
pixel.
\param ll_y y coordiate for lower left corner of area to draw in
pixel.
\param ur_x x coordiate for upper right corner of area to draw in
pixel.
\param ur_y y coordiate for upper right corner of area to draw in
pixel.
*/
void nav_draw(GlowWind* w, double ll_x, double ll_y, double ur_x, double ur_y)
{
nav_draw(w, (int)ll_x, (int)ll_y, (int)ur_x, (int)ur_y);
}
//! Handle events.
/*! Calls the event handler of GrowCtx. */
int event_handler(glow_eEvent event, int x, int y, int w, int h);
......@@ -700,16 +609,15 @@ public:
/*! \param node Node.*/
void delete_node_cons(void* node);
//! Set defered redraw.
/*! The redraw will be deferd until a call to redraw_defered() is made. */
void set_defered_redraw();
//! Mark that window needs to be redrawn.
/*! The window will be redrawn when a call to redraw_if_dirty() is made. */
void set_dirty();
//! Execute the defered redrawings.
/*! Execute redrawing the defered redrawing area since the call to
* set_defered_redraw(). */
void redraw_defered();
//! Redraw the window if it is dirty.
/*! Redraw the window if it has been marked as dirty by set_dirty() */
void redraw_if_dirty();
int defered_redraw_active; //!< Defered redraw is active.
int is_dirty; //!< Defered redraw is active.
GlowArray a_nc; //!< Array of nodeclasses.
GlowArray a_cc; //!< Array of connection classes.
GlowArray a; //!< Object array.
......@@ -906,18 +814,11 @@ public:
\param pix_x x coordinate in pixel.
\param pix_y y coordinate in pixel.
*/
void position_to_pixel(double x, double y, int* pix_x, int* pix_y)
{
*pix_x = int(x * mw.zoom_factor_x - mw.offset_x);
*pix_y = int(y * mw.zoom_factor_y - mw.offset_y);
}
void position_to_pixel(double x, double y, int* pix_x, int* pix_y);
//! Unzoom.
/*! Return to base zoom factor. */
void unzoom()
{
zoom(mw.base_zoom_factor / mw.zoom_factor_x);
}
void unzoom();
//! Position the view so that the specified object is in the center of the
//! window.
......@@ -936,23 +837,18 @@ public:
/*! No drawing is performed. */
void set_nodraw()
{
nodraw++;
nodraw = 1;
}
//! Reset nodraw.
/*! Drawing is resumed when the nodraw counter is zero. */
void reset_nodraw()
{
if (nodraw)
nodraw--;
nodraw = 0;
}
void reconfigure();
//! Redraw the window.
/*! The window is cleard and all objects are redrawn. */
void redraw();
//! Send an object deleted event callback if this event is registred.
/*! \param object Object that is to be deleted. */
void object_deleted(GlowArrayElem* object);
......@@ -1089,7 +985,7 @@ public:
\param ur_x x coordinate for upper right corner of area in pixel.
\param ur_y y coordinate for upper right corner of area in pixel.
*/
void draw_grid(GlowWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
void draw_grid(DrawWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
//! Register callback functions for userdata handling.
/*!
......@@ -1140,7 +1036,7 @@ public:
//! Destructor
/*! Delete all objects in the context. */
~GlowCtx();
virtual ~GlowCtx();
};
//! Start autoscrolling.
......
This diff is collapsed.
......@@ -49,10 +49,7 @@ public:
int layout_adjusted;
void configure();
void zoom(double factor);
void unzoom()
{
zoom(mw.base_zoom_factor / mw.zoom_factor_x);
}
void unzoom();
void nav_zoom();
void get_zoom(double* factor_x, double* factor_y);
void get_prefered_zoom_y(int height, double* factor_y);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -123,7 +123,7 @@ public:
multiplied with the parentnodes transform, to give the appropriate
coordinates for the drawing.
*/
void draw(GlowWind* w, GlowTransform* t, int highlight, int hot, void* node,
void draw(DrawWind* w, GlowTransform* t, int highlight, int hot, void* node,
void* colornode);
//! Erase the object.
......@@ -132,7 +132,7 @@ public:
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase(GlowWind* w, GlowTransform* t, int hot, void* node);
void erase(DrawWind* w, GlowTransform* t, int hot, void* node);
//! Redraw the background of the annotation
/*!
......@@ -140,7 +140,7 @@ public:
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase_background(GlowWind* w, GlowTransform* t, int hot, void* node);
void erase_background(DrawWind* w, GlowTransform* t, int hot, void* node);
//! Calculate the border for a set of objects or for a parent node.
/*!
......
This diff is collapsed.
......@@ -843,8 +843,6 @@ void grow_RedrawDefered(grow_tCtx ctx);
/*! \param ctx Grow context. */
void grow_Redraw(grow_tCtx ctx);
void grow_SetInputFocus(grow_tCtx ctx);
//! Set editing mode of grow.
/*!
\param ctx Grow context.
......@@ -3345,7 +3343,6 @@ int grow_SetObjectClass(grow_tObject object, grow_tNodeClass nodeclass);
int grow_CheckObjectName(grow_tCtx ctx, char* name);
int grow_KeyPressed(grow_tCtx ctx, int key);
void grow_SignalSend(grow_tCtx ctx, char* signalname);
void grow_DrawObject(grow_tObject object);
void grow_NavRedraw(grow_tCtx ctx);
/*@}*/
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -92,7 +92,7 @@ public:
void open(std::ifstream& fp);
//! Erase the object
void erase(GlowWind* w)
void erase(DrawWind* w)
{
erase(w, (GlowTransform*)NULL, hot, NULL);
}
......@@ -104,7 +104,7 @@ public:
\param ur_x Upper right x coordinate of drawing area.
\param ur_y Upper right y coordinate of drawing area.
*/
void draw(GlowWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
void draw(DrawWind* w, int ll_x, int ll_y, int ur_x, int ur_y);
//! Draw the objects if any part is inside the drawing area, and extends the
//! drawing area.
......@@ -118,7 +118,7 @@ public:
drawing area,
the drawingarea is extended so it contains the whole objects.
*/
void draw(GlowWind* w, int* ll_x, int* ll_y, int* ur_x, int* ur_y);
void draw(DrawWind* w, int* ll_x, int* ll_y, int* ur_x, int* ur_y);
//! Set object highlight.
/*!
......@@ -154,7 +154,7 @@ public:
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase(GlowWind* w, GlowTransform* t, int hot, void* node);
void erase(DrawWind* w, GlowTransform* t, int hot, void* node);
//! Draw the object.
/*!
......@@ -170,12 +170,9 @@ public:
multiplied with the parentnodes transform, to give the appropriate
coordinates for the drawing.
*/
void draw(GlowWind* w, GlowTransform* t, int highlight, int hot, void* node,
void draw(DrawWind* w, GlowTransform* t, int highlight, int hot, void* node,
void* colornode);
//! Redraw the area inside the objects border.
void draw();
//! Configure the axis
/*! Calculate the layout for the axis, length of lines and which values that
* should be dislayed.
......@@ -278,7 +275,7 @@ public:
void set_original_text_color(glow_eDrawType drawtype)
{
text_color_drawtype = drawtype;
draw();
ctx->set_dirty();
}
//! Format axis text.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -157,11 +157,9 @@ public:
strcpy(nc->n_name, name);
}
int event_handler(GlowWind* w, glow_eEvent event, double fx, double fy);
int event_handler(
GlowWind* w, glow_eEvent event, int x, int y, double fx, double fy);
int nc_event_handler(
GlowWind* w, glow_eEvent event, double x, double y, int* idx);
int event_handler(glow_eEvent event, double fx, double fy);
int event_handler(glow_eEvent event, int x, int y, double fx, double fy);
int nc_event_handler(glow_eEvent event, double x, double y, int* idx);
void configure(char* tools1, char* tools2, int tools1_cnt, int tools2_cnt,
unsigned int show_mask1, unsigned int show_mask2,
unsigned int insensitive_mask1, unsigned int insensitive_mask2);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -55,7 +55,6 @@ public:
void zoom();
void nav_zoom();
void print_zoom();
void traverse(int x, int y);
void posit(double x, double y);
void posit_z(int x, int y);
void save(std::ofstream& fp, glow_eSaveMode mode);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment