From: arif Date: Tue, 13 Jul 2010 15:33:24 +0000 (+0000) Subject: xdot images X-Git-Tag: LAST_LIBGRAPH~32^2~1279 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67e311e44d5fa995b7e8ab8eed502c141f994f32;p=graphviz xdot images --- diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index ed31616d9..07003d2d4 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -31,6 +31,8 @@ XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else #include "appmouse.h" #include "hotkeymap.h" #include "polytess.h" +#include "glcompimage.h" + //delta values static float dx = 0.0; @@ -426,22 +428,24 @@ void InsertImage(sdot_op * o, int param) { - float w,h,x,y; + float w,h,x,y,X,Y,Z; + glCompImage *i; + if(!o->obj) return; - w=atof(agget(o->obj,"width"))*72; - h=atof(agget(o->obj,"height"))*72; if(!o->iData.data) + { o->iData.data = load_png(o->op.u.image.name, &o->iData.w, &o->iData.h); - x=o->op.u.image.pos.x; - y=o->op.u.image.pos.y; - x=x+(o->iData.w-w)/2.0; - y=y+(o->iData.h-h)/2.0; - // glRasterPos3f(x,y,5); - glRasterPos3f(20,20,0); - if(o->iData.data) - glDrawPixels(o->iData.w,o->iData.h,GL_RGBA,GL_UNSIGNED_BYTE,o->iData.data); + x=o->op.u.image.pos.x; + y=o->op.u.image.pos.y; + i = glCompImageNew(NULL, x, y); + glCompImageLoadPng(i, o->op.u.image.name,0); + i->common.functions.draw(i); + + } + + } void EmbedText(sdot_op* o, int param) { diff --git a/cmd/smyrna/gui/glcompui.c b/cmd/smyrna/gui/glcompui.c index cc9c74ed4..d46d7765b 100644 --- a/cmd/smyrna/gui/glcompui.c +++ b/cmd/smyrna/gui/glcompui.c @@ -381,18 +381,16 @@ glCompSet *glcreate_gl_topview_menu(void) p->shadowwidth = 0; i = glCompImageNew((glCompObj *) p, 0, 0); - glCompImageLoadPng(i, smyrnaPath("mod_fisheye.png")); + glCompImageLoadPng(i, smyrnaPath("mod_fisheye.png"),1); imgFisheye = i; i->common.visible = 0; i = glCompImageNew((glCompObj *) p, 0, 52); - glCompImageLoadPng(i, smyrnaPath("mod_3D.png")); + glCompImageLoadPng(i, smyrnaPath("mod_3D.png"),1); img3D = i; i->common.visible = 0; -/* l=glCompLabelNew((glCompObj *)s,100,5,view->Topview->Graphdata.GraphFileName); - glCompLabelSetFontSize(l,24);*/ + -// testContainer(s); return s; diff --git a/cmd/smyrna/smyrna.vcproj b/cmd/smyrna/smyrna.vcproj index 73e3df3c4..4ba47dd11 100644 --- a/cmd/smyrna/smyrna.vcproj +++ b/cmd/smyrna/smyrna.vcproj @@ -336,18 +336,10 @@ RelativePath=".\draw.c" > - - - - @@ -440,10 +432,6 @@ RelativePath=".\smyrna_utils.c" > - - diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index 3bf2607b8..dfdb79522 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -2,7 +2,7 @@ image = glCompImageNew((glCompObj *) b, 0, 0); - rv = glCompImageLoadPng(b->image, fileName); + rv = glCompImageLoadPng(b->image, fileName,1); if (rv) { b->image->common.anchor.leftAnchor = 1; b->image->common.anchor.left = 0; diff --git a/lib/glcomp/glcompimage.c b/lib/glcomp/glcompimage.c index 4525258f1..c0d06df22 100644 --- a/lib/glcomp/glcompimage.c +++ b/lib/glcomp/glcompimage.c @@ -49,13 +49,13 @@ void glCompImageDelete(glCompImage * p) extern unsigned char *load_png(char *file_name, int *imageWidth, int *imageHeight); int glCompImageLoad(glCompImage * i, unsigned char *data, int width, - int height) + int height,int is2D) { if (data != NULL) { /*valid image data */ glCompDeleteTexture(i->texture); i->texture = glCompSetAddNewTexImage(i->common.compset, width, height, data, - 1); + is2D); if (i->texture) { i->common.width = width; i->common.height = height; @@ -68,26 +68,26 @@ int glCompImageLoad(glCompImage * i, unsigned char *data, int width, -int glCompImageLoadPng(glCompImage * i, char *pngFile) +int glCompImageLoadPng(glCompImage * i, char *pngFile,int is2D) { int imageWidth, imageHeight; unsigned char *data; data = load_png(pngFile, &imageWidth, &imageHeight); - return glCompImageLoad(i, data, imageWidth, imageHeight); + return glCompImageLoad(i, data, imageWidth, imageHeight,is2D); } -int glCompImageLoadRaw(glCompSet * s, glCompImage * i, char *rawFile) +int glCompImageLoadRaw(glCompSet * s, glCompImage * i, char *rawFile,int is2D) { int imageWidth, imageHeight; unsigned char *data; data = load_png(rawFile, &imageWidth, &imageHeight); - return glCompImageLoad(i, data, imageWidth, imageHeight); + return glCompImageLoad(i, data, imageWidth, imageHeight,is2D); } void glCompImageDraw(void *obj) { glCompImage *p; static glCompCommon ref; -// static GLfloat w,h,d; + static GLfloat w,h,d; p = (glCompImage *) obj; ref = p->common; glCompCalcWidget((glCompCommon *) p->common.parent, &p->common, &ref); @@ -96,15 +96,18 @@ void glCompImageDraw(void *obj) if (!p->texture) return; - glRasterPos2f(ref.pos.x, ref.pos.y); -// glPixelZoom(2,2); - glDrawPixels(p->texture->width, p->texture->height, GL_RGBA, - GL_UNSIGNED_BYTE, p->texture->data); + if(p->texture->id <=0) + { + glRasterPos2f(ref.pos.x, ref.pos.y); + glDrawPixels(p->texture->width, p->texture->height, GL_RGBA,GL_UNSIGNED_BYTE, p->texture->data); + } + else + { -/* w=ref.width; + w=ref.width; h=ref.height; d=(GLfloat)p->common.layer* (GLfloat)GLCOMPSET_BEVEL_DIFF; - glDisable(GL_BLEND); + glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBindTexture(GL_TEXTURE_2D,p->texture->id); @@ -115,8 +118,10 @@ void glCompImageDraw(void *obj) glTexCoord2d(0.0f, 0.0f);glVertex3d(ref.pos.x,ref.pos.y+h,d); glEnd(); + glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND);*/ + glEnable(GL_BLEND); + } } diff --git a/lib/glcomp/glcompimage.h b/lib/glcomp/glcompimage.h index cf3d533e9..5d54d040c 100644 --- a/lib/glcomp/glcompimage.h +++ b/lib/glcomp/glcompimage.h @@ -26,8 +26,8 @@ extern "C" { GLfloat y); extern void glCompImageDelete(glCompImage * p); extern int glCompImageLoad(glCompImage * i, unsigned char *data, - int width, int height); - extern int glCompImageLoadPng(glCompImage * i, char *pngFile); + int width, int height,int is2D); + extern int glCompImageLoadPng(glCompImage * i, char *pngFile,int is2D); extern void glCompImageDraw(void *obj); extern void glCompImageClick(glCompObj * o, GLfloat x, GLfloat y, glMouseButtonType t); diff --git a/lib/glcomp/glcomptexture.c b/lib/glcomp/glcomptexture.c index fc24a06a4..cc57e2824 100644 --- a/lib/glcomp/glcomptexture.c +++ b/lib/glcomp/glcomptexture.c @@ -78,10 +78,13 @@ static glCompTex *glCompSetAddNewTexture(glCompSet * s, int width, t->userCount = 1; t->width = (GLfloat) width; t->height = (GLfloat) height; - s->textureCount++; - s->textures = + if(s) + { + s->textureCount++; + s->textures = realloc(s->textures, s->textureCount * sizeof(glCompTex *)); - s->textures[s->textureCount - 1] = t; + s->textures[s->textureCount - 1] = t; + } return t; diff --git a/lib/glcomp/glutils.c b/lib/glcomp/glutils.c index 10b185a82..9a06781b1 100644 --- a/lib/glcomp/glutils.c +++ b/lib/glcomp/glutils.c @@ -506,6 +506,12 @@ void glCompCalcWidget(glCompCommon * parent, glCompCommon * child, GLfloat borderWidth; ref->height = child->height; ref->width = child->width; + if(!parent) + { + child->refPos.x = child->pos.x; + child->refPos.y = child->pos.y; + return; + } if (parent->borderType == glBorderNone) borderWidth = 0; else