]> granicus.if.org Git - graphviz/commitdiff
gdi_plus fixed
authorarif <devnull@localhost>
Mon, 23 Mar 2009 15:38:58 +0000 (15:38 +0000)
committerarif <devnull@localhost>
Mon, 23 Mar 2009 15:38:58 +0000 (15:38 +0000)
glcopm:most of the licensed code removed , few left

20 files changed:
cmd/smyrna/draw.c
cmd/smyrna/glexpose.c
cmd/smyrna/gltemplate.c
cmd/smyrna/gui/menucallbacks.c
cmd/smyrna/main.c
cmd/smyrna/smyrna.vcproj
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topfisheyeview.c
cmd/smyrna/topview.c
cmd/smyrna/viewport.c
graphviz.sln
lib/glcomp/glTexFont.c
lib/glcomp/glTexFont.h
lib/glcomp/glcomp.vcproj
lib/glcomp/glcompbutton.c
lib/glcomp/glcompdefs.h
lib/glcomp/glcomplabel.c
lib/glcomp/glcompset.h
plugin/gdiplus/gvplugin_gdiplus.h
plugin/gdiplus/gvrender_gdiplus.cpp

index 51116e480f47f4fbd2c33249c2f49a08cbe1e3d2..e991333aa3e633ea060ba12b7a0a28b0af8c4efa 100755 (executable)
@@ -476,10 +476,10 @@ static void EmbedText(xdot_op * op, int param)
        x = (GLfloat) op->u.text.x + op->u.text.width;
        fontSize(view->fontset->fonts[view->fontset->activefont],view->FontSize);
     if (param == 0)
-       fontColor(view->fontset->fonts[view->fontset->activefont],view->penColor.R, view->penColor.G, view->penColor.B);
+       fontColor(view->fontset->fonts[view->fontset->activefont],view->penColor.R, view->penColor.G, view->penColor.B,1);
     if (param == 1)            //selected
        fontColor(view->fontset->fonts[view->fontset->activefont],view->selectedNodeColor.R, view->selectedNodeColor.G,
-                 view->selectedNodeColor.B);
+                 view->selectedNodeColor.B,1);
        fontDrawString(view->fontset->fonts[view->fontset->activefont], (x - dx), (GLfloat)op->u.text.y -  dy,
                   (GLfloat)op->u.text.width, op->u.text.text);
 }
index 43439e7506ada3640a7d91df254f7856f7032de5..ea63cdcb56a21c45c0b1cbfc7739c532d3173af3 100644 (file)
@@ -102,6 +102,7 @@ int glexpose_main(ViewInfo * view)
     draw_selection_box(view);
     drawBorders(view);
        drawRotatingTools();
+
 //     drawtestpoly();
        /*DEBUG*/
 /*     if (view->mouse.mouse_mode == MM_PAN)
@@ -183,6 +184,9 @@ int glexpose_drawgraph(ViewInfo * view)
                                drawtopologicalfisheye(view->Topview);
                        }
                        glCompSetDraw(view->Topview->topviewmenu);
+//                     OtkUpdateCheck();
+       //              OtkDisplayFunct();
+
                }
                else
                        drawGraph(view->g[view->activeGraph]);  //xdot based drawing functions
index b5dd952e928d0b34cfd8a2790d4dfb43658ab3ae..89faaf3d1d22eafbe2ae98769f1ecc0f23206040 100755 (executable)
@@ -137,7 +137,6 @@ static void realize(GtkWidget * widget, gpointer data)
 #else
     smyrna_font = smyrnaPath("arial.tga");
 #endif
-//    g_print("loading font....%i\n", fontLoad(smyrna_font));
 
        add_font(view->fontset,"Times 14");//wired in default font
        /*** OpenGL BEGIN ***/
index d4bb72f8d68106376e8e27de2f3e875506e92eb5..6ec5726710949af8e98a9aa5c181ac7b3236f690 100755 (executable)
@@ -140,10 +140,15 @@ void mTopviewSettingsSlot(GtkWidget * widget, gpointer user_data)
 void mShowToolBoxSlot(GtkWidget * widget, gpointer user_data)
 {
 
-    gtk_widget_hide(glade_xml_get_widget(xml, "frmToolBox"));
-    gtk_widget_show(glade_xml_get_widget(xml, "frmToolBox"));
+    gtk_widget_hide(glade_xml_get_widget(xml, "gtkglwindow"));
+    gtk_widget_show(glade_xml_get_widget(xml, "gtkglwindow"));
     gtk_window_set_keep_above((GtkWindow *)
-                             glade_xml_get_widget(xml, "frmToolBox"), 1);
+                             glade_xml_get_widget(xml, "gtkglwindow"), 1);
+
+if(!gtk_widget_set_gl_capability    (glade_xml_get_widget(xml, "glfixed"), configure_gl(),gtk_widget_get_gl_context(view->drawing_area),0,0))
+       printf("glwidget creation failed \n");
+
+       
 
 }
 
index 1803a0d82bf5908ca251cdc677ef9489e2a2de12..ba37f5712cec68881ec5e9054ac2c28ec961cd7e 100755 (executable)
@@ -22,7 +22,9 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define WIN32_LEAN_AND_MEAN 1
 #include <windows.h>
+#include <windowsx.h>
 #endif
+#include "otk_lib.h"
 #include <gtk/gtk.h>
 #include <gtk/gtkgl.h>
 #include <glade/glade.h>
@@ -116,7 +118,7 @@ int main(int argc, char *argv[])
     GdkGLConfig *glconfig;
     char* initFileName;
 
-    smyrnaDir = getenv ("SMYRNA_PATH");
+       smyrnaDir = getenv ("SMYRNA_PATH");
 #ifndef _WIN32
     if (!smyrnaDir)
        smyrnaDir = SMYRNA_PATH;
index afe8e7d43d5cdf77e52434287b256ea010eebe7a..d474b9567fa8ea5bbd818c2b6ca64cff5609b23d 100644 (file)
                                Name="VCCLCompilerTool"
                                AdditionalOptions="/D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
                                Optimization="0"
-                               AdditionalIncludeDirectories="&quot;$(SolutionDir)/lib/gvc&quot;;&quot;C:\gtk\include\libglade-2.0&quot;;&quot;$(SolutionDir)/lib/neatogen&quot;;&quot;$(SolutionDir)/lib/sparse&quot;;&quot;$(SolutionDir)/lib/topfish&quot;;&quot;C:\gtk\lib\gtkglext-1.0\include&quot;;&quot;C:\gtk\include\gtkglext-1.0\&quot;;C:\gtk\include\cairo;&quot;C:\gtk\include\atk-1.0&quot;;&quot;C:\gtk\lib\gtk-2.0\include\cairo&quot;;&quot;C:\gtk\lib\gtk-2.0\include&quot;;&quot;C:\gtk\include\gtk-2.0\&quot;;&quot;$(SolutionDir)/cmd/smyrna/gui&quot;;&quot;$(SolutionDir)/cmd/smyrna&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)/lib/glcomp&quot;;&quot;C:\gtk\lib\glib-2.0\include&quot;;&quot;C:\gtk\include\glib-2.0&quot;;&quot;C:\gtk\include\pango-1.0\&quot;;C:\gtk\include;&quot;$(SolutionDir)/lib/common&quot;;&quot;$(SolutionDir)/lib/cdt&quot;;&quot;$(SolutionDir)/lib/cgraph&quot;;&quot;$(SolutionDir)/windows\lib\ingraphs&quot;;&quot;$(SolutionDir)/lib/xdot&quot;"
+                               AdditionalIncludeDirectories="&quot;C:\graphviz-ms\graphviz2\lib\windirent&quot;;&quot;$(SolutionDir)/lib/gvc&quot;;&quot;C:\gtk\include\libglade-2.0&quot;;&quot;$(SolutionDir)/lib/neatogen&quot;;&quot;$(SolutionDir)/lib/sparse&quot;;&quot;$(SolutionDir)/lib/topfish&quot;;&quot;C:\gtk\lib\gtkglext-1.0\include&quot;;&quot;C:\gtk\include\gtkglext-1.0\&quot;;C:\gtk\include\cairo;&quot;C:\gtk\include\atk-1.0&quot;;&quot;C:\gtk\lib\gtk-2.0\include\cairo&quot;;&quot;C:\gtk\lib\gtk-2.0\include&quot;;&quot;C:\gtk\include\gtk-2.0\&quot;;&quot;$(SolutionDir)/cmd/smyrna/gui&quot;;&quot;$(SolutionDir)/cmd/smyrna&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)/lib/glcomp&quot;;&quot;C:\gtk\lib\glib-2.0\include&quot;;&quot;C:\gtk\include\glib-2.0&quot;;&quot;C:\gtk\include\pango-1.0\&quot;;C:\gtk\include;&quot;$(SolutionDir)/lib/common&quot;;&quot;$(SolutionDir)/lib/cdt&quot;;&quot;$(SolutionDir)/lib/cgraph&quot;;&quot;$(SolutionDir)/windows\lib\ingraphs&quot;;&quot;$(SolutionDir)/lib/xdot&quot;;&quot;$(SolutionDir)/lib/otk_lib&quot;"
                                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_TRIANGLE;HAVE_CONFIG_H;HAVE_GTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="3"
                                UsePrecompiledHeader="0"
