mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-02 21:10:38 +08:00
experiment to stub out C++ only GUI
This commit is contained in:
parent
b54c02908b
commit
be580fc9ee
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 3.10)
|
||||||
project (slic3r)
|
project (slic3r)
|
||||||
|
|
||||||
# only on newer GCCs: -ftemplate-backtrace-limit=0
|
# only on newer GCCs: -ftemplate-backtrace-limit=0
|
||||||
@ -17,14 +17,17 @@ IF(CMAKE_HOST_APPLE)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation -lc++")
|
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation -lc++")
|
||||||
ELSE(CMAKE_HOST_APPLE)
|
ELSE(CMAKE_HOST_APPLE)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -L.")
|
||||||
ENDIF(CMAKE_HOST_APPLE)
|
ENDIF(CMAKE_HOST_APPLE)
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
|
||||||
set(Boost_USE_STATIC_RUNTIME ON)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
find_package(Boost COMPONENTS system thread filesystem)
|
find_package(Boost COMPONENTS system thread filesystem)
|
||||||
|
|
||||||
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/../xs/src/)
|
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/../xs/src/)
|
||||||
|
set(GUI_LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/GUI/)
|
||||||
|
|
||||||
include_directories(${LIBDIR})
|
include_directories(${LIBDIR})
|
||||||
include_directories(${LIBDIR}/libslic3r)
|
include_directories(${LIBDIR}/libslic3r)
|
||||||
@ -123,29 +126,29 @@ add_library(poly2tri STATIC
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_executable(slic3r slic3r.cpp)
|
add_executable(slic3r slic3r.cpp)
|
||||||
set_target_properties(slic3r PROPERTIES LINK_SEARCH_START_STATIC 1)
|
#set_target_properties(slic3r PROPERTIES LINK_SEARCH_START_STATIC 1)
|
||||||
set_target_properties(slic3r PROPERTIES LINK_SEARCH_END_STATIC 1)
|
#set_target_properties(slic3r PROPERTIES LINK_SEARCH_END_STATIC 1)
|
||||||
|
|
||||||
add_executable(extrude-tin utils/extrude-tin.cpp)
|
#add_executable(extrude-tin utils/extrude-tin.cpp)
|
||||||
set_target_properties(extrude-tin PROPERTIES LINK_SEARCH_START_STATIC 1)
|
#set_target_properties(extrude-tin PROPERTIES LINK_SEARCH_START_STATIC 1)
|
||||||
set_target_properties(extrude-tin PROPERTIES LINK_SEARCH_END_STATIC 1)
|
#set_target_properties(extrude-tin PROPERTIES LINK_SEARCH_END_STATIC 1)
|
||||||
|
|
||||||
set(wxWidgets_USE_STATIC)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
SET(wxWidgets_USE_LIBS)
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
|
||||||
set(Boost_USE_STATIC_RUNTIME ON)
|
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
|
||||||
find_library(bsystem_l boost_system)
|
find_library(bsystem_l boost_system)
|
||||||
add_library(bsystem STATIC IMPORTED)
|
add_library(bsystem SHARED IMPORTED)
|
||||||
set_target_properties(bsystem PROPERTIES IMPORTED_LOCATION ${bsystem_l})
|
set_target_properties(bsystem PROPERTIES IMPORTED_LOCATION ${bsystem_l})
|
||||||
find_library(bthread_l boost_thread)
|
find_library(bthread_l boost_thread)
|
||||||
add_library(bthread STATIC IMPORTED)
|
add_library(bthread SHARED IMPORTED)
|
||||||
set_target_properties(bthread PROPERTIES IMPORTED_LOCATION ${bthread_l})
|
set_target_properties(bthread PROPERTIES IMPORTED_LOCATION ${bthread_l})
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
#find_package(wxWidgets)
|
set(wxWidgets_USE_STATIC OFF)
|
||||||
#disable wx for the time being - we're not building any of the gui yet
|
set(wxWidgets_USE_UNICODE ON)
|
||||||
|
|
||||||
|
find_package(wxWidgets COMPONENTS base aui core)
|
||||||
|
|
||||||
IF(CMAKE_HOST_UNIX)
|
IF(CMAKE_HOST_UNIX)
|
||||||
#set(Boost_LIBRARIES bsystem bthread bfilesystem)
|
#set(Boost_LIBRARIES bsystem bthread bfilesystem)
|
||||||
ENDIF(CMAKE_HOST_UNIX)
|
ENDIF(CMAKE_HOST_UNIX)
|
||||||
@ -155,9 +158,15 @@ target_link_libraries (slic3r libslic3r admesh BSpline clipper expat polypartiti
|
|||||||
IF(wxWidgets_FOUND)
|
IF(wxWidgets_FOUND)
|
||||||
MESSAGE("wx found!")
|
MESSAGE("wx found!")
|
||||||
INCLUDE("${wxWidgets_USE_FILE}")
|
INCLUDE("${wxWidgets_USE_FILE}")
|
||||||
add_library(slic3r_gui STATIC ${LIBDIR}/slic3r/GUI/3DScene.cpp ${LIBDIR}/slic3r/GUI/GUI.cpp)
|
include_directories(${GUI_LIBDIR})
|
||||||
|
include_directories(${wxWidgets_INCLUDE})
|
||||||
|
|
||||||
|
add_library(slic3r_gui STATIC
|
||||||
|
${GUI_LIBDIR}/MainFrame.cpp
|
||||||
|
${GUI_LIBDIR}/GUI.cpp
|
||||||
|
)
|
||||||
#only build GUI lib if building with wx
|
#only build GUI lib if building with wx
|
||||||
target_link_libraries (slic3r slic3r-gui ${wxWidgets_LIBRARIES})
|
target_link_libraries (slic3r slic3r_gui ${wxWidgets_LIBRARIES})
|
||||||
ELSE(wxWidgets_FOUND)
|
ELSE(wxWidgets_FOUND)
|
||||||
# For convenience. When we cannot continue, inform the user
|
# For convenience. When we cannot continue, inform the user
|
||||||
MESSAGE("wx not found!")
|
MESSAGE("wx not found!")
|
||||||
@ -170,8 +179,8 @@ IF (WIN32)
|
|||||||
${LIBDIR}/boost/nowide/iostream.cpp
|
${LIBDIR}/boost/nowide/iostream.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(slic3r boost-nowide)
|
target_link_libraries(slic3r STATIC boost-nowide)
|
||||||
target_link_libraries(extrude-tin boost-nowide)
|
# target_link_libraries(extrude-tin boost-nowide)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
target_link_libraries (extrude-tin libslic3r admesh BSpline clipper expat polypartition poly2tri ${Boost_LIBRARIES})
|
#target_link_libraries (extrude-tin libslic3r admesh BSpline clipper expat polypartition poly2tri ${Boost_LIBRARIES})
|
||||||
|
22
src/GUI/GUI.cpp
Normal file
22
src/GUI/GUI.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "MainFrame.hpp"
|
||||||
|
#include "GUI.hpp"
|
||||||
|
//using namespace Slic3r;
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ID_Hello = 1
|
||||||
|
};
|
||||||
|
bool Slic3rGUI::OnInit()
|
||||||
|
{
|
||||||
|
MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
|
frame->Show( true );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
10
src/GUI/GUI.hpp
Normal file
10
src/GUI/GUI.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef GUI_HPP
|
||||||
|
#define GUI_HPP
|
||||||
|
#include "MainFrame.hpp"
|
||||||
|
class Slic3rGUI: public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GUI_HPP
|
90
src/GUI/MainFrame.cpp
Normal file
90
src/GUI/MainFrame.cpp
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#include "MainFrame.hpp"
|
||||||
|
|
||||||
|
wxBEGIN_EVENT_TABLE(MainFrame, wxFrame)
|
||||||
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
|
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false),
|
||||||
|
tabpanel(NULL)
|
||||||
|
{
|
||||||
|
// Set icon to either the .ico if windows or png for everything else.
|
||||||
|
|
||||||
|
this->init_tabpanel();
|
||||||
|
this->init_menubar();
|
||||||
|
|
||||||
|
wxToolTip::SetAutoPop(TOOLTIP_TIMER);
|
||||||
|
|
||||||
|
// STUB: Initialize status bar with text.
|
||||||
|
/* # initialize status bar
|
||||||
|
$self->{statusbar} = Slic3r::GUI::ProgressStatusBar->new($self, -1);
|
||||||
|
$self->{statusbar}->SetStatusText("Version $Slic3r::VERSION - Remember to check for updates at http://slic3r.org/");
|
||||||
|
$self->SetStatusBar($self->{statusbar}); */
|
||||||
|
|
||||||
|
this->loaded = 1;
|
||||||
|
|
||||||
|
// Initialize layout
|
||||||
|
{
|
||||||
|
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
sizer->Add(this->tabpanel, 1, wxEXPAND);
|
||||||
|
sizer->SetSizeHints(this);
|
||||||
|
this->Fit();
|
||||||
|
this->SetMinSize(wxSize(760, 490));
|
||||||
|
this->SetSize(this->GetMinSize());
|
||||||
|
wxTheApp->SetTopWindow(this);
|
||||||
|
this->Show();
|
||||||
|
this->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Private initialization function for the main frame tab panel.
|
||||||
|
void MainFrame::init_tabpanel()
|
||||||
|
{
|
||||||
|
this->tabpanel = new wxAuiNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP);
|
||||||
|
auto panel = this->tabpanel;
|
||||||
|
|
||||||
|
panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, ([=](wxAuiNotebookEvent& e)
|
||||||
|
{
|
||||||
|
auto panel = this->tabpanel->GetPage(this->tabpanel->GetSelection());
|
||||||
|
if panel->can('OnActivate') panel->OnActivate();
|
||||||
|
}), panel->GetId());
|
||||||
|
|
||||||
|
// this->plater = Slic3r::GUI::Plater(panel, _("Plater"));
|
||||||
|
// this->controller = Slic3r::GUI::Controller(panel, _("Controller"));
|
||||||
|
|
||||||
|
/*
|
||||||
|
sub _init_tabpanel {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{tabpanel} = my $panel = Wx::AuiNotebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP);
|
||||||
|
EVT_AUINOTEBOOK_PAGE_CHANGED($self, $self->{tabpanel}, sub {
|
||||||
|
my $panel = $self->{tabpanel}->GetPage($self->{tabpanel}->GetSelection);
|
||||||
|
$panel->OnActivate if $panel->can('OnActivate');
|
||||||
|
if ($self->{tabpanel}->GetSelection > 1) {
|
||||||
|
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag | wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||||
|
} elsif(($Slic3r::GUI::Settings->{_}{show_host} == 0) && ($self->{tabpanel}->GetSelection == 1)){
|
||||||
|
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag | wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||||
|
} else {
|
||||||
|
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag & ~wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
EVT_AUINOTEBOOK_PAGE_CLOSE($self, $self->{tabpanel}, sub {
|
||||||
|
my $panel = $self->{tabpanel}->GetPage($self->{tabpanel}->GetSelection);
|
||||||
|
if ($panel->isa('Slic3r::GUI::PresetEditor')) {
|
||||||
|
delete $self->{preset_editor_tabs}{$panel->name};
|
||||||
|
}
|
||||||
|
wxTheApp->CallAfter(sub {
|
||||||
|
$self->{tabpanel}->SetSelection(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$panel->AddPage($self->{plater} = Slic3r::GUI::Plater->new($panel), "Plater");
|
||||||
|
$panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), "Controller")
|
||||||
|
if ($Slic3r::GUI::Settings->{_}{show_host});
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainFrame::init_menubar()
|
||||||
|
{
|
||||||
|
}
|
31
src/GUI/MainFrame.hpp
Normal file
31
src/GUI/MainFrame.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
#ifndef MAINFRAME_HPP
|
||||||
|
#define MAINFRAME_HPP
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
#include <wx/aui/auibook.h>
|
||||||
|
#include <wx/tooltip.h>
|
||||||
|
|
||||||
|
constexpr unsigned int TOOLTIP_TIMER = 32767;
|
||||||
|
|
||||||
|
class MainFrame: public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
private:
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
void init_menubar(); //< Routine to intialize all top-level menu items.
|
||||||
|
void init_tabpanel(); //< Routine to initialize all of the tabs.
|
||||||
|
|
||||||
|
bool loaded; //< Main frame itself has finished loading.
|
||||||
|
// STUB: preset editor tabs storage
|
||||||
|
// STUB: Statusbar reference
|
||||||
|
|
||||||
|
wxAuiNotebook* tabpanel;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINFRAME_HPP
|
@ -13,6 +13,7 @@
|
|||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/nowide/args.hpp>
|
#include <boost/nowide/args.hpp>
|
||||||
#include <boost/nowide/iostream.hpp>
|
#include <boost/nowide/iostream.hpp>
|
||||||
|
#include "GUI/GUI.hpp"
|
||||||
|
|
||||||
|
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
@ -40,6 +41,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
DynamicPrintConfig print_config;
|
DynamicPrintConfig print_config;
|
||||||
|
|
||||||
|
Slic3rGUI *gui = new Slic3rGUI;
|
||||||
|
|
||||||
|
Slic3rGUI::SetInstance(gui);
|
||||||
|
wxEntry(argc, argv);
|
||||||
|
|
||||||
// load config files supplied via --load
|
// load config files supplied via --load
|
||||||
for (const std::string &file : cli_config.load.values) {
|
for (const std::string &file : cli_config.load.values) {
|
||||||
if (!boost::filesystem::exists(file)) {
|
if (!boost::filesystem::exists(file)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user