[Dda-cvs] ntdda/src/win32gui drawdialog.c, 1.9, 1.10 jointdialog.c, 1.1, 1.2
Status: Beta
Brought to you by:
doolin
From: David M. D. <do...@us...> - 2006-11-25 17:11:38
|
Update of /cvsroot/dda/ntdda/src/win32gui In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv6303/src/win32gui Modified Files: drawdialog.c jointdialog.c Log Message: Added rooz latest patch for joint drawing. Index: jointdialog.c =================================================================== RCS file: /cvsroot/dda/ntdda/src/win32gui/jointdialog.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** jointdialog.c 1 Aug 2006 06:16:28 -0000 1.1 --- jointdialog.c 25 Nov 2006 17:11:28 -0000 1.2 *************** *** 1,4 **** ! ! /** ! * Refactor joint dialog code here. ! */ \ No newline at end of file --- 1,67 ---- ! #define STRICT ! #include<windows.h> ! #include"resource.h" ! #include "drawdialog.h" ! //#include "joint.h" ! #include"math.h" ! ! //#include "winmain.h" ! ! #ifdef __cplusplus ! extern "C" { ! #endif ! #if 0 ! } ! #endif ! ! ! extern addJoint (hDlg); ! ! // Added by Roozbeh to Draw a Joint using dialog box ! BOOL CALLBACK ! JointDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ! { ! extern POINT ptBegin, ptNew, ptOld; ! extern int type; ! extern double ScaleX, ScaleY; ! extern int maxSize; ! extern JOINTLIST *jointlist; ! ! switch (message) { ! case WM_INITDIALOG: ! ! SetDlgItemInt (hDlg, IDC_X1, 0, FALSE); ! SetDlgItemInt (hDlg, IDC_Y1, 0, FALSE); ! SetDlgItemInt (hDlg, IDC_X2, 10, FALSE); ! SetDlgItemInt (hDlg, IDC_Y2, 10, FALSE); ! SetDlgItemInt (hDlg, IDC_TYPE, 1, FALSE); ! ! return TRUE; ! ! case WM_COMMAND: ! switch (LOWORD (wParam)) { ! ! case IDOK: ! ! // Make this a function call with a descriptive name. ! ptBegin.x = GetDlgItemInt (hDlg, IDC_X1, NULL, TRUE); ! ptBegin.y = GetDlgItemInt (hDlg, IDC_Y1, NULL, TRUE); ! ptNew.x = GetDlgItemInt (hDlg, IDC_X2, NULL, TRUE); ! ptNew.y = GetDlgItemInt (hDlg, IDC_Y2, NULL, TRUE); ! type = GetDlgItemInt (hDlg, IDC_TYPE, NULL, TRUE); ! ptBegin.x = (long) floor (ptBegin.x / (ScaleX / maxSize)); ! ptBegin.y = (long) floor (ptBegin.y / (ScaleY / maxSize)); ! ptNew.x = (long) floor (ptNew.x / (ScaleX / maxSize)); ! ptNew.y = (long) floor (ptNew.y / (ScaleY / maxSize)); ! ! addJoint (hDlg); ! ! return FALSE; ! case IDCANCEL: ! EndDialog (hDlg, 0); ! return TRUE; ! } ! break; ! } ! return FALSE; ! } \ No newline at end of file Index: drawdialog.c =================================================================== RCS file: /cvsroot/dda/ntdda/src/win32gui/drawdialog.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** drawdialog.c 1 Aug 2006 06:16:28 -0000 1.9 --- drawdialog.c 25 Nov 2006 17:11:28 -0000 1.10 *************** *** 1,21 **** /* File contains functions to handle the creation and editing ! * of geometry files for DDA. ! * ! * Overall behavior: ! * ! * 1. At the moment, the dialog will save and write to a file ! * any created geometry. This geometry is not passed by either ! * pointer to geometry struct or by file name to the calling * program. */ ! ! /** ! * TODO list: ! * ! * 1. Object scaling needs to be handled on object creation, and ! * the current object scale needs to be stored to allow rescaling. ! * ! * ! */ #include <math.h> --- 1,21 ---- /* File contains functions to handle the creation and editing ! * of geometry files for DDA. ! * ! * Overall behavior: ! * ! * 1. At the moment, the dialog will save and write to a file ! * any created geometry. This geometry is not passed by either ! * pointer to geometry struct or by file name to the calling * program. */ ! ! /** ! * TODO list: ! * ! * 1. Object scaling needs to be handled on object creation, and ! * the current object scale needs to be stored to allow rescaling. ! * ! * ! */ #include <math.h> *************** *** 33,47 **** #pragma warning( disable : 4115 ) #endif ! ! // Unnecessary. Prototypes are used by the compiler ! // for type checking. In this case, each of these ! // callbacks is defined before being invoked, rendering // the prototype unnecessary. - //Added by Roozbeh - //BOOL CALLBACK JointDlgProc (HWND, UINT, WPARAM, LPARAM); - //BOOL CALLBACK TunnelDlgProc (HWND, UINT, WPARAM, LPARAM); - //BOOL CALLBACK ArcDlgProc (HWND, UINT, WPARAM, LPARAM); - //BOOL CALLBACK BlockDlgProc (HWND, UINT, WPARAM, LPARAM); - //Added by Roozbeh static HINSTANCE hInstance; --- 33,41 ---- #pragma warning( disable : 4115 ) #endif ! ! // Unnecessary. Prototypes are used by the compiler ! // for type checking. In this case, each of these ! // callbacks is defined before being invoked, rendering // the prototype unnecessary. static HINSTANCE hInstance; *************** *** 81,99 **** /* FIXME: Describe function of these two scale variables. */ ! static double ScaleX, ScaleY; static int ScaledX, ScaledY; /* These are typed doubly-linked lists. See drawdialog.h, * ddadlist.c and ddadlist.c */ ! static JOINTLIST *jointlist; static POINTLIST *pointlist; static Boltlist *boltlist; ! static POINT ptBegin, ptNew, ptOld; static enum TOOLTYPE tool; ! static int type = 1, inside = 0; ! static int radius, maxSize; static HPEN hCurrentPen; static HBRUSH hCurrentBr; --- 75,95 ---- /* FIXME: Describe function of these two scale variables. */ ! double ScaleX, ScaleY; static int ScaledX, ScaledY; /* These are typed doubly-linked lists. See drawdialog.h, * ddadlist.c and ddadlist.c */ ! JOINTLIST *jointlist; static POINTLIST *pointlist; static Boltlist *boltlist; ! POINT ptBegin, ptNew, ptOld; static enum TOOLTYPE tool; ! int type = 1; ! static int inside = 0; ! static int radius; ! int maxSize; static HPEN hCurrentPen; static HBRUSH hCurrentBr; *************** *** 125,129 **** /* Mouse handling functions */ ! static void addJoint (HWND); static void addPoint (HWND); static void addBolt (HWND); --- 121,125 ---- /* Mouse handling functions */ ! void addJoint (HWND); static void addPoint (HWND); static void addBolt (HWND); *************** *** 208,216 **** - - - - - // Changed some variable names to make this less verbose. static ddaboolean --- 204,207 ---- *************** *** 232,236 **** if ((currentx > endpx2 + eps) || (currentx < endpx1 - eps)) return FALSE; ! } if (endpy1 > endpy2) { --- 223,227 ---- if ((currentx > endpx2 + eps) || (currentx < endpx1 - eps)) return FALSE; ! } if (endpy1 > endpy2) { *************** *** 268,272 **** return 0; } /* close inBoundingBoxEP */ ! static int --- 259,263 ---- return 0; } /* close inBoundingBoxEP */ ! static int *************** *** 314,321 **** } ! ! ! // This routine needs to have an associated ROP ! // to redraw the background color when the object // is deselected. static void //travis --- 305,312 ---- } ! ! ! // This routine needs to have an associated ROP ! // to redraw the background color when the object // is deselected. static void //travis *************** *** 353,357 **** } /* drawBlockBox() */ ! // Need an associated "deselection" function. static void --- 344,348 ---- } /* drawBlockBox() */ ! // Need an associated "deselection" function. static void *************** *** 365,369 **** } ! /** @todo Fix the api to not take the point struct. */ --- 356,360 ---- } ! /** @todo Fix the api to not take the point struct. */ *************** *** 396,407 **** LineTo (hdc, endp2x, endp2y); ! ! // Always use bracing, even around single statement blocks. ! // They tend to grow, reduces blunders. if (jp->is_selected) { ! drawJointHandles (jp); } } ! //Added By Roozbeh --- 387,398 ---- LineTo (hdc, endp2x, endp2y); ! ! // Always use bracing, even around single statement blocks. ! // They tend to grow, reduces blunders. if (jp->is_selected) { ! drawJointHandles (jp); } } ! //Added By Roozbeh *************** *** 419,423 **** } /* close redrawPoints *///Added By Roozbeh ! /* This produces an infinite loop and does not allow the --- 410,414 ---- } /* close redrawPoints *///Added By Roozbeh ! /* This produces an infinite loop and does not allow the *************** *** 474,478 **** } /* close handlePaint() *///Added By Roozbeh ! static void --- 465,469 ---- } /* close handlePaint() *///Added By Roozbeh ! static void *************** *** 537,541 **** } /* close handleMouseDown() */ ! static void --- 528,532 ---- } /* close handleMouseDown() */ ! static void *************** *** 592,598 **** ! ! ! static void addJoint (HWND hDlg) { --- 583,587 ---- ! void addJoint (HWND hDlg) { *************** *** 939,952 **** */ return FALSE; ! } else { ! ! // The following is some ugly shit that shot ! // through the DDA code. Leave it alone for ! // now, handle it later. /* Open file and save data. * If it exists already, delete it. ! */ ! // FIXME: OpenFile is 16 bit win32. This code needs to ! // be changed to use either CreateFile, or better yet, // find a way to use fopen. if (-1 != OpenFile (filepath.gpath, &of, OF_WRITE)) --- 928,941 ---- */ return FALSE; ! } else { ! ! // The following is some ugly shit that shot ! // through the DDA code. Leave it alone for ! // now, handle it later. /* Open file and save data. * If it exists already, delete it. ! */ ! // FIXME: OpenFile is 16 bit win32. This code needs to ! // be changed to use either CreateFile, or better yet, // find a way to use fopen. if (-1 != OpenFile (filepath.gpath, &of, OF_WRITE)) *************** *** 957,984 **** MB_OK | MB_ICONINFORMATION); return 0; ! } ! // We are going to close this here because we want to ! // fopen instead, because it is posix compliant and // CreateFile and OpenFile are MS Windows specific. ! _lclose (hFile); ! ! //////////////////////////////////////////////// ! /// Because we grabbing a new struct here, then deleting /// it afterwards, we can do cooler stuff here. geomstruct = gdata_new (); ! ! // These are all going to go away soon. transferJointlistToGeomStruct (geomstruct, jointlist); ! transferPointlistToGeomStruct (geomstruct, pointlist); transferBoltlistToGeomStruct (geomstruct, boltlist); ! ! // We use fopen for posix compliance and the file pointer // for convenience. ! fp = fopen(filepath.gpath, "w+"); // This call will be replaced shortly. geomstruct->dumptofile(geomstruct, fprintf, fp); ! fclose(fp); gdata_delete (geomstruct); --- 946,973 ---- MB_OK | MB_ICONINFORMATION); return 0; ! } ! // We are going to close this here because we want to ! // fopen instead, because it is posix compliant and // CreateFile and OpenFile are MS Windows specific. ! _lclose (hFile); ! ! //////////////////////////////////////////////// ! /// Because we grabbing a new struct here, then deleting /// it afterwards, we can do cooler stuff here. geomstruct = gdata_new (); ! ! // These are all going to go away soon. transferJointlistToGeomStruct (geomstruct, jointlist); ! transferPointlistToGeomStruct (geomstruct, pointlist); transferBoltlistToGeomStruct (geomstruct, boltlist); ! ! // We use fopen for posix compliance and the file pointer // for convenience. ! fp = fopen(filepath.gpath, "w+"); // This call will be replaced shortly. geomstruct->dumptofile(geomstruct, fprintf, fp); ! fclose(fp); gdata_delete (geomstruct); *************** *** 1098,1102 **** } else { SendMessage (hDlg, WM_COMMAND, DD_GROFF, 0L); ! } } --- 1087,1091 ---- } else { SendMessage (hDlg, WM_COMMAND, DD_GROFF, 0L); ! } } *************** *** 1160,1165 **** ! ! /// Function is scheduled for deletion. void --- 1149,1154 ---- ! ! /// Function is scheduled for deletion. void *************** *** 1169,1174 **** int numjoints; JOINTLIST *ptr; ! Joint *jtmp; ! double jscale = ScaleX/maxSize; /* just in case... */ --- 1158,1163 ---- int numjoints; JOINTLIST *ptr; ! Joint *jtmp; ! double jscale = ScaleX/maxSize; /* just in case... */ *************** *** 1183,1195 **** dlist_traverse (ptr, jointlist) { jtmp = ptr->val; ! ! // Scaling needs to be performed at initialization of each joint. ! // If the geometry is rescaled, that should be handled by traversing ! // the joint list and rescaling as a ratio between old and new scales // for existing joints. New joints go in with the new scale of course. gd->joints[i + 1][1] = jtmp->epx1 * jscale; gd->joints[i + 1][2] = jtmp->epy1 * jscale; gd->joints[i + 1][3] = jtmp->epx2 * jscale; ! gd->joints[i + 1][4] = jtmp->epy2 * jscale; gd->joints[i + 1][5] = jtmp->type; i++; --- 1172,1184 ---- dlist_traverse (ptr, jointlist) { jtmp = ptr->val; ! ! // Scaling needs to be performed at initialization of each joint. ! // If the geometry is rescaled, that should be handled by traversing ! // the joint list and rescaling as a ratio between old and new scales // for existing joints. New joints go in with the new scale of course. gd->joints[i + 1][1] = jtmp->epx1 * jscale; gd->joints[i + 1][2] = jtmp->epy1 * jscale; gd->joints[i + 1][3] = jtmp->epx2 * jscale; ! gd->joints[i + 1][4] = jtmp->epy2 * jscale; gd->joints[i + 1][5] = jtmp->type; i++; *************** *** 1490,1537 **** } /* close handleMouseUp() */ - - // Added by Roozbeh to Draw a Joint using dialog box - BOOL CALLBACK - JointDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) - { - switch (message) { - case WM_INITDIALOG: - - SetDlgItemInt (hDlg, IDC_X1, 0, FALSE); - SetDlgItemInt (hDlg, IDC_Y1, 0, FALSE); - SetDlgItemInt (hDlg, IDC_X2, 10, FALSE); - SetDlgItemInt (hDlg, IDC_Y2, 10, FALSE); - SetDlgItemInt (hDlg, IDC_TYPE, 1, FALSE); - - return TRUE; - - case WM_COMMAND: - switch (LOWORD (wParam)) { - - case IDOK: - - // Make this a function call with a descriptive name. - ptBegin.x = GetDlgItemInt (hDlg, IDC_X1, NULL, TRUE); - ptBegin.y = GetDlgItemInt (hDlg, IDC_Y1, NULL, TRUE); - ptNew.x = GetDlgItemInt (hDlg, IDC_X2, NULL, TRUE); - ptNew.y = GetDlgItemInt (hDlg, IDC_Y2, NULL, TRUE); - type = GetDlgItemInt (hDlg, IDC_TYPE, NULL, TRUE); - ptBegin.x = (long) floor (ptBegin.x / (ScaleX / maxSize)); - ptBegin.y = (long) floor (ptBegin.y / (ScaleY / maxSize)); - ptNew.x = (long) floor (ptNew.x / (ScaleX / maxSize)); - ptNew.y = (long) floor (ptNew.y / (ScaleY / maxSize)); - - addJoint (hDlg); - - return FALSE; - case IDCANCEL: - EndDialog (hDlg, 0); - return TRUE; - } - break; - } - return FALSE; - } - // Added by Roozbeh to Draw a Tuunel using dialog box BOOL CALLBACK --- 1479,1482 ---- *************** *** 1603,1614 **** return FALSE; } ! ! // Added by Roozbeh to Draw a Arc using dialog box ! ! // Refactor all these messages to call functions. ! // Feel free to put them into new files. It will ! // make it easier to maintain in the future. BOOL CALLBACK ArcDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) --- 1548,1559 ---- return FALSE; } ! ! // Added by Roozbeh to Draw a Arc using dialog box ! ! // Refactor all these messages to call functions. ! // Feel free to put them into new files. It will ! // make it easier to maintain in the future. BOOL CALLBACK ArcDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) |