-                               WarningLevel="3"
+                               WarningLevel="0"
                                Detect64BitPortabilityProblems="true"
                                DebugInformationFormat="4"
                                DisableSpecificWarnings="4995;4996"
@@ -62,7 +62,7 @@
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="mspng.lib gtk-win32-2.0.lib asprintf.lib atk-1.0.lib bz2.lib cairo.lib charset.lib croco-0.6.lib expat.lib expatw.lib glade-2.0.lib fontconfig.lib freetype.lib gdk_pixbuf-2.0.lib gdkglext-win32-1.0.lib gdk-win32-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gsf-1.lib gsf-win32-1.lib gthread-2.0.lib gtkglext-win32-1.0.lib iconv.lib intl.lib jpeg.lib libexpat.lib libexpatw.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib popt.lib rsvg-2.lib tiff.lib xml2.lib libgdkglext-win32-1.0.dll.a libgtkglext-win32-1.0.dll.a glu32.lib opengl32.lib ltdl.lib hs_regex.lib zdll.lib gladeui-1.lib glcomp.lib cgraph.lib gvc.lib xdot.lib topfish.lib ingraphs.lib neatogen.lib gts.lib $(NOINHERIT)"
+                               AdditionalDependencies="mspng.lib gtk-win32-2.0.lib asprintf.lib atk-1.0.lib bz2.lib cairo.lib charset.lib croco-0.6.lib expat.lib expatw.lib glade-2.0.lib fontconfig.lib freetype.lib gdk_pixbuf-2.0.lib gdkglext-win32-1.0.lib gdk-win32-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gsf-1.lib gsf-win32-1.lib gthread-2.0.lib gtkglext-win32-1.0.lib iconv.lib intl.lib jpeg.lib libexpat.lib libexpatw.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib popt.lib rsvg-2.lib tiff.lib xml2.lib libgdkglext-win32-1.0.dll.a libgtkglext-win32-1.0.dll.a glu32.lib opengl32.lib ltdl.lib hs_regex.lib zdll.lib gladeui-1.lib glcomp.lib cgraph.lib gvc.lib xdot.lib topfish.lib ingraphs.lib neatogen.lib gts.lib User32.lib Gdi32.lib shlwapi.lib $(NOINHERIT)"
                                OutputFile="c:/graphviz-ms/bin/$(ProjectName).exe"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="C:\glade_setup\lib;&quot;C:\graphviz-ms\bin&quot;;C:\gtk\lib;C:\GnuWin32\lib;&quot;C:\Projects\graphviz2\lib\zlib-1.2.3\lib&quot;;C:\Projects\cairo_build\lib;C:\Projects\ATT\GTK\GTKTest2\lib;C:\GtkGLExt\1.0\lib;C:\GTK\2.0\bin;C:\GTK\2.0\lib"
index 2814c5c180d92e78157a57cb51ae762e2b537aad..605999febc20f7bc31ff4dc7e62caa05079b519a 100644 (file)
@@ -18,7 +18,7 @@
 
 #ifdef WIN32
 #include "windows.h"
-#include "gltexfont.h"
+//#include "gltexfont.h"
 //#define       SMYRNA_GLADE "C:/Projects/graphviz2/share/gui/smyrna.glade"
 #define        SMYRNA_ATTRS "c:/graphviz-ms/share/gui/attrs.txt"
 #endif
