00001
00002
00003
00004
00005
00006
00007
00008 #define MODULE_DESIGN 1
00009
00010 #include "design.h"
00011
00012 #define SIZESTATUS1 195 // 130 //This must also be defined in SETUP.C
00013
00014 #define NFILESLIST 5
00015 #define LASTFILECMD 31000
00016
00017 typedef struct tagLASTFILESLIST{
00018 BOOL present;
00019 char file[256];
00020 } LASTFILESLIST;
00021
00022 static VOID DesignMenuCommand(int,HWND,long);
00023 static void EngageSkeletonTool(int item);
00024 static void EngageDesignerTool(int );
00025 static void ExecuteDesignerAction(int );
00026 static BOOL SetTriViewCursor(BOOL);
00027 static void UpdateLastFilesList(char *);
00028
00029 extern HINSTANCE __cdecl ResourceX(void);
00030
00031 HBITMAP hBmBackground=NULL;
00032
00033 static HWND hWndHelp=NULL;
00034 static BOOL bTrackMouse=FALSE,bTrackIcon=FALSE,bToolCaptured=FALSE,
00035 bSpaceDown=FALSE,bTrackPan=FALSE,bTrackZoom=FALSE,
00036 bCtrlDown=FALSE,bShiftDown=FALSE,bAltDown=FALSE;
00037 static BOOL in_subroutine_mode=FALSE,bResizing=FALSE;
00038 static int ScreenXsize,ScreenYsize;
00039 static UINT screen_ready=0;
00040 static int trap_scroll_cursor=0;
00041 static int tmessage_table[MAXTOOLS]={
00042 IDS_T_NOTOOL, IDS_T_NODETOOL, IDS_T_PAN, IDS_T_INZOOM,
00043 IDS_T_GRABBER,IDS_T_ROTATOR,IDS_T_EXPANDER,IDS_T_PLOTTER,
00044 IDS_T_SHAPER, IDS_T_MAGNETTO, IDS_T_BUILDER, IDS_T_PLOT3D,
00045 IDS_T_PRIMS, IDS_T_SKANIMATE, IDS_T_SELECTOR, IDS_T_DESELECTOR,
00046 IDS_T_SKGRAB, IDS_T_SKADD, IDS_T_SKDELETE, IDS_T_SKSUBDIV,
00047 IDS_T_SKASSIGN, IDS_T_SKSELECT, IDS_T_SKDUPLICATE,IDS_T_SKTWIST,
00048 IDS_T_SKRUBBERBONES,IDS_T_SKRENAME
00049 };
00050 static int lmessage_table[2]={IDS_SWAPSVIEW,IDS_SWAP3VIEW};
00051 static char gszSCEsaved[256]={"unnamed.mfx"};
00052 static LASTFILESLIST LastFilesList[NFILESLIST];
00053 static int nLastFiles=0;
00054
00055 static char WIN32_environment[512];
00056
00057 char *R_GetEnv(char const *aa){
00058 if(GetEnvironmentVariable((LPTSTR)aa,(LPTSTR)WIN32_environment,256) == 0)
00059 return NULL;
00060 return WIN32_environment;
00061 }
00062
00063 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00064 LPSTR lpCmdLine, int nCmdShow){
00065 BOOL bMsg;
00066 int i;
00067 MSG msg;
00068 HWND hWndPrev;
00069 HMODULE hLibSpin;
00070 HANDLE hAccel,hNewAccel;
00071 #include "..\timeout.c"
00072 hWndPrev = FindWindow(szMainClass, NULL);
00073 if (hWndPrev != NULL){
00074 SetForegroundWindow(hWndPrev);
00075 BringWindowToTop(hWndPrev);
00076 ShowWindow (hWndPrev,SW_SHOW);
00077 return FALSE;
00078 }
00079
00080 {
00081 FILE *fini=NULL; int ix;
00082 GetModuleFileName(hInstance,IniFilename,256);
00083 *FileInPath(IniFilename) = '\0';
00084 strcpy(TempPath,IniFilename);
00085 strcat(IniFilename,"OPENFX_.CFG");
00086 if((fini=fopen(IniFilename,"r")) != NULL){
00087 fscanf(fini,"%ld",&ix);
00088 strcpy(TempPath,"X");
00089 fscanf(fini," %[^\n]",TempPath);
00090 if(ix > 1){
00091 fscanf(fini," %[^\n]",IniFilename);
00092 }
00093 else *FileInPath(IniFilename) = '\0';
00094 fclose(fini);
00095 }
00096 else {
00097 char *pE;
00098 pE=R_GetEnv("TEMP");
00099 if(pE != NULL){
00100 strcpy(TempPath,pE); strcat(TempPath,"\\");
00101 strcpy(IniFilename,TempPath);
00102 *FileInPath(TempPath) = '\0';
00103 }
00104 *FileInPath(IniFilename) = '\0';
00105 }
00106 strcat(IniFilename,"OPENFX_.INI");
00107 }
00108
00109 hInstance=ResourceX();
00110 InitCommonControls();
00111 debug=NULL;
00112
00113 strcpy(ruler_name,"None");
00114 ghdc_triview_Bitmap[0]=ghdc_triview_Bitmap[1]=
00115 ghdc_triview_Bitmap[2]=ghdc_view_Bitmap=NULL;
00116 ghbm_triview[0]=ghbm_triview[1]=ghbm_triview[2]=ghbm_view=NULL;
00117 gCurTool=gCurCommand=gCurSelect=gCurZoom=gCurAction
00118 =gCurCoord=gCurLock=-1;
00119 if(!hPrevInstance){
00120 WNDCLASS wc;
00121 BOOL rc;
00122 if((ghpaletteScreen=CreateAppPalette(&ScreenXsize,&ScreenYsize)) == NULL)
00123 return FALSE;
00124 wc.lpszClassName = szMainClass;
00125 wc.style = CS_HREDRAW | CS_VREDRAW;
00126 wc.lpfnWndProc = (WNDPROC)MainModelerWndProc;
00127 wc.cbClsExtra = 0;
00128 wc.cbWndExtra = 0;
00129 wc.hInstance = hInstance;
00130 wc.hIcon = LoadIcon(hInstance,"MODELERICON");
00131 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00132 wc.hbrBackground = NULL;
00133 wc.lpszMenuName = MAKEINTRESOURCE(MODELER_MENU);
00134 rc = RegisterClass( &wc );
00135 if(!rc)return FALSE;
00136 wc.lpszClassName = szTriViewClass;
00137 wc.style = CS_DBLCLKS;
00138 wc.lpfnWndProc = (WNDPROC)ModelerTriViewWndProc;
00139 wc.cbClsExtra = 0;
00140 wc.cbWndExtra = 0;
00141 wc.hInstance = hInstance;
00142 wc.hIcon = NULL;
00143 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00144 wc.hbrBackground = NULL;
00145 wc.lpszMenuName = NULL;
00146 rc = RegisterClass( &wc );
00147 if(!rc)return FALSE;
00148 wc.lpszClassName = szViewClass;
00149 wc.style = 0;
00150 wc.lpfnWndProc = (WNDPROC)ModelerViewWndProc;
00151 wc.cbClsExtra = 0;
00152 wc.cbWndExtra = 0;
00153 wc.hInstance = hInstance;
00154 wc.hIcon = NULL;
00155 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
00156 wc.hbrBackground = NULL;
00157 wc.lpszMenuName = NULL;
00158 rc = RegisterClass( &wc );
00159 if(!rc)return FALSE;
00160 wc.lpszClassName = szToolboxClass;
00161 wc.style = 0;
00162 wc.lpfnWndProc = (WNDPROC)ToolboxWndProc;
00163 wc.cbClsExtra = 0;
00164 wc.cbWndExtra = 0;
00165 wc.hInstance = hInstance;
00166 wc.hIcon = NULL;
00167 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00168 wc.hbrBackground = NULL;
00169 wc.lpszMenuName = NULL;
00170 if(!RegisterClass(&wc))return FALSE;
00171 wc.lpszClassName = szToolBtnClass;
00172 wc.style = CS_DBLCLKS;
00173 wc.lpfnWndProc = (WNDPROC)ToolBtnWndProc;
00174 wc.cbClsExtra = 0;
00175 wc.cbWndExtra = 0;
00176 wc.hInstance = hInstance;
00177 wc.hIcon = NULL;
00178 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00179 wc.hbrBackground = NULL;
00180 wc.lpszMenuName = NULL;
00181 if(!RegisterClass(&wc))return FALSE;
00182 }
00183 if((hLibSpin=LoadLibrary("spin.dll")) == NULL){
00184 MessageBox (NULL,"SPIN.DLL",NULL,
00185 MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
00186 return FALSE;
00187 }
00188 ghinst_main=hInstance;
00189 LoadPreferences();
00190 LoadArrowIcons();
00191
00192 if(!SetupMainWindow(ghinst_main,nCmdShow))return FALSE;
00193 ActivatePreferences();
00194 if(!DesignStartup(&screen_ready))return FALSE;
00195 if(setjmp(j_buf) != 0){
00196 MessageBox (NULL,"Fatal ERROR", NULL, MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
00197 return 0;
00198 }
00199 hAccel=LoadAccelerators(ghinst_main,MAKEINTRESOURCE(MODELER_ACCEL));
00200 if(hAccel == NULL){
00201 MessageBox (NULL,"No accelerator table", NULL, MB_OK|MB_ICONEXCLAMATION|
00202 MB_TASKMODAL);
00203 return 0;
00204 }
00205 hNewAccel=hAccel;
00206 ghwndOpenGLview=NULL;
00207 StartOpenGL(TRUE);
00208 PostMessage(ghwnd_main,WM_COMMAND,IDM_WINDOW_SHOWALL,0);
00209 if(GetCommandLine() != NULL){
00210 long l,X__argc=0;
00211 char *cp,*cp1,cmdl[256];
00212 strcpy(cmdl,GetCommandLine());
00213 AnsiLower(cmdl);
00214 if((cp=strstr(cmdl,".exe")) != NULL){
00215 if((cp=strchr(cp,' ')) != NULL){
00216 cp++;
00217 if((cp1=strchr(cp,'"')) != NULL)cp=cp1+1;
00218 if((cp1=strchr(cp,'"')) != NULL)*cp1=0;
00219 l=strlen(cp);
00220 X__argc=2;
00221 if(l < 2)X__argc=0;
00222 }
00223 else X__argc=0;
00224 }
00225 else X__argc=0;
00226 if(X__argc > 1){
00227
00228 WritePrivateProfileString("CALLBACK","FILE",cp,IniFilename);
00229 PostMessage(ghwnd_main,WM_COMMAND,IDM_FILE_LOAD_DIRECT,0);
00230 }
00231 }
00232 while (GetMessage(&msg,NULL,0,0)){
00233 bMsg=TRUE;
00234 if(!IsWindow(ghwndCoord1) || !IsDialogMessage(ghwndCoord1,&msg)){
00235 if(!IsWindow(ghwndDlgAttribs) || !IsAttribDlgMessage(ghwndDlgAttribs,&msg)){
00236 if(!IsWindow(ghwndDlgExpand) || !IsDialogMessage(ghwndDlgExpand,&msg)){
00237 if(!IsWindow(ghwndDlgPrimitives) || !IsPrimitivesDialogMessage(&msg)){
00238 if(!IsWindow(ghwndSkEdit) || !IsDialogMessage(ghwndSkEdit,&msg)){
00239 if(!IsWindow(ghwndSkToolbar) || !IsDialogMessage(ghwndSkToolbar,&msg)){
00240 if(!IsWindow(hWndHelp) || !IsDialogMessage(hWndHelp,&msg)){
00241 if(!TranslateAccelerator(ghwnd_main,hNewAccel,&msg)){
00242 TranslateMessage(&msg);
00243 DispatchMessage(&msg);
00244 }
00245 }
00246 }
00247 }
00248 }
00249 }
00250 }
00251 }
00252 }
00253 if(debug != NULL)fclose(debug);
00254 DesignShutdown();
00255 FreeLibrary(hLibSpin);
00256 return (msg.wParam);
00257 }
00258
00259
00260
00261 LRESULT CALLBACK MainModelerWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00262 LPARAM lparam ){
00263 static BOOL bCaptured=FALSE;
00264 static int last_x,last_y,type=0;
00265 static RECT rc;
00266 BOOL flag;
00267 int i,x,y,ltype;
00268 switch( msg ){
00269 case WM_CREATE:{
00270 HMENU hmenu=GetMenu(hwnd);
00271 #if __DEMO__
00272 EnableMenuItem(hmenu,IDM_FILE_SAVE_ALL,MF_GRAYED);
00273 EnableMenuItem(hmenu,IDM_FILE_SAVE_OBJECT,MF_GRAYED);
00274 EnableMenuItem(hmenu,IDM_FILE_SAVE_NAMED,MF_GRAYED);
00275 EnableMenuItem(hmenu,IDM_FILE_SAVE_LETTERS,MF_GRAYED);
00276 EnableMenuItem(hmenu,IDM_FILE_SAVE_PATH,MF_GRAYED);
00277 EnableMenuItem(hmenu,IDM_FILE_IMPORT_TDD,MF_GRAYED);
00278 EnableMenuItem(hmenu,IDM_FILE_IMPORT_SCN,MF_GRAYED);
00279 EnableMenuItem(hmenu,IDM_FILE_PRINT,MF_GRAYED);
00280 EnableMenuItem(hmenu,IDM_FILE_BEZIER,MF_GRAYED);
00281 EnableMenuItem(hmenu,IDM_FILE_HEIGHT,MF_GRAYED);
00282 EnableMenuItem(hmenu,IDM_FILE_TRACEOUTLINE,MF_GRAYED);
00283 EnableMenuItem(hmenu,IDM_FILE_EXPORT_3DS,MF_GRAYED);
00284 EnableMenuItem(hmenu,IDM_FILE_EXPORT_DXF,MF_GRAYED);
00285 EnableMenuItem(hmenu,IDM_FILE_EXPORT_STL,MF_GRAYED);
00286 EnableMenuItem(hmenu,IDM_FILE_EXPORT_VRML,MF_GRAYED);
00287 #endif
00288 if(bBackgroundImage){
00289 hBmBackground=LoadImage(ghinst_main,"modeler.bmp",IMAGE_BITMAP,
00290 0,0,LR_LOADFROMFILE);
00291 if(hBmBackground == NULL)
00292 hBmBackground=LoadBitmap(ghinst_main,"screenbitmap");
00293 }
00294 }
00295 break;
00296 case WM_DESTROY:
00297 if(hBmBackground != NULL)DeleteObject(hBmBackground);
00298 hBmBackground=NULL;
00299 break;
00300 case WM_ACTIVATE:
00301 if(LOWORD(wparam) != WA_INACTIVE)SetFocus(hwnd);
00302
00303 SendMessage(hwnd,WM_NCACTIVATE,(WPARAM)TRUE,0);
00304 break;
00305 case WM_ACTIVATEAPP:
00306 PostMessage(hwnd,WM_NCACTIVATE,wparam,0);
00307 break;
00308 case WM_SETCURSOR:
00309 if((HWND)wparam == ghwnd_main && current_message >= 0){
00310 current_message = -1;
00311 SendPrgmMessage(IDS_ZERO,1);
00312 }
00313 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00314 case WM_MENUSELECT:{
00315 HMENU hmenu;
00316 UINT fuFlags,uItem,id,i;
00317 bSpaceDown=FALSE; bCtrlDown=FALSE; bShiftDown=FALSE; bAltDown=FALSE;
00318 hmenu=(HMENU)lparam;
00319 fuFlags=(UINT)HIWORD(wparam);
00320 uItem=(UINT)LOWORD(wparam);
00321 id=0;
00322 if(fuFlags == 0xFFFF)id=0;
00323 else if(fuFlags & MF_POPUP){
00324 }
00325 else{
00326 id=CheckMenuHelpData(uItem);
00327 }
00328 DisplayMenuHelpData(ghwnd_info,id);
00329 }
00330 break;
00331 case WM_TIMER:
00332 if(update_timer == 1){
00333 KillTimer(ghwnd_main,update_timer); update_timer=0;
00334 if(bTrackPan || bTrackZoom)DrawQuickModel();
00335 }
00336 break;
00337 case WM_LBUTTONDOWN:
00338 x=(short)LOWORD(lparam); y=(short)HIWORD(lparam);
00339 type=0;
00340 if(View == TRIVIEW){
00341 if(x > WindowLeftOrigin+Window0sizeX - 20 &&
00342 x < WindowLeftOrigin+Window0sizeX + 20 &&
00343 y > WindowTopOrigin+Window0sizeY - 20 &&
00344 y < WindowTopOrigin+Window0sizeY + 20)type=1;
00345 else if(x > WindowLeftOrigin+Window0sizeX - 10 &&
00346 x < WindowLeftOrigin+Window0sizeX + 10 &&
00347 y > WindowTopOrigin+10 &&
00348 y < WindowTopOrigin+TriviewSpaceY)type=2;
00349 else if(y > WindowTopOrigin+Window0sizeY - 10 &&
00350 y < WindowTopOrigin+Window0sizeY + 10 &&
00351 x > WindowLeftOrigin+10 &&
00352 x < WindowLeftOrigin+TriviewSpaceX-10)type=3;
00353 }
00354 if (type == 1)SetCursor(LoadCursor(NULL,IDC_SIZEALL));
00355 else if(type == 2)SetCursor(LoadCursor(NULL,IDC_SIZEWE));
00356 else if(type == 3)SetCursor(LoadCursor(NULL,IDC_SIZENS));
00357 if(type > 0){
00358 HDC hdc;
00359 hdc=GetDC(ghwnd_main);
00360 FocusActiveWindow(hdc,FALSE);
00361 ReleaseDC(ghwnd_main,hdc);
00362 SetCapture(hwnd);
00363 DeleteMemoryWindows();
00364 bResizing=TRUE;
00365 bCaptured=TRUE;
00366 GetClientRect(hwnd,&rc);
00367 last_x=x; last_y=y;
00368 }
00369 break;
00370 case WM_LBUTTONUP:
00371 if(bCaptured){
00372 HDC hdc;
00373 hdc=GetDC(ghwnd_main);
00374 FocusActiveWindow(hdc,TRUE);
00375 ReleaseDC(ghwnd_main,hdc);
00376 ReleaseCapture();
00377 bCaptured=FALSE;
00378 bResizing=FALSE;
00379 CreateMemoryWindows();
00380 DrawModel();
00381 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
00382 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
00383 type=0;
00384 }
00385 break;
00386 case WM_MOUSEWHEEL:{
00387 long zDelta;
00388 zDelta = GET_WHEEL_DELTA_WPARAM(wparam);
00389 Zoom2( (double)zDelta/(double)WHEEL_DELTA);
00390 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
00391 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
00392 }
00393 return 0;
00394 case WM_MOUSEMOVE:
00395 x=(short)LOWORD(lparam); y=(short)HIWORD(lparam);
00396 if(!bCaptured && View == TRIVIEW){
00397 ltype=0;
00398 if(x > WindowLeftOrigin+Window0sizeX - 20 &&
00399 x < WindowLeftOrigin+Window0sizeX + 20 &&
00400 y > WindowTopOrigin+Window0sizeY - 20 &&
00401 y < WindowTopOrigin+Window0sizeY + 20)ltype=1;
00402 else if(x > WindowLeftOrigin+Window0sizeX - 10 &&
00403 x < WindowLeftOrigin+Window0sizeX + 10 &&
00404 y > WindowTopOrigin+10 &&
00405 y < WindowTopOrigin+TriviewSpaceY)ltype=2;
00406 else if(y > WindowTopOrigin+Window0sizeY - 10 &&
00407 y < WindowTopOrigin+Window0sizeY + 10 &&
00408 x > WindowLeftOrigin+10 &&
00409 x < WindowLeftOrigin+TriviewSpaceX-10)ltype=3;
00410 if (ltype == 1)SetCursor(LoadCursor(NULL,IDC_SIZEALL));
00411 else if(ltype == 2)SetCursor(LoadCursor(NULL,IDC_SIZEWE));
00412 else if(ltype == 3)SetCursor(LoadCursor(NULL,IDC_SIZENS));
00413 }
00414 if(bCaptured){
00415 int dx,dy;
00416 if (type == 1)SetCursor(LoadCursor(NULL,IDC_SIZEALL));
00417 else if(type == 2)SetCursor(LoadCursor(NULL,IDC_SIZEWE));
00418 else if(type == 3)SetCursor(LoadCursor(NULL,IDC_SIZENS));
00419 dx=x-last_x; dy=y-last_y;
00420 if(dx != 0 || dy != 0){
00421 if (type == 2)dy=0;
00422 else if(type == 3)dx=0;
00423 Window0sizeX += dx;
00424 Window0sizeX = max(20,Window0sizeX);
00425 Window0sizeX = min(TriviewSpaceX-30,Window0sizeX);
00426 Window0sizeY += dy;
00427 Window0sizeY = max(20,Window0sizeY);
00428 Window0sizeY = min(TriviewSpaceY-30,Window0sizeY);
00429 SetWindowSize(rc.right,rc.bottom,View,FALSE);
00430 GetTriview(FALSE);
00431 for(i=0;i<3;i++)
00432 MoveWindow(ghwnd_triview[i],
00433 WindowsXmin[i],WindowsYmin[i],
00434 WindowSizeX[i],WindowSizeY[i],TRUE);
00435 MoveWindow(ghwnd_view,WindowViewXmin,WindowViewYmin,
00436 WindowViewXsize,WindowViewYsize,TRUE);
00437 if(ghwndOpenGLview != NULL)MoveWindow(ghwndOpenGLview,
00438 WindowViewXmin,WindowViewYmin,
00439 WindowViewXsize,WindowViewYsize,TRUE);
00440 else UpdateWindow(ghwnd_view);
00441 UpdateWindow(ghwnd_triview[1]);
00442
00443 }
00444 last_x=x; last_y=y;
00445 }
00446 break;
00447 case WM_RBUTTONDOWN:
00448 SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
00449 break;
00450 case WM_ERASEBKGND:{
00451 HDC hDC;
00452 HPALETTE hpalT;
00453 HBRUSH hOldBrush;
00454 RECT rc1;
00455 hDC = (HDC)wparam;
00456 if(hBmBackground == NULL){
00457 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00458 RealizePalette (hDC);
00459 hOldBrush = SelectObject (hDC,ghbrushScreen);
00460 GetClientRect(hwnd,(LPRECT)&rc1);
00461 PatBlt(hDC,0,0,rc1.right,rc1.bottom,PATCOPY);
00462 SelectPalette(hDC,hpalT,FALSE);
00463 SelectObject (hDC, hOldBrush);
00464 }
00465 else{
00466 HDC hMemDC;
00467 HBITMAP hbmOld;
00468 BITMAP bm;
00469 GetObject(hBmBackground,sizeof(BITMAP),&bm);
00470 hMemDC = CreateCompatibleDC(hDC);
00471 hbmOld = SelectObject(hMemDC,hBmBackground);
00472 for(x=0;x<(ScreenXsize/bm.bmWidth)+1;x++)
00473 for(y=0;y<(ScreenYsize/bm.bmHeight)+1;y++)
00474 BitBlt(hDC,
00475 x*bm.bmWidth,y*bm.bmHeight,
00476 bm.bmWidth,
00477 bm.bmHeight,
00478 hMemDC,
00479 0,0,
00480 SRCCOPY);
00481 SelectObject(hMemDC,hbmOld);
00482 DeleteDC(hMemDC);
00483 }
00484 return TRUE;
00485 }
00486 case WM_QUERYNEWPALETTE:{
00487 HDC hDC;
00488 HPALETTE hpalT;
00489 hDC=GetDC(hwnd);
00490 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00491 if(RealizePalette (hDC) > 0)InvalidateRect (hwnd, (LPRECT) (NULL), 1);
00492 SelectPalette(hDC,hpalT,FALSE);
00493 ReleaseDC(hwnd,hDC);
00494 return TRUE;
00495 }
00496 case WM_PALETTECHANGED:
00497 if ((HWND)wparam != hwnd ){
00498 HDC hDC;
00499 HPALETTE hpalT;
00500 hDC=GetDC(hwnd);
00501 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00502 if(RealizePalette (hDC) > 0)InvalidateRect (hwnd, (LPRECT) (NULL), 1);
00503 SelectPalette(hDC,hpalT,FALSE);
00504 ReleaseDC(hwnd,hDC);
00505 }
00506 break;
00507 case WM_PAINT: {
00508 HDC hdc;
00509 PAINTSTRUCT ps;
00510 HBRUSH hOldBrush;
00511 HPALETTE hpalT;
00512 RECT rc1;
00513 hdc=BeginPaint(hwnd,&ps);
00514 hpalT = SelectPalette(hdc,ghpaletteScreen,FALSE);
00515 RealizePalette (hdc);
00516 if(hBmBackground == NULL){
00517 hOldBrush = SelectObject (hdc,ghbrushScreen);
00518 GetClientRect(hwnd,(LPRECT)&rc1);
00519 PatBlt(hdc,0,0,rc1.right,rc1.bottom,PATCOPY);
00520 SelectObject (hdc, hOldBrush);
00521 }
00522 if(!bResizing)FocusActiveWindow(hdc,TRUE);
00523 SelectPalette(hdc,hpalT,FALSE);
00524 EndPaint(hwnd,&ps);
00525 }
00526 break;
00527 case WM_SYSCOMMAND:
00528 switch(LOWORD(wparam & 0xfff0)){
00529 case SC_CLOSE:
00530 if(in_subroutine_mode)PostMessage(hwnd,WM_COMMAND,
00531 IDM_FILE_UPDATE_ANIMATOR,0);
00532 else PostMessage(hwnd,WM_COMMAND,IDM_FILE_EXIT,0);
00533 break;
00534 default:
00535 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00536 break;
00537 }
00538 break;
00539 case (WM_USER+1):
00540 StartOpenGL(FALSE);
00541 StartOpenGL(FALSE);
00542 if(ghwndOpenGLview != NULL)PostMessage(ghwndOpenGLview,(WM_USER+4),0,0);
00543 break;
00544 case WM_COMMAND:
00545 if(HIWORD(wparam) == 1)lparam=ActiveView;
00546 if(HIWORD(wparam) == BN_CLICKED){
00547 DesignMenuCommand(LOWORD(wparam),hwnd,lparam);
00548 }
00549 else DesignMenuCommand(LOWORD(wparam),hwnd,lparam);
00550 break;
00551 case WM_SIZE:{
00552 int cx,cy;
00553 int StatusPartsList[2]={0,-1};
00554 if(screen_ready){
00555 DeleteMemoryWindows();
00556 cx=LOWORD(lparam); cy=HIWORD(lparam);
00557 SetWindowSize(cx,cy,View,FALSE);
00558 GetTriview(FALSE);
00559 if(View == TRIVIEW){
00560 for(i=0;i<3;i++){
00561 MoveWindow(ghwnd_triview[i],WindowsXmin[i],WindowsYmin[i],
00562 WindowSizeX[i],WindowSizeY[i],TRUE);
00563 }
00564 }
00565 else{
00566 MoveWindow(ghwnd_current,
00567 WindowsXmin[ActiveView],WindowsYmin[ActiveView],
00568 WindowSizeX[ActiveView],WindowSizeY[ActiveView],TRUE);
00569 }
00570 MoveWindow(ghwnd_view,WindowViewXmin,WindowViewYmin,
00571 WindowViewXsize,WindowViewYsize,TRUE);
00572 if(ghwndOpenGLview != NULL)MoveWindow(ghwndOpenGLview,
00573 WindowViewXmin,WindowViewYmin,
00574 WindowViewXsize,WindowViewYsize,TRUE);
00575 StatusPartsList[0]=cx-SIZESTATUS1;
00576 SendMessage(ghwnd_info,SB_SETPARTS,(WPARAM)2,(LPARAM)StatusPartsList);
00577 MoveToolsWindow();
00578 SendMessage(ghwnd_info,msg,wparam,lparam);
00579 if(CreateMemoryWindows()){
00580 DrawModel();
00581 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
00582 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
00583 }
00584 else{
00585 DeleteMemoryWindows();
00586 }
00587 }
00588 }
00589 break;
00590 case WM_KEYDOWN:
00591 ExecuteKeyboardKeyCommand(wparam);
00592 case WM_KEYUP:
00593 if(!bTrackMouse && !bTrackIcon && !bToolCaptured && !bTrackPan){
00594 if(GetKeyState(VK_SPACE) & 0x8000)bSpaceDown=TRUE; else bSpaceDown=FALSE;
00595 if(GetKeyState(VK_CONTROL) & 0x8000)bCtrlDown=TRUE; else bCtrlDown=FALSE;
00596 if(GetKeyState(VK_SHIFT) & 0x8000)bShiftDown=TRUE; else bShiftDown=FALSE;
00597 if(GetKeyState(VK_MENU) & 0x8000)bAltDown=TRUE; else bAltDown=FALSE;
00598 if(CursorInTriview())SetTriViewCursor(FALSE);
00599 }
00600 break;
00601 case WM_SETFOCUS:
00602 if(GetKeyState(VK_SPACE) & 0x8000)bSpaceDown=TRUE; else bSpaceDown=FALSE;
00603 if(GetKeyState(VK_SHIFT) & 0x8000)bShiftDown=TRUE; else bShiftDown=FALSE;
00604 if(GetKeyState(VK_CONTROL) & 0x8000)bCtrlDown=TRUE; else bCtrlDown=FALSE;
00605 if(GetKeyState(VK_MENU) & 0x8000)bAltDown=TRUE; else bAltDown=FALSE;
00606 if(CursorInTriview())SetTriViewCursor(FALSE);
00607 break;
00608 case WM_KILLFOCUS:
00609 if(bSpaceDown || bCtrlDown || bShiftDown || bAltDown){
00610 bSpaceDown=FALSE;
00611 bCtrlDown=FALSE;
00612 bShiftDown=FALSE;
00613 bAltDown=FALSE;
00614 if(CursorInTriview())SetTriViewCursor(FALSE);
00615 }
00616 break;
00617 case WM_SYSKEYDOWN:
00618 if(((lparam & 0x40000000) == 0) && wparam == VK_MENU){
00619 bAltDown=TRUE;
00620 if((bSpaceDown || tool == INZOOM || tool == MAGNETTO) && CursorInTriview())SetTriViewCursor(FALSE);
00621 }
00622 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00623 case WM_SYSKEYUP:
00624 bAltDown=FALSE;
00625 if((bSpaceDown || tool == INZOOM || tool == MAGNETTO) && CursorInTriview())SetTriViewCursor(FALSE);
00626 break;
00627 default:
00628 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00629 }
00630 return( 0L );
00631 }
00632
00633 LRESULT CALLBACK ModelerTriViewWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00634 LPARAM lparam ){
00635 HDC hdc;
00636 RECT rc;
00637 int id;
00638 static int iIconSave = -1;
00639 static BOOL bMouseDown=FALSE;
00640 BOOL flag1,flag2;
00641 switch( msg ){
00642 case WM_ERASEBKGND:{
00643 HDC hDC;
00644 HPALETTE hpalT;
00645 HBRUSH hOldBrush;
00646 if(bResizing)return TRUE;
00647 hDC = (HDC)wparam;
00648 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00649 RealizePalette (hDC);
00650 hOldBrush = SelectObject (hDC,ghbrushWindow);
00651 GetClientRect(hwnd,(LPRECT)&rc);
00652 PatBlt(hDC,0,0,rc.right,rc.bottom,PATCOPY);
00653 SelectPalette(hDC,hpalT,FALSE);
00654 SelectObject (hDC, hOldBrush);
00655 return TRUE;
00656 }
00657 case WM_QUERYNEWPALETTE:{
00658 HDC hDC;
00659 HPALETTE hpalT;
00660 hDC=GetDC(hwnd);
00661 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00662 if(RealizePalette (hDC) > 0)InvalidateRect (hwnd, (LPRECT) (NULL), 1);
00663 SelectPalette(hDC,hpalT,FALSE);
00664 ReleaseDC(hwnd,hDC);
00665 return TRUE;
00666 }
00667 case WM_PALETTECHANGED:
00668 if ((HWND)wparam != hwnd ){
00669 HDC hDC;
00670 HPALETTE hpalT;
00671 hDC=GetDC(hwnd);
00672 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00673 if(RealizePalette (hDC) > 0)InvalidateRect (hwnd, (LPRECT) (NULL), 1);
00674 SelectPalette(hDC,hpalT,FALSE);
00675 ReleaseDC(hwnd,hDC);
00676 }
00677 break;
00678 case WM_SETCURSOR:
00679 if(!SetTriViewCursor(TRUE))return(DefWindowProc(hwnd,msg,wparam,lparam));
00680 break;
00681 case WM_RBUTTONDOWN:
00682 if(bToolCaptured){
00683 if(bMouseDown || bTrackMouse)break;
00684 goto RELEASE_CAPTURE;
00685 }
00686 else if(!bTrackMouse)SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
00687 else if(!bTrackIcon){
00688 if(tool == NOTOOL){
00689
00690
00691 }
00692 else ToolAction((int)LOWORD(lparam),(int)HIWORD(lparam));
00693 }
00694 break;
00695 case WM_LBUTTONDBLCLK:
00696 break; if(tool != PLOTTER)break;
00697 if(bToolCaptured){
00698 RELEASE_CAPTURE:
00699 UpdateWindow(hwnd);
00700 ToolUp(hwnd,ActiveView,(int)LOWORD(lparam),(int)HIWORD(lparam));
00701 UpdateWindow(hwnd);
00702 bToolCaptured=FALSE;
00703 ClipCursor(NULL);
00704 SetCursor(ghcurSave);
00705 ReleaseCapture();
00706 Plot3dOff();
00707 }
00708 else{
00709 if(CheckWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam)) >= 0)break;
00710 if(bTrackMouse)MessageBeep(MB_OK);
00711 SetCapture(hwnd);
00712 GetWindowRect(hwnd,&rc);
00713 rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00714 ghcurSave=SetCursor(ghcurCross);
00715 ClipCursor(&rc);
00716 ToolDown(hwnd,ActiveView,(int)LOWORD(lparam),(int)HIWORD(lparam));
00717 ToolAction((int)LOWORD(lparam),(int)HIWORD(lparam));
00718 bToolCaptured=TRUE;
00719 }
00720 break;
00721 case WM_LBUTTONDOWN:
00722 if(bToolCaptured){
00723 ToolAction((int)LOWORD(lparam),(int)HIWORD(lparam));
00724 bMouseDown=TRUE;
00725 break;
00726 }
00727 if(hwnd != ghwnd_current){
00728 hdc=GetDC(ghwnd_main);
00729 FocusActiveWindow(hdc,FALSE);
00730 ghwnd_current=hwnd; ActiveView=GetWindowLong(hwnd,GWL_ID);
00731 FocusActiveWindow(hdc,TRUE);
00732 ReleaseDC(ghwnd_main,hdc);
00733 }
00734 SetCapture(hwnd);
00735 if(bSpaceDown){
00736 PanToolDown((int)LOWORD(lparam),(int)HIWORD(lparam),
00737 bCtrlDown,bAltDown,hwnd);
00738 GetWindowRect(hwnd,&rc);
00739 rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00740 ClipCursor(&rc);
00741 bTrackPan=TRUE;
00742 }
00743 else if((iIconSave=CheckWindowIcon((int)LOWORD(lparam),
00744 (int)HIWORD(lparam))) >= 0){
00745 InvertWindowIcon(iIconSave,hwnd);
00746 bTrackIcon=TRUE;
00747 }
00748 else if(tool == PAN){
00749 PanToolDown((int)LOWORD(lparam),(int)HIWORD(lparam),
00750 FALSE,FALSE,hwnd);
00751 GetWindowRect(hwnd,&rc);
00752 rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00753 ClipCursor(&rc);
00754 bTrackPan=TRUE;
00755 }
00756 else if(tool == INZOOM){
00757 Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00758 bTrackZoom=TRUE;
00759 ZoomView((int)LOWORD(lparam),(int)HIWORD(lparam));
00760 bTrackZoom=FALSE;
00761 ReleaseCapture();
00762 }
00763 else{
00764 GetWindowRect(hwnd,&rc);
00765 rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00766 ghcurSave=SetCursor(ghcurCross);
00767 ClipCursor(&rc);
00768 bTrackMouse=TRUE;
00769 }
00770 if(bTrackMouse){
00771 Move3dCursor(1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00772 ToolDown(hwnd,ActiveView,(int)LOWORD(lparam),(int)HIWORD(lparam));
00773 if(!(GetAsyncKeyState(VK_LBUTTON) & 0x8000)){
00774 bTrackMouse=FALSE;
00775 ReleaseCapture();
00776 ClipCursor(NULL);
00777 }
00778 }
00779 break;
00780 case WM_LBUTTONUP:
00781 if(bToolCaptured){
00782 bMouseDown=FALSE;
00783 break;
00784 }
00785 if(bTrackIcon){
00786 if(iIconSave >= 0){
00787 InvertWindowIcon(iIconSave,hwnd);
00788 if (iIconSave == 0)iIconSave=IDM_PAN_LEFT;
00789 else if(iIconSave == 1)iIconSave=IDM_PAN_RIGHT;
00790 else if(iIconSave == 2)iIconSave=IDM_PAN_UP;
00791 else if(iIconSave == 3)iIconSave=IDM_PAN_DOWN;
00792 else if(iIconSave == 4)iIconSave=IDM_WINDOW_SWITCHWINDOWS;
00793 else if(iIconSave == 5)iIconSave=IDM_WINDOW_SWITCHWINDOW0;
00794 else if(iIconSave == 6)iIconSave=IDM_WINDOW_SWITCHWINDOW1;
00795 PostMessage(ghwnd_main,WM_COMMAND,(WPARAM)iIconSave,
00796 (LPARAM)GetWindowLong(hwnd,GWL_ID));
00797 }
00798 iIconSave = -1;
00799 bTrackIcon=FALSE;
00800 ReleaseCapture();
00801 }
00802 else if(bTrackPan){
00803 ClipCursor(NULL);
00804 ReleaseCapture();
00805 if(bSpaceDown){
00806 flag1=bCtrlDown;
00807 flag2=bAltDown;
00808 }
00809 else{
00810 if(tool == INZOOM){
00811 if(bAltDown){flag1=FALSE; flag2=TRUE;}
00812 else {flag1=TRUE; flag2=FALSE;}
00813 }
00814 else {flag1=FALSE; flag2=FALSE;}
00815 }
00816 PanToolUp((int)LOWORD(lparam),(int)HIWORD(lparam),
00817 flag1,flag2,hwnd);
00818 bTrackPan=FALSE;
00819 if(!(GetKeyState(VK_SPACE)&0x8000))bSpaceDown=FALSE;
00820 if(!(GetKeyState(VK_CONTROL)&0x8000))bCtrlDown=FALSE;
00821 if(!(GetKeyState(VK_SHIFT)&0x8000))bShiftDown=FALSE;
00822 if(!(GetKeyState(VK_MENU)&0x8000))bAltDown=FALSE;
00823 SetTriViewCursor(FALSE);
00824 }
00825 else if(bTrackMouse){
00826 bTrackMouse=FALSE;
00827 ClipCursor(NULL);
00828 SetCursor(ghcurSave);
00829 UpdateWindow(hwnd);
00830 ToolUp(hwnd,ActiveView,(int)LOWORD(lparam),(int)HIWORD(lparam));
00831 UpdateWindow(hwnd);
00832 ReleaseCapture();
00833 }
00834 break;
00835 case WM_MOUSEMOVE:
00836 if(bToolCaptured){
00837 ToolMove(hwnd,ActiveView,(int)LOWORD(lparam),(int)HIWORD(lparam));
00838 break;
00839 }
00840 if(bTrackMouse){
00841 if(tool != EXPANDER && tool != ROTATOR && tool != SHAPER &&
00842 sktool == NO)Move3dCursor(0,(int)LOWORD(lparam),(int)HIWORD(lparam));
00843 ToolMove(hwnd,ActiveView,(int)LOWORD(lparam),(int)HIWORD(lparam));
00844 }
00845 else if(bTrackIcon){
00846 int new_icon;
00847 new_icon=CheckWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam));
00848 if(new_icon != iIconSave){
00849 if(iIconSave >= 0)InvertWindowIcon(iIconSave,hwnd);
00850 iIconSave=new_icon;
00851 if(iIconSave >= 0)InvertWindowIcon(iIconSave,hwnd);
00852 }
00853 }
00854 else if(bTrackPan){
00855 if(tool == PAN || tool == INZOOM || bSpaceDown){
00856 if(bSpaceDown){
00857 flag1=bCtrlDown;
00858 flag2=bAltDown;
00859 }
00860 else{
00861 if(tool == INZOOM && !bAltDown)flag1=TRUE; else flag1=FALSE;
00862 if(tool == INZOOM && bAltDown)flag2=TRUE; else flag2=FALSE;
00863 }
00864 PanToolMove((int)LOWORD(lparam),(int)HIWORD(lparam),
00865 flag1,flag2,hwnd);
00866 }
00867 }
00868 else {
00869 int icon,new_message;
00870 icon=CheckWindowIcon((int)LOWORD(lparam),(int)HIWORD(lparam));
00871 if(icon >= 0){
00872 if(icon == 4)new_message=lmessage_table[View];
00873 else new_message=IDS_SWAPOTHER;
00874 if(new_message != current_message){
00875 current_message=new_message;
00876 SendPrgmMessage(current_message,1);
00877 }
00878 }
00879 else if(current_message != tmessage_table[tool]){
00880 current_message = tmessage_table[tool];
00881 SendPrgmMessage(current_message,1);
00882 }
00883 }
00884 break;
00885 case WM_PAINT:{
00886 PAINTSTRUCT ps;
00887 HPALETTE hpalT;
00888 hdc=BeginPaint(hwnd,&ps);
00889 if(!bResizing){
00890 hpalT = SelectPalette(hdc,ghpaletteScreen,FALSE);
00891 RealizePalette (hdc);
00892 GetClientRect(hwnd,&rc);
00893 id=(int)GetWindowLong(hwnd,GWL_ID);
00894 if(ghdc_triview_Bitmap[id] != NULL)BitBlt(hdc,0,0,
00895 rc.right,rc.bottom,ghdc_triview_Bitmap[id],0,0,SRCCOPY);
00896 DrawOne3dCursor(hdc,id);
00897
00898
00899
00900 if(SelectedShader >= 0)DrawShaderInOne(hdc,id,SelectedShader);
00901 if(sktool == YES && tool != SKANIMATE)DrawSkeletonInOne(hdc,id);
00902 SelectPalette(hdc,hpalT,FALSE);
00903 }
00904 EndPaint(hwnd,&ps);
00905 }
00906 break;
00907 default:
00908 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00909 }
00910 return( 0L );
00911 }
00912
00913 LRESULT CALLBACK ModelerViewWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00914 LPARAM lparam ){
00915 int oldi;
00916 static BOOL bTrackMouseV=FALSE,bTrackPan=FALSE;
00917 static long xs,ys;
00918 RECT rc;
00919 switch( msg ){
00920 case WM_SETCURSOR:
00921 if(LOWORD(lparam) != HTCLIENT)SetCursor(ghcurArrow);
00922 else if (tool == SELECTOR)SetCursor (ghcurSelect);
00923 else if(tool == DESELECTOR)SetCursor(ghcurDeselect);
00924 else if(tool == GRABBER)SetCursor(ghcurGrabber);
00925 else{
00926 if(LOWORD(lparam) == HTCLIENT)SetCursor(ghcurPan);
00927 else SetCursor(ghcurArrow);
00928 }
00929 break;
00930 case WM_ERASEBKGND:{
00931 HDC hDC;
00932 HPALETTE hpalT;
00933 HBRUSH hOldBrush;
00934 if(bResizing)return TRUE;
00935 hDC = (HDC)wparam;
00936 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00937 RealizePalette (hDC);
00938 hOldBrush = SelectObject (hDC,ghbrushWindow);
00939 GetClientRect(hwnd,(LPRECT)&rc);
00940 PatBlt(hDC,0,0,rc.right,rc.bottom,PATCOPY);
00941 SelectPalette(hDC,hpalT,FALSE);
00942 SelectObject (hDC, hOldBrush);
00943 return TRUE;
00944 }
00945 case WM_QUERYNEWPALETTE:{
00946 HDC hDC;
00947 HPALETTE hpalT;
00948 hDC=GetDC(hwnd);
00949 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00950 if(RealizePalette (hDC) > 0)InvalidateRect (hwnd, (LPRECT) (NULL), 1);
00951 SelectPalette(hDC,hpalT,FALSE);
00952 ReleaseDC(hwnd,hDC);
00953 return TRUE;
00954 }
00955 case WM_PALETTECHANGED:
00956 if ((HWND)wparam != hwnd ){
00957 HDC hDC;
00958 HPALETTE hpalT;
00959 hDC=GetDC(hwnd);
00960 hpalT = SelectPalette(hDC,ghpaletteScreen,FALSE);
00961 if(RealizePalette (hDC) > 0)InvalidateRect (hwnd, (LPRECT) (NULL), 1);
00962 SelectPalette(hDC,hpalT,FALSE);
00963 ReleaseDC(hwnd,hDC);
00964 }
00965 break;
00966 case WM_LBUTTONDOWN:
00967 if(tool == SELECTOR || tool == DESELECTOR || tool == GRABBER){
00968 SetCapture(hwnd);
00969 GetWindowRect(hwnd,&rc);
00970 rc.left += 1; rc.top += 1; rc.right -= 1; rc.bottom -= 1;
00971 ClipCursor(&rc);
00972 bTrackMouseV=TRUE;
00973 if(tool == GRABBER){xs=LOWORD(lparam); ys=HIWORD(lparam);}
00974 else SelectorDown(hwnd,-1,(int)LOWORD(lparam),(int)HIWORD(lparam));
00975 }
00976 else {
00977 GetClientRect(hwnd,&rc);
00978
00979
00980
00981
00982
00983 if(LOWORD(lparam) < 5*Textwidth &&
00984 HIWORD(lparam) < Textheight)
00985 PostMessage(ghwnd_main,WM_COMMAND,IDM_VIEW_HIDDENLINE,0);
00986 else{
00987 xs=LOWORD(lparam);
00988 ys=HIWORD(lparam);
00989 SetCapture(hwnd);
00990 bTrackPan=TRUE;
00991 }
00992 }
00993 break;
00994 case WM_MOUSEMOVE:
00995 if(bTrackMouseV){
00996 if(tool == GRABBER){
00997 long xs1,ys1;
00998 xs1=LOWORD(lparam); ys1=HIWORD(lparam);
00999 MoveInPerspective(xs1-xs,ys1-ys);
01000 xs=xs1; ys=ys1;
01001 DrawQuick3dView(0);
01002 }
01003 else SelectorMove(hwnd,-1,(int)LOWORD(lparam),(int)HIWORD(lparam));
01004 }
01005 else if(bTrackPan){
01006 long dx,dy;
01007 dx=(short)LOWORD(lparam)-xs; xs=(short)LOWORD(lparam);
01008 dy=(short)HIWORD(lparam)-ys; ys=(short)HIWORD(lparam);
01009 if(labs(dx) > 0 || labs(dy) > 0){
01010 PerspFi=PerspFi+(double)dx;
01011 while(PerspFi < -180.0)PerspFi += 360.0;
01012 while(PerspFi > 180.0)PerspFi -= 360.0;
01013 SetScrollPos(hwnd,SB_HORZ,(int)PerspFi+180,TRUE);
01014 PerspTheta=PerspTheta+(double)dy;
01015 if(PerspTheta > -90 && PerspTheta < 90)
01016 SetScrollPos(hwnd,SB_VERT,(int)PerspTheta+90,TRUE);
01017 DrawQuick3dView(0);
01018 }
01019 }
01020 else{
01021 GetClientRect(hwnd,&rc);
01022 if(LOWORD(lparam) > rc.right-5*Textwidth &&
01023 LOWORD(lparam) < rc.right &&
01024 HIWORD(lparam) > rc.bottom-Textheight &&
01025 HIWORD(lparam) < rc.bottom){
01026 if(current_message < 0){
01027 current_message=0;
01028 SendPrgmMessage(IDS_PERSPVIEW,1);
01029 }
01030 }
01031 else if(current_message != IDS_VIEWUPDATE){
01032 current_message = IDS_VIEWUPDATE;
01033 SendPrgmMessage(IDS_VIEWUPDATE,1);
01034 }
01035 }
01036 break;
01037 case WM_LBUTTONUP:
01038 if(bTrackMouseV){
01039 if(tool == SELECTOR || tool == DESELECTOR)
01040 SelectorUp(hwnd,-1,(int)LOWORD(lparam),(int)HIWORD(lparam),TRUE,FALSE);
01041 else if(tool == GRABBER)DrawModel();
01042 bTrackMouseV=FALSE;
01043 ClipCursor(NULL);
01044 ReleaseCapture();
01045 }
01046 else if(bTrackPan){
01047 ReleaseCapture();
01048 bTrackPan=FALSE;
01049 PostMessage(ghwnd_main,WM_COMMAND,IDM_VIEW_WIREFRAME,0);
01050 }
01051 break;
01052 case WM_RBUTTONDOWN:
01053 if(bTrackMouseV || bTrackPan)break;
01054 else{
01055 POINT pt;
01056 HMENU hMenu=LoadMenu(ghinst_main,"ViewWindowPopupMenu");
01057 if(hMenu == NULL)break;
01058 pt.x=LOWORD(lparam);
01059 pt.y=HIWORD(lparam);
01060 ClientToScreen(hwnd,&pt);
01061 TrackPopupMenu(GetSubMenu(hMenu,0),TPM_LEFTALIGN | TPM_LEFTBUTTON,
01062 pt.x,pt.y,0,ghwnd_main,NULL);
01063 DestroyMenu(hMenu);
01064 }
01065 break;
01066 case WM_HSCROLL:
01067 oldi=(int)PerspFi;
01068 switch (LOWORD(wparam)) {
01069 case SB_ENDSCROLL:
01070 break;
01071 case SB_LINEDOWN:
01072 PerspFi += 5; PerspFi = min( 180,PerspFi); break;
01073 case SB_LINEUP:
01074 PerspFi -= 5; PerspFi = max(-180,PerspFi); break;
01075 case SB_PAGEDOWN:
01076 PerspFi += 45; PerspFi = min( 180,PerspFi); break;
01077 case SB_PAGEUP:
01078 PerspFi -= 45; PerspFi = max(-180,PerspFi); break;
01079 case SB_THUMBTRACK:
01080 case SB_THUMBPOSITION:
01081 PerspFi=(double)HIWORD(wparam)-180; break;
01082 default: break;
01083 }
01084 if(oldi != (int)PerspFi){
01085 SetScrollPos(hwnd,SB_HORZ,(int)PerspFi+180,TRUE);
01086 Draw3dView(0,0);
01087 UpdateWindow(ghwnd_view);
01088 }
01089 break;
01090 case WM_VSCROLL:
01091 oldi=(int)PerspTheta;
01092 switch (LOWORD(wparam)) {
01093 case SB_ENDSCROLL:
01094 break;
01095 case SB_LINEDOWN:
01096 PerspTheta += 5; PerspTheta = min( 90,PerspTheta); break;
01097 case SB_LINEUP:
01098 PerspTheta -= 5; PerspTheta = max(-90,PerspTheta); break;
01099 case SB_PAGEDOWN:
01100 PerspTheta += 20; PerspTheta = min( 90,PerspTheta); break;
01101 case SB_PAGEUP:
01102 PerspTheta -= 20; PerspTheta = max(-90,PerspTheta); break;
01103 case SB_THUMBTRACK:
01104 case SB_THUMBPOSITION:
01105 PerspTheta=(double)HIWORD(wparam)-90;
01106 break;
01107 default: break;
01108 }
01109 if(oldi != (int)PerspTheta){
01110 SetScrollPos(hwnd,SB_VERT,(int)PerspTheta+90,TRUE);
01111 Draw3dView(0,0);
01112 UpdateWindow(ghwnd_view);
01113 }
01114 break;
01115 case WM_PAINT: {
01116 HDC hdc;
01117 PAINTSTRUCT ps;
01118 HPALETTE hpalT;
01119 hdc=BeginPaint(hwnd,&ps);
01120 if(!bResizing){
01121 hpalT = SelectPalette(hdc,ghpaletteScreen,FALSE);
01122 RealizePalette (hdc);
01123 GetClientRect(hwnd,&rc);
01124 if(ghdc_view_Bitmap != NULL){
01125 COLORREF oldtextcolour;
01126 int oldbkmode;
01127 oldbkmode=SetBkMode(ghdc_view_Bitmap,TRANSPARENT);
01128 oldtextcolour=SetTextColor(ghdc_view_Bitmap,RGB(255,255,255));
01129 TextOut(ghdc_view_Bitmap,
01130 1,1,
01131 "View",strlen("View"));
01132 SetBkMode(ghdc_view_Bitmap,oldbkmode);
01133 SetTextColor(ghdc_view_Bitmap,oldtextcolour);
01134 BitBlt(hdc,0,0,rc.right,rc.bottom,ghdc_view_Bitmap,0,0,SRCCOPY);
01135 }
01136 SelectPalette(hdc,hpalT,FALSE);
01137 }
01138 EndPaint(hwnd,&ps);
01139 }
01140 break;
01141 default:
01142 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
01143 }
01144 return( 0L );
01145 }
01146
01147
01148
01149 static BOOL SetTriViewCursor(BOOL type){
01150
01151
01152
01153 if(bSpaceDown){
01154 if(bCtrlDown)SetCursor(ghcurZin);
01155 else if(bAltDown)SetCursor(ghcurZout);
01156 else SetCursor(ghcurPan);
01157 }
01158 else if(tool == MAGNETTO && bCtrlDown && bAltDown)SetCursor(ghcurMagnetCu);
01159 else if(tool == MAGNETTO && bAltDown)SetCursor(ghcurMagnetFr);
01160 else if(tool == MAGNETTO && bCtrlDown)SetCursor(ghcurMagnetTw);
01161 else if(tool < NTOOLS)SetCursor(ghcurTools[tool]);
01162 else if(tool == SELECTOR){
01163 if(bShiftDown)SetCursor(ghcurSel_l_a);
01164 else if(bCtrlDown)SetCursor(ghcurSel_c_a);
01165 else SetCursor(ghcurSel_a);
01166 }
01167 else if(tool == DESELECTOR){
01168 if(bShiftDown)SetCursor(ghcurSel_l_s);
01169 else if(bCtrlDown)SetCursor(ghcurSel_c_s);
01170 else SetCursor(ghcurSel_s);
01171 }
01172 else if(tool == PRIMS)SetCursor(ghcurPrims);
01173 else if(sktool == YES)SetCursor(ghcurArrowD);
01174 else if(type)return FALSE;
01175 else SetCursor(ghcurArrow);
01176 return TRUE;
01177 }
01178
01179
01180
01181 #include "glmenu.h"
01182 #include "callback.h"
01183 #include "..\animate\callall.h"
01184 #if __HELP_WS__
01185 #include "..\help_ws\include\htmlhelp.h"
01186 #endif
01187
01188 #define FI_SCE 0
01189 #define FI_DXF 1
01190 #define FI_3DS 2
01191 #define FI_STL 3
01192
01193 static long identify_file_format(char *name){
01194 char cf[256];
01195 int ff=FI_SCE;
01196 strcpy(cf,name);
01197 if (strstr(cf,".DXF") || strstr(cf,".dxf"))ff=FI_DXF;
01198 else if(strstr(cf,".3DS") || strstr(cf,".3ds"))ff=FI_3DS;
01199 else if(strstr(cf,".STL") || strstr(cf,".stl"))ff=FI_STL;
01200 return ff;
01201 }
01202
01203 static VOID DesignMenuCommand(int item, HWND hwnd, long lparam){
01204 BOOL bUpdate=FALSE;
01205 int id;
01206 char temp_str[256];
01207 if(item >= 30000 && item < LASTFILECMD){
01208 if(ExecuteExternalAction(item-30000,ghwnd_main)){
01209 DrawModel();
01210 UpdateCounters();
01211 UpdateSkTreeView();
01212 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01213 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01214 }
01215 return;
01216 }
01217 switch (item){
01218 case IDC_CENTRE_DIALOG_CURSOR:
01219 CentreDialogOnCursor((HWND)lparam);
01220 break;
01221 case IDC_CENTRE_DIALOG_SCREEN:
01222 break;
01223 case IDC_UPDATE_VERTEXHEAP:
01224 UpdateVertexHeap((long)lparam);
01225 break;
01226 case IDC_UPDATE_EDGEHEAP:
01227 UpdateEdgeHeap((long)lparam);
01228 break;
01229 case IDC_UPDATE_FACEHEAP:
01230 UpdateFaceHeap((long)lparam);
01231 break;
01232 case LASTFILECMD+1:
01233 case LASTFILECMD+2:
01234 case LASTFILECMD+3:
01235 case LASTFILECMD+4:
01236 case LASTFILECMD+5:
01237 case IDM_FILE_NEW:
01238 case IDM_FILE_LOAD_MODEL:
01239 if(tool != NOTOOL)SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
01240 if(EDIT_ACTION){
01241 int fResult;
01242 fResult=SendPrgmQuery(IDQ_CHANGED,2);
01243 if(fResult == IDCANCEL)break;
01244 if(fResult == IDYES){
01245 #if !__DEMO__
01246 if(SelectSfxFileName(1,gszSCEfile,gszSCEdir,IDX_MISC_SAVEMODEL,
01247 "(*.MFX)|*.mfx|",hwnd) == TRUE){
01248 AppendFileExtension(gszSCEfile,".mfx");
01249 UpdateLastFilesList(gszSCEfile);
01250 ghcurSave=SetCursor(ghcurWait);
01251 SaveObject(gszSCEfile,1);
01252 SetCursor(ghcurSave);
01253 }
01254 else break;
01255 #endif
01256 }
01257 }
01258 if(item == IDM_FILE_NEW)goto NEWMODELPOINT;
01259 if(item == LASTFILECMD+1 || item == LASTFILECMD+2 ||
01260 item == LASTFILECMD+3 || item == LASTFILECMD+4 ||
01261 item == LASTFILECMD+5){
01262 strcpy(gszSCEfile,LastFilesList[item-LASTFILECMD-1].file);
01263 goto LOADALL_POINT;
01264 }
01265 LoadString(ghinst_main,IDX_MISC_LOADFILTER,temp_str,256);
01266 if(SelectSfxFileName(0,gszSCEfile,gszSCEdir,IDX_MISC_OPENMODEL,
01267 temp_str,hwnd) == TRUE){
01268 int i,fid;
01269 UpdateLastFilesList(gszSCEfile);
01270 LOADALL_POINT:
01271 fid=identify_file_format(gszSCEfile);
01272 ghcurSave=SetCursor(ghcurWait);
01273 Empty_Undo();
01274 EraseAll(1);
01275 for(i=0;i<3;i++)UpdateWindow(ghwnd_triview[i]);
01276 UpdateWindow(ghwnd_view); UpdateWindow(ghwnd_main);
01277 if(fid == FI_SCE && LoadObject(gszSCEfile,0) == OK){
01278 int check_flag;
01279 SetPrgmMessage(IDS_CURRENT,gszSCEfile);
01280 SendPrgmMessage(IDS_CURRENT,0);
01281 if(ShadowFlag)check_flag=MF_CHECKED; else check_flag=MF_UNCHECKED;
01282 CheckMenuItem(GetMenu(ghwnd_main),IDM_ATTRIBUTES_SHADOW,check_flag);
01283 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVE,MF_ENABLED);
01284 strcpy(gszSCEsaved,gszSCEfile);
01285 }
01286 else if(fid == FI_DXF || fid == FI_3DS || fid == FI_STL){
01287 strcpy(gszSCEsaved,"unnamed.mfx");
01288 if(fid == FI_DXF)LoadXmodel(gszSCEfile,"dxfcon.dll");
01289 if(fid == FI_3DS)LoadXmodel(gszSCEfile,"3dscon.dll");
01290 if(fid == FI_STL)LoadXmodel(gszSCEfile,"stlcon.dll");
01291 SendPrgmMessage(IDS_DEFAULT,0);
01292 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVE,MF_GRAYED);
01293 gszSCEfile[0]='\0';
01294 }
01295 UpdateCounters();
01296 UpdateSkTreeView();
01297 DrawModel();
01298 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01299 else PostMessage(ghwndOpenGLview,(WM_USER+4),0,0);
01300 SetCursor(ghcurSave);
01301 }
01302 break;
01303 case IDM_FILE_LOAD_RELATIVE: id=1; goto LOAD_POINT;
01304 case IDM_FILE_LOAD_ABSOLUTE: id=2; goto LOAD_POINT;
01305 case IDM_FILE_LOAD_COORDS: id=3; goto LOAD_POINT;
01306 LOAD_POINT:
01307 if(SelectSfxFileName(0,gszSCEfile,gszSCEdir,IDX_MISC_INCLUDEMODEL,
01308 "(*.MFX)|*.mfx|",hwnd) == TRUE){
01309 int i,nMatsCopy,nMapsCopy;
01310 Empty_Undo();
01311 nMapsCopy=nImaps;
01312 nMatsCopy=nMats;
01313 ghcurSave=SetCursor(ghcurWait);
01314 if(LoadObject(gszSCEfile,(short)id) != OK){
01315 SendPrgmMessage(IDS_FAILINCLUDE,1);
01316 }
01317 else{
01318 PurgeDuplicateMaps(nMapsCopy);
01319 PurgeDuplicateMaterials(nMatsCopy);
01320 }
01321 SendPrgmMessage(IDS_CURRENT,0);
01322 UpdateCounters();
01323 UpdateSkTreeView();
01324 DrawModel();
01325 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01326 else PostMessage(ghwndOpenGLview,(WM_USER+4),0,0);
01327 SetCursor(ghcurSave);
01328 }
01329 break;
01330 case IDM_FILE_LOAD_PATH:
01331 if(SelectSfxFileName(0,gszPTHfile,gszPTHdir,IDX_MISC_LOADPATH,
01332 "(*.PTH)|*.pth|",hwnd) == TRUE){
01333 Empty_Undo();
01334 EDIT_ACTION=YES;
01335 ghcurSave=SetCursor(ghcurWait);
01336 LoadAApoly(0,gszPTHfile);
01337 UpdateCounters();
01338 DrawModel();
01339 SetCursor(ghcurSave);
01340 }
01341 break;
01342 #if !__DEMO__
01343 case IDM_FILE_SAVE:
01344 ghcurSave=SetCursor(ghcurWait);
01345 SaveObject(gszSCEsaved,4);
01346 SetCursor(ghcurSave);
01347 break;
01348 case IDM_FILE_SAVE_ALL:
01349 if(SelectSfxFileName(1,gszSCEfile,gszSCEdir,IDX_MISC_SAVEMODEL,
01350 "(*.MFX)|*.mfx|",hwnd) == TRUE){
01351 AppendFileExtension(gszSCEfile,".mfx");
01352 UpdateLastFilesList(gszSCEfile);
01353 ghcurSave=SetCursor(ghcurWait);
01354 SaveObject(gszSCEfile,1);
01355 SetCursor(ghcurSave);
01356 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVE,MF_ENABLED);
01357 strcpy(gszSCEsaved,gszSCEfile);
01358 SetPrgmMessage(IDS_CURRENT,gszSCEfile);
01359 SendPrgmMessage(IDS_CURRENT,0);
01360 }
01361 break;
01362 case IDM_FILE_SAVE_OBJECT:
01363 if(SelectSfxFileName(1,gszSCEfile,gszSCEdir,IDX_MISC_SAVESELECTED,
01364 "(*.MFX)|*.mfx|",hwnd) == TRUE){
01365 AppendFileExtension(gszSCEfile,".mfx");
01366 ghcurSave=SetCursor(ghcurWait);
01367 SaveObject(gszSCEfile,0);
01368 SetCursor(ghcurSave);
01369 }
01370 break;
01371 case IDM_FILE_SAVE_NAMED:{
01372 char temp[255];
01373 Empty_Undo();
01374
01375
01376
01377
01378 }
01379 break;
01380 case IDM_FILE_SAVE_LETTERS:{
01381 char temp[255];
01382 Empty_Undo();
01383
01384
01385
01386
01387 }
01388 break;
01389 case IDM_FILE_SAVE_PATH:
01390 Empty_Undo();
01391 SavePath();
01392 break;
01393 #endif
01394 case IDM_PRIMITIVE_QADD_8:
01395 Save_Undo(0);
01396 if(BuildTTFfontString(ghwnd_main)){
01397 Zoom(CENTREWORLD,1);
01398 DrawModel();
01399 UpdateCounters();
01400 UpdateSkTreeView();
01401 }
01402 break;
01403 break;
01404 case IDM_PRIMITIVE_QADD_9:
01405 case IDM_FILE_IMPORT_ATM:
01406 Save_Undo(0);
01407 if(BuildATMfontString(ghwnd_main)){
01408 Zoom(CENTREWORLD,1);
01409 DrawModel();
01410 UpdateCounters();
01411 UpdateSkTreeView();
01412 }
01413 break;
01414 case IDM_FILE_IMPORT_SLELETON:
01415 if(SelectSfxFileName(0,gszSCEfile,gszSCEdir,IDX_MISC_INCLUDEMODEL,
01416 "(*.MFX)|*.mfx|",hwnd) == TRUE){
01417 Save_Undo(0);
01418 if(AddExternalSkeleton(gszSCEfile) != OK){
01419 SendPrgmMessage(IDS_FAILINCLUDE,1);
01420 }
01421 }
01422 break;
01423 case IDM_FILE_EXPORT_DXF:
01424 ExportDXFmodel(ghwnd_main);
01425 break;
01426 case IDM_FILE_EXPORT_3DS:
01427 Export3DSmodel(ghwnd_main);
01428 break;
01429 case IDM_FILE_EXPORT_STL:
01430 ExportModel(NULL,"stlout.dll");
01431 break;
01432 case IDM_FILE_EXPORT_VRML:
01433 ExportModel(NULL,"vrmlout.dll");
01434 break;
01435 case IDM_FILE_BOUNDINGBOX_CLEAR:
01436 ClearWireFrame();
01437 break;
01438 case IDM_FILE_BOUNDINGBOX_AUTO:
01439 case IDM_FILE_BOUNDINGBOX_MAKE:
01440 case IDM_FILE_BOUNDINGBOX_UNMAKE:
01441 Empty_Undo();
01442 if(tool != NOTOOL && tool != NODETOOL){
01443 SendPrgmQuery(IDQ_TOOLNOTFINISHED,0);
01444 break;
01445 }
01446 if (item == IDM_FILE_BOUNDINGBOX_MAKE)MakeWireFrame();
01447 else if(item == IDM_FILE_BOUNDINGBOX_UNMAKE)UnMakeWireFrame();
01448 else if(item == IDM_FILE_BOUNDINGBOX_AUTO)MakeAutoWireFrame();
01449 break;
01450 case IDM_FILE_BEZIER:
01451 if(ExecuteBezierModeler(ghwnd_main)){
01452 DrawModel();
01453 UpdateCounters();
01454 }
01455 break;
01456 case IDM_FILE_TRACEOUTLINE:
01457 if(TraceImageOutline(ghwnd_main)){
01458 DrawModel();
01459 UpdateCounters();
01460 }
01461 break;
01462
01463 case IDM_FILE_PAINTMAP:
01464 if(PaintMapOutline(ghwnd_main)){
01465 DrawModel();
01466 UpdateCounters();
01467 }
01468 break;
01469 case IDM_FILE_VIEWER:
01470 LoadMDIviewer();
01471 break;
01472 case IDM_FILE_HEIGHT:
01473 if(LoadHeightField(ghwnd_main)){
01474 DrawModel();
01475 UpdateCounters();
01476 }
01477 break;
01478 case IDM_FILE_EXTERNAL:
01479 if(ExecuteExternalModeler(ghwnd_main)){
01480 DrawModel();
01481 UpdateCounters();
01482 UpdateSkTreeView();
01483 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01484 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01485 }
01486 break;
01487 case IDM_FILE_ANIMATOR:
01488 ExecuteAnimator(FALSE);
01489 break;
01490 case IDM_FILE_UPDATE_ANIMATOR:{
01491 char load_file[256];
01492 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_UPDATE_ANIMATOR,MF_GRAYED);
01493 in_subroutine_mode=FALSE;
01494 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_ANIMATOR,MF_ENABLED);
01495 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_EXIT,MF_ENABLED);
01496 GetPrivateProfileString("CALLBACK","FILE","$$$",
01497 load_file,sizeof(load_file),IniFilename);
01498 if(strncmp(load_file,"$$$",3) == 0){
01499 SendPrgmQuery(IDQ_MODELERACTIVATEFAIL,0);
01500 break;
01501 }
01502 if(EDIT_ACTION && SendPrgmQuery(IDQ_SAVEBEFOREUPDATING,1) == IDYES){
01503 ghcurSave=SetCursor(ghcurWait);
01504 SaveObject(load_file,3);
01505 }
01506 else ghcurSave=SetCursor(ghcurWait);
01507 Empty_Undo();
01508 EraseAll(1);
01509 DrawModel();
01510 UpdateCounters();
01511 SetCursor(ghcurSave);
01512 ExecuteAnimator(TRUE);
01513 }
01514 break;
01515 case IDM_FILE_PRINT:
01516 break;
01517 case IDM_CONTEXT_TOOLSLEFT:
01518 bToolpannelLeft ^= 1;
01519 UpdateIconPositions();
01520 break;
01521 case IDM_CONTEXT_TOOLSSMALL:
01522 bToolpannelSmall ^= 1;
01523 ChangeToolboxBitmaps();
01524 UpdateIconPositions();
01525 break;
01526 case IDM_FILE_PREFERENCES:{
01527 PreferencesPropertyDlgProc(ghwnd_main);
01528 SendMessage(ghwndTooltip,TTM_ACTIVATE,(WPARAM)Preferences.tooltips,0);
01529 if(Preferences.toolleft != bToolpannelLeft ||
01530 Preferences.toolsmall != bToolpannelSmall){
01531 if(bToolpannelSmall != Preferences.toolsmall){
01532 bToolpannelSmall=Preferences.toolsmall;
01533 ChangeToolboxBitmaps();
01534 }
01535 bToolpannelLeft=Preferences.toolleft;
01536 UpdateIconPositions();
01537 }
01538 }
01539 break;
01540 case IDM_FILE_EXIT:
01541 if(EDIT_ACTION){
01542 int fResult;
01543 fResult=SendPrgmQuery(IDQ_CHANGED,2);
01544 if(fResult == IDNO)PostQuitMessage(0L);
01545 if(fResult == IDYES){
01546 #if !__DEMO__
01547 if(SelectSfxFileName(1,gszSCEfile,gszSCEdir,IDX_MISC_SAVEMODEL,
01548 "(*.MFX)|*.mfx|",hwnd) == TRUE){
01549 AppendFileExtension(gszSCEfile,".mfx");
01550 ghcurSave=SetCursor(ghcurWait);
01551 SaveObject(gszSCEfile,1);
01552 SetCursor(ghcurSave);
01553 PostQuitMessage(0L);
01554 }
01555 #endif
01556 }
01557 break;
01558 }
01559
01560 else PostQuitMessage(0L);
01561 break;
01562 case IDM_CALLBACK_SHUTDOWN:
01563 if(EDIT_ACTION)PostMessage(ghwnd_main,WM_COMMAND,IDM_FILE_EXIT,0);
01564 else PostQuitMessage(0L);
01565 break;
01566 case IDM_CALLBACK_LOAD_MODELER: {
01567 char load_file[255];
01568 if(EDIT_ACTION){
01569 HWND hWndPrev;
01570 SendPrgmQuery(IDQ_MODELERBUSY,0);
01571 PostMessage(ghwnd_main,WM_COMMAND,IDM_FILE_ANIMATOR,0);
01572 hWndPrev = FindWindow("OFX:AnimatorClass",NULL);
01573 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,
01574 IDM_CALLBACK_NORELOAD,0);
01575 break;
01576 }
01577 GetPrivateProfileString("CALLBACK","FILE","$$$",
01578 load_file,sizeof(load_file),IniFilename);
01579 if(strncmp(load_file,"$$$",3) == 0){
01580 SendPrgmQuery(IDQ_MODELERACTIVATEFAIL,0);
01581 break;
01582 }
01583 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_UPDATE_ANIMATOR,MF_ENABLED);
01584 in_subroutine_mode=TRUE;
01585 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_ANIMATOR,MF_GRAYED);
01586 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_EXIT,MF_GRAYED);
01587 strcpy(gszSCEfile,load_file);
01588 strcpy(gszSCEdir,load_file);
01589 *FileInPath(gszSCEdir) = '\0';
01590 goto LOADALL_POINT;
01591 }
01592 break;
01593 case IDM_FILE_LOAD_DIRECT: {
01594 char load_file[255];
01595 GetPrivateProfileString("CALLBACK","FILE","$$$",
01596 load_file,sizeof(load_file),IniFilename);
01597 if(strncmp(load_file,"$$$",3) == 0)break;
01598 strcpy(gszSCEfile,load_file);
01599 strcpy(gszSCEdir,load_file);
01600 *FileInPath(gszSCEdir) = '\0';
01601 goto LOADALL_POINT;
01602 }
01603 break;
01604 case IDM_EDIT_UNDO:
01605 Restore_Undo();
01606 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01607 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01608 break;
01609 case IDM_KEY_DELETE:
01610 Save_Undo(2);
01611 bUpdate=DeleteSelectedNurbsSurfaces();
01612 case IDM_EDIT_ERASE_VERTICES:
01613 if(!bUpdate)Save_Undo(2);
01614 if(EraseVertex(YES) || bUpdate){
01615 EDIT_ACTION=YES;
01616 DrawModel();
01617 UpdateCounters();
01618 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01619 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01620 }
01621 break;
01622 case IDM_EDIT_ERASE_EDGES:
01623 Save_Undo(2);
01624 if(EraseEdge(YES)){
01625 EDIT_ACTION=YES;
01626 DrawModel();
01627 UpdateCounters();
01628 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01629 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01630 }
01631 break;
01632 case IDM_EDIT_ERASE_ALL:
01633 if(SendPrgmQuery(IDQ_CONFIRM,1) == IDYES){
01634 NEWMODELPOINT:
01635 Empty_Undo();
01636 EraseAll(1);
01637 DrawModel();
01638 UpdateCounters();
01639 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01640 else PostMessage(ghwndOpenGLview,(WM_USER+4),0,0);
01641 SendPrgmMessage(IDS_DEFAULT,0);
01642 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_SAVE,MF_GRAYED);
01643 strcpy(gszSCEsaved,"unnamed.mfx");
01644 gszSCEfile[0]='\0';
01645 }
01646 break;
01647 case IDM_EDIT_ERASE_INDICATEDEDGE:
01648 Save_Undo(2);
01649 if(EraseIndicatedEdge()){
01650 EDIT_ACTION=YES;
01651 DrawModel();
01652 UpdateCounters();
01653 }
01654 break;
01655 case IDM_EDIT_ERASE_INDICATEDVERTEX:
01656 Save_Undo(2);
01657 if(EraseIndicatedVertex()){
01658 EDIT_ACTION=YES;
01659 DrawModel();
01660 UpdateCounters();
01661 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01662 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01663 }
01664 break;
01665 case IDM_EDIT_ERASE_HIERARCHY:
01666 EDIT_ACTION=YES;
01667 EraseAllSkeleton();
01668 break;
01669 case IDM_EDIT_ERASE_VERTEXMAPPING:
01670 EDIT_ACTION=YES;
01671 EraseVertexMapping();
01672 break;
01673
01674 case IDM_EDIT_SELECTALL:
01675 case IDM_EDIT_DESELECTALL:
01676 case IDM_EDIT_SWAPSELECT:
01677 case IDM_EDIT_SELECTCONNECT:
01678 case IDM_EDIT_DESELECTCONNECT:
01679 case IDM_EDIT_SELECTBY_COLOUR:
01680 case IDM_EDIT_SELECTBY_MAP:
01681 case IDM_EDIT_SELECTBY_SHADER:
01682 case IDM_EDIT_SELECTBY_BEZIER:
01683 case IDM_EDIT_SELECTBY_INVIEW:
01684 case IDM_EDIT_SELECTBY_OUTVIEW:
01685 case IDM_EDIT_SELECTMAPPED:
01686 case IDM_EDIT_DESELECTMAPPED:
01687 case IDM_EDIT_DESELECT_EVERY:
01688 Empty_Undo();
01689 ExecuteSelect(item);
01690 break;
01691
01692 case IDM_TOOLS_NODE:
01693 if(tool != NODETOOL)EngageDesignerTool(NODETOOL);
01694 break;
01695 case IDM_TOOLS_PAN:
01696 if(tool != PAN)EngageDesignerTool(PAN);
01697 break;
01698 case IDM_TOOLS_ZOOMIN:
01699 if(tool != INZOOM)EngageDesignerTool(INZOOM);
01700 break;
01701 case IDM_TOOLS_GRABBER:
01702 if(tool != GRABBER)EngageDesignerTool(GRABBER);
01703 break;
01704 case IDM_TOOLS_BUILDER:
01705 if(tool != BUILDER)EngageDesignerTool(BUILDER);
01706 break;
01707 case IDM_TOOLS_EXPANDER:
01708 if(tool != EXPANDER)EngageDesignerTool(EXPANDER);
01709 break;
01710 case IDM_TOOLS_ROTATOR:
01711 if(tool != ROTATOR)EngageDesignerTool(ROTATOR);
01712 break;
01713 case IDM_TOOLS_PLOTTER:
01714 if(tool != PLOTTER && tool != PLOT3D)EngageDesignerTool(PLOTTER);
01715 break;
01716 case IDM_TOOLS_SHAPER:
01717 if(tool != SHAPER)EngageDesignerTool(SHAPER);
01718 else EngageDesignerTool(MAGNETTO);
01719 break;
01720 case IDM_TOOLS_MAGNET_ATTRACT:
01721 if(tool != MAGNETTO && tool != SHAPER)EngageDesignerTool(MAGNETTO);
01722 break;
01723 case IDM_TOOLS_PLOT3D:
01724 if(tool != PLOT3D)EngageDesignerTool(PLOT3D);
01725 else EngageDesignerTool(PLOTTER);
01726 break;
01727
01728 case IDM_TOOLS_SELECTOR:
01729 if(tool != SELECTOR && tool != DESELECTOR)EngageDesignerTool(SELECTOR);
01730 break;
01731 case IDM_TOOLS_DESELECTOR:
01732 if(tool != DESELECTOR)EngageDesignerTool(DESELECTOR);
01733 else EngageDesignerTool(SELECTOR);
01734 break;
01735 case IDM_TOOLS_PRIMITIVES:
01736 if(tool != PRIMS)EngageDesignerTool(PRIMS);
01737 break;
01738 case IDM_PRIMITIVE_QADD:
01739 ExecutePrimitivesMenu(hwnd);
01740 break;
01741 case IDM_PRIMITIVE_QADD_1:
01742 case IDM_PRIMITIVE_QADD_2:
01743 case IDM_PRIMITIVE_QADD_3:
01744 case IDM_PRIMITIVE_QADD_4:
01745 case IDM_PRIMITIVE_QADD_5:
01746 case IDM_PRIMITIVE_QADD_6:
01747 case IDM_PRIMITIVE_QADD_7:
01748 AddSinglePrimitive(item);
01749 break;
01750 case IDM_SNAP_CLOSEST:
01751 case IDM_SNAP_CLOSESELECT:
01752 case IDM_SNAP_MIDPOINT:
01753 case IDM_SNAP_MIDSELECT:
01754 case IDM_SNAP_CENTROID:
01755 case IDM_SNAP_HPLANE:
01756 case IDM_SNAP_VPLANERL:
01757 case IDM_SNAP_VPLANEFB:
01758 case IDM_SNAP_STORE:
01759 case IDM_SNAP_TOSTORED:
01760 case IDM_SNAP_TOCOORD:
01761 case IDM_SNAP_INCREMENT:
01762 Empty_Undo();
01763 SnapCursorTo(item);
01764 break;
01765 case IDM_ACTIONS_BOOLEAN:
01766 case IDM_ACTIONS_TWIST:
01767 case IDM_ACTIONS_ORIENTATE:
01768 case IDM_ACTIONS_REVERSE:
01769 case IDM_ACTIONS_JOINS:
01770 case IDM_ACTIONS_MOVE:
01771 case IDM_ACTIONS_BUILD:
01772 case IDM_ACTIONS_SMOOTH:
01773 case IDM_ACTIONS_EFFECTS_PLAN:
01774 case IDM_ACTIONS_FACET:
01775 case IDM_ACTIONS_EXTRUDE_BEVEL:
01776 case IDM_ACTIONS_EXTRUDE_ROUND:
01777 case IDM_ACTIONS_BEZIER:
01778 case IDM_ACTIONS_EXPAND:
01779 case IDM_ACTIONS_FLIP:
01780 case IDM_ACTIONS_DUPLICATE_CONNECT:
01781 case IDM_ACTIONS_SPIN:
01782 case IDM_ACTIONS_DUPLICATE_MULTI:
01783 case IDM_ACTIONS_JOIN:
01784 case IDM_ACTIONS_EFFECTS_SHATTER:
01785 case IDM_ACTIONS_EXTRUDE_ALONG:
01786 case IDM_ACTIONS_EFFECTS_EXPLODE:
01787 case IDM_ACTIONS_ROTATE_CLOCKWISE:
01788 case IDM_ACTIONS_ROTATE_ANTICLOCKWISE:
01789 case IDM_ACTIONS_WELD:
01790 case IDM_ACTIONS_FILL:
01791 case IDM_ACTIONS_SUBDIVIDE:
01792 case IDM_TOOLS_EXTRUDE:
01793 case IDM_ACTIONS_DUPLICATE_MAKE:
01794 case IDM_TOOLS_ADDVERTEX:
01795 case IDM_TOOLS_BUILDFACET:
01796 case IDM_ACTIONS_TURNINDICATEDEDGE:
01797 case IDM_ACTIONS_SPLITALONG:
01798 case IDM_ACTIONS_GROW:
01799 ExecuteDesignerAction(item);
01800 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01801 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01802 break;
01803 case IDM_ACTIONS_SPECIAL_3DPLOT:
01804 case IDM_ACTIONS_SPECIAL_HELIX:
01805 case IDM_ACTIONS_SPECIAL_SPIRAL:
01806 case IDM_ACTIONS_SPECIAL_3DSPIRAL:
01807 case IDM_ACTIONS_SPECIAL_LINE:
01808 case IDM_ACTIONS_SPECIAL_BUTTERFLY:
01809 EDIT_ACTION=YES;
01810 SpecialFunction(item);
01811 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
01812 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01813 break;
01814
01815 case IDM_ATTRIBUTES_FACE:
01816 Empty_Undo();
01817 if(!IsWindow(ghwndDlgAttribs)){
01818 ghwndDlgAttribs=CreateDialog(ghinst_main,
01819 MAKEINTRESOURCE(DLG_ATTRIBS),
01820 ghwnd_main,(DLGPROC)AttribsDlgProc);
01821 }
01822 else{
01823 DestroyWindow(ghwndDlgAttribs);
01824 ghwndDlgAttribs=NULL;
01825 }
01826 break;
01827 case IDM_ATTRIBUTES_DEFAULT:
01828 DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_DEFAULT),ghwnd_main,
01829 (DLGPROC)DefaultAttribsDlgProc);
01830 break;
01831 case IDM_ATTRIBUTES_NEWMAP:
01832 if(axis_move_flag >= 0)break;
01833 Empty_Undo();
01834 DisengageDesignerTool();
01835 EditImageMap(-2);
01836 break;
01837 case IDM_ATTRIBUTES_MAP:
01838 Empty_Undo();
01839 DisengageDesignerTool();
01840 if(axis_move_flag >= 0){
01841 int id;
01842 id=axis_move_flag;
01843 axis_move_flag = -1;
01844 EditImageMap(id);
01845 }
01846 else {
01847 EditImageMap(-1);
01848 }
01849 break;
01850 case IDM_ATTRIBUTES_MAPAXES:
01851 DisengageDesignerTool();
01852 if(SelectedBrush < 0)PositionBrushOnOff(1,-1);
01853 else PositionBrushOnOff(0,SelectedBrush);
01854
01855 break;
01856 case IDM_ATTRIBUTES_PURGE:
01857 PurgeUnusedMaps();
01858 break;
01859 case IDM_ATTRIBUTES_SHADER_PURGE:
01860 PurgeUnusedMaterials();
01861 break;
01862 case IDM_ATTRIBUTES_VECTOR:
01863 VectorMaps();
01864 break;
01865 case IDM_ATTRIBUTES_EMBEDALLMAPS:
01866 EmbedAllMapsImages();
01867 break;
01868 case IDM_ATTRIBUTES_EXPORTALLMAPS:
01869 SaveRamImagesFromAllMaps();
01870 break;
01871 case IDM_ATTRIBUTES_UNLOADALLMAPS:
01872 UnloadRamImagesFromAllMaps();
01873 break;
01874 case IDM_MATERIAL_EDIT:
01875 Empty_Undo();
01876 DisengageDesignerTool();
01877 if(axis_move_flag >= 0){
01878 int id;
01879 id=axis_move_flag;
01880 axis_move_flag = -1;
01881 EditMaterial(id);
01882 }
01883 else {
01884 EditMaterial(-1);
01885 }
01886 break;
01887 case IDM_ATTRIBUTES_SHADER_NEW:
01888 CreateMaterial(TRUE);
01889 break;
01890 case IDM_ATTRIBUTES_SHADER_DELETE:
01891 DeleteMaterial(-1);
01892 break;
01893 case IDM_ATTRIBUTES_SHADER_PREVIEW:
01894
01895 break;
01896 case IDM_ATTRIBUTES_CENTREPOINT:
01897 ObjectAxis.Origin.xyz[0]=NpointerX;
01898 ObjectAxis.Origin.xyz[1]=NpointerY;
01899 ObjectAxis.Origin.xyz[2]=NpointerZ;
01900 EDIT_ACTION=YES;
01901 DrawModel();
01902 break;
01903 case IDM_ATTRIBUTES_FOLLOWPOINT:
01904 ObjectAxis.Offset.xyz[0]=NpointerX;
01905 ObjectAxis.Offset.xyz[1]=NpointerY;
01906 ObjectAxis.Offset.xyz[2]=NpointerZ;
01907 EDIT_ACTION=YES;
01908 DrawModel();
01909 break;
01910 case IDM_ATTRIBUTES_SHADOW:
01911
01912
01913
01914
01915
01916
01917 break;
01918 case IDM_ATTRIBUTES_MIRROR:
01919
01920 break;
01921 case IDM_ATTRIBUTES_REFINDEX:{
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932 }
01933 break;
01934 case IDM_ATTRIBUTES_EXPORTMATERIALS:
01935 ExportMaterialsToFile(hwnd);
01936 break;
01937 case IDM_ATTRIBUTES_IMPORTMATERIALS:
01938 ImportMaterialsFromFile(hwnd);
01939 break;
01940 case IDM_ATTRIBUTES_MAPFROMMAP:
01941 Empty_Undo();
01942 SelectMapAndMapVertices();
01943 break;
01944 case IDM_ATTRIBUTES_WRAPMAP:
01945 Empty_Undo();
01946 WrapMapSelectedFaces();
01947 if(ghwndOpenGLview != NULL)PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
01948 EDIT_ACTION=YES;
01949 break;
01950 case IDM_ATTRIBUTES_MAPONPATH:
01951 Empty_Undo();
01952 MapOntoPath();
01953 break;
01954 case IDM_ATTRIBUTES_SETVERTEXMAPPING:
01955 Empty_Undo();
01956 SetMapCoords();
01957 break;
01958 case IDM_ATTRIBUTES_EXTERNALSHADER:
01959 EnableToolPannels(ALL_PANNELS,FALSE);
01960
01961
01962 EnableToolPannels(ALL_PANNELS,TRUE);
01963 break;
01964 case IDM_HIERARCHY_NAME:{
01965 static BOOL in_hm=FALSE;
01966 if(Preferences.attribs_sheet){
01967 Empty_Undo();
01968 EDIT_ACTION=YES;
01969 SkeletonTreeView(ghwnd_main);
01970 }
01971 else{
01972 if(in_hm)break;
01973 in_hm=TRUE;
01974 Empty_Undo();
01975 EDIT_ACTION=YES;
01976 DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_SKEL),ghwnd_main,
01977 (DLGPROC)HierarchyDlgProc);
01978 in_hm=FALSE;
01979 }
01980 }
01981 break;
01982 case IDM_HIERARCHY_SELECT:
01983 case IDM_HIERARCHY_POSE:
01984 case IDM_HIERARCHY_STRETCH:
01985 case IDM_HIERARCHY_BUILD:
01986 case IDM_HIERARCHY_REMOVE:
01987 case IDM_HIERARCHY_INSERT:
01988 case IDM_HIERARCHY_ATTACH:
01989 case IDM_HIERARCHY_DUPLICATE:
01990 case IDM_HIERARCHY_TWIST:
01991 case IDM_HIERARCHY_RUBBERBONES:
01992 case IDM_HIERARCHY_RENAME:
01993 EngageSkeletonTool(item);
01994 break;
01995 case IDM_HIERARCHY_RUBBERMODELCONST: {
01996 HMENU hmenu;
01997 hmenu=GetMenu(ghwnd_main);
01998 rubberbone_model=1;
01999 if(rubberbone_model == 1){
02000 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELCONST,MF_CHECKED);
02001 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELVARI,MF_UNCHECKED);
02002 }
02003 else {
02004 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELCONST,MF_UNCHECKED);
02005 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELVARI,MF_CHECKED);
02006 }
02007 break;
02008 }
02009 case IDM_HIERARCHY_RUBBERMODELVARI: {
02010 HMENU hmenu;
02011 hmenu=GetMenu(ghwnd_main);
02012 rubberbone_model=0;
02013 if(rubberbone_model == 1){
02014 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELCONST,MF_CHECKED);
02015 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELVARI,MF_UNCHECKED);
02016 }
02017 else {
02018 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELCONST,MF_UNCHECKED);
02019 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELVARI,MF_CHECKED);
02020 }
02021 break;
02022 }
02023 case IDM_HIERARCHY_RESETWEIGHT:
02024 ResetSkeletonWeights();
02025 break;
02026 case IDM_HIERARCHY_AUTOASSIGN:
02027 AutoVerticesToSkeleton();
02028 break;
02029 case IDM_VIEW_HIDE:
02030 ExecuteHide(TRUE); DrawModel(); UpdateCounters();
02031 if(ghwndOpenGLview != NULL)PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02032 break;
02033 case IDM_VIEW_REVEAL:
02034 ExecuteHide(FALSE); DrawModel(); UpdateCounters();
02035 if(ghwndOpenGLview != NULL)PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02036 break;
02037 case IDM_ZOOM_IN:
02038 Zoom(ZOOMIN,1);
02039 break;
02040 case IDM_ZOOM_OUT:
02041 Zoom(ZOOMOUT,1);
02042 break;
02043 case IDM_ZOOM_CENTRE:
02044 Zoom(RECENTRE,1);
02045 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02046 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02047 break;
02048 case IDM_VIEW_RESTORE:
02049 GetTriview(TRUE);
02050 NpointerX=NpointerY=NpointerZ=0;
02051 DrawModel();
02052 UpdateRuler(0);
02053 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02054 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02055 break;
02056 case IDM_VIEW_FULL:
02057 Zoom(CENTREWORLD,1);
02058 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02059 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02060 break;
02061 case IDM_VIEW_DRAWING_HIDEEDGES:
02062 global_quickdraw ^= 1;
02063 if(global_quickdraw)CheckMenuItem(GetMenu(ghwnd_main),
02064 IDM_VIEW_DRAWING_HIDEEDGES,MF_CHECKED);
02065 else CheckMenuItem(GetMenu(ghwnd_main),
02066 IDM_VIEW_DRAWING_HIDEEDGES,MF_UNCHECKED);
02067 DrawModel();
02068 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02069 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02070 break;
02071 case IDM_VIEW_DRAWING_HIDEJOINS:
02072 draw_joins ^= 1;
02073 if(!draw_joins)CheckMenuItem(GetMenu(ghwnd_main),
02074 IDM_VIEW_DRAWING_HIDEJOINS,MF_CHECKED);
02075 else CheckMenuItem(GetMenu(ghwnd_main),
02076 IDM_VIEW_DRAWING_HIDEJOINS,MF_UNCHECKED);
02077 DrawModel();
02078 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02079 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02080 break;
02081 case IDM_VIEW_RENDERNOW:
02082 Render_View(0,1);
02083 break;
02084 case IDM_WINDOW_QUICKRENDER:
02085 case IDM_VIEW_RENDERINWINDOW:
02086 Render_View(0,2);
02087 break;
02088 case IDM_VIEW_RENDER:
02089 Render_View(0,0);
02090 break;
02091 case IDM_VIEW_SHOW:{
02092 int result;
02093 char modulename[255],cp[128],cn[128];
02094 GetPrivateProfileString("VIEWER","FILE","$$$",
02095 cn,sizeof(cn),IniFilename);
02096 GetPrivateProfileString("VIEWER","PATH","$$$",
02097 cp,sizeof(cp),IniFilename);
02098 if(strncmp(cn,"$$$",3) == 0 || strncmp(cp,"$$$",3) == 0){
02099 SendPrgmQuery(IDQ_NOVIEWIMAGE,0);
02100 }
02101 else LoadViewer(1);
02102 }
02103 break;
02104 case IDM_VIEW_WIREFRAME:
02105 if(ghwndOpenGLview == NULL)Draw3dView(0,1);
02106 break;
02107 case IDM_VIEW_HIDDENLINE:
02108 if(ghwndOpenGLview == NULL)Draw3dView(1,0);
02109 break;
02110 case IDM_VIEW_DRAW_GRID:
02111 draw_grid_on ^= 1;
02112 if(draw_grid_on)
02113 CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_CHECKED);
02114 else
02115 CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_UNCHECKED);
02116 DrawModel();
02117 break;
02118 case IDM_VIEW_GRID:
02119 grid_on ^= 1;
02120 if(grid_on)CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_GRID,MF_CHECKED);
02121 else CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_GRID,MF_UNCHECKED);
02122
02123 break;
02124 case IDM_VIEW_DEFINEGRID:
02125 SetUpGrid();
02126 if(draw_grid_on)
02127 CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_CHECKED);
02128 else
02129 CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_UNCHECKED);
02130 DrawModel();
02131 break;
02132 case IDM_VIEW_FEEDBACK_CURSOR:{
02133 char tt[128];
02134 Draw3dCursor();
02135 CursorToggle ^= 1;
02136 Draw3dCursor();
02137 if(CursorToggle){
02138 LoadString(ghinst_main,IDX_MISC_CROSSHAIR,tt,128);
02139 ModifyMenu(GetMenu(ghwnd_main),IDM_VIEW_FEEDBACK_CURSOR,
02140 MF_BYCOMMAND|MF_STRING,IDM_VIEW_FEEDBACK_CURSOR,tt);
02141 }
02142 else{
02143 LoadString(ghinst_main,IDX_MISC_CROSSWIRE,tt,128);
02144 ModifyMenu(GetMenu(ghwnd_main),IDM_VIEW_FEEDBACK_CURSOR,
02145 MF_BYCOMMAND|MF_STRING,IDM_VIEW_FEEDBACK_CURSOR,tt);
02146 }
02147 }
02148 break;
02149 case IDM_WINDOW_SWITCHWINDOWS:
02150 SwitchWindow(-1);
02151 break;
02152 case IDM_VIEW_SWAPVIEWPOINT:
02153 WindowBox_view ^= 1;
02154 SetUpWindowBoxView(WindowBox_view);
02155 SwapViewBitmaps();
02156 if(WindowBox_view)CheckMenuItem(GetMenu(ghwnd_main),
02157 IDM_VIEW_SWAPVIEWPOINT,MF_CHECKED);
02158 else CheckMenuItem(GetMenu(ghwnd_main),
02159 IDM_VIEW_SWAPVIEWPOINT,MF_UNCHECKED);
02160 DrawModel();
02161 break;
02162 case IDM_WINDOW_SWITCHWINDOW0:
02163 SwitchWindow(0);
02164 break;
02165 case IDM_WINDOW_SWITCHWINDOW1:
02166 SwitchWindow(1);
02167 break;
02168 case IDM_WINDOW_COORDS:{
02169 HMENU hmenu;
02170 int cv[2]={SW_HIDE,SW_SHOWNA};
02171 hmenu=GetMenu(ghwnd_main);
02172 coords_visible ^=1;
02173 if(IsWindow(ghwndCoord1))ShowWindow(ghwndCoord1,cv[coords_visible]);
02174 if(coords_visible)CheckMenuItem(hmenu,IDM_WINDOW_COORDS,MF_CHECKED);
02175 else CheckMenuItem(hmenu,IDM_WINDOW_COORDS,MF_UNCHECKED);
02176 }
02177 break;
02178 case IDM_WINDOW_ACTIVATE:{
02179 RECT r;
02180 POINT p;
02181 HDC hdc;
02182 int i;
02183 if(sktool == YES && tool == SKANIMATE){
02184 TabSkeletonAxis();
02185 break;
02186 }
02187 if(View == ONEVIEW){
02188 if(ActiveView == TRIFRONT)
02189 PostMessage(hwnd,WM_COMMAND,IDM_WINDOW_SWITCHWINDOW1,0);
02190 else
02191 PostMessage(hwnd,WM_COMMAND,IDM_WINDOW_SWITCHWINDOW0,0);
02192 break;
02193 }
02194 hdc=GetDC(ghwnd_main);
02195 FocusActiveWindow(hdc,FALSE);
02196 ActiveView++; if(ActiveView > 2)ActiveView=0;
02197 ghwnd_current=ghwnd_triview[ActiveView];
02198 FocusActiveWindow(hdc,FALSE);
02199 ReleaseDC(ghwnd_main,hdc);
02200 }
02201 break;
02202 case IDM_WINDOW_DATA:{
02203 HMENU hmenu;
02204 int cv[2]={SW_HIDE,SW_SHOW};
02205 hmenu=GetMenu(ghwnd_main);
02206 if(ghwndData)data_visible ^=1;
02207 if(ghwndData)ShowWindow(ghwndData,cv[data_visible]);
02208 if(data_visible)CheckMenuItem(hmenu,IDM_WINDOW_DATA,MF_CHECKED);
02209 else CheckMenuItem(hmenu,IDM_WINDOW_DATA,MF_UNCHECKED);
02210 }
02211 break;
02212 case IDM_WINDOW_TOOLLEFT:
02213 break;
02214 case IDM_WINDOW_RESET:
02215 Window0sizeX=TriviewSpaceX/2;
02216 Window0sizeY=TriviewSpaceY/2;
02217 if(View == TRIVIEW)FormatScreen();
02218 break;
02219 case IDM_WINDOW_SHOWALL:
02220 ToolboxShow(FALSE);
02221 ToolboxShow(TRUE);
02222 break;
02223 case IDM_WINDOW_SHOWOPENGL:
02224 StartOpenGL(FALSE);
02225 if(ghwndOpenGLview != NULL)PostMessage(ghwndOpenGLview,(WM_USER+4),0,0);
02226 break;
02227 case IDM_STOP:
02228 if(sktool == YES)DisengageSkeletonTool();
02229 else if(SelectedBrush >= 0)PositionBrushOnOff(0,SelectedBrush);
02230 else if(SelectedShader >= 0)PositionMaterialOnOff(0,SelectedShader);
02231 else if(tool != NOTOOL)DisengageDesignerTool();
02232 break;
02233 case IDM_HELP_HOME:{
02234 char lname[256],res_str[256];
02235 LoadString(ghinst_main,IDX_MISC_HOMEPAGE,res_str,256);
02236 strcpy(lname,gszHomeDir);
02237 ShellExecute(ghwnd_main,NULL,res_str,NULL,lname,0);
02238 }
02239 break;
02240 case IDM_HELP_SUPPORT:{
02241 char lname[256],res_str[256];
02242 LoadString(ghinst_main,IDX_MISC_SUPPORTPAGE,res_str,256);
02243 strcpy(lname,gszHomeDir);
02244 ShellExecute(ghwnd_main,NULL,res_str,NULL,lname,0);
02245 }
02246 break;
02247 case IDM_HELP:{
02248 char lname[256],res_str[256],res_str1[256],res_str2[256];
02249 LoadString(ghinst_main,IDX_MISC_HELPFILENAME,res_str,256);
02250 strcpy(lname,gszHomeDir); strcat(lname,"help\\");
02251 strcpy(res_str1,lname);
02252 strcat(res_str1,res_str);
02253 #if !__HELP_WS__
02254 ShellExecute(ghwnd_main,NULL,res_str1,
02255 NULL,lname,SW_SHOW);
02256 #else
02257 {
02258 HH_WINTYPE hhwin;
02259 char localname[32],localname1[32]=">";
02260 sprintf(localname,"MHelp%ld",rand());
02261 strcat(localname1,localname);
02262 memset(&hhwin,0,sizeof(HH_WINTYPE));
02263 hhwin.cbStruct=sizeof(HH_WINTYPE);
02264 hhwin.fsValidMembers = HHWIN_PARAM_SHOWSTATE |
02265 HHWIN_PARAM_PROPERTIES|
02266 HHWIN_PARAM_CUR_TAB|
02267 HHWIN_PARAM_EXPANSION|
02268 HHWIN_PARAM_RECT;
02269 hhwin.rcWindowPos.top=0;
02270 hhwin.rcWindowPos.left=0;
02271 hhwin.rcWindowPos.right=700;
02272 hhwin.rcWindowPos.bottom=500;
02273 hhwin.nShowState=SW_SHOW;
02274 hhwin.pszType=localname;
02275 LoadString(ghinst_main,IDX_MISC_HELPTITLE1,res_str,256);
02276 hhwin.pszCaption=res_str;
02277 hhwin.fNotExpanded = FALSE;
02278 hhwin.fsWinProperties = HHWIN_PROP_TRI_PANE|HHWIN_PROP_TAB_SEARCH;
02279 hhwin.curNavType=HHWIN_NAVTYPE_TOC;
02280 strcpy(res_str2,res_str1);
02281 strcat(res_str2,"::toc.hhc");
02282 hhwin.pszToc=res_str2;
02283 HtmlHelp(ghwnd_main,NULL,HH_SET_WIN_TYPE,(DWORD)&hhwin);
02284 hWndHelp=HtmlHelp(ghwnd_main,localname1,HH_DISPLAY_TOPIC,(DWORD)res_str1);
02285 }
02286 #endif
02287 }
02288 break;
02289 case IDM_HELP_GENERAL:{
02290 char lname[256],res_str[256],res_str1[256],res_str2[256];
02291 LoadString(ghinst_main,IDX_MISC_HELPFILENAME1,res_str,256);
02292 strcpy(lname,gszHomeDir); strcat(lname,"help\\");
02293 strcpy(res_str1,lname);
02294 strcat(res_str1,res_str);
02295 #if !__HELP_WS__
02296 ShellExecute(ghwnd_main,NULL,res_str1,
02297 NULL,lname,SW_SHOW);
02298 #else
02299 {
02300 HH_WINTYPE hhwin;
02301 char localname[32],localname1[32]=">";
02302 sprintf(localname,"GHelp%ld",rand());
02303 strcat(localname1,localname);
02304 memset(&hhwin,0,sizeof(HH_WINTYPE));
02305 hhwin.cbStruct=sizeof(HH_WINTYPE);
02306 hhwin.fsValidMembers = HHWIN_PARAM_SHOWSTATE |
02307 HHWIN_PARAM_PROPERTIES|
02308 HHWIN_PARAM_CUR_TAB|
02309 HHWIN_PARAM_EXPANSION|
02310 HHWIN_PARAM_RECT;
02311 hhwin.rcWindowPos.top=0;
02312 hhwin.rcWindowPos.left=0;
02313 hhwin.rcWindowPos.right=700;
02314 hhwin.rcWindowPos.bottom=500;
02315 hhwin.nShowState=SW_SHOW;
02316 hhwin.pszType=localname;
02317 LoadString(ghinst_main,IDX_MISC_HELPTITLE2,res_str,256);
02318 hhwin.pszCaption=res_str;
02319 hhwin.fNotExpanded = FALSE;
02320 hhwin.fsWinProperties = HHWIN_PROP_TRI_PANE|HHWIN_PROP_TAB_SEARCH;
02321 hhwin.curNavType=HHWIN_NAVTYPE_TOC;
02322 strcpy(res_str2,res_str1);
02323 strcat(res_str2,"::toc.hhc");
02324 hhwin.pszToc=res_str2;
02325 HtmlHelp(ghwnd_main,NULL,HH_SET_WIN_TYPE,(DWORD)&hhwin);
02326 hWndHelp=HtmlHelp(ghwnd_main,localname1,HH_DISPLAY_TOPIC,(DWORD)res_str1);
02327 }
02328 #endif
02329 }
02330 break;
02331 case IDM_HELP_HELP:
02332
02333 break;
02334 case IDM_HELP_ABOUT:
02335 DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_ABOUT),ghwnd_main,
02336 (DLGPROC)AboutDlgProc);
02337 break;
02338 case IDM_COORDS_DEFINE:
02339 UpdateRuler(3);
02340 break;
02341 case IDM_COORDS_ORIGIN:
02342 UpdateRuler(2);
02343 break;
02344 case IDM_COORDS_RELATIVE:
02345 UpdateRuler(1);
02346 break;
02347 case IDM_COORDS_MEASURE:
02348 UpdateRuler(0);
02349 break;
02350 case IDM_PAN_UP1:
02351 if(lparam == TRITOP )Zoom(PANFORWARD,1);
02352 if(lparam == TRIFRONT)Zoom(PANUP,1);
02353 if(lparam == TRIRIGHT)Zoom(PANUP,1);
02354 break;
02355 case IDM_PAN_UP:
02356 Nudge(item);
02357 break;
02358 case IDM_PAN_DOWN1:
02359 if(lparam == TRITOP )Zoom(PANBACK,1);
02360 if(lparam == TRIFRONT)Zoom(PANDOWN,1);
02361 if(lparam == TRIRIGHT)Zoom(PANDOWN,1);
02362 break;
02363 case IDM_PAN_DOWN:
02364 Nudge(item);
02365 break;
02366 case IDM_PAN_LEFT1:
02367 if(lparam == TRITOP )Zoom(PANLEFT,1);
02368 if(lparam == TRIFRONT)Zoom(PANLEFT,1);
02369 if(lparam == TRIRIGHT)Zoom(PANBACK,1);
02370 break;
02371 case IDM_PAN_LEFT:
02372 Nudge(item);
02373 break;
02374 case IDM_PAN_RIGHT1:
02375 if(lparam == TRITOP )Zoom(PANRIGHT,1);
02376 if(lparam == TRIFRONT)Zoom(PANRIGHT,1);
02377 if(lparam == TRIRIGHT)Zoom(PANFORWARD,1);
02378 break;
02379 case IDM_PAN_RIGHT:
02380 Nudge(item);
02381 break;
02382 case IDM_LOCK_SQUARE:
02383 case IDM_LOCK_CIRCLE:
02384 case IDM_LOCK_TRIANGLE:
02385 case IDM_LOCK_LOCK:
02386 ExecuteLockAction(item,SelectedBrush);
02387 break;
02388 case IDM_GLVIEW_ABOUT:
02389 case IDM_GLVIEW_SCROLLBARS:
02390 case IDM_GLVIEW_TWOSIDE:
02391 case IDM_GLVIEW_OVERLAY:
02392 case IDM_GLVIEW_STEREO:
02393 case IDM_GLVIEW_PREFS:
02394 case IDM_GLVIEW_HELP:
02395 case IDM_GLVIEW_MAP:
02396 case IDM_GLVIEW_SHADERS:
02397 case IDM_GLVIEW_ORTHO:
02398 case IDM_GLVIEW_SELECT_ONLY:
02399 case IDM_GLVIEW_OVERLAY_ALL:
02400 if(ghwndOpenGLview != NULL){
02401 SendMessage(ghwndOpenGLview,WM_COMMAND,item,0);
02402 }
02403 break;
02404 case IDM_NURBS_PRIM1:
02405 MakeNewNurbsSurface(1);
02406 break;
02407 case IDM_NURBS_PRIM2:
02408 MakeNewNurbsSurface(2);
02409 break;
02410 case IDM_NURBS_PRIM3:
02411 MakeNewNurbsSurface(3);
02412 break;
02413 case IDM_NURBS_PRIM4:
02414 MakeNewNurbsSurface(4);
02415 break;
02416 case IDM_NURBS_CREATE:
02417 MakeNewNurbsSurface(0);
02418 break;
02419 case IDM_NURBS_SELECT:
02420 SelectAllNurbs(TRUE);
02421 break;
02422 case IDM_NURBS_DESELECT:
02423 SelectAllNurbs(FALSE);
02424 break;
02425 case IDM_NURBS_SWAP:
02426 SwapNurbsSelection();
02427 break;
02428 case IDM_NURBS_DELETE:
02429 Save_Undo(2);
02430 if(DeleteSelectedNurbsSurfaces()){
02431 EDIT_ACTION=YES;
02432 DrawModel();
02433 UpdateCounters();
02434 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02435 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02436 }
02437 break;
02438 case IDM_NURBS_EDIT:
02439 EditSelectedNurbsSurface();
02440 break;
02441 case IDM_NURBS_HIDE:
02442 HideNurbs(TRUE);
02443 break;
02444 case IDM_NURBS_REVEAL:
02445 HideNurbs(FALSE);
02446 break;
02447 case IDM_NURBS_SETWEIGHTS:
02448 SetSelectedNurbsWeights();
02449 break;
02450 case IDM_NURBS_SPLIT:
02451 Save_Undo(2);
02452 SplitNurbs();
02453 break;
02454 case IDM_NURBS_TRIANGULATE2:
02455 Save_Undo(0);
02456 MeshNurbsSurface();
02457 break;
02458 case IDM_NURBS_TRIANGULATE1:
02459 Save_Undo(0);
02460 TriangulateNurbsSurface();
02461 break;
02462 default: break;
02463 }
02464 return;
02465 }
02466
02467 void ExecuteKeyboardKeyCommand(int key){
02468 switch(key){
02469 case VK_ESCAPE:{
02470 HWND hWnd;
02471 if(tool != NOTOOL)SendMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
02472 if((hWnd=FindWindow("OFX:RenderClass",NULL)) != NULL){
02473 PostMessage(hWnd,WM_CALLBACK_ABANDON,0,0);
02474 }
02475 }
02476 break;
02477 case VK_PRIOR:
02478
02479 break;
02480 case VK_NEXT:
02481
02482 break;
02483 case VK_HOME:
02484
02485 break;
02486 case VK_END:
02487
02488 break;
02489 default: break;
02490 }
02491 }
02492
02493 static void EngageSkeletonTool(int item){
02494 EDIT_ACTION=YES;
02495 DisengageDesignerTool();
02496 Empty_Undo();
02497 EnableToolPannels(SELECT_PANNEL,FALSE);
02498 ActivateAllMenus(ghwnd_main,MF_GRAYED);
02499 EnableMenuItem(GetMenu(ghwnd_main),IDM_STOP,MF_ENABLED);
02500 DrawMenuBar(ghwnd_main);
02501 sktool=YES;
02502 SetSkToolbarState(FALSE);
02503 SetCursor(ghcurArrowD);
02504 switch (item){
02505 case IDM_HIERARCHY_POSE: tool=SKANIMATE; break;
02506 case IDM_HIERARCHY_BUILD: tool=SKADD; break;
02507 case IDM_HIERARCHY_STRETCH: tool=SKGRAB; break;
02508 case IDM_HIERARCHY_TWIST: tool=SKTWIST; break;
02509 case IDM_HIERARCHY_REMOVE: tool=SKDELETE; break;
02510 case IDM_HIERARCHY_INSERT: tool=SKSUBDIV; break;
02511 case IDM_HIERARCHY_ATTACH: tool=SKASSIGN; break;
02512 case IDM_HIERARCHY_SELECT: tool=SKSELECT; break;
02513 case IDM_HIERARCHY_DUPLICATE: tool=SKDUPLICATE; break;
02514 case IDM_HIERARCHY_RUBBERBONES: tool=SKRUBBERBONES; break;
02515 case IDM_HIERARCHY_RENAME: tool=SKRENAME; break;
02516 default: break;
02517 }
02518 InvalidateRect(ghwndTools,NULL,FALSE);
02519 SkToolOn();
02520 if(tool == SKANIMATE){
02521 DrawModel();
02522 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02523 }
02524 else{
02525 SkeletonToolBar(ghwnd_main);
02526 DrawSkeleton();
02527 }
02528 }
02529
02530 void DisengageSkeletonTool(void){
02531 int oldtool;
02532 ActivateAllMenus(ghwnd_main,MF_ENABLED);
02533 EnableMenuItem(GetMenu(ghwnd_main),IDM_STOP,MF_GRAYED);
02534 EnableToolPannels(SELECT_PANNEL,TRUE);
02535 DrawMenuBar(ghwnd_main);
02536 oldtool=(int)tool;
02537 SkToolOff();
02538 SetSkToolbarState(TRUE);
02539 sktool=NO;
02540 tool=NOTOOL;
02541 SetCursor(ghcurArrow);
02542 InvalidateRect(ghwndTools,NULL,FALSE);
02543 if(oldtool == SKANIMATE){
02544 DrawModel();
02545 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
02546 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
02547 }
02548 else{
02549 SkeletonToolBar(ghwnd_main);
02550 DrawSkeleton();
02551 }
02552 }
02553
02554 static void EngageDesignerTool(int newtool){
02555 int oldtool;
02556 oldtool=tool;
02557 if(tool > INZOOM)EDIT_ACTION=YES;
02558 if(tool != NOTOOL || SelectedBrush >= 0 || SelectedShader >= 0)DisengageDesignerTool();
02559 Empty_Undo();
02560 tool=newtool;
02561 if(newtool == SELECTOR || newtool == DESELECTOR){
02562 if(tool == SELECTOR){
02563 SendPrgmMessage(IDS_T_SELECTOR,1);
02564 SetCursor(ghcurSelect);
02565 }
02566 else{
02567 SendPrgmMessage(IDS_T_DESELECTOR,1);
02568 SetCursor(ghcurDeselect);
02569 }
02570 goto UPD;
02571 }
02572 if(tool > INZOOM){
02573 EnableToolPannels(COMMAND_PANNEL|ACTION_PANNEL,FALSE);
02574 ActivateAllMenus(ghwnd_main,MF_GRAYED);
02575 DrawMenuBar(ghwnd_main);
02576 }
02577 if(tool != NOTOOL)EnableMenuItem(GetMenu(ghwnd_main),IDM_STOP,MF_ENABLED);
02578 if(tool == NODETOOL){
02579 SendPrgmMessage(IDS_T_NODETOOL,1);
02580 }
02581 else if(tool == PLOTTER){
02582 SendPrgmMessage(IDS_T_PLOTTER,1);
02583 Save_Undo(0);
02584 Plot3dOn();
02585 }
02586 else if(tool == GRABBER){
02587 SendPrgmMessage(IDS_T_GRABBER,1);
02588 Save_Undo(1);
02589 }
02590 else if(tool == PLOT3D || tool == BUILDER){
02591 if(tool == PLOT3D)SendPrgmMessage(IDS_T_PLOT3D,1);
02592 if(tool == BUILDER)SendPrgmMessage(IDS_T_BUILDER,1);
02593 Plot3dOn();
02594 }
02595 else if(tool == EXPANDER){
02596 SendPrgmMessage(IDS_T_EXPANDER,1);
02597 Save_Undo(1);
02598 IxpandOn();
02599 }
02600 else if(tool == ROTATOR){
02601 SendPrgmMessage(IDS_T_ROTATOR,1);
02602 Save_Undo(1);
02603 IrotateOn();
02604 }
02605 else if(tool == PRIMS){
02606 SendPrgmMessage(IDS_T_PRIMS,1);
02607 Save_Undo(0);
02608 if(!PrimitiveOn()){
02609 DisengageDesignerTool();
02610 }
02611 }
02612 else if(tool == SHAPER){
02613 SendPrgmMessage(IDS_T_SHAPER,1);
02614
02615 }
02616 else if(tool == MAGNETTO){
02617 SendPrgmMessage(IDS_T_MAGNETTO,1);
02618 Save_Undo(1);
02619 }
02620 else if(newtool == PAN){
02621 SendPrgmMessage(IDS_T_PAN,1);
02622 tool=newtool;
02623 }
02624 else if(newtool == INZOOM){
02625 SendPrgmMessage(IDS_T_INZOOM,1);
02626 tool=newtool;
02627 }
02628 UPD:
02629 if(newtool >= NTOOLS)newtool=NODETOOL;
02630 else if(tool != NOTOOL)SetCursor(ghcurTools[newtool]);
02631 InvalidateRect(ghwndTools,NULL,FALSE);
02632 return;
02633 }
02634
02635 void DisengageDesignerTool(void){
02636 int otool;
02637 otool=tool;
02638 if(SelectedBrush >= 0)PositionBrushOnOff(0,SelectedBrush);
02639 if(SelectedShader >= 0)PositionMaterialOnOff(0,SelectedShader);
02640 if(sktool == YES)DisengageSkeletonTool();
02641 if(tool == NOTOOL)return;
02642 if (tool == SELECTOR || tool == DESELECTOR){
02643 tool=NOTOOL;
02644 goto UPD;
02645 }
02646 if(tool > INZOOM){
02647 ActivateAllMenus(ghwnd_main,MF_ENABLED);
02648
02649 EnableToolPannels(COMMAND_PANNEL|ACTION_PANNEL,TRUE);
02650 DrawMenuBar(ghwnd_main);
02651 }
02652 if(tool != NOTOOL)EnableMenuItem(GetMenu(ghwnd_main),IDM_STOP,MF_GRAYED);
02653 if(tool == GRABBER){
02654 tool=NOTOOL;
02655 }
02656 else if(tool == PLOTTER || tool == PLOT3D || tool == BUILDER){
02657 Plot3dOff();
02658 tool=NOTOOL;
02659 }
02660 else if(tool == EXPANDER || tool == ROTATOR || tool == SHAPER){
02661 tool=NOTOOL;
02662 }
02663 else if(tool == MAGNETTO){
02664 tool=NOTOOL;
02665 }
02666 else if(tool == PRIMS){
02667 PrimitiveOff();
02668 tool=NOTOOL;
02669 }
02670 else if(tool == PAN || tool == INZOOM){
02671 tool=NOTOOL;
02672 }
02673 else if(tool == NODETOOL){
02674 tool=NOTOOL;
02675 }
02676 UPD:
02677 if(otool >= NTOOLS)otool=NODETOOL;
02678 InvalidateRect(ghwndTools,NULL,FALSE);
02679 SendPrgmMessage(IDS_T_NOTOOL,1);
02680 SetCursor(ghcurArrow);
02681 }
02682
02683 static void ExecuteDesignerAction(int item){
02684 if(tool > INZOOM)DisengageDesignerTool();
02685 if(sktool || SelectedBrush >= 0 || SelectedShader >= 0){
02686 SendPrgmQuery(IDQ_TOOLNOTFINISHED,0);
02687 return;
02688 }
02689 Empty_Undo();
02690 EDIT_ACTION=YES;
02691 switch (item){
02692 case IDM_TOOLS_ADDVERTEX:
02693 Save_Undo(0);
02694 if(!UpdateVertexHeap(Nvert+1))break;
02695 CreateVertex();
02696 DrawVerticesOnly((MainVp+Nvert-1));
02697 UpdateCounters();
02698 break;
02699 case IDM_TOOLS_BUILDFACET:
02700 Save_Undo(0);
02701 AddFace();
02702 UpdateCounters();
02703 break;
02704 case IDM_ACTIONS_DUPLICATE_MAKE:
02705 if(Nnurbs == 0 && NvertSelect == 0){
02706 SendPrgmQuery(IDQ_TOOFEWVERTICES,0);
02707 break;
02708 }
02709 Save_Undo(0);
02710 DuplicateSelectedNurbs();
02711 if(NvertSelect != 0 && AddCopy(1)){
02712 UpdateCounters();
02713 tool=GRABBER;
02714 InvalidateRect(ghwndTools,NULL,FALSE);
02715 SetCursor(ghcurTools[tool]);
02716 }
02717 break;
02718 case IDM_TOOLS_EXTRUDE:
02719 if(NvertSelect == 0){
02720 SendPrgmQuery(IDQ_TOOFEWVERTICES,0);
02721 break;
02722 }
02723 Save_Undo(0);
02724 if(Extrude(0)){
02725 UpdateCounters();
02726 tool=GRABBER;
02727 InvalidateRect(ghwndTools,NULL,FALSE);
02728 SetCursor(ghcurTools[tool]);
02729 }
02730 break;
02731 case IDM_ACTIONS_SUBDIVIDE:
02732 if(NvertSelect < 2 || Nedge < 1){
02733 SendPrgmQuery(IDQ_TOOFEWVERTICES,0);
02734 break;
02735 }
02736 Save_Undo(2);
02737 if(Subdivide(0,0,1) == OK){
02738 do_NOT_abort=TRUE;
02739 DrawModel();
02740 do_NOT_abort=FALSE;
02741 UpdateCounters();
02742 }
02743 break;
02744 case IDM_ACTIONS_FILL:
02745 if(NvertSelect == 0){
02746 SendPrgmQuery(IDQ_TOOFEWVERTICES,0);
02747 break;
02748 }
02749 if(NvertSelect == 0)break;
02750 Save_Undo(0);
02751 if(AutoFillFace(0)){
02752 do_NOT_abort=TRUE;
02753 DrawModel();
02754 do_NOT_abort=FALSE;
02755 UpdateCounters();
02756 }
02757 break;
02758 case IDM_ACTIONS_GROW:
02759 if(NvertSelect == 0){
02760 SendPrgmQuery(IDQ_TOOFEWVERTICES,0);
02761 break;
02762 }
02763 GrowSelectedAlongNormal();
02764 DrawModel();
02765 break;
02766 case IDM_ACTIONS_WELD:
02767 Replace_Faces(0,0.0);
02768 DrawModel();
02769 UpdateCounters();
02770 break;
02771 case IDM_ACTIONS_ROTATE_CLOCKWISE:
02772 case IDM_ACTIONS_ROTATE_ANTICLOCKWISE:
02773 Save_Undo(1);
02774 ActionRotate(ActiveView,90.0,1);
02775 break;
02776 case IDM_ACTIONS_EFFECTS_EXPLODE:
02777 Explode(1);
02778 break;
02779 case IDM_ACTIONS_EXTRUDE_ALONG:
02780 ExtrudeAlong();
02781 break;
02782 case IDM_ACTIONS_EFFECTS_SHATTER:
02783 ShatterEffect();
02784 break;
02785 case IDM_ACTIONS_JOIN:
02786 JoinTwoCurves();
02787 break;
02788 case IDM_ACTIONS_SPIN:
02789 Spin(1,0,FALSE,ActiveView);
02790 break;
02791 case IDM_ACTIONS_DUPLICATE_MULTI:
02792 Spin(0,0,FALSE,ActiveView);
02793 break;
02794 case IDM_ACTIONS_DUPLICATE_CONNECT:
02795 CopyConnected();
02796 break;
02797 case IDM_ACTIONS_FLIP:
02798 Flip();
02799 break;
02800 case IDM_ACTIONS_EXPAND:
02801 if(!IsWindow(ghwndDlgExpand)){
02802 ghwndDlgExpand=CreateDialog(ghinst_main,MAKEINTRESOURCE(DLG_EXPAND),
02803 ghwnd_main,(DLGPROC)ExpandDlgProc);
02804 if(IsWindow(ghwndDlgExpand))ShowWindow(ghwndDlgExpand,SW_SHOW);
02805 }
02806 break;
02807 case IDM_ACTIONS_MOVE:
02808 Save_Undo(1);
02809 DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_MOVE),ghwnd_main,
02810 (DLGPROC)MoveDlgProc);
02811 do_NOT_abort=TRUE;
02812 DrawModel();
02813 do_NOT_abort=FALSE;
02814 UpdateCounters();
02815 break;
02816 case IDM_ACTIONS_BEZIER:
02817 MakeBezierCurve();
02818 break;
02819 case IDM_ACTIONS_FACET:
02820 AutoFacetCurveWithHoles(0,1,0,0.0,0.0);
02821 break;
02822 case IDM_ACTIONS_EXTRUDE_BEVEL:
02823 AutoFacetCurveWithHoles(1,1,0,0.0,0.0);
02824 break;
02825 case IDM_ACTIONS_EXTRUDE_ROUND:
02826 AutoFacetCurveWithHoles(2,1,0,0.0,0.0);
02827 break;
02828 case IDM_ACTIONS_EFFECTS_PLAN:
02829 if(NvertSelect == 0)return;
02830 UnPlan();
02831 break;
02832 case IDM_ACTIONS_SMOOTH:
02833 SmoothCurve();
02834 break;
02835 case IDM_ACTIONS_BUILD:
02836 SendPrgmMessage(IDS_PLOTTERR,1);
02837 Save_Undo(0);
02838 EnableToolPannels(SELECT_PANNEL|COMMAND_PANNEL|ACTION_PANNEL|
02839 TOOL_PANNEL,FALSE);
02840 ActivateAllMenus(ghwnd_main,MF_GRAYED);
02841 DialogBox(ghinst_main,MAKEINTRESOURCE(DLG_BUILD),ghwnd_main,
02842 (DLGPROC)BuildAccurateCurveDlgProc);
02843 ActivateAllMenus(ghwnd_main,MF_ENABLED);
02844 EnableToolPannels(SELECT_PANNEL|COMMAND_PANNEL|ACTION_PANNEL|
02845 TOOL_PANNEL,TRUE);
02846 break;
02847 case IDM_ACTIONS_TURNINDICATEDEDGE:
02848 Save_Undo(2);
02849 TurnIndicatedEdge();
02850 DrawModel();
02851 UpdateCounters();
02852 break;
02853 case IDM_ACTIONS_SPLITALONG:
02854 Save_Undo(2);
02855 SplitSelectedAlongMaterialsMaps();
02856 DrawModel();
02857 UpdateCounters();
02858 break;
02859 case IDM_ACTIONS_BOOLEAN:
02860 LoadInternalAction("boolean.dll"); break;
02861 case IDM_ACTIONS_TWIST:
02862 LoadInternalAction("twist.dll"); break;
02863 case IDM_ACTIONS_ORIENTATE:
02864 LoadInternalAction("orient.dll"); break;
02865 case IDM_ACTIONS_REVERSE:
02866 LoadInternalAction("reverse.dll"); break;
02867 case IDM_ACTIONS_JOINS:
02868 LoadInternalAction("joins.dll"); break;
02869 default: break;
02870 }
02871 }
02872
02873
02874
02875 void InitializeLastFilesList(void){
02876 int i,id;
02877 HMENU hmenu;
02878 char iname[32],lname[256];
02879 hmenu=GetSubMenu(GetMenu(ghwnd_main),0);
02880 for(nLastFiles=0,i=0;i<NFILESLIST;i++){
02881 LastFilesList[i].present=FALSE;
02882 sprintf(iname,"STARTFILE%ld",i);
02883 GetPrivateProfileString(IniSection,iname,"$$$",
02884 LastFilesList[i].file,256,IniFilename);
02885 if(strncmp(LastFilesList[i].file,"$$$",3) == 0)break;
02886 LastFilesList[i].present=TRUE;
02887 nLastFiles++;
02888 id=LASTFILECMD+1+i;
02889 sprintf(lname,"&%ld %s",i+1,FileInPath(LastFilesList[i].file));
02890 InsertMenu(hmenu,IDM_FILE_EXIT,MF_ENABLED | MF_STRING,id,lname);
02891 }
02892 if(nLastFiles > 0)InsertMenu(hmenu,IDM_FILE_EXIT,MF_SEPARATOR,LASTFILECMD,0);
02893 }
02894
02895 static void UpdateLastFilesList(char *newname){
02896 int i,k,id;
02897 char iname[32],lname[256];
02898 HMENU hmenu;
02899 hmenu=GetSubMenu(GetMenu(ghwnd_main),0);
02900 if(nLastFiles > 0){
02901 for(i=0;i<nLastFiles;i++)
02902 if(strcmp(LastFilesList[i].file,newname) == 0)return;
02903 RemoveMenu(hmenu,LASTFILECMD,MF_BYCOMMAND);
02904 for(i=0;i<nLastFiles;i++)RemoveMenu(hmenu,LASTFILECMD+1+i,MF_BYCOMMAND);
02905 nLastFiles=min(nLastFiles+1,NFILESLIST);
02906 for(i=nLastFiles-1;i>0;i--){
02907 LastFilesList[i].present=LastFilesList[i-1].present;
02908 strcpy(LastFilesList[i].file,LastFilesList[i-1].file);
02909 }
02910 }
02911 else nLastFiles=1;
02912 LastFilesList[0].present=TRUE;
02913 strcpy(LastFilesList[0].file,newname);
02914 for(i=0;i<nLastFiles;i++){
02915 id=LASTFILECMD+1+i;
02916 sprintf(lname,"&%ld %s",i+1,FileInPath(LastFilesList[i].file));
02917 InsertMenu(hmenu,IDM_FILE_EXIT,MF_ENABLED | MF_STRING,id,lname);
02918 }
02919 InsertMenu(hmenu,IDM_FILE_EXIT,MF_SEPARATOR,LASTFILECMD,0);
02920 for(i=0;i<nLastFiles;i++){
02921 sprintf(iname,"STARTFILE%ld",i);
02922 WritePrivateProfileString(IniSection,iname,
02923 LastFilesList[i].file,IniFilename);
02924 }
02925 return;
02926 }
02927
02928
02929 #if 0
02930 case WM_MOUSEWHEEL:
02931 step_size = step_size_base*step_multiplier3;
02932 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)step_size *= 2;
02933 if(((long)wParam) < 0)step_size *= -1;
02934
02935
02936 zpos_offset += step_size;
02937 InvalidateRect(hWnd,NULL,FALSE);
02938 return 0;
02939 #endif
02940