From c822939003e983f2c308b1a0410d84c47332359e Mon Sep 17 00:00:00 2001 From: arif Date: Wed, 15 Oct 2008 21:39:25 +0000 Subject: [PATCH] 2 new files added beacon.h beacon.c still working on info boxes, --- cmd/smyrna/draw.c | 82 +++++++++++++++++++------------ cmd/smyrna/draw.h | 2 +- cmd/smyrna/glmotion.c | 1 + cmd/smyrna/gltemplate.c | 2 + cmd/smyrna/gui/Makefile.am | 4 +- cmd/smyrna/gui/toolboxcallbacks.c | 17 +++++-- cmd/smyrna/gui/toolboxcallbacks.h | 2 +- cmd/smyrna/smyrnadefs.h | 1 + cmd/smyrna/viewport.c | 13 +---- 9 files changed, 74 insertions(+), 50 deletions(-) diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index bdf0baeaf..1646e1694 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -781,56 +781,74 @@ void drawEllipse(float xradius, float yradius,int angle1,int angle2) glEnd(); } -int draw_node_hintbox_gl_polygon(GLfloat x,GLfloat y,GLfloat fs,GLfloat pad,GLfloat z,GLfloat kts) -{ - float w; - kts=kts*(GLfloat)1.15; - w=fs*kts+2*pad; - glBegin(GL_POLYGON); //big rectangle - glVertex3f(x-w/(GLfloat)2.0 , y+fs ,z); - glVertex3f(x-w/(GLfloat)2.0 ,y+2*fs+2*pad,z); - glVertex3f(x+w/(GLfloat)2.0,y+2*fs+2*pad,z); - glVertex3f(x+w/(GLfloat)2.0,y+fs,z); - glVertex3f(x-w/(GLfloat)2.0 , y+fs ,z); - glEnd(); +int draw_node_hintbox_gl_polygon(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text) +{ - glBegin(GL_POLYGON); //litle triangle - glVertex3f(x,y,z); - glVertex3f(x-(fs/3) , y+fs ,z); - glVertex3f(x+fs/3,y+fs,z); - glVertex3f(x,y,z); + float X,Y,Z,pad; + pad=fs/5.0; + X=x;Y=y+fs;Z=z; + glBegin(GL_POLYGON); + //rectangle + glVertex3f(X,Y,Z); + Y=Y + 2*fs+2*pad; + glVertex3f(X,Y,Z); + X=X+2*pad+strlen(text)*fs; + glVertex3f(X,Y,Z); + Y=y+fs; + glVertex3f(X,Y,Z); + X=x; + glVertex3f(X,Y,Z); + //triangle + glEnd(); + X=x;Y=y; + glBegin(GL_POLYGON); + glVertex3f(X,Y,Z); + Y=Y + fs; + glVertex3f(X,Y,Z); + X=X+2*pad; + glVertex3f(X,Y,Z); + X=x;Y=y; + glVertex3f(X,Y,Z); glEnd(); + return 1; } -int draw_node_hintbox_gl_line(GLfloat x,GLfloat y,GLfloat fs,GLfloat pad,GLfloat z,GLfloat kts) +int draw_node_hintbox_gl_line(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text) { - float w; - kts=kts*(GLfloat)1.15; - w=fs*kts+(GLfloat)2*pad; + + float X,Y,Z,pad; + pad=fs/5.0; + X=x;Y=y;Z=z+0.001; glBegin(GL_LINE_STRIP); - glVertex3f(x,y,z); - glVertex3f(x-(fs/(GLfloat)3) , y+fs ,z); - glVertex3f(x-w/(GLfloat)2.0 , y+fs ,z); - glVertex3f(x-w/(GLfloat)2.0 ,y+2*fs+2*pad,z); - glVertex3f(x+w/(GLfloat)2.0,y+2*fs+2*pad,z); - glVertex3f(x+w/(GLfloat)2.0,y+fs,z); - glVertex3f(x+fs/(GLfloat)3,y+fs,z); - glVertex3f(x,y,z); + glVertex3f(X,Y,Z); + Y=Y + 2*fs+2*pad; + glVertex3f(X,Y,Z); + X=X+2*pad+strlen(text)*fs; + glVertex3f(X,Y,Z); + Y=y+fs; + glVertex3f(X,Y,Z); + X=x+fs; + glVertex3f(X,Y,Z); + X=x;Y=y; + glVertex3f(X,Y,Z); glEnd(); + + + return 1; } -int draw_node_hintbox(GLfloat x,GLfloat y,GLfloat fs,GLfloat pad,GLfloat z,GLfloat kts,GLfloat z_offset) +int draw_node_hintbox(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text) { glColor3f(1,1,0); - draw_node_hintbox_gl_polygon(x,y,fs,pad,z+(GLfloat)z_offset/100,kts); + draw_node_hintbox_gl_polygon(x,y,z,fs,text); glColor3f(0,0,1); - draw_node_hintbox_gl_line(x,y,fs,pad,z+(GLfloat)0.001+(GLfloat)z_offset/100,kts); + draw_node_hintbox_gl_line(x,y,z,fs,text); return 1; } diff --git a/cmd/smyrna/draw.h b/cmd/smyrna/draw.h index b2a883364..8a0d96f7f 100755 --- a/cmd/smyrna/draw.h +++ b/cmd/smyrna/draw.h @@ -43,7 +43,7 @@ extern void drawCircle(float x, float y, float radius, float zdepth); extern RGBColor GetRGBColor(char *color); extern void drawBorders(ViewInfo * view); void drawEllipse(float xradius, float yradius,int angle1,int angle2); -int draw_node_hintbox(GLfloat x,GLfloat y,GLfloat fs,GLfloat pad,GLfloat z,GLfloat kts,GLfloat z_offset); +int draw_node_hintbox(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text); void draw_sphere(float x,float y,float z,float r); diff --git a/cmd/smyrna/glmotion.c b/cmd/smyrna/glmotion.c index 05e559933..c3c94e810 100644 --- a/cmd/smyrna/glmotion.c +++ b/cmd/smyrna/glmotion.c @@ -13,6 +13,7 @@ int glmotion_main(ViewInfo * v,GdkEventMotion * event,GtkWidget * widget) { redraw = FALSE; + view->FontSizeConst=GetOGLDistance(14); /*panning */ if ((event->state & GDK_BUTTON1_MASK)&& (v->mouse.mouse_mode == MM_PAN)) glmotion_pan(v); diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index 0c1f69fea..b1d13af89 100755 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -400,6 +400,8 @@ static gboolean motion_notify_event(GtkWidget * widget, if ((event->state & GDK_BUTTON1_MASK) && (view->mouse.mouse_mode == MM_ZOOM)) { + view->FontSizeConst=GetOGLDistance(14); + if (glmotion_main(view, event, widget)) redraw = TRUE; } diff --git a/cmd/smyrna/gui/Makefile.am b/cmd/smyrna/gui/Makefile.am index 331a1f8e6..cf550f073 100644 --- a/cmd/smyrna/gui/Makefile.am +++ b/cmd/smyrna/gui/Makefile.am @@ -19,9 +19,9 @@ AM_CPPFLAGS = \ if WITH_SMYRNA noinst_HEADERS = callbacks.h datalistcallbacks.h filterscallbacks.h gui.h \ - menucallbacks.h toolboxcallbacks.h + menucallbacks.h toolboxcallbacks.h beacon.h noinst_LTLIBRARIES = libgui_C.la endif libgui_C_la_SOURCES = callbacks.c datalistcallbacks.c filterscallbacks.c \ - gui.c menucallbacks.c toolboxcallbacks.c + gui.c menucallbacks.c toolboxcallbacks.c beacon.c diff --git a/cmd/smyrna/gui/toolboxcallbacks.c b/cmd/smyrna/gui/toolboxcallbacks.c index 876a75ca7..07df234ca 100755 --- a/cmd/smyrna/gui/toolboxcallbacks.c +++ b/cmd/smyrna/gui/toolboxcallbacks.c @@ -87,7 +87,8 @@ void btnToolZoomFit_clicked(GtkWidget * widget, gpointer user_data) { float scx,scy,gcx,gcy,z,GDX,SDX,GDY,SDY; - + GtkTextBuffer *a; + char* test; (view->active_camera >=0) ? (z=view->cameras[view->active_camera]->r):(z=view->zoom*-1); @@ -110,8 +111,7 @@ void btnToolZoomFit_clicked(GtkWidget * widget, gpointer user_data) } btnToolFit_clicked(NULL,NULL); -// xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL); - gtk_widget_hide (glade_xml_get_widget(xml, "consoleText")); + write_to_console("test entry\n"); } void btnToolFit_clicked(GtkWidget * widget, gpointer user_data) @@ -187,3 +187,14 @@ void btnToolDeleteEdge_clicked(GtkWidget * widget, gpointer user_data) void btnToolFindEdge_clicked(GtkWidget * widget, gpointer user_data) { } + +int write_to_console(char* text) +{ + //init console text + GtkTextIter iter; + if(!view->consoleText) + view->consoleText=gtk_text_buffer_new(NULL); + gtk_text_buffer_get_end_iter(view->consoleText,&iter); + gtk_text_buffer_insert (view->consoleText,&iter,text,-1); + gtk_text_view_set_buffer ((GtkTextView*)glade_xml_get_widget(xml, "consoleText"),view->consoleText); +} diff --git a/cmd/smyrna/gui/toolboxcallbacks.h b/cmd/smyrna/gui/toolboxcallbacks.h index 65a62cc71..074998e1b 100755 --- a/cmd/smyrna/gui/toolboxcallbacks.h +++ b/cmd/smyrna/gui/toolboxcallbacks.h @@ -49,7 +49,7 @@ _BB void btnToolFindNode_clicked(GtkWidget * widget, gpointer user_data); _BB void btnToolAddEdge_clicked(GtkWidget * widget, gpointer user_data); _BB void btnToolDeleteEdge_clicked(GtkWidget * widget, gpointer user_data); _BB void btnToolFindEdge_clicked(GtkWidget * widget, gpointer user_data); - +int write_to_console(char* text); #endif diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 209f788be..baa9d2201 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -489,6 +489,7 @@ typedef struct _ViewInfo viewtype_t dfltViewType; gvk_layout dfltEngine; GtkTextBuffer* consoleText; + int FontSizeConst; } ViewInfo; extern ViewInfo *view; diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index be135c1d1..8bbdd6a31 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -257,7 +257,7 @@ there i go, turn the page atoi(get_attribute_value ("drawedges", view, g)); view->drawlabels= atoi(get_attribute_value ("drawlabels", view, g)); - + view->FontSizeConst=0; //this will be calculated later in topview.c while calculating optimum font size //FIXME: I don't think an openGL function can be called before it // is initialized. @@ -270,8 +270,7 @@ void init_viewport(ViewInfo * view) { char *template_file; FILE *input_file; - GtkTextBuffer *a; - char* test; + /*loading default visual attributes */ @@ -291,14 +290,6 @@ void init_viewport(ViewInfo * view) #ifndef _WIN32 free (template_file); #endif - //init console text - xml = glade_xml_new(smyrnaGlade, NULL, NULL); - gtk_widget_hide (glade_xml_get_widget(xml, "consoleText")); - view->consoleText=gtk_text_buffer_new(NULL); - gtk_text_buffer_set_text (view->consoleText,"Smyrna console is initialized:\n",-1); - a=gtk_text_view_get_buffer((GtkTextView*)glade_xml_get_widget(xml, "consoleText")); - test=gtk_text_buffer_get_text (a,0,5,1); - gtk_text_view_set_buffer ((GtkTextView*)glade_xml_get_widget(xml, "consoleText"),view->consoleText); //init graphs view->g = NULL; //no graph, gl screen should check it view->graphCount = 0; //and disable interactivity if count is zero -- 2.40.0