void UnfoldPattern::initConnect(){
	connect(ui.actionImport, SIGNAL(triggered()), this, SLOT(openFile()));
	connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(saveObjFile()));
	connect(ui.actionSave_Texture, SIGNAL(triggered()), this, SLOT(saveTextureFile()));
	
	connect(ui.actionCoordidate_System, SIGNAL(triggered()), this, SLOT(showCoorSystem()));
	connect(ui.actionSymmetry_axis, SIGNAL(triggered()), this, SLOT(showSymAxis()));

	connect(ui.actionStartUnfold, SIGNAL(triggered()), this, SLOT(startUnfoldModel()));
}
示例#2
0
/*
 *----------------------------------------------------------
 *      savingMenu
 *  Added by Thompson Peter Lied at 08/03/2004
 *----------------------------------------------------------
 */
void savingMenu(int item)
{
	switch(item)
	{
		case 0:
				writeOptikOutput( sessionFileName );
				break;
		case 1:
				writeVertigoOutput( sessionFileName );
				break;
		case 2:
				saveCellsFile( expFileName );
				break;
		case 3:
				saveSessionFile( sessionFileName );
				break;
		case 4:
				savePrimitivesFile( primitivesFileName, NumberPrimitives);
				break;
		case 5:
				if ( expFilePresent )
						writeInventorOutput( expFileName );
				else
						writeInventorOutput( "foo.iv" );
				/* saveInventorFile(); */
				break;
		case 6:
				saveObjFile( sessionFileName );
				break;
				/* Added by Thompson Peter Lied in 23/08/2002 */
				/* This function writes the pattern file and material library
				 */
		case 7:
				savePatternFile( sessionFileName );
				break;
				/* end */
		case 8:
				saveVectors( sessionFileName );
				break;
		case 9:
				saveVectorField( sessionFileName );
				break;
		default:
				break;
	}
	glutPostRedisplay();
}
示例#3
0
LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;   
    static int dwPos;
    switch (message) 
    { 

    case WM_CREATE:{ 
        toolBar = createToolbar(hWnd); 
        objectSelector = createComboEx(hWnd); 
        initButtons(hWnd);
        break;
    }  
    case WM_SIZE:{ 
        width = LOWORD(lParam);
        height = HIWORD(lParam);
        MoveWindow(toolBar, 0, 20, width, 5, TRUE);
        MoveWindow(hwndEdit, 0, 40, width / 2 - 5, height - 40, TRUE); 
        MoveWindow(hwndView, width / 2, 40, width / 2, height / 2, TRUE);
        MoveWindow(objectSelector, width/2+10, height/2+100, 100, 100, TRUE);
        MoveWindow(checkBox, width / 2 + 120, height / 2 + 100, 120, 20, TRUE);
        MoveWindow(deleteButton, width / 2 + 245, height / 2 + 100, 40, 40, TRUE);

        MoveWindow(controlButtons[0], width / 2 + 450, height / 2 + 180, 40, 40, TRUE);
        MoveWindow(controlButtons[1], width / 2 + 350, height / 2 + 180, 40, 40, TRUE);
        MoveWindow(controlButtons[2], width / 2 + 400, height / 2 + 120, 40, 40, TRUE);
        MoveWindow(controlButtons[3], width / 2 + 400, height / 2 + 240, 40, 40, TRUE);

        MoveWindow(controlButtons[4], width / 2 + 450, height / 2 + 300, 40, 40, TRUE);
        MoveWindow(controlButtons[5], width / 2 + 350, height / 2 + 300, 40, 40, TRUE);
        reSizeGLScene(width / 2, height / 2);
        DrawGLScene();
        break; 
    }
    case WM_LBUTTONDOWN:{
        SetFocus(mainWindow);
        break;
    }
    case WM_MOUSEWHEEL:
        if ((short)HIWORD(wParam) > 0)
        {
            objCamera.Move_Camera(CAMERASPEED);
            DrawGLScene();
        }
        if ((short)HIWORD(wParam) < 0)
        {
            objCamera.Move_Camera(-CAMERASPEED);
            DrawGLScene();
        }
        break;
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);   
        if (HIWORD(wParam) == CBN_SELCHANGE)
            // If the user makes a selection from the list:
            //   Send CB_GETCURSEL message to get the index of the selected list item.
            //   Send CB_GETLBTEXT message to get the item.
        { 
            int ItemIndex = SendMessage((HWND)lParam, (UINT)CB_GETCURSEL,
                (WPARAM)0, (LPARAM)0);
            if (ItemIndex != CB_ERR){
                EnableWindow(deleteButton, TRUE);  
                LPCSTR nameStr = objNames[ItemIndex].c_str();
                fileToEdit(nameStr); 
                int hid = BST_CHECKED; 
                selected = objects[ItemIndex];
                currentObjIndex = ItemIndex;
                if (objects[ItemIndex]->hidden == true){
                    hid = BST_UNCHECKED;
                }
                else{
                    hid = BST_CHECKED;
                }
                CheckDlgButton(hWnd, ID_CHECK_DISP_OBJ, hid);
            }
            else{
                CheckDlgButton(hWnd, ID_CHECK_DISP_OBJ, BST_INDETERMINATE);
            }
        }
        switch (wmId)
        {
        case ID_CHECK_DISP_OBJ:
            if (wmEvent == BN_CLICKED)
            {
                dwPos = SendMessage(checkBox, BM_GETCHECK, 0, 0);
                if (dwPos == BST_CHECKED)
                {
                    CheckDlgButton(hWnd, ID_CHECK_DISP_OBJ, BST_UNCHECKED);
                    selected->hidden = true;
                    DrawGLScene();

                }
                else if (dwPos == BST_UNCHECKED) {
                    CheckDlgButton(hWnd, ID_CHECK_DISP_OBJ, BST_CHECKED);
                    selected->hidden = false;
                    DrawGLScene();
                }
                dwPos = SendMessage(checkBox, BM_GETCHECK, 0, 0);
            }
            break;
        case ID_BUTTON_DEL_OBJ:
            if (wmEvent == BN_CLICKED)
            {
                int ItemIndex = SendMessage(objectSelector, (UINT)CB_GETCURSEL,
                    (WPARAM)0, (LPARAM)0);
                if (ItemIndex != CB_ERR){
                    objects.erase(objects.begin() + ItemIndex);
                    objNames.erase(objNames.begin() + ItemIndex);
                    SendMessage(objectSelector, (UINT)CB_DELETESTRING,
                        (WPARAM)ItemIndex, (LPARAM)0);
                }
                int top = SendMessage(objectSelector, (UINT)CB_GETCOUNT, (WPARAM)0, (LPARAM)0);
                if (top != 0){
                    SendMessage(objectSelector, (UINT)CB_SETCURSEL, (WPARAM)top - 1, (LPARAM)0);
                    selected = objects[top - 1];
                    LPCSTR nameStr = objNames[top - 1].c_str();
                    fileToEdit(nameStr);
                }
                else{
                    SendMessage(objectSelector, (UINT)CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
                    selected = NULL;
                    SetDlgItemText(hWnd, ID_EDITOR, TEXT(""));
                    SendMessage(toolBar, TB_ENABLEBUTTON, IDM_SAVE, FALSE);
                }

                ItemIndex = SendMessage(objectSelector, (UINT)CB_GETCURSEL,
                    (WPARAM)0, (LPARAM)0);
                if (ItemIndex == CB_ERR){
                    EnableWindow(deleteButton, FALSE);
                    CheckDlgButton(hWnd, ID_CHECK_DISP_OBJ, BST_INDETERMINATE);
                }
                else{
                    int hid = BST_CHECKED;
                    if (objects[ItemIndex]->hidden == true){
                        hid = BST_UNCHECKED;
                    }
                    else{
                        hid = BST_CHECKED;
                    }
                    CheckDlgButton(hWnd, ID_CHECK_DISP_OBJ, hid);
                }
                DrawGLScene();
            }
            break; 
        case ID_BUTTON_RIGHT:
            if (selected){
                selected->t_x += 0.1f;
                DrawGLScene();
            }
            break;
        case ID_BUTTON_LEFT:
            if (selected){
                selected->t_x -= 0.1f;
                DrawGLScene();
            }
            break;
        case ID_BUTTON_DOWN:
            if (selected){
                selected->t_y -= 0.1f;
                DrawGLScene();
            }
            break;
        case ID_BUTTON_UP:
            if (selected){
                selected->t_y += 0.1f;
                DrawGLScene();
            }
            break;
        case ID_BUTTON_ROTATE_RIGHT:
            if (selected){
                selected->rotation -= 1.0f;
                if (selected->rotation > 359.0f)
                    selected->rotation = 0.0f;
                if (selected->rotation < -1.0f)
                    selected->rotation = 359.0f;
                DrawGLScene();
            }
            break;
        case ID_BUTTON_ROTATE_LEFT:
            if (selected){
                selected->rotation += 1.0f;
                if (selected->rotation > 359.0f)
                    selected->rotation = 0.0f;
                if (selected->rotation < -1.0f)
                    selected->rotation = 359.0f;
                DrawGLScene();
            }
            break;
        case ID_EDITOR:
            switch (wmEvent)
            {
            case EN_MAXTEXT:
                MessageBeep(0);
            default:
                break;
            }
            break;
        case IDM_SAVE:{
            BOOL res = saveObjFile(hWnd, ID_EDITOR);
            if (!res){
                MessageBox(NULL, TEXT("Writting error"),
                    TEXT("Error"), MB_ICONERROR);
            }
            break;
        }
        case IDM_RUN:{
            objects.clear();
            for (std::vector<std::string>::iterator it = objNames.begin(); it != objNames.end(); ++it){
                objects.push_back(new MifObject(*it));
            }
            int ItemIndex = SendMessage(objectSelector, (UINT)CB_GETCOUNT,
                (WPARAM)0, (LPARAM)0);
            if (ItemIndex != 0){
                selected = objects[currentObjIndex];
            }
            else{
                selected = NULL;
            }
            DrawGLScene();
            break;
        }
        case IDM_OPEN:{
            BOOL loaded = openFileIntoEditor(hwndEdit, ID_EDIT);
            SendMessage(toolBar, TB_ENABLEBUTTON, IDM_SAVE, loaded); 
            DrawGLScene();
            break;
        }
        case IDM_about: 
            DialogBox(hInst, MAKEINTRESOURCE(IDD_aboutBOX), mainWindow, about);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_KEYDOWN:
        switch (wParam)
        {
        case VK_UP:
            objCamera.Move_Camera(CAMERASPEED);
            break;
        case VK_DOWN:
            objCamera.Move_Camera(-CAMERASPEED);
            break;
        case VK_LEFT:
            objCamera.Strafe_Camera(-CAMERASPEED);
            break;
        case VK_RIGHT:
            objCamera.Strafe_Camera(CAMERASPEED);
            break;
        case VK_HOME:
            openFileIntoEditor(hwndEdit, ID_EDIT);
            break; 
        case VK_F1:
            {
                primitive = GL_LINE_LOOP;
                DrawGLScene();
            }
            break;
        case VK_F2:
            {
                primitive = GL_POLYGON;
                DrawGLScene();
                  }
            break;
        case VK_ESCAPE:{
            SetWindowTextA(hwndEdit, "");
            PostQuitMessage(0);
            break;
        }
        default:
            return 0;
        }
        DrawGLScene();
        break;
    case WM_PAINT:
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    }
    return DefWindowProc(hWnd, message, wParam, lParam);
}