@@ -182,6 +182,8 @@ typedef struct {
     topviewdata *TopviewData;
     void *customptr;
     Hierarchy *h;
+       glCompColor srcColor;   //fine node colors of topfisheye
+       glCompColor tarColor;   //supernode colors of fisheye
     int is_top_fisheye;        //1 draw hierarchy 0 draw regular topview
     focus_t* fs;
     struct {
index 49abf835341c5b625650ee910c84354a7eb9dd43..b7ac291bf828d6f3e6cf05239d5fe8baef9cdce0 100644 (file)
@@ -15,9 +15,7 @@
 #include "topfisheyeview.h"
 
 #include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
+#include "glcomptextpng.h"
 #include "math.h"
 #include "memory.h"
 #include "viewport.h"
 #include "hier.h"
 #include "topfisheyeview.h"
 #include <string.h>
+#include "color.h"
+
 
 static int get_temp_coords(topview* t,int level,int v,double* coord_x,double* coord_y);
 static int get_temp_coords2(topview* t,int level,int v,double* coord_x,double* coord_y,float *R,float *G,float *B);
 static int FLUSH=0;
+
+static void color_interpolation(glCompColor srcColor,glCompColor tarColor,glCompColor* color,int levelcount,int level)
+{
+       if (levelcount <=0)
+               return;
+
+
+       color->R=((float)level*tarColor.R-(float)level*srcColor.R+(float)levelcount*srcColor.R) /
+                               (float)levelcount;
+       color->G=((float)level*tarColor.G-(float)level*srcColor.G+(float)levelcount*srcColor.G) /
+                               (float)levelcount;
+       color->B=((float)level*tarColor.B-(float)level*srcColor.B+(float)levelcount*srcColor.B) /
+                               (float)levelcount;
+}
+
 static double dist(double x1, double y1, double x2, double y2)
 {
     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
@@ -52,6 +67,7 @@ static double G(double x)
            1) * x / (view->fmg.fisheye_distortion_fac * x + 1);
 }
 
+
 void fisheye_polar(double x_focus, double y_focus, topview * t)
 {
     int i;
@@ -230,6 +246,7 @@ void prepare_topological_fisheye(topview* t)
     Hierarchy *hp;
     ex_vtx_data *gg;
     topview_node *np;
+       gvcolor_t cl;
 
     v_data *graph = makeGraph(t, &ne);
 
@@ -258,6 +275,20 @@ void prepare_topological_fisheye(topview* t)
     view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
        view->Topview->parms.repos.rescale=Polar;
 
+       //topological fisheye 
+
+       colorxlate(get_attribute_value("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl,
+               RGBA_DOUBLE);
+       view->Topview->srcColor.R = (float) cl.u.RGBA[0];
+    view->Topview->srcColor.G = (float) cl.u.RGBA[1];
+    view->Topview->srcColor.B = (float) cl.u.RGBA[2];
+       colorxlate(get_attribute_value("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl,
+               RGBA_DOUBLE);
+       view->Topview->tarColor.R = (float) cl.u.RGBA[0];
+    view->Topview->tarColor.G = (float) cl.u.RGBA[1];
+    view->Topview->tarColor.B = (float) cl.u.RGBA[2];
+
+
        sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
        sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
        sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
@@ -301,9 +332,19 @@ void printalllevels(topview* t)
 
 void drawtopfishnodes(topview * t)
 {
-    int level, v;
+       glCompColor srcColor;
+       glCompColor tarColor;
+       glCompColor color;
+       int level, v;
     Hierarchy *hp = t->h;
-
+       static max_visible_level=0;
+       srcColor.R=view->Topview->srcColor.R;
+       srcColor.G=view->Topview->srcColor.G;
+       srcColor.B=view->Topview->srcColor.B;
+       tarColor.R=view->Topview->tarColor.R;
+       tarColor.G=view->Topview->tarColor.G;
+       tarColor.B=view->Topview->tarColor.B;
+       
        
        glEnable(GL_POINT_SMOOTH);      /*turn this off to make points look square*/
        //draw focused node little bigger than others
@@ -331,12 +372,17 @@ void drawtopfishnodes(topview * t)
                                                                && (-y0 / view->zoom < view->clipY2))))
                                                continue;
 
-                               if (level !=0)
-                                       glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 /  (GLfloat) hp->nlevels,
-                                 (GLfloat) level / (GLfloat) hp->nlevels, (GLfloat)0,(GLfloat)view->defaultnodealpha);
-                               else
-                               glColor4f((GLfloat) 1,
-                                 (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultnodealpha);
+//                             if (level !=0)
+//                                     glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 /  (GLfloat) hp->nlevels,
+//                               (GLfloat) level / (GLfloat) hp->nlevels, (GLfloat)0,(GLfloat)view->defaultnodealpha);
+       //                      else
+//                             glColor4f((GLfloat) 1,
+//                               (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultnodealpha);
+
+                               if (max_visible_level < level)
+                                       max_visible_level=level;
+                               color_interpolation(srcColor,tarColor,&color,max_visible_level,level);
+                               glColor4f(color.R,color.G,color.B,(GLfloat)view->defaultnodealpha);
 
 /*                                                             glColor3f((GLfloat) (hp->nlevels - level)*0.5 /  (GLfloat) hp->nlevels,
                                  (GLfloat) level / (GLfloat) hp->nlevels, 0);*/
@@ -375,14 +421,14 @@ void drawtopfishnodelabels(topview* t)
                                if((v==t->fs->foci_nodes[0]) &&(focusnodes))
                                {
                                        fs=view->FontSizeConst*(float)1.4;
-                                       fontColorA(view->fontset->fonts[view->fontset->activefont],(float)0, (float)0, (float)1, (float)1);
+                                       fontColor(view->fontset->fonts[view->fontset->activefont],(float)0, (float)0, (float)1, (float)1);
                                        fontSize(view->fontset->fonts[view->fontset->activefont],fs);
                                        fontDrawString(view->fontset->fonts[view->fontset->activefont],gg[v].physical_x_coord,gg[v].physical_y_coord, (fs*strlen(buf)*(GLfloat)0.4),buf);
                                }
                                else if (finenodes)
                                {
-                                       fs=view->FontSizeConst;
-                                       fontColorA(view->fontset->fonts[view->fontset->activefont],0, 0, 0, 1);
+                                       fs=view->FontSizeConst*1.2;
+                                       fontColor(view->fontset->fonts[view->fontset->activefont],0, 0, 0, 1);
                                        fontSize(view->fontset->fonts[view->fontset->activefont],fs);
                                        fontDrawString(view->fontset->fonts[view->fontset->activefont],gg[v].physical_x_coord,gg[v].physical_y_coord, (fs*strlen(buf)*(GLfloat)0.4),buf);
                                }
@@ -394,8 +440,20 @@ void drawtopfishnodelabels(topview* t)
 }
 void drawtopfishedges(topview * t)
 {
-    int level, v, i, n;
+       glCompColor srcColor;
+       glCompColor tarColor;
+       glCompColor color;
+
+       int level, v, i, n;
     Hierarchy *hp = t->h;
+               static max_visible_level=0;
+       srcColor.R=view->Topview->srcColor.R;
+       srcColor.G=view->Topview->srcColor.G;
+       srcColor.B=view->Topview->srcColor.B;
+       tarColor.R=view->Topview->tarColor.R;
+       tarColor.G=view->Topview->tarColor.G;
+       tarColor.B=view->Topview->tarColor.B;
+
        //and edges
        glBegin(GL_LINES);
     for (level = 0; level < hp->nlevels; level++)
@@ -411,12 +469,14 @@ void drawtopfishedges(topview * t)
                                {
                                        double x, y;
                                        n = g[v].edges[i];
-                               if (level !=0)
-                                       glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 /  (GLfloat) hp->nlevels,
-                                 (GLfloat) level / (GLfloat) hp->nlevels, 0,view->defaultedgealpha);
-                               else
-                               glColor4f((GLfloat) 1,
-                                 (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultedgealpha);
+
+
+                               if (max_visible_level < level)
+                                       max_visible_level=level;
+                               color_interpolation(srcColor,tarColor,&color,max_visible_level,level);
+                               glColor4f(color.R,color.G,color.B,(GLfloat)view->defaultnodealpha);
+
+
                                        if      (get_temp_coords(t,level,n,&x,&y))
                                        {
                                                        glVertex3f((GLfloat) x0, (GLfloat) y0,(GLfloat) 0);
@@ -573,6 +633,7 @@ void changetopfishfocus(topview * t, float *x, float *y,
                                   float *z, int num_foci)
 {
 
+       gvcolor_t cl;
        focus_t *fs = t->fs;
     int i;
     int closest_fine_node;
@@ -594,6 +655,19 @@ void changetopfishfocus(topview * t, float *x, float *y,
     view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft);
     view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
 
+       colorxlate(get_attribute_value("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl,
+               RGBA_DOUBLE);
+       view->Topview->srcColor.R = (float) cl.u.RGBA[0];
+    view->Topview->srcColor.G = (float) cl.u.RGBA[1];
+    view->Topview->srcColor.B = (float) cl.u.RGBA[2];
+       colorxlate(get_attribute_value("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl,
+               RGBA_DOUBLE);
+       view->Topview->tarColor.R = (float) cl.u.RGBA[0];
+    view->Topview->tarColor.G = (float) cl.u.RGBA[1];
+    view->Topview->tarColor.B = (float) cl.u.RGBA[2];
+
+
+
        sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
        sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
        sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
@@ -602,6 +676,7 @@ void changetopfishfocus(topview * t, float *x, float *y,
 
 
 
+
     set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
 
 
@@ -726,4 +801,3 @@ void drawtopologicalfisheyestatic(topview * t)
     glEnd();*/
 }
 
-
index 8480b23be1e5507bf3317f0b46f0b038929e142d..45b2a5947c3b6e1fd4654c83d51a6ba1fb2ee7d8 100755 (executable)
@@ -14,9 +14,7 @@
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 #include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
+#include "glcomptextpng.h"
 #include "glcompbutton.h"
 #include "glcomppanel.h"
 #include "glcomplabel.h"
@@ -37,6 +35,9 @@
 #else
 #include "regex.h"
 #endif
+#include "otk_lib.h"
+
+
 
 static float dx = 0.0;
 static float dy = 0.0;
@@ -55,6 +56,7 @@ static int get_color_from_edge(topview_edge * e);
 static int draw_node_hint_boxes(void);
 static int pick_node(topview_node * n);
 
+
 void cleartopview(topview * t)
 {
     /*clear nodes */
@@ -81,6 +83,13 @@ void preparetopview(Agraph_t * g, topview * t)
 
        int maxlabelsize=0;
        float maxedgelen,minedgelen,len,edgelength;
+
+//     OtkInitWindow( 700, 500, NULL, NULL );
+//     OtkMakeButton( OtkOuterWindow, 10.0, 10.0, 80.0, 80.0, "Hello World !", 0, 0 );
+//     OtkMainLoop();
+
+
+
        maxedgelen=0;
        minedgelen=(float)99999999.00000;       //FIX ME if you have a giant graph or fix your graph
        edgelength=0;
@@ -641,7 +650,7 @@ static int draw_node_hint_boxes(void)
                          )
                          ;
        fontSize(view->fontset->fonts[view->fontset->activefont],fs);
-       fontColorA(view->fontset->fonts[view->fontset->activefont],0, 0, 1, 1);
+       fontColor(view->fontset->fonts[view->fontset->activefont],0, 0, 1, 1);
 
 
        fontDrawString(
@@ -858,7 +867,8 @@ static int draw_topview_label(topview_node * v, float zdepth)
        && (v->distorted_y / view->zoom * -1 < view->clipY2)) 
        {
                fs=calculate_font_size(v);
-               
+               if (v->degree==0)
+                       printf("haha\n");
        
 
 /*             fs = (v->degree ==1) ? 
@@ -866,9 +876,11 @@ static int draw_topview_label(topview_node * v, float zdepth)
                                        :
                                (float) (log((double) v->degree +(double) 0.5) *(double) 3)*14;*/
 
-               fs =(float) (log((double) v->degree +(double) 0.5) *(double) 3)*14;
+               fs =(float) (log((double) v->degree +(double) 0.7) *(double) 3)*14;
        //      fs=view->FontSize;
        fs = fs * v->zoom_factor;
+       if (v->degree < 3)
+               fs=fs*2;
        if (OD_Selected(v->Node) == 1) {
            ddx = dx;
            ddy = dy;
@@ -877,21 +889,22 @@ static int draw_topview_label(topview_node * v, float zdepth)
                return 0;
 
 //     fs= 10;
-       fs= fs * (float)0.2;
+       fs= fs * (float)0.182;
 
 
 
        fontSize(view->fontset->fonts[view->fontset->activefont],fs);
        if ((log((float) v->degree) * -0.6 * view->zoom) > 0)
-           fontColorA(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
+           fontColor(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
                       view->penColor.G, view->penColor.B,
                       view->penColor.A / (float) log((double) v->degree) *
                       (float) -0.4 * (float) view->zoom);
        else
-           fontColorA(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
+           fontColor(view->fontset->fonts[view->fontset->activefont],(float) log((double) v->degree + (double) 1),
                       view->penColor.G, view->penColor.B, (float)0.7);
 
-//     fontColorA(0,0,0,1);
+       fontColor(view->fontset->fonts[view->fontset->activefont],0,0,0,view->penColor.A / (float) log((double) v->degree) *
+                      (float) -0.4 * (float) view->zoom);
        fontDrawString(view->fontset->fonts[view->fontset->activefont],(v->distorted_x - ddx),
                        (v->distorted_y - ddy),  (fs * strlen(v->Label)*(float)0.6),v->Label   );
 
index aa3d989b244e30eb79e6a28dfb6a89fad8101a2b..92a0c96c78222dbef661dade2b6ccbdb6a0869e1 100755 (executable)
@@ -70,7 +70,7 @@ void clear_viewport(ViewInfo * view)
     free(view);
 }
 
-static char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g)
+char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g)
 {
     char *buf;
     buf = agget(g, attr);
index fc653bf6e0aee821b78257057eef8d1aec989d55..1bde76cf74823b38ca27a320b0c7c697828e1b58 100644 (file)
@@ -184,8 +184,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "lib\libpng\1.2.24
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gvplugin_gdiplus", "plugin\gdiplus\gvplugin_gdiplus.vcproj", "{0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otk", "lib\otk_lib\otk.vcproj", "{343EB043-1F93-4F40-989D-FA309E4668AF}"
-EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -396,10 +394,6 @@ Global
                {0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}.Debug|Win32.Build.0 = Debug|Win32
                {0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}.Release|Win32.ActiveCfg = Release|Win32
                {0F4D5D8F-F4D6-4A5D-97E0-9B482257F493}.Release|Win32.Build.0 = Release|Win32
-               {343EB043-1F93-4F40-989D-FA309E4668AF}.Debug|Win32.ActiveCfg = Debug|Win32
-               {343EB043-1F93-4F40-989D-FA309E4668AF}.Debug|Win32.Build.0 = Debug|Win32
-               {343EB043-1F93-4F40-989D-FA309E4668AF}.Release|Win32.ActiveCfg = Release|Win32
-               {343EB043-1F93-4F40-989D-FA309E4668AF}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index d3df3064396c413188d3ccf380b59353a2cbd600..1c51218c09fe140c8f73a235798233cfc10ac5ac 100755 (executable)
-/* vim:set shiftwidth=4 ts=8: */
-/*
-    glTexFont Library R6
-
-    Copyright (c) 1999 Nate Miller
-    
-    Notice: Usage of any code in this file is subject to the rules
-    described in the LICENSE.TXT file included in this directory.
-    Reading, compiling, or otherwise using this code constitutes
-    automatic acceptance of the rules in said text file.
-
-    File        -- glTexFont.c
-    Date        -- 5/30/99
-    Author      -- Nate 'm|d' Miller
-    Contact     -- vandals1@home.com
-    Web         -- http://members.home.com/vandals1
-*/
-//#define FONT_LIB_DEBUG /* un-comment for debug regions */
 #include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
 #include "glpangofont.h"
 #include "memory.h"
 
-/* just a global for our default colors */
-float white[] = {1.0, 1.0, 1.0, 1.0};
-float gray[] = {0.5, 0.5, 0.5, 1.0};
-
-
-/*
-    tPoints contains our map for the font image.  After fontMakeMap this array
-    will contain all the information to get the proper key from the font map.
-*/
 vec2_t tPoints[257]; 
 
-/*
-=============
-fontLoad
-
-Load the passed image name and use it for the font.  
-=============
-*/
-int fontLoad (texFont_t* font,char *name)
-{
-    glGenTextures (1, &(font->texId));
-
-       font->blockRow = FONT_BLOCK_ROW;
-       font->blockCol = FONT_BLOCK_COL;
-
-       fontMakeMap (font);
-
-//    return fontLoadTGA (name, font.texId);
-    return fontLoadPNG ("c:\\pango_test.png", font->texId);
 
-}
-/*
-=============
-fontLoadEx
-
-Loads the passed image which has 'col' characters per column and 'row' 
-characters per row. 
-=============
-*/
-int fontLoadEx (texFont_t* font,char *name, int row, int col)
+int glCompLoadFont (glCompText* font,char *name)
 {
-    /* make sure we have valid dimensions */
-/*     if (row * col != 256)
-               return 0;*/
-
     glGenTextures (1, &(font->texId));
-
-       font->blockRow = row;
-       font->blockCol = col;
-
        fontMakeMap (font);
+    return glCompLoadFontPNG ("c:\\pango_test.png", font->texId);
 
-    return fontLoadTGA (name, font->texId);
 }
-/*
-=============
-fontDrawChar
-
-Draws a character that is 'size' pixels in w and h.  
-=============
-*/
-void fontDrawChar (texFont_t* font,char c, GLfloat x, GLfloat y, GLfloat size, int shadow)
-{
-       if (!font->gradient && !shadow)
-        glColor4fv (font->fgColor);
-    else if (!font->gradient && shadow)
-        glColor4fv (font->bgColor);
-    else if (font->gradient && !shadow)
-        glColor4fv (font->gdColor);
-
-    glBegin (GL_QUADS);
-               glTexCoord2f (tPoints[(int)c][0], tPoints[(int)c][1]);
-               glVertex3f (x, y,0);
 
-       glTexCoord2f (tPoints[(int)c][0] + font->tIncX, tPoints[(int)c][1]);
-               glVertex3f (x + size, y,0);
-
-        if (!shadow)
-            glColor4fv (font->fgColor);
-        else glColor4fv (font->bgColor);
-
-        glTexCoord2f (tPoints[(int)c][0] + font->tIncX, tPoints[(int)c][1] + font->tIncY);
-               glVertex3f (x + size + font->italic, y + size,0);
 
-        glTexCoord2f (tPoints[(int)c][0], tPoints[(int)c][1] + font->tIncY);
-               glVertex3f (x + font->italic, y + size,0);
-       glEnd ();
-}
-/*
-=============
-fontScissorNormal
-
-Normal scissor region for text rendering.  
-=============
-*/
-void fontScissorNormal (texFont_t* font,int xpos, int ypos, int tabs, int carrage, int size, int len)
+void fontForeColorReset (glCompText* font)
 {
-    int sy;
-    int ex;
-    int ey;
-
-    ex = len * size * tabs;
-
-    if (carrage)
-       {
-               sy = ypos - (size * carrage);
-               ey = size * (carrage + 1);
-       } else {
-               sy = ypos;
-               ey = size;
-       }
-    glScissor (xpos, sy, ex, ey);
-}
-/*
-=============
 
-=============
-fontFgColorReset
-
-Resets the font color.
-=============
-*/
-void fontForeColorReset (texFont_t* font)
-{
-    fontColorCopy (white, font->fgColor);
-}
-/*
-=============
-fontBgColorReset
+       font->color.R=1.00;
+       font->color.G=1.00;
+       font->color.B=1.00;
+       font->color.A=1.00;
 
-Resets the shadow color.
-=============
-*/
-void fontShadowColorReset (texFont_t* font)
-{
-    fontColorCopy (gray, font->bgColor);
-}
-/*
-=============
-fontGdColorReset
 
-Resets the gradient color.
-=============
-*/
-void fontGradientColorReset (texFont_t* font)
-{
-    fontColorCopy (gray, font->gdColor);
 }
-/*
-=============
-fontReset
-
-Resets the font.  Only resets variables that could possible change.
-=============
-*/
-void fontReset (texFont_t* font)
+void fontReset (glCompText* font)
 {
-    font->size = 12;
-    font->shadow = 0;
-    font->region = 0;
-    font->gradient = 0;
-    font->italic = 0;
-    font->bold = 0;
-    font->regionX = 0;
-    font->regionY = 0;
-    font->regionW = 0;
-    font->regionH = 0;
+    font->fontheight = 12;
     fontForeColorReset (font);
-    fontShadowColorReset (font);
-    fontGradientColorReset (font);
-}
-/*
-=============
-fontRegion
-
-Sets up a font region.  Only good for one fontDrawString. 
-=============
-*/
-void fontRegion (texFont_t* font,float x, float y, float w, float h)
-{
-    font->region = 1;
-    font->regionX = x;
-    font->regionY = y - h;
-    font->regionW = w;
-    font->regionH = h;
 }
-/*
-=============
-fontSize
-
-Sets the font size.
-=============
-*/
-void fontSize (texFont_t* font,GLfloat size)
+void fontSize (glCompText* font,GLfloat size)
 {
-    font->size = size;
+    font->fontheight = size;
 }
-void fontzdepth(texFont_t* font,GLfloat zdepth)
+void fontzdepth(glCompText* font,GLfloat zdepth)
 {
        font->zdepth=zdepth;
 }
-/*
-=============
-fontShadow
-
-Draws a shadow if called.
-=============
-*/
-void fontShadow (texFont_t* font)
-{
-    font->shadow = 1;
-}
-/*
-=============
-fontGradient
-
-Draws gradient text if called.
-=============
-*/
-void fontGradient (texFont_t* font)
-{
-    font->gradient = 1;
-}
-/*
-=============
-fontRenderChar
-
-Draws a character to the screen
-Bold is just a hack, nothing special
-=============
-*/
-void fontRenderChar (texFont_t* font,char c, GLfloat x, GLfloat y, GLfloat size)
-{
-    if (font->shadow)
-    {
-        if (!font->bold)
-               fontDrawChar (font,c, x + (GLfloat)1.0,  y + (GLfloat)1.0, size, 1);
-        else fontDrawChar (font,c, x + (GLfloat)2.0,  y + (GLfloat)1.0, size, 1);
-    }
-    
-
-
-       fontDrawChar (font,c, x, y, size, 0);
-
-       if (font->bold)
-        fontDrawChar (font,c, x + (GLfloat)1.0, y, size, 0);
-}
-/*
-=============
-fontSlashParser
-
-Handles all the fun that comes with a \\, returns amount to advance string.
-After this funtion *buffptr ++ will be the next character to draw or parse.
-=============
-*/
-int fontSlashParser (texFont_t* font,char *buffPtr, GLfloat *x, GLfloat *y)
-{
-    int ret = 0;
-
-    *buffPtr ++;
-
-    if (!*buffPtr)
-        return ret;
-
-    switch (*buffPtr)
-    {
-        case 'a':
-        case 'c':
-            *x -= font->size;
-            return fontSetColorFromToken (font,buffPtr);
-        break;
-        case 'i':
-            *x -= font->size;
-            return fontItalicsMode (font,buffPtr);
-        break;
-        case 'b':
-            *x -= font->size;
-            return fontBoldMode (font,buffPtr);
-        break;
-        default:
-            *buffPtr --;
-            fontRenderChar (font,*buffPtr, *x, *y, font->size);
-            return ret;
-        break;
-    }
-}
-/*
-=============
-fontWalkString
-
-Does the actual rendering of our string.  
-=============
-*/
-void fontWalkString (texFont_t* font,char *buffPtr, GLfloat xpos, GLfloat ypos, int *vPort,float width)
+void fontWalkString (glCompText* font,char *bf, GLfloat xpos, GLfloat ypos, int *vPort,float width)
 {
-    GLfloat size = font->size;
+       GLfloat size = font->fontheight;
        GLfloat x = xpos;
        GLfloat y = ypos;
        GLfloat carrage = 0;
@@ -330,30 +51,16 @@ void fontWalkString (texFont_t* font,char *buffPtr, GLfloat xpos, GLfloat ypos,
        GLfloat charGap;
        xMax = vPort[0] + vPort[2];
 
-    carrage = (GLfloat) fontGetCharHits (buffPtr, '\n');
-       tabs = (GLfloat) fontGetCharHits (buffPtr, '\t');
+    carrage = (GLfloat) fontGetCharHits (bf, '\n');
+       tabs = (GLfloat) fontGetCharHits (bf, '\t');
 
        if (!tabs)
                tabs = 1;
        else tabs *= FONT_TAB_SPACE;
-
-/*    if (font.region)
-    {
-        fontScissorTextRegion ();
-        x = font.regionX;
-        y = (font.regionY + font.regionH) - font.size;
-    } else 
-       fontScissorNormal (xpos, ypos, tabs, carrage, font.size, len); */
-
-#ifdef FONT_LIB_DEBUG
-    glClearColor (1,0,1,1);
-    glClear (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
-#endif
-
     /* lets draw! */
        //width for each char should be calculated , we need the max line length of the paragraph
 
-       tempC=buffPtr;
+       tempC=bf;
        charCount=0;
        maxcharCount=0;
 
@@ -380,52 +87,24 @@ void fontWalkString (texFont_t* font,char *buffPtr, GLfloat xpos, GLfloat ypos,
        charGap=(width / (float)maxcharCount);
 
 
-       for ( ; *buffPtr; *buffPtr ++, x += charGap) //size*0.7 is the distance between2 characters
+       for ( ; *bf; *bf ++, x += charGap) //size*0.7 is the distance between2 characters
        {
-       //      if (x > xMax)
-       //              break;
-    /*    if (font.region)
-        {
-            if (x + size > (font.regionX + font.regionW))
-            {
-                y -= size;
-                x = font.regionX;
-            }
-            if (y < font.regionY)
-                break;
-        }*/
 
+           glBegin (GL_QUADS);
+               glTexCoord2f (tPoints[(int)(*bf)][0], tPoints[(int)(*bf)][1]);
+               glVertex3f (x, y,0);
 
+       glTexCoord2f (tPoints[(int)(*bf)][0] + font->tIncX, tPoints[(int)(*bf)][1]);
+               glVertex3f (x + size, y,0);
 
-/*
-               if(*buffPtr==' ')               //SPACE
-                       x = x + size;*/
+               glColor4f (font->color.R,font->color.G,font->color.B,font->color.A);
 
-               switch (*buffPtr)
-               {
+        glTexCoord2f (tPoints[(int)(*bf)][0] + font->tIncX, tPoints[(int)(*bf)][1] + font->tIncY);
+               glVertex3f (x + size, y + size,0);
 
-               
-                       case '\n':
-                               y -= size;
-                x = xpos - size;
-                               continue; 
-                       break;
-                       case '\t':
-                               x += (size * FONT_TAB_SPACE);
-                               continue; 
-                       break;
-            case '\\':
-                buffPtr += fontSlashParser (font,buffPtr, &x, &y);
-                if (*buffPtr == '\n' || *buffPtr == '\t')
-                {
-                    buffPtr -= 1;
-                    continue;
-                }
-            break;
-            default :
-                fontRenderChar (font,*buffPtr, x, y, size);
-            break;
-               }
+        glTexCoord2f (tPoints[(int)(*bf)][0], tPoints[(int)(*bf)][1] + font->tIncY);
+               glVertex3f (x , y + size,0);
+               glEnd ();
        }
 }
 /*
@@ -436,21 +115,10 @@ Renders a string at xpos, ypos.
 =============
 */
 void 
-fontDrawString (texFont_t* font, GLfloat xpos, GLfloat ypos, 
-    GLfloat width, char *s, ...)
+fontDrawString (glCompText* font, GLfloat xpos, GLfloat ypos, 
+    GLfloat width, char *s)
 {
-       va_list msg;
-    char buffer[FONT_MAX_LEN] = {'\0'};
     int vPort[4];
-       
-       va_start (msg, s);
-#ifdef _WIN32
-       _vsntprintf (buffer, FONT_MAX_LEN - 1, s, msg); 
-#else /* not Windows */
-       vsnprintf (buffer, FONT_MAX_LEN - 1, s, msg);   
-#endif
-       va_end (msg);
-
     /* get current viewport */
     glGetIntegerv (GL_VIEWPORT, vPort);
     /* setup various opengl things that we need */
@@ -471,7 +139,7 @@ fontDrawString (texFont_t* font, GLfloat xpos, GLfloat ypos,
     /* draw the string */
 
 
-       fontWalkString (font,buffer, xpos, ypos, vPort,(float)width);
+       fontWalkString (font,s, xpos, ypos, vPort,(float)width);
        
 /*     glMatrixMode (GL_PROJECTION);
        glPopMatrix ();
@@ -483,75 +151,6 @@ fontDrawString (texFont_t* font, GLfloat xpos, GLfloat ypos,
 }
 /*
 =============
-fontSetColorFromToken
-
-Grabs a color token from a buffer and sets color.  
-=============
-*/     
-int fontSetColorFromToken (texFont_t* font,char *s)
-{
-       int clr[4];
-       int ret = 1;
-
-       if (*s == 'c')
-       {
-               s += 1;
-               if (sscanf (s, "(%d %d %d)", &clr[0], &clr[1], &clr[2]) != 3)
-                       return -1;
-               fontColor (font,clr[0] * FONT_ITOF, clr[1] * FONT_ITOF, clr[2] * FONT_ITOF);
-       } else if (*s == 'a')
-       {
-               s += 1;
-               if (sscanf (s, "(%d %d %d %d)", &clr[0], &clr[1], &clr[2], &clr[3]) != 4)
-                       return -1;
-               fontColorA (font,clr[0] * FONT_ITOF, clr[1] * FONT_ITOF, clr[2] * FONT_ITOF, clr[3] * FONT_ITOF);
-       }
-
-       while (*s != ')' && ret ++)
-               s += 1;
-
-    return ret + 1;
-}
-/*
-=============
-fontItalicsMode
-
-Either turns on or off italics.
-=============
-*/     
-int fontItalicsMode (texFont_t* font,char *s)
-{
-    s += 1;
-
-    if (*s == '+')
-        font->italic = FONT_ITALIC;
-    else if (*s == '-')
-        font->italic = 0;
-    else return -1;
-
-    return 2;
-}
-/*
-=============
-fontBoldMode
-
-Either turns on or off bold.
-=============
-*/     
-int fontBoldMode (texFont_t* font,char *s)
-{
-    s += 1;
-
-    if (*s == '+')
-        font->bold = 1;
-    else if (*s == '-')
-        font->bold = 0;
-    else return -1;
-
-    return 2;
-}
-/*
-=============
 fontGetCharHits
 
 Returns number of times a character is found in a buffer.
@@ -577,15 +176,15 @@ fontMakeMap
 Makes the font map which allows the correct characters to be drawn.
 =============
 */
-void fontMakeMap (texFont_t* font)
+void fontMakeMap (glCompText* font)
 {
 #define VCOPY(d,x,y) {d[0] = x; d[1] = y;}
        int i = 0;
        float x, y;
 
 
-       font->tIncX = (float)pow (font->blockCol, -1);
-       font->tIncY = (float)pow (font->blockRow, -1);
+       font->tIncX = (float)pow (C_DPI, -1);
+       font->tIncY = (float)pow (R_DPI, -1);
 
        
        for (y = 1 - font->tIncY; y >= 0; y -= font->tIncY)
@@ -695,33 +294,21 @@ static int fontId(fontset_t* fontset,char* fontdesc)
        }
        return -1;
 }
-/*
-       load font via font description
-       returns the id,
-       if font already exists no malloc just returns the id
-*/
 
-texFont_t* font_init()
+
+glCompText* font_init()
 {
-    texFont_t* font = NEW(texFont_t);
-
-       font->fgColor[0]=1.0;font->fgColor[1]=1.0;font->fgColor[2]=1.0;font->fgColor[3]=1.0;
-       font->gdColor[0]=0.5;font->gdColor[1]=0.5;font->gdColor[2]=0.5;font->gdColor[3]=1.0;
-       font->bgColor[0]=0.5;font->bgColor[1]=0.5;font->bgColor[2]=0.5;font->bgColor[3]=1.0;
-       font->size=12;
-       font->shadow=0;
-       font->gradient=0;
-       font->italic=0;
-       font->bold=0;
-       font->region=0;
-       font->regionX=0;
-       font->regionY=0;
-       font->regionW=0;
-       font->regionH=0;
+    glCompText* font = NEW(glCompText);
+
+       font->color.R=1.00;
+       font->color.G=1.00;
+       font->color.B=1.00;
+       font->color.A=1.00;
+
+
+       font->fontheight=12;
        font->tIncX=0.0;
        font->tIncY=0.0;
-       font->blockRow=FONT_BLOCK_ROW;
-       font->blockCol=FONT_BLOCK_COL;
        font->texId=-1;
        font->fontdesc=(char*)0;
 
@@ -730,34 +317,18 @@ texFont_t* font_init()
     return font;
 }
 
-void copy_font(texFont_t* targetfont,const texFont_t* sourcefont)
+void copy_font(glCompText* targetfont,const glCompText* sourcefont)
 {
-       targetfont->fgColor[0]=sourcefont->fgColor[0];
-       targetfont->fgColor[1]=sourcefont->fgColor[1];
-       targetfont->fgColor[2]=sourcefont->fgColor[2];
-       targetfont->fgColor[3]=sourcefont->fgColor[3];
-       targetfont->gdColor[0]=sourcefont->gdColor[0];
-       targetfont->gdColor[1]=sourcefont->gdColor[1];
-       targetfont->gdColor[2]=sourcefont->gdColor[2];
-       targetfont->gdColor[3]=sourcefont->gdColor[3];
-       targetfont->bgColor[0]=sourcefont->bgColor[0];
-       targetfont->bgColor[1]=sourcefont->bgColor[1];
-       targetfont->bgColor[2]=sourcefont->bgColor[2];
-       targetfont->bgColor[3]=sourcefont->bgColor[3];
-       targetfont->size=sourcefont->size;
-       targetfont->shadow=sourcefont->shadow;
-       targetfont->gradient=sourcefont->gradient;
-       targetfont->italic=sourcefont->italic;
-       targetfont->bold=sourcefont->bold;
-       targetfont->region=sourcefont->region;
-       targetfont->regionX=sourcefont->regionX;
-       targetfont->regionY=sourcefont->regionY;
-       targetfont->regionW=sourcefont->regionW;
-       targetfont->regionH=sourcefont->regionH;
+       targetfont->color.R=sourcefont->color.R;
+       targetfont->color.G=sourcefont->color.G;
+       targetfont->color.B=sourcefont->color.B;
+       targetfont->color.A=sourcefont->color.A;
+
+
+
+       targetfont->fontheight=sourcefont->fontheight;
        targetfont->tIncX=sourcefont->tIncX;
        targetfont->tIncY=sourcefont->tIncY;
-       targetfont->blockRow=sourcefont->blockRow;
-       targetfont->blockCol=sourcefont->blockCol;
        targetfont->texId=sourcefont->texId;
        if (targetfont->fontdesc)
                free(targetfont->fontdesc);
@@ -794,7 +365,7 @@ int add_font(fontset_t* fontset,char* fontdesc)
 {
     int id;    
     size_t sz;
-    texFont_t* tf;
+    glCompText* tf;
 
     id=fontId(fontset,fontdesc);
 
@@ -806,11 +377,11 @@ int add_font(fontset_t* fontset,char* fontdesc)
         }
        sprintf(fontpath,"%s/%s.png",fontset->font_directory,fontdesc);
        if(create_font_file(fontdesc,fontpath,(float)32,(float)32)==0) {
-           fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,texFont_t*);
+           fontset->fonts = ALLOC(fontset->count+1,fontset->fonts,glCompText*);
            fontset->fonts[fontset->count] = tf = font_init ();
            tf->fontdesc = strdup(fontdesc);
            glGenTextures (1, &(tf->texId));    //get  opengl texture name
-           if ((tf->texId >= 0) && fontLoadPNG (fontpath, tf->texId)) {
+           if ((tf->texId >= 0) && glCompLoadFontPNG (fontpath, tf->texId)) {
                fontset->activefont=fontset->count;
                fontset->count++;
                return fontset->count;
@@ -846,3 +417,12 @@ void free_font_set(fontset_t* fontset)
     free(fontset);
 }
 
+void fontColor (glCompText* font,float r, float g, float b,float a)
+{
+
+       
+       font->color.R=r;
+       font->color.G=g;
+       font->color.B=b;
+       font->color.A=a;
+}
index 8d257d8f1365b84be4a0bc5d287682470cb4cd2c..f666e6d1044af16ad57a06e37fe0ed4ff6967029 100755 (executable)
@@ -1,19 +1,5 @@
-/*
-    Copyright (c) 1999 Nate Miller
-    
-    Notice: Usage of any code in this file is subject to the rules
-    described in the LICENSE.TXT file included in this directory.
-    Reading, compiling, or otherwise using this code constitutes
-    automatic acceptance of the rules in said text file.
-
-    File        -- glTexFont.h
-    Date        -- 5/30/99
-    Author      -- Nate 'm|d' Miller
-    Contact     -- vandals1@home.com
-    Web         -- http://members.home.com/vandals1
-*/
-#ifndef __GLTEXFONTH__
-#define __GLTEXFONTH__
+#ifndef GLCOMPTEXT_H
+#define GLTEXFONTH_H
 
 #include <stdlib.h>
 #include <string.h>
@@ -26,13 +12,6 @@ typedef float GLfloat;
 #endif
 #include "glcompdefs.h"
 
-/* Error Codes */
-#define FONT_FILE_NOT_FOUND          -13 /* file was not found */
-#define FONT_BAD_IMAGE_TYPE          -14 /* color mapped image or image is not uncompressed */
-#define FONT_BAD_DIMENSION           -15 /* dimension is not a power of 2 */
-#define FONT_BAD_BITS                -16 /* image bits is not 8, 24 or 32 */
-#define FONT_BAD_DATA                -17 /* image data could not be loaded */
-#define GL_TEX_FONT_VERSION          6
 
 #ifndef vec2_t
 typedef float vec2_t[2];
@@ -42,112 +21,27 @@ typedef float vec2_t[2];
 #ifdef __cplusplus
 extern "C" {
 #endif
-/*
-       check if font is already loaded
-       if loaded returns the id
-       else returns -1
-*/
-/* int fontId(fontset_t* fontset,char* fontdesc); */
-
-/*
-       Initialize fontset as an empty set
-*/
-
 extern fontset_t* fontset_init(void);
-
 void free_font_set(fontset_t* fontset);
-void copy_font(texFont_t* targetfont,const texFont_t* sourcefont);
-/*
-       load font via font description
-       returns the id,
-       if font already exists no malloc just returns the id
-*/
+void copy_font(glCompText* targetfont,const glCompText* sourcefont);
 int add_font(fontset_t* fontset,char* fontdesc);
-       
-/*
-=============
-fontLoad
-
-Loads up out font from the passed image file name.  
-=============
-*/
-int fontLoad (texFont_t* font,char *name);
-/*
-=============
-fontLoadEx
-    
-Same as above but it loads a custom font map with row chars per row and col
-chars per column.  
-=============
-*/
-int fontLoadEx (texFont_t* font,char *name, int row, int col);
-/*
-=============
-fontDrawString
-
-Draws a string at (xpos, ypos) in the applications window.
-=============
-*/
-void fontDrawString (texFont_t*, GLfloat , GLfloat , GLfloat, char*, ...);
-/*
-=============
-fontRegion
-
-Sets up a font region.  Upper left corner is described by (xpos, ypos).
-The region is w units wide and h units tall.  
-=============
-*/
-void fontRegion (texFont_t* font,float xpos, float ypos, float w, float h);
-/*
-=============
-fontSize 
-
-Sets the font size.
-=============
-*/
-void fontSize (texFont_t* font,GLfloat size);
-
-
-void fontzdepth(texFont_t* font,float zdepth);
-
-/*
-=============
-fontShadow
-
-Draws shadowed text.
-=============
-*/
-void fontShadow (texFont_t* font);
-/*
-=============
-fontGradient
-
-Draws gradient text. 
-=============
-*/
-void fontGradient (texFont_t* font);
-/*
-=============
-fontColor*, fontShadowColor*, fonrGradientColor*
-
-
-Sets color for various operations. 
-=============
-*/
-
-texFont_t* font_init(void);
-void fontColor (texFont_t* font,float r, float g, float b);
-void fontColorA (texFont_t* font,float r, float g, float b, float a);
-void fontColorp (texFont_t* font,float *clr);
-void fontColorAp (texFont_t* font,float *clr);
-void fontShadowColor (texFont_t* font,float r, float g, float b);
-void fontShadowColorA (texFont_t* font,float r, float g, float b, float a);
-void fontShadowColorp (texFont_t* font,float *clr);
-void fontShadowColorAp (texFont_t* font,float *clr);
-void fontGradientColor (texFont_t* font,float r, float g, float b);
-void fontGradientColorA (texFont_t* font,float r, float g, float b, float a);
-void fontGradientColorp (texFont_t* font,float *clr);
-void fontGradientColorAp (texFont_t* font,float *clr);
+int glCompLoadFont (glCompText* font,char *name);
+void fontDrawString (glCompText*, GLfloat , GLfloat , GLfloat, char*);
+void fontSize (glCompText* font,GLfloat size);
+void fontzdepth(glCompText* font,float zdepth);
+glCompText* font_init(void);
+void fontColor (glCompText* font,float r, float g, float b,float a);
+
+void fontDrawChar (glCompText*,char, GLfloat, GLfloat, GLfloat);
+void fontScissorNormal (glCompText* font,int xpos, int ypos, int tabs, int carrage, int size, int len);
+int fontSetColorFromToken (glCompText* font,char *s);
+int fontGetCharHits (char *s, char f);
+void fontMakeMap (glCompText* font);
+void fontSetModes (int state);
+void fontReset (glCompText* font);
+int fontItalicsMode (glCompText* font,char *s);
+int fontBoldMode (glCompText* font,char *s);
+void fontRenderChar (glCompText* font,char c, GLfloat x, GLfloat y, GLfloat size);
 #ifdef __cplusplus
 }
 #endif
index 15f9898b0dbe94574afa2a28940f0ac3c37ad0ae..6a0d70bc9e98af6837f4c9254aeb7666ce47a6c5 100644 (file)
                                RelativePath=".\glTexFont.h"
                                >
                        </File>
-                       <File
-                               RelativePath=".\glTexFontDefs.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\glTexFontInclude.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\glTexFontTGA.h"
-                               >
-                       </File>
                        <File
                                RelativePath=".\glutils.h"
                                >
                                RelativePath=".\glcompset.c"
                                >
                        </File>
+                       <File
+                               RelativePath=".\glcomptextpng.c"
+                               >
+                       </File>
                        <File
                                RelativePath=".\glcomptexture.c"
                                >
                                RelativePath=".\glTexFont.c"
                                >
                        </File>
-                       <File
-                               RelativePath=".\glTexFontColor.c"
-                               >
-                       </File>
-                       <File
-                               RelativePath=".\glTexFontTGA.c"
-                               >
-                       </File>
                        <File
                                RelativePath=".\glutils.c"
                                >
index 36396d16993d6f0ddc1a2bec38bfb8d895d1fbd7..dea3d3df82751c48ea60b33b7e766808b11757d7 100644 (file)
@@ -184,7 +184,7 @@ int glCompDrawButton(glCompButton * p)
             p->fontsize) / (GLfloat) 2.0 + p->pos.y + p->thickness;
        fontSize(p->font,p->fontsize);
 //              fontColorA (p->fontcolor.R,p->fontcolor.B,p->fontcolor.G,p->fontcolor.A);
-       fontColorA(p->font,0, 0, 0, 1);
+       fontColor(p->font,0, 0, 0, 1);
        fontDrawString(p->font,(GLfloat) fontx, (GLfloat) fonty,
                        (p->fontsize *(GLfloat) strlen(p->caption) *
                              GLCOMPSET_FONT_SIZE_FACTOR), p->caption);
index 826273a7fa3c6e8fae7c219cab83262c27b36820..c38e5b0e6a1e1b04569f7d646fcf0934e25fff63 100644 (file)
@@ -1,9 +1,17 @@
 #ifndef GLCOMPDEFS_H
 #define GLCOMPDEFS_H
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
 #ifdef _WIN32
-#include "windows.h"
+#include <windows.h>
+#include <winuser.h>
+#include <tchar.h>
 #endif
+#include <GL/gl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <GL/gl.h>
 #define        GLCOMPSET_BEVEL_DIFF                            (GLfloat)0.001
 #define GLCOMPSET_DEFAULT_PAD          (GLfloat)3
 
+#define FONT_GET_MODES              1 
+#define FONT_RESTORE_MODES          2 
+#define FONT_MAX_LEN                1024 /* maximum chars to draw to the screen, used for buffers also */
+#define FONT_TAB_SPACE              4    /* spaces to draw for a tab, make option? */
+#define FONT_ITOF                   (float) pow (255, -1)
+#define FONT_ITALIC                 8    /* italic amount in pixels */
+#define fontColorCopy(a,b)          {b[0]= a[0]; b[1]= a[1]; b[2]= a[2]; b[3]= a[3];} /* copys colors */
+
+#define C_DPI              16
+#define R_DPI              16
+
+
 typedef void (*callbackfunc_t) (void *component);
 typedef enum { inverted_y,scientific_y} glCompOrientation;
 
@@ -62,32 +82,21 @@ typedef struct {
 } glCompTexture;
 typedef struct
 {
-    float fgColor[4];   /* foreground color, default white */
-    float gdColor[4];   /* gradient color, default gray */
-    float bgColor[4];   /* background color, default gray */
-    float size;           /* size of text, default 12 */
-    int shadow;         /* shadow text? default 0 */
-    int gradient;       /* gradient? default 0 */
-    int italic;         /* italic amount, defaul 0 */
-    int bold;           /* bold text? */
-    int region;         /* do we have a text region */
-    float regionX;        /* lower left x */
-    float regionY;        /* lower left y */
-    float regionW;        /* text region w */
-    float regionH;        /* text region h */
+       char* fontdesc; //font description
+       glCompColor color;
+    float fontheight;           /* size of text, default 12 */
     float tIncX;        /* used for texture coords, x axis amount to move */
     float tIncY;        /* used for texture coords, y axis amount to move */
     int blockRow;       /* characters per row */
     int blockCol;       /* characters per col */
-    unsigned int texId; /* texture id */
+    int texId; /* texture id */
        float zdepth;   //third dimension , depth of fonts
-       char* fontdesc; //font description
-} texFont_t;
+} glCompText;
 
 
 typedef struct
 {
-       texFont_t** fonts;
+       glCompText** fonts;
        int count;
        int activefont;
        char* font_directory;   //location where the glfont files are stored
@@ -109,7 +118,7 @@ typedef struct _glCompPanel {
     int visible;
     void *parentset;           //parent compset
     int data;
-    texFont_t* font;   //pointer to font to use
+    glCompText* font;  //pointer to font to use
        glCompOrientation orientation;
 
 } glCompPanel;
@@ -131,7 +140,7 @@ typedef struct _glCompTrackBar {
     int visible;
     void *parentset;           //parent compset
     int data;
-    texFont_t* font;   //pointer to font to use
+    glCompText* font;  //pointer to font to use
        glCompOrientation orientation;
 
 }glCompTrackBar;
@@ -144,7 +153,7 @@ typedef struct _glCompLabel {
     char *text;
     GLfloat fontsizefactor;
     glCompPanel *panel;                //container panel
-    texFont_t* font;   //pointer to font to use
+    glCompText* font;  //pointer to font to use
        glCompOrientation orientation;
 
 } glCompLabel;
@@ -171,7 +180,7 @@ typedef struct _glCompButton {
     callbackfunc_t callbackfunc;       //call back for button click
     void *customptr;           //general purpose void pointer to pass to call back
     int data;
-    texFont_t* font;   //pointer to font to use
+    glCompText* font;  //pointer to font to use
        glCompOrientation orientation;
 
 } glCompButton;
@@ -187,7 +196,7 @@ typedef struct {
     int active;                        //0 dont draw, 1 draw
     int enabled;               //0 disabled 1 enabled(allow mouse interaction)
     GLfloat clickedX, clickedY;
-    texFont_t* font;   //pointer to font to use
+    glCompText* font;  //pointer to font to use
 } glCompSet;
 
 #endif
index af23f9fd6a82b090c7d8801931f95fe95a640fb9..ef22c074302d837acd6e812d5d005be12670def7 100644 (file)
@@ -65,7 +65,7 @@ int glCompDrawLabel(glCompLabel * p)
        }
 
        fontSize(p->font, p->size);
-       fontColorA(p->font,p->color.R, p->color.G, p->color.B, p->color.A);
+       fontColor(p->font,p->color.R, p->color.G, p->color.B, p->color.A);
 
        fontDrawString(p->font, p->pos.x,  p->pos.y,
                        (p->size * p->fontsizefactor *
index d9c5eb433c7c6cf0ac91625d538ccca436720678..17166d00e92a7cade113854aea92933431267faf 100644 (file)
@@ -20,9 +20,7 @@
 #define GLCOMPSET_H
 
 #include "glTexFont.h"
-#include "glTexFontTGA.h"
-#include "glTexFontDefs.h"
-#include "glTexFontInclude.h"
+#include "glcomptextpng.h"
 #include "glcomptexture.h"
 
 
index 19eb14085ea8124cb2a78795b12258c16644f818..5cbf359d8e74633e8d8fe6a90554c74bc5625533 100755 (executable)
@@ -41,6 +41,13 @@ struct GraphicsContext
 
 static const int BYTES_PER_PIXEL = 4;          /* bytes per pixel */
 
+#define ADD_ATTR(a) \
+  if (a) { \
+        strcat(buf, comma ? " " : ", "); \
+        comma = 1; \
+        strcat(buf, a); \
+  }
+
 extern void SaveBitmapToStream(Gdiplus::Bitmap &bitmap, IStream *stream, int format);
 
 #endif
index b880abf06e4d8d7e798ff54682899dc0bf0b0843..a2b486c9aeeaccfba5d1f0ff3e04a7d55f52c623 100755 (executable)
@@ -34,6 +34,22 @@ extern "C" size_t gvwrite(GVJ_t *job, const unsigned char *s, unsigned int len);
 using namespace std;
 using namespace Gdiplus;
 
+
+
+static char* gdiplus_psfontResolve (PostscriptAlias* pa)
+{
+    static char buf[1024];
+    int comma=0;
+    strcpy(buf, pa->family);
+
+    ADD_ATTR(pa->weight);
+    ADD_ATTR(pa->stretch);
+    ADD_ATTR(pa->style);
+   
+    return buf;
+}
+
+
 /* Graphics for internal use, so that we can record image etc. for subsequent retrieval off the job struct */
 struct ImageGraphics: public Graphics
 {
@@ -186,13 +202,31 @@ static auto_ptr<Font> find_font(char *fontname, double fontsize)
                return auto_ptr<Font>(new Font(reference.hdc, &found_font));
        }
        else
-               return auto_ptr<Font>(new Font(FontFamily::GenericSerif(), fontsize));
+       {
+               strncpy(font_to_find.lfFaceName,"Times New Roman", sizeof(font_to_find.lfFaceName) - 1);
+               font_to_find.lfFaceName[sizeof(font_to_find.lfFaceName) - 1] = '\0';
+               font_to_find.lfPitchAndFamily = 0;
+               if(EnumFontFamiliesExA(reference.hdc,
+                       &font_to_find,
+                               fetch_first_font,
+                               (LPARAM)&found_font,
+               0) == 0) 
+               {
+                       found_font.lfHeight = (LONG)-fontsize;
+                       found_font.lfWidth = 0;
+                       return auto_ptr<Font>(new Font(reference.hdc, &found_font));
+               }
+
+       }
+//     "gdiplus cannot find the default font Times New Roman."
+       return NULL;
 }
 
 static void gdiplusgen_textpara(GVJ_t *job, pointf p, textpara_t *para)
 {
        /* convert incoming UTF8 string to wide chars */
        /* NOTE: conversion is 1 or more UTF8 chars to 1 wide char */
+       char* fontname;
        int wide_count = MultiByteToWideChar(CP_UTF8, 0, para->str, -1, NULL, 0);
        if (wide_count > 1) {
                vector<WCHAR> wide_str(wide_count);
@@ -224,7 +258,15 @@ static void gdiplusgen_textpara(GVJ_t *job, pointf p, textpara_t *para)
                Gdiplus::Font* a=find_font(para->fontname, para->fontsize).get();
                /* draw the text */
                SolidBrush brush(Color(job->obj->pencolor.u.rgba [3], job->obj->pencolor.u.rgba [0], job->obj->pencolor.u.rgba [1], job->obj->pencolor.u.rgba [2]));
-               context->DrawString(&wide_str.front(), wide_count - 1, find_font(para->fontname, para->fontsize).get(), PointF(0, -center), &brush);
+
+
+#ifdef HAVE_GD_FONTCONFIG
+    if (para->postscript_alias)
+               fontname = para->postscript_alias->family;
+    else
+#endif
+       fontname = para->fontname;
+               context->DrawString(&wide_str.front(), wide_count - 1, find_font(fontname, para->fontsize).get(), PointF(0, -center), &brush);
                context->Restore(saved);
        }
 }