Author Topic: Early WIP on v2.55  (Read 138162 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: Early WIP on v2.55
« Reply #345 on: December 19, 2018, 06:26:23 pm »
And here is what could be the ToolWindow with the Pandora's build-in color selector.

Code: [Select]
C_IMPORT HWND      zColorCtrl(IN long x, IN long y, IN long w, IN long h, IN HWND hParent, IN long nID, IN long UseColor);
C_IMPORT long      zGetPickColor(IN long nColor, IN long RW);
« Last Edit: December 19, 2018, 06:40:28 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #346 on: December 19, 2018, 08:46:11 pm »
Dear friend,

I will respond to your messages a little later; need to have my somewhat late dinner first.

Attached please find my today's work. Added wireframe overlay, bounding boxes, and bounding spheres rendering modes.

BTW the bounding spheres rendering mode revealed that our mesh radius calc is evidently incorrect; the radius seems to be too large. Need to do something about it later on...  :-\
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: Early WIP on v2.55
« Reply #347 on: December 19, 2018, 09:33:11 pm »
Mike

May i ask you why you remove this code from

BOOL DetectHotKeys(MSG* msg) { // PAT: 10-26-2018 The new tool popup window is now fired here

    if (gP.useSplitFrame == 2) { // PAT: 12-16-2018
        if (!ZI_IsLButtonDown()) {
            gP.useSplitFrame = 1;
            ZD_SetObjectFrameToUse(ID_SPLITTER_VERT, gP.useSplitFrame, true);
            PutFocusOn(gP.hGL);
        }
    }


    if (msg->wParam == VK_MENU) {
        if (GetMenuState(gP.hMnu, MENU_INFOTIP, MF_BYCOMMAND) & MF_CHECKED) { // MLL 11-28-2018: info tip ALT mode support
            static BOOL isVisibilitySaved = FALSE; // ALT key autorepeat suppressor
            size_t nMeshCount = gtm_meshes.size();
            if ((msg->message == WM_SYSKEYDOWN) && (infoTipMeshID > -1) && !isVisibilitySaved) { // only if other than background
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #348 on: December 19, 2018, 09:51:25 pm »
May i ask you why you remove this code from ...

Patrice,

I don't know what you're talking about. I have never gotten a Main.cpp from you for sync'ing that would contain such code... :o

Please merge my latest patch with your code and then send me all your main project files for final re-sync'ing.


[UPD] Ah yes, this code fixes the glitch with the green dots staying on the splitter after a double click.
« Last Edit: December 19, 2018, 09:58:17 pm by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #349 on: December 19, 2018, 10:27:45 pm »
You're welcome, my friend, and thank you for the sync zip!

Main.cpp and texture files are identical. What redards Splitter.h, I don't see why we should forward declare the same function twice in 15 lines of code. Please use the following code starting on line 85 in Splitter.h:

........
        void gl_DrawScene();
        if (gP.splitXoffset == 0) { // Move to center
            gP.splitXoffset = (w - SPLITTER_WIDTH) / 2;
            for (x = 0; x <= gP.splitXoffset; x += nStep) {
                MoveWindow(gP.hGL, -x, 0, w, h, TRUE);
                MoveSplitter();
                gP.redraw = -1; gl_DrawScene(); // Let the animation play while moving the window
                //Sleep(0);
            }
        } else { // Dock to the right
            for (x = WasXoffset; x >= 0; x -= nStep) {
                MoveWindow(gP.hGL, -x, 0, w, h, TRUE);
                MoveSplitter();
                gP.redraw = -1; gl_DrawScene(); // Let the animation play while moving the window
                //Sleep(0);
            }
            gP.splitXoffset = 0;
        }
........
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: Early WIP on v2.55
« Reply #350 on: December 19, 2018, 10:30:00 pm »
Quote
Here's the old DSW converted to a new VS 2013 SLN. It compiles for both x86 and x64 without a single error or warning.

Thank you very much!

That would allow us to display this kind of help file directly inside of OR
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #351 on: December 19, 2018, 10:36:09 pm »
:D

Very nice but with one objection: an RTF file is going to be perhaps 10 times larger than a corresponding (zipped) CHM. ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: Early WIP on v2.55
« Reply #352 on: December 19, 2018, 11:21:57 pm »
I would like to have something directly embedded into OR.

About the example you have kindly coverted for me, i didn't know that it was base on MFC.

MFC is a NoNo for me, what i want, is a pure Win32 solution (like the one i am using in my other applications, but so far i can only display plain text without images, because OLE is missing from my code).

Here is the very short Win32 code i am using to display plain text without image.

Code: [Select]
#pragma once
#include <Richedit.h>

DWORD CALLBACK EditStreamCallback(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG* pcb) {
    HANDLE hFile = (HANDLE)dwCookie;
    return !ReadFile(hFile, lpBuff, cb, (DWORD*)pcb, NULL);
}

BOOL LoadRTF(IN HWND hWnd) {
    BOOL fSuccess = FALSE;
    HANDLE fHandle = 0;
    EDITSTREAM es = { 0 };
    WCHAR szFileName[MAX_PATH] = {0};
    Path_Combine(szFileName, skSkinFolder(), L"HELP.rtf");
    if (FileExist(szFileName)) {
        if (zFOpen(szFileName, 0, 2, fHandle) == 0) {
            es.pfnCallback = EditStreamCallback;
            es.dwCookie = (DWORD_PTR) fHandle;
            LRESULT nRet = SendMessage(hWnd, EM_STREAMIN, SF_RTF, (LPARAM) &es);
            zFClose(fHandle); fHandle = 0;
        }
    }
    return fSuccess;
}

void MoveHelp () {
    if (IsWindowVisible(gP.hHelp)) {
        RECT rc = { 0 };
        GetViewRect(gP.hMain, &rc);
        MoveWindow(gP.hHelp, 0, 0, Width(rc), Height(rc), true);
        PutFocusOn(gP.hHelp);
    }
}

// Create help control
HWND CreateHelp(IN HINSTANCE hInstance) {
    RECT lpr; GetViewRect(gP.hGL, &lpr);

    DWORD dwStyle = WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_READONLY | WS_BORDER;
    DWORD dwExStyle = 0;
    //HWND hWnd = CreateWindowEx(0, L"RichEdit20A", $NULL, dwStyle, 0, 0, 0, 0, gP.hMain, (HMENU) IDC_RICHEDIT, hInstance, NULL);

    HWND hWnd = CreateWindowEx(0, MSFTEDIT_CLASS, L"", dwStyle, 0, 0, Width(lpr), Height(lpr), gP.hMain, NULL, hInstance, NULL);
    //HWND hWnd = CreateWindowEx(0, L"RichEdit20A", $NULL, dwStyle, 100, 0, Width(lpr), Height(lpr), gP.hMain, NULL, hInstance, NULL);
    if (IsWindow(hWnd)) {
        LoadRTF(hWnd);
    }
    return hWnd;
}

and in Main.cpp
Code: [Select]
                    //HMODULE hRichEdit = LoadLibrary(L"RICHED20.DLL");
                    HMODULE hRichEdit = LoadLibrary(L"Msftedit.dll");
                    if (hRichEdit) {
                        gP.hHelp = CreateHelp(hInstance);
                        if (IsWindow(gP.hHelp)) {
                            Path_Combine(gP.mt.FullName, skSkinFolder(), L"BTN_Help.png");
                            hCtrl = skButtonImage(gP.hMain, gP.mt.FullName, ClientW - 127, 664, IDC_USERHELP, 5);
                            skCreateToolTip(hCtrl, TipFormat(L"User help"));
                        }
                    }
« Last Edit: December 19, 2018, 11:28:59 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #353 on: December 20, 2018, 12:05:36 am »
... so far i can only display plain text without images, because OLE is missing from my code).

Probably if you could copy the RTF file onto the clipboard as RTF_TEXT then you would be able to paste-special it into your rich text control automagically together with the images? I think (but I'm not sure) the clipboard copy-paste operations would use system OLE facilities rather than your literal code... :-\
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: Early WIP on v2.55
« Reply #354 on: December 20, 2018, 12:13:14 am »
I just checked the new "Bounding volumes".

I can see the sphere problem you have found, but all in one that is a nice addition!
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #355 on: December 20, 2018, 12:37:18 am »
Re. sphere problem, that's because we calc the radius as half the distance between literal min and max bounds. But we shoul calc it as half the distance between two diagonally opposing corners of the real AABB whose calc I added to the function. That's gonna generate a shorter diagonal and radius, hence, a tighter bounding sphere. 8)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #356 on: December 20, 2018, 01:43:21 am »
Here's the last patch for today. It implements rendering color coded meshes. The bounding sphere radius isn't fixed yet.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #357 on: December 20, 2018, 08:27:24 am »
!!! MAKE SURE TO MERGE THE PRECEDING PATCH FIRST !!! (see message #360 above)

Here comes today's first patch: Close all and clear scene implemented. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: Early WIP on v2.55
« Reply #358 on: December 20, 2018, 12:14:09 pm »
Here is the rudimentary code i came with, for the Help.h

Code: [Select]
#pragma once
#include <Richedit.h>
#include <Richole.h>

BOOL InsertObject(HWND hRichEdit, LPCTSTR pszFileName) {
    HRESULT hr;

    LPRICHEDITOLE pRichEditOle;
    SendMessage(hRichEdit, EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle);
    if (pRichEditOle == NULL) { return FALSE; }

    LPLOCKBYTES pLockBytes = NULL;
    hr = CreateILockBytesOnHGlobal(NULL, TRUE, &pLockBytes);
    if (FAILED(hr)) { return FALSE; }

    LPSTORAGE pStorage;
    hr = StgCreateDocfileOnILockBytes(pLockBytes, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, &pStorage);
    if (FAILED(hr)) { return FALSE; }

    FORMATETC formatEtc;
    formatEtc.cfFormat = 0;
    formatEtc.ptd = NULL;
    formatEtc.dwAspect = DVASPECT_CONTENT;
    formatEtc.lindex = -1;
    formatEtc.tymed = TYMED_NULL;

    LPOLECLIENTSITE pClientSite;
    hr = pRichEditOle->GetClientSite(&pClientSite);
    if (FAILED(hr)) { return FALSE; }

    LPUNKNOWN pUnk;
    CLSID clsid = CLSID_NULL;

    hr = OleCreateFromFile(clsid, pszFileName, IID_IUnknown, OLERENDER_DRAW, &formatEtc, pClientSite, pStorage, (void**)&pUnk);
    pClientSite->Release();
    if (FAILED(hr)) { return FALSE; }

    LPOLEOBJECT pObject;
    hr = pUnk->QueryInterface(IID_IOleObject, (void**)&pObject);
    pUnk->Release();
    if (FAILED(hr)) { return FALSE; }

    OleSetContainedObject(pObject, TRUE);
    REOBJECT reobject = { sizeof(REOBJECT)};
    hr = pObject->GetUserClassID(&clsid);
    if (FAILED(hr)) { pObject->Release(); return FALSE; }

    reobject.clsid = clsid;
    reobject.cp = REO_CP_SELECTION;
    reobject.dvaspect = DVASPECT_CONTENT;
    reobject.dwFlags = REO_RESIZABLE | REO_BELOWBASELINE;
    reobject.dwUser = 0;
    reobject.poleobj = pObject;
    reobject.polesite = pClientSite;
    reobject.pstg = pStorage;
    SIZEL sizel = { 0 };
    reobject.sizel = sizel;

    SendMessage(hRichEdit, EM_SETSEL, 0, -1);
    DWORD dwStart, dwEnd;
    SendMessage(hRichEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
    SendMessage(hRichEdit, EM_SETSEL, dwEnd+1, dwEnd+1);
    SendMessage(hRichEdit, EM_REPLACESEL, TRUE, (WPARAM)L"\n");

    hr = pRichEditOle->InsertObject(&reobject);
    pObject->Release();
    pRichEditOle->Release();

    if (FAILED(hr)) { return FALSE; }
   
    return TRUE;
}

BOOL LoadRTF(IN HWND hWnd) {
    BOOL fSuccess = FALSE;
    HANDLE fHandle = 0;
    EDITSTREAM es = { 0 };
    WCHAR szFileName[MAX_PATH] = { 0 };
    Path_Combine(szFileName, skSkinFolder(), L"HELP.rtf");
    if (FileExist(szFileName)) {
        fSuccess = InsertObject(hWnd, szFileName);
    }
    return fSuccess;
}

void MoveHelp () {
    if (IsWindowVisible(gP.hHelp)) {
        RECT rc = { 0 };
        GetViewRect(gP.hMain, &rc);
        MoveWindow(gP.hHelp, SPLITTER_WIDTH, 0, Width(rc) - SPLITTER_WIDTH, Height(rc), true);
        PutFocusOn(gP.hHelp);
    }
}

// Create help control
HWND CreateHelp(IN HINSTANCE hInstance) {
    RECT lpr; GetViewRect(gP.hGL, &lpr);

    DWORD dwStyle = WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_READONLY;// | WS_BORDER;
    DWORD dwExStyle = 0;
    HWND hWnd = CreateWindowEx(0, MSFTEDIT_CLASS, L"", dwStyle, 0, 0, 0, 0, gP.hMain, NULL, hInstance, NULL);
    if (IsWindow(hWnd)) {
        LoadRTF(hWnd);
    }
    return hWnd;
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #359 on: December 20, 2018, 01:22:47 pm »
The code seems clear enough to me. :)

Re. custom skinned color dialogs, I think putting them directly on the tool window i) will make the window unnecessarily and disproportionately large, and ii) will leave the three buttons mostly without work though they'll still be needed for other tasks in other shading modes.

So, I'd suggest putting them in a neatly skinned window of their own to show on pressing the buttons instead of the standard color dialogs. I suppose the arrow button that pops up the list of predefined colors can also be skinned to match the general look of the app's other windows?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)