// drawRotatingTools();
// draw_cube();
drawRotatingAxis();
- draw_selpoly(&view->Topview->selPoly);
+ draw_selpoly(&view->Topview->sel.selPoly);
// draw_stuff();
// test_color_pallete();
// drawtestpoly();
appmouse_middle_drag(view,(int)event->x,(int)event->y);
redraw = TRUE;
}
- if(view->Topview->selPoly.cnt > 0)
+ if(view->Topview->sel.selPoly.cnt > 0)
redraw=TRUE;
if(a==MM_POLYGON_SELECT)
{
- add_selpoly(view->g[view->activeGraph],&view->Topview->selPoly,view->mouse.GLfinalPos);
+ add_selpoly(view->g[view->activeGraph],&view->Topview->sel.selPoly,view->mouse.GLfinalPos);
}
int action=get_key_action(v,key);
if(lastAction==MM_POLYGON_SELECT)
{
- clear_selpoly(&view->Topview->selPoly);
+ clear_selpoly(&view->Topview->sel.selPoly);
glexpose();
}
v->keymap.down=0;
glexpose();
}
}
+void selectedges(glCompObj *obj, GLfloat x, GLfloat y)
+{
+ if(view->Topview->sel.selectEdges==0)
+ view->Topview->sel.selectEdges=1;
+ else
+ view->Topview->sel.selectEdges=0;
+
+}
+void selectnodes(glCompObj *obj, GLfloat x, GLfloat y)
+{
+ if(view->Topview->sel.selectNodes==0)
+ view->Topview->sel.selectNodes=1;
+ else
+ view->Topview->sel.selectNodes=0;
+
+}
glCompSet *glcreate_gl_topview_menu(void)
glCompButtonHide(b);
to2DBtn = b;
+ y=y+off;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "N");
+ b->common.callbacks.click = selectnodes;
+ b->groupid=-1;
+ b->status=1;
+
+ y=y+off;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "E");
+ b->common.callbacks.click = selectedges;
+ b->groupid=-1;
- p = glCompPanelNew((glCompObj *) p, 25, 0, 52, 110);
+ p = glCompPanelNew((glCompObj *) p, 25, 0, 52, 110);
p->common.align = glAlignTop;
p->common.data = 0;
p->common.color.A = 0;
for (v = agfstnode(g); v; v = agnxtnode(g, v))
{
- posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A;
- if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1))
- select_node(g,v,0);
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
+ if(view->Topview->sel.selectNodes==1)
{
- posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail;
- posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead;
- if(is_point_in_rectangle(posT.x,posT.y,x1,y1,x2-x1,y2-y1))
- if(is_point_in_rectangle(posH.x,posH.y,x1,y1,x2-x1,y2-y1))
- select_edge(g,e,0);
+ posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A;
+ if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1))
+ select_node(g,v,0);
}
+ if(view->Topview->sel.selectEdges==1)
+ for (e = agfstout(g, v); e; e = agnxtout(g, e))
+ {
+ posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail;
+ posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead;
+ if(is_point_in_rectangle(posT.x,posT.y,x1,y1,x2-x1,y2-y1))
+ if(is_point_in_rectangle(posH.x,posH.y,x1,y1,x2-x1,y2-y1))
+ select_edge(g,e,0);
+ }
}
}
int TVref; //topview data structure reference
} temp_node_record;
-/*#define OD_ID(p) (((custom_object_data*)AGDATA(p))->ID)
-#define OD_ObjName(p) (((custom_object_data*)AGDATA(p))->ObjName)
-#define OD_ObjType(p) (((custom_object_data*)AGDATA(p))->ObjType)
-#define OD_Layer(p) (((custom_object_data*)AGDATA(p))->Layer)
-#define OD_Visible(p) (p->data.Visible)
-#define OD_Locked(p) (((custom_object_data*)AGDATA(p))->Locked)
-#define OD_Highlighted(p) (((custom_object_data*)AGDATA(p))->Highlighted)
-#define OD_NumDataCount(p) (((custom_object_data*)AGDATA(p))->NumDataCount)
-#define OD_NumData(p) (((custom_object_data*)AGDATA(p))->NumData)
-#define OD_StrDataCount(p) (((custom_object_data*)AGDATA(p))->StrDataCount)
-#define OD_StrData(p) (((custom_object_data*)AGDATA(p))->StrData)
-#define OD_Selected(p) (((custom_object_data*)AGDATA(p))->Selected)
-#define OD_Preselected(p) (((custom_object_data*)AGDATA(p))->Preselected)
-#define OD_SelFlag(p) (((custom_object_data*)AGDATA(p))->selectionflag)
-#define OD_TVRef(p) (((custom_object_data*)AGDATA(p))->TVRef)*/
-
#define OD_Visible(p) (p.data.Visible)
#define OD_Locked(p) (p.data.Locked)
#define OD_Highlighted(p) (p.data.Highlighted)
int printLabel;
}edgeRec;
+ typedef struct _selection {
+ glCompPoly selPoly;
+ int selectNodes;
+ int selectEdges;
+ } selection;
typedef struct {
topview_node *Nodes;
topviewcache cache;
int xdotId;
- glCompPoly selPoly;
-
-
-
+ selection sel;
+
} topview;
} attribute;
-/* typedef struct _selection {
- int Active; //0 there is no selection need to be applied
- char Type; //0 single selection , 1 rectangle , 2 rectangleX
- int PickingType; //0 normal, union,2 subtract 3 intersection
- float X, Y, W, H; //selection boundries
- int Anti; //subtract selections if 1
- int AlreadySelected; //for single selections to avoid selecting more than one object
- glCompColor SelectionColor;
- float node_distance; //to get the closest node , this value is updated for each node, distance between selection coords and node coords, smallest gets to be selected
- topview_node *single_selected_node; //pointer to selected node in a single node/edge selection cycle,after each node loop this value is checked and if it is in the limits that node is selected or deselected
- //before the node/edge loop this value is nulled
- topview_edge *single_selected_edge; //pointer to selected/picked edge
-
- } selection;*/
typedef struct _magnifier {
float x, y;
float kts; //zoom X
t->picked_edge_count = 0;
t->picked_edges = '\0';
t->global_z=0;
- t->selPoly.cnt=0;
- t->selPoly.pts=NULL;
+ t->sel.selPoly.cnt=0;
+ t->sel.selPoly.pts=NULL;
if(!t)
return ;
{
topview* rv=(topview*)malloc(sizeof(topview));
rv->maxnodedegree = 1;
+
/*create glcomp menu system */
view->widgets = glcreate_gl_topview_menu();
rv->cache.selnode_id=-1;
rv->cache.edge_id=-1;
rv->cache.seledge_id=-1;
+ rv->sel.selectEdges=0;
+ rv->sel.selectNodes=1;
+
updateSmGraph(g,rv);
return rv;
}
glCompObj *obj;
glCompSet *s = o->common.compset;
int ind = 0;
- if (p->groupid > 0) {
+ ((glCompButton *) o)->status=((glCompButton *) o)->refStatus ;
+ if (p->groupid > 0)
+ {
for (; ind < s->objcnt; ind++) {
obj = s->obj[ind];
- if (obj->objType == glButtonObj) {
+ if ((obj->objType == glButtonObj)&&(obj!=o)) {
if (((glCompButton *) obj)->groupid == p->groupid)
((glCompButton *) obj)->status = 0;
}
}
p->status = 1;
- } else {
+ }
+ else {
if (p->groupid == -1) {
if (p->status == 0)
p->status = 1;
{
/*Put your internal code here */
+
+ ((glCompButton *) obj)->refStatus = ((glCompButton *) obj)->status;
((glCompButton *) obj)->status = 1;
if (((glCompButton *) obj)->common.callbacks.mousedown)
((glCompButton *) obj)->common.callbacks.mousedown(obj, x, y, t);
glMouseButtonType t)
{
/*Put your internal code here */
+
if (((glCompButton *) obj)->common.callbacks.mouseup)
((glCompButton *) obj)->common.callbacks.mouseup(obj, x, y, t);
}
GLfloat width, height;
glCompLabel *label;
int status; //0 not pressed 1 pressed;
+ int refStatus; //0 not pressed 1 pressed;
int groupid;
glCompImage *image; /*glyph */
glCompButtonGlyph glyphPos;
}
/*bitmap base 2D text rendering */
+static void change_fontC(unsigned char* d,int w,int h,glCompColor* c)
+{
+ int size=w*h*4;
+ int ind=0;
+ for (ind;ind <=size; ind=ind+4)
+ {
+ if(d[ind+3] != 0)
+ {
+ d[ind]=c->R*255;
+ d[ind+1]=c->G*255;
+ d[ind+2]=c->B*255;
+ d[ind+3]=c->A*255;
+ }
+ }
+}
+
+
void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y)
{
+ change_fontC(f->tex->data,f->tex->width,f->tex->height,&f->color);
glRasterPos2f(x, y);
- glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE,
- f->tex->data);
+ glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE, f->tex->data);
}
/*text rendering functions, depends on a globject to retrieve stats*/
h = f->tex->height;
ref = parentObj->common;
z = ref.pos.z;
- switch (f->justify.HJustify) {
+ switch (f->justify.HJustify)
+ {
case glFontHJustifyNone:
case glFontHJustifyLeft:
x = ref.refPos.x;