Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPPGUI: 3D Plater #19

Open
lordofhyphens opened this issue May 7, 2018 · 72 comments

Comments

@lordofhyphens
Copy link
Owner

commented May 7, 2018

Port 3D Plater to C++ GUI.

@lordofhyphens lordofhyphens added this to To do in C++ GUI via automation May 7, 2018

@EitanSomething

This comment has been minimized.

Copy link

commented May 10, 2018

I would love to help, but I would need instructions on how to run the C++ GUI on windows.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 10, 2018

https://github.com/lordofhyphens/Slic3r/blob/cppgui/src/windows-build.txt there's the basics (written by someone else). You also need to have wxWidgets development files built and installed somewhere; the variable that needs to be set is WXWIN (for findWxWidgets). It should pick up the shared libraries no problem.

Whether or not you use VC++ (it needs to support c++11) is something that I currently don't care about. CMake should function with VC++ just fine and there's docs available online for that.

https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/

I don't do any development on Windows at this time, so that's the best I've got right now; I haven't even gotten the build server set up for Windows.

What I do know is that right now Slic3r is expecting the slic3r binary to live in the src dir and its var directory to be one directory level above it. Slic3r will just crash if it's anywhere else (this must be sorted out before this gets merged back to main branch).

@EitanSomething

This comment has been minimized.

Copy link

commented May 10, 2018

when i run CMake i get the error wx not found!

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 10, 2018

https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.zip

Download and build that to their instructions. Install to whatever directory.

Set the environment variable WXWIN to the directory you installed to.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 10, 2018

I built wxWidgets with the following two lines:

cmake -G "MinGW Makefiles" ..\wxWidgets-3.1.1 -DCMAKE_INSTALL_PREFIX=C:\dev\wxWidgets
-3.1.1-shared -DwxBUILD_SHARED=ON -DwxUSE_STL=ON

cmake --build . --target install -- -j4

I did build in a separate directory, wxWidgets-build when I ran these.

I then set WXWIN=C:\dev\wxWidgets-3.1.1-shared (search online for how to set environment variables on windows)

This assumes you built with MinGW-w64 and are using its make (I tend to use Powershell when I am on Windows).

My current "issue" on Windows is the opposite of yours; I can build and find wx, but not boost.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 10, 2018

Update: I can build on Windows now.

In the src subdirectory, I execute the following commands:

cmake -G"MinGW Makefiles" -DBOOST_ROOT=C:\dev\boost_1_63_0 
cmake --build . -- -j4
@EitanSomething

This comment has been minimized.

Copy link

commented May 10, 2018

Where did you create folder wxWidgets-build

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 11, 2018

I cannot, however, right now guarantee that Windows c++ gui works as intended. I was seeing some weird behavior with the 2d plater that currently doesn't happen on Linux (wxGTK).

You can currently ignore the initial errors, those are caused by me doing something incorrectly and windows wxwidgets popping a dialog box (whereas they are just console spam on linux)

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 11, 2018

Hop onto IRC #slic3r this will go quicker there.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 11, 2018

If your wxwidgets source folder is C:\dev\wxwidgets-src, then your wxwidgets-build dir would be C:\dev\wxwidgets-build

The "..\wxWidgets-3.1.1" in the command-line is the hint as to where wxWidgets-Build is.

@EitanSomething

This comment has been minimized.

Copy link

commented May 14, 2018

I extracted the wxWidgets into "C:\dev\wxWidgets-3.1.1"

I created and environment variable called WXWIN and set it to "C:\dev\wxWidgets-3.1.1"

I then created a folder called wxWidgets-build in "C:\dev"

I cd to "C:\dev\wxWidgets-build" and ran
cmake -G "MinGW Makefiles" ..\wxWidgets-3.1.1 -DCMAKE_INSTALL_PREFIX=C:\dev\wxWidgets-3.1.1-shared -DwxBUILD_SHARED=ON -DwxUSE_STL=ON

cmake --build . --target install -- -j4

I set enviroment variacle WXWIN to "C:/dev/wxWidgets-3.1.1-shared"

I opened up CMake and set where is the Source Code to "C:/Users/Eitan/Desktop/Slic3r/src"
and Where to build the binaries to "C:/Users/Eitan/Desktop/Slic3r/build"

I configured and selected MinGW Makefiles and used default native compilers.

I get in red "Wx not found!"

What am I doing wrong

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 14, 2018

WXWIN needs to be the full path to where wxwidgets is installed, so C:\dev\wxWidgets-3.1.1-shared

@EitanSomething

This comment has been minimized.

Copy link

commented May 14, 2018

That what I did

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 14, 2018

I'll do a clean build in a different checkout dir later today to see what is going on.

@EitanSomething

This comment has been minimized.

Copy link

commented May 14, 2018

Thanks.Can you can you record how you got it to work.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2018

  1. Install mingw-w64 7.3.0 with posix threads and seh exceptions
  2. Install Cmake (at least version 3.9)
  3. Download wxwidgets 3.1.1
  4. Extract wxwidgets to C:\dev\wxwidgets-3.1.1-src
  5. mkdir C:\dev\wxwidgets-3.1.1-build
  6. cd C:\dev\wxwidgets-3.1.1-build
  7. cmake -G"MinGW Makefiles" ../wxwidgets-3.1.1-src -DwxBUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=C:\dev\wxWidgets-3.1.1-static
  8. cmake --build . --target install -- -j4 (reference: http://docs.wxwidgets.org/3.1/overview_cmake.html)
  9. Set WXWIN `image
  10. Download and build Boost as per the wiki.
  11. Checkout Slic3r source
  12. mkdir /path/to/Slic3r/build
  13. cd /path/to/Slic3r/build
  14. cmake -G"MinGW Makefiles" ..\src\ -DBOOST_ROOT=C:\dev\boost_1_63_0
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/g++.exe
-- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Could NOT find Boost
-- Found wxWidgets: C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/wxbase31u_net.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/wxmsw31u_gl.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/wxmsw31u_html.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/wxmsw31u_aui.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/wxmsw31u_core.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/wxbase31u.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/libwxpng.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/libwxtiff.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/libwxjpeg.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/libwxzlib.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/libwxregexu.a;C:/dev/wxWidgets-3.1.1-static/lib/gcc_lib/libwxexpat.a;opengl32;glu32;winmm;comctl32;oleacc;rpcrt4;shlwapi;version;wsock32 (found version "3.1.1")
wx found!
-- Configuring done
-- Generating done
  1. cmake --build . -- -j4
  2. Watch Slic3r build.
@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

When running step 7 i get the error

MSBUILD : error MSB1001: Unknown switch.
Switch: -j4

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2018

Delete the wxwidgets-build directory and repeat the updated step 7. You're getting that error because you have MSVC installed and its version of make is getting detected instead of mingw.

@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

Do I need to set SLIC3R_STATIC to 1 in environment variables

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2018

No; I've recently changed the CMakeLists to take it on a -D command.

@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

Do I need to cd to /path/to/Slic3r and run
Build.PL
Build.PL --gui
before step 14

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2018

No. You should never run the Perl build scripts with this branch.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2018

I made a slight mistake, delete the build directory, remake it, and start again from step 14.

@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

Do you need to set WXWIN to something before step 7

@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

Do I need to add something from http://docs.wxwidgets.org/3.1/overview_cmake.html to /path/to/Slic3r/src/CMakeLists.txt

@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

I added
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
to the CMakelists.txt file in /path/to/Slic3r/src

@EitanSomething

This comment has been minimized.

Copy link

commented May 15, 2018

When I run "cmake . --build -- -j4" I get the error

CMake Error: The source directory "C:/Users/Eitan/Desktop/cppgui/build/-j4" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented May 15, 2018

@EitanSomething No, you don't need to set WXWIN until right before step 14.

The CMakeLists.txt file should build on Windows as-is (and it does on my system on a clean checkout of the software).

cmake --build . -- -j4 instead, I transposed them when typing into Github.

@EitanSomething

This comment has been minimized.

Copy link

commented Jun 7, 2018

You can take over this part of the project.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 7, 2018

@EitanSomething

This comment has been minimized.

Copy link

commented Jun 7, 2018

I will continue working on getting it to work with visual studios in the summer. I think the best bet is to use the MinGW debugger in VS.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 8, 2018

As soon as I made Plate3D based on wxGLCanvas instead of wxPanel, it scaled automatically. Not sure why I couldn't get it to do that as a child. I played around with the mouse input, and didn't have any big problems.

@lordofhyphens, design question, I was thinking of having a base class which is just a renderer with camera movement which all of the 3D windows would extend. Most of the input controls and additional features aren't shared between the plater, preview and dialogs. Thoughts? Additionally, would it be ok to only support rendering triangles; if so, it would make the base renderer quite concise.That would require the 3d preview to generate triangles instead of quads, but I don't think it would affect any other code.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 8, 2018

@TheThirdOne sounds like a good design. The 3D view gets reused a lot in Slic3r.

@EitanSomething

This comment has been minimized.

Copy link

commented Jun 8, 2018

Better part rotation is needed.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 9, 2018

No visible progress today. Made a base class and copied (as comments) most of the relevant perl code and started to to convert it. The lighting opengl calls aren't directly compatible, and I haven't ever used lighting without shaders, so I'm not sure exactly how to do that. I think its just a matter of making arrays to pass instead of having multiple arguments, but not sure.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 9, 2018

@TheThirdOne if the arguments are strongly related, you could pass tuples or POD structs. The nice thing about the POD structure is that you get an initializer list for it.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 12, 2018

The only visible progress I made today was the gradient background. I have have the main render method done now though; it just comes down to implementing sub routines like drawGround and drawVolumes.

@lordofhyphens: I am not sure why the ground rendering is using buffers. I thought the main reason to use buffers was to minimize the transfer of data between the CPU and GPU; it mainly is an optimization to make objects that aren't modified much faster. If that understanding is correct, why is being deleted immediately after being used; deleting it immediately should get rid of most or all of the benefit? And if it doesn't offer a significant performance benefit, why bother with the additional code path?

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 12, 2018

@TheThirdOne probably inexperience at the time of the developer. If you have what you believe is a better solution, go for it.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 14, 2018

I worked on getting the camera movement working, and hit an issue with the lateral movement. gluUnProject returns (-)nan on pretty much any input point. I think I must have the projection matrix set up incorrectly or something. Looking on it with fresh eyes in the morning may reveal a stupid error though.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 15, 2018

Still haven't figured out the issue with unprojecting. It should be possible to make a system that doesn't use it if only using the turntable system of rotation. The trackball system is turned off in the perl version, but I don't know if there are any forks that people use that have it enabled.

I got bed rendering working, but the setting the bed shape isn't coded yet.

@lordofhyphens, it probably makes sense to have a volume struct (or class) like what the perl version has. Do you think that should just be a part of the base class's header or should it be separate? Pretty much the only files that would need to access it would be descendants of the base class.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 15, 2018

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 19, 2018

Setting the bed shape is working. The next step to work on would be loading volumes.

Currently, this is what it looks like:
plate

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 20, 2018

I got volume loading working, though with a segmentation fault when full screened and without proper lighting. My next steps will be to debug both of those issues.

It took me far longer than it should have to get GLVertexArray linking with the gui executable.

@lordofhyphens: Also, I didn't see the update method you had already made so my question on IRC was worthless.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 20, 2018

I will figure out how to make a Doxygen target for building; hopefully it helps.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 21, 2018

Fixed the issues (including the gluUnproject issue) and began working on selection.

here is it working:
modelloaded

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 22, 2018

Hover works now, but with some coloring issues. I believe that the Default colorscheme is incorrectly setup for part_color which makes the parts transparent; I just made it straight yellow in the meantime. Just a few minutes ago I realized that with multiple volumes, coloring for some of the volumes get's messed up.

@lordofhyphens, I pushed the menu fix to menuquickfix and the rest of my changes are built on top of that at Scene3D.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 23, 2018

I fixed the color issues. Part by fixing the colorscheme issues, and adding an i++ for the multiple volume issue. I got moving volumes working.

moving

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 26, 2018

I did a little cleaning up of the code and looked into the Cut dialog and 3d preview to prepare for implementing one of them.

I also spent some time looking for an stl with multiple volumes to make sure that my code matches the perl code for how multi volume objects are handled. I didn't find one though. I'll probably just create one, but I don't have software ready to that.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 26, 2018

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 27, 2018

Thanks, for the suggestion. I didn't think about just using Slic3r. It appears that my implementation does indeed treat multiple volumes correctly. Though as testing that I noticed a lag before auto arrange took place. Perl Slic3r has a similar lag, but on beginning to move a model rather than the end. I am not sure what is causing that.

I continued cleanup a bit, then moved on to implementing the cut dialog.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jun 28, 2018

I did some detailed reading of the perl code trying to understand why each part is needed. This essentially came down to commenting out parts I thought were unnecessary and then seeing when it crashed. Only one piece that I thought was unnecessary actually was.

I should have a good enough understanding of the system now to start non-blindly translating and hopefully get something on screen.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 28, 2018

@TheThirdOne that is an excellent approach.

Something else you could do to augment it is to write down the desired behaviors of the system in the form of Given-When-Then https://g.co/kgs/6tZesH and use that to guide your development.

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jun 29, 2018

@TheThirdOne by the way, if you need to print debug statements, make use of the methods in Slic3r::Log. There's a helper macro as well in misc_ui.hpp to convert wxString() constructs to std::wstring.

My primary use of it is to let me compose more complicated debug print statements.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jul 1, 2018

I made progress on translating ObjectCutDialog, but I don't have anything on-screen yet.

@lordofhyphens, I saw logging used it in Plater and Plate2D. I used it to help me debug as I wrote Scene3D and Plate3D. I don't have any logging in it currently because I don't have a good idea of what should vs shouldn't be logged. Most of it would just be rendering specific except for selection and moving which I believe are logged later upon signalling the plater.

On another unrelated note, should the code handle being built without OpenGL? There are a few references to Slic3r::GUI::have_OpenGL in the perl code. I would think they would need to be converted to preprocessor stuff if building the GUI with OpenGL should be supported.

@TheThirdOne

This comment has been minimized.

Copy link

commented Jul 2, 2018

When I opened up Sllic3r with a model to test the cut dialog, I ran into a weird bug where features from the back of a model can be see from the front.

wierdness

I didn't spend much time trying to figure this out, but I did confirm it does happen with an early version too. I think this must be due to differences in OpenGL implementations between my different machines.

I worked on translating the cut dialog more and got it onscreen, though mostly empty.

@lordofhyphens lordofhyphens moved this from To do to In progress in C++ GUI Jul 17, 2018

@lordofhyphens lordofhyphens moved this from In progress to Done in C++ GUI Jul 17, 2018

@lordofhyphens

This comment has been minimized.

Copy link
Owner Author

commented Jul 17, 2018

Code has been merged #35. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
3 participants
You can’t perform that action at this time.