Skip to content

Commit

Permalink
compilation fixes
Browse files Browse the repository at this point in the history
also some freepyscad update
  • Loading branch information
supermerill authored and supermerill committed Jun 23, 2020
1 parent 29b5390 commit bf215bb
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 45 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ccpp_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
- name: make deps
working-directory: ./deps/build
run: make
- name: ls libs
working-directory: ./deps/build
run: ls ./destdir/usr/local/lib
- name: rename wxscintilla
working-directory: ./deps/build/destdir/usr/local/lib
run: cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a
- name: ls libs
working-directory: ./deps/build
run: ls ./destdir/usr/local/lib
- name: clean deps
working-directory: ./deps/build
run: rm -rf dep_*
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ccpp_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
- name: make deps
working-directory: ./deps/build
run: make
- name: rename wxscintilla
working-directory: ./deps/build/destdir/usr/local/lib
run: cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a
- name: ls libs
working-directory: ./deps/build
run: ls ./destdir/usr/local/lib
- name: clean deps
working-directory: ./deps/build
run: rm -rf dep_*
Expand Down
2 changes: 2 additions & 0 deletions deps/deps-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ ExternalProject_Add(dep_wxwidgets
--with-opengl
--enable-unicode
--enable-graphics_ctx
--enable-stc
--enable-aui
--with-regex=builtin
--with-libpng=builtin
--with-libxpm=builtin
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/opencsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_executable(opencsg_example WIN32
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../../src/slic3r/GUI/I18N.cpp)

find_package(wxWidgets 3.1 REQUIRED COMPONENTS core base gl html stc scintilla aui)
find_package(wxWidgets 3.1 REQUIRED COMPONENTS core base gl html)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenCSG REQUIRED)
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ if (SLIC3R_GUI)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set (wxWidgets_CONFIG_OPTIONS "--toolkit=gtk${SLIC3R_GTK}")
if (SLIC3R_WX_STABLE)
find_package(wxWidgets 3.0 REQUIRED COMPONENTS base core adv html gl stc scintilla aui)
find_package(wxWidgets 3.0 REQUIRED COMPONENTS base core adv html gl stc)
else ()
find_package(wxWidgets 3.1 QUIET COMPONENTS base core adv html gl stc scintilla aui)
find_package(wxWidgets 3.1 QUIET COMPONENTS base core adv html gl stc)

if (NOT wxWidgets_FOUND)
message(FATAL_ERROR "\nCould not find wxWidgets 3.1.\n"
"Hint: On Linux you can set -DSLIC3R_WX_STABLE=1 to use wxWidgets 3.0\n")
endif ()
endif ()
else ()
find_package(wxWidgets 3.1 REQUIRED COMPONENTS html adv gl core base stc scintilla aui)
find_package(wxWidgets 3.1 REQUIRED COMPONENTS html adv gl core base stc scintilla)
endif ()

if(UNIX)
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ class ConfigOptionPercentsTempl : public ConfigOptionFloatsTempl<NULLABLE>
ConfigOption* clone() const override { return new ConfigOptionPercentsTempl(*this); }
ConfigOptionPercentsTempl& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
bool operator==(const ConfigOptionPercentsTempl &rhs) const { return this->values == rhs.values; }
double get_abs_value(size_t i, double ratio_over) const { return is_nil(i) ? 0 : ratio_over * get_at(i) / 100; }
double get_abs_value(size_t i, double ratio_over) const { return this->is_nil(i) ? 0 : ratio_over * this->get_at(i) / 100; }

std::string serialize() const override
{
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/GCode/CoolingBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <boost/log/trivial.hpp>
#include <iostream>
#include <float.h>
#include <unordered_set>

#if 0
#define DEBUG
Expand Down
3 changes: 2 additions & 1 deletion src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ void PerimeterGenerator::process()
}
} else {
if (this->object_config->thin_walls_merge) {
entities = this->_traverse_loops(contours.front(), ThickPolylines{});
ThickPolylines no_thin_walls;
entities = this->_traverse_loops(contours.front(), no_thin_walls);
_merge_thin_walls(entities, thin_walls);
} else {
entities = this->_traverse_loops(contours.front(), thin_walls);
Expand Down
79 changes: 41 additions & 38 deletions src/slic3r/GUI/FreeCADDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
#include "FreeCADDialog.hpp"

#include "I18N.hpp"
#include "libslic3r/Utils.hpp"
#include "GUI.hpp"
#include "GUI_ObjectList.hpp"
#include "slic3r/Utils/Http.hpp"
#include "AppConfig.hpp"
#include "Tab.hpp"

#include <iostream>
#include <ctime>
#include <stdio.h>
#include <stdlib.h>

#include <wx/scrolwin.h>
#include <wx/display.h>
#include <wx/file.h>
#include <wx/gbsizer.h>
#include "wxExtensions.hpp"
#include <iostream>

//C++11

#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <regex>
#include <boost/locale.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/log/trivial.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>

#if ENABLE_SCROLLABLE
static wxSize get_screen_size(wxWindow* window)
Expand Down Expand Up @@ -74,7 +77,7 @@ namespace GUI {
}

// Downloads a file (http get operation). Cancels if the Updater is being destroyed.
void get_string_from_web_async(const std::string &url, FreeCADDialog* free, std::function<void(FreeCADDialog*, std::string)> listener)
void get_string_from_web_async(const std::string &url, FreeCADDialog* free, std::function<void(FreeCADDialog*, std::string&)> listener)
{

Slic3r::Http::get(url)
Expand All @@ -96,20 +99,19 @@ namespace GUI {
std::string create_help_text() {
std::stringstream ss;

ss << " == common 3D primitives ==\n";
ss << " == 3D obj ==\n";
ss << "cube(x,y,z)\n";
ss << "cylinder(r|d,h)\n";
ss << "poly_int(a,nb)\n";
ss << "poly_ext(r,nb)\n";
ss << "cone(r1|d2,r2|d2,h)\n";
ss << "iso_thread(d,p,h,internal,offset)\n";
ss << "solid_slices(array_points, centers)\n";
ss << "importStl(filepath)\n";
ss << " == common 3D operation ==\n";
ss << "ngon(a|r,n,h)\n";
ss << "cone(r1,r2,h)\n";
ss << "iso_thread(d,p,h\n ,internal,offset)\n";
ss << "solid_slices(...)\n";
ss << "importStl(file)\n";
ss << " == 3D op ==\n";
ss << "cut()(...3D)\n";
ss << "union()(...3D)\n";
ss << "intersection()(...3D)\n";
ss << " == common object modifier ==\n";
ss << " == Object modifier ==\n";
ss << ".x/y/z() | .center()\n";
ss << ".move(x,y,z)\n";
ss << ".rotate(x,y,z)\n";
Expand Down Expand Up @@ -162,8 +164,7 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
commands.emplace_back(PyCommand{"offset", PyCommandType::pctOPERATION, { "length","fillet" }, "offset(length,fillet)(...obj)"});
commands.emplace_back(PyCommand{"chamfer", PyCommandType::pctOPERATION, { "l" }, "chamfer(l)(...obj)"});
commands.emplace_back(PyCommand{"fillet", PyCommandType::pctOPERATION, { "l" }, "fillet(l)(...obj)"});
commands.emplace_back(PyCommand{"poly_ext", PyCommandType::pctOBJECT, {"r", "nb", "h", "d="}, "poly_ext(r,nb,h)\npoly_ext(d=,nb=,h=)"});
commands.emplace_back(PyCommand{"poly_int", PyCommandType::pctOBJECT, { "a", "nb", "h", "d=" }, "poly_int(a,nb,h)\npoly_int(d=,nb=,h=)"});
commands.emplace_back(PyCommand{"ngon", PyCommandType::pctOBJECT, {"r", "nb", "h", "a=", "d="}, "ngon(r,n,h)\ngon(d=,n=,h=)\ngon(a=,n=,h=)" });
commands.emplace_back(PyCommand{"triangle", PyCommandType::pctOBJECT, { "x","y","z" }, "triangle(x,y,z)"});
commands.emplace_back(PyCommand{ "iso_thread", PyCommandType::pctOBJECT, {"d","p","h","internal","offset","fn="},
"iso_thread(d,p,h,internal, offset,[fn=])\nm3 screw: iso_thread(3,0.5,10,False,0)\nm3 nut: cut()(...,iso_thread(3,0.5,3,True,0.15))" });
Expand All @@ -179,6 +180,8 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
commands.emplace_back(PyCommand{"bezier", PyCommandType::pctOBJECT});
commands.emplace_back(PyCommand{"square", PyCommandType::pctOBJECT});
commands.emplace_back(PyCommand{"importSvg", PyCommandType::pctOBJECT, "importSvg(filename,ids)"});
commands.emplace_back(PyCommand{"poly_ext", PyCommandType::pctOBJECT, {"r", "nb", "h", "d="}, "poly_ext(r,nb,h)\npoly_ext(d=,nb=,h=)" });
commands.emplace_back(PyCommand{"poly_int", PyCommandType::pctOBJECT, { "a", "nb", "h", "d=" }, "poly_int(a,nb,h)\npoly_int(d=,nb=,h=)" });
commands.emplace_back(PyCommand{"xy", PyCommandType::pctMODIFIER | PyCommandType::pctNO_PARAMETER});
commands.emplace_back(PyCommand{"z", PyCommandType::pctMODIFIER | PyCommandType::pctNO_PARAMETER});
commands.emplace_back(PyCommand{"center", PyCommandType::pctMODIFIER | PyCommandType::pctNO_PARAMETER});
Expand All @@ -201,7 +204,7 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)

// fonts
const wxFont& font = wxGetApp().normal_font();
const wxFont& bold_font = wxGetApp().bold_font();
//const wxFont& bold_font = wxGetApp().bold_font();
SetFont(font);

wxIcon *freecad_icon = new wxIcon();
Expand Down Expand Up @@ -288,7 +291,7 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
}

void FreeCADDialog::close_me(wxCommandEvent& event_args) {
bool ok = this->write_text_in_file(m_text->GetText(), boost::filesystem::path(Slic3r::data_dir()) / "temp" / "current_pyscad.py");
this->write_text_in_file(m_text->GetText(), boost::filesystem::path(Slic3r::data_dir()) / "temp" / "current_pyscad.py");
this->gui_app->change_calibration_dialog(this, nullptr);
this->Destroy();
}
Expand Down Expand Up @@ -488,7 +491,7 @@ void FreeCADDialog::on_char_add(wxStyledTextEvent& event) {
// Find the word start
int current_pos = stc->GetCurrentPos();
int word_start_pos = stc->WordStartPosition(current_pos, true);
int len_entered = current_pos - word_start_pos;
//int len_entered = current_pos - word_start_pos;
const wxString str = stc->GetTextRange(word_start_pos, current_pos + 1);
//if(current_pos>1)
// std::cout << "char typed: " << (char)stc->GetCharAt(current_pos)<<" with length "<< len_entered
Expand Down Expand Up @@ -552,7 +555,7 @@ void FreeCADDialog::on_key_type(wxKeyEvent& event)
int nb_words = 0;
wxString possible;
for (const PyCommand &cmd : commands) {
if (str.IsEmpty() || cmd.name.StartsWith(str) && ((cmd.type & PyCommandType::pctDO_NOT_SHOW) == 0)) {
if ( (str.IsEmpty() || cmd.name.StartsWith(str)) && ((cmd.type & PyCommandType::pctDO_NOT_SHOW) == 0) ){
nb_words++; possible += possible.empty() ? cmd.name : (" " + cmd.name);
}
}
Expand Down Expand Up @@ -637,24 +640,24 @@ void FreeCADDialog::createSTC()
(wxObject*)NULL,
this);

m_text->StyleSetForeground(wxSTC_P_DEFAULT, wxColour(0, 0, 0));
m_text->StyleSetForeground(wxSTC_P_COMMENTLINE, wxColour(128, 255, 128)); // comment, grennsish
m_text->StyleSetForeground(wxSTC_P_COMMENTBLOCK, wxColour(128, 255, 128)); // comment, grennsish
m_text->StyleSetForeground(wxSTC_P_NUMBER, wxColour(255, 128, 0)); // number red-orange
m_text->StyleSetForeground(wxSTC_P_STRING, wxColour(128, 256, 0)); // string, light green
m_text->StyleSetBackground(wxSTC_P_STRINGEOL, wxColour(255, 0, 0)); // End of line where string is not closed
m_text->StyleSetForeground(wxSTC_P_CHARACTER, wxColour(128, 256, 0));
m_text->StyleSetForeground(wxSTC_P_WORD, wxColour(0, 0, 128));
m_text->StyleSetForeground(wxSTC_P_DEFAULT, wxColour(0u, 0u, 0u));
m_text->StyleSetForeground(wxSTC_P_COMMENTLINE, wxColour(128u, 255u, 128u)); // comment, grennsish
m_text->StyleSetForeground(wxSTC_P_COMMENTBLOCK, wxColour(128u, 255u, 128u)); // comment, grennsish
m_text->StyleSetForeground(wxSTC_P_NUMBER, wxColour(255u, 128u, 0u)); // number red-orange
m_text->StyleSetForeground(wxSTC_P_STRING, wxColour(128u, 256u, 0u)); // string, light green
m_text->StyleSetBackground(wxSTC_P_STRINGEOL, wxColour(255u, 0u, 0u)); // End of line where string is not closed
m_text->StyleSetForeground(wxSTC_P_CHARACTER, wxColour(128u, 256u, 0u));
m_text->StyleSetForeground(wxSTC_P_WORD, wxColour(0u, 0u, 128u));
m_text->StyleSetBold(wxSTC_P_WORD, true),
m_text->StyleSetForeground(wxSTC_P_WORD2, wxColour(0, 0, 128));
m_text->StyleSetForeground(wxSTC_P_TRIPLE, wxColour(128, 0, 0)); // triple quote
m_text->StyleSetForeground(wxSTC_P_TRIPLEDOUBLE, wxColour(128, 0, 0)); //triple double quote
m_text->StyleSetForeground(wxSTC_P_DEFNAME, wxColour(0, 128, 128)); // Function or method name definition
m_text->StyleSetForeground(wxSTC_P_WORD2, wxColour(0u, 0u, 128u));
m_text->StyleSetForeground(wxSTC_P_TRIPLE, wxColour(128u, 0u, 0u)); // triple quote
m_text->StyleSetForeground(wxSTC_P_TRIPLEDOUBLE, wxColour(128u, 0u, 0u)); //triple double quote
m_text->StyleSetForeground(wxSTC_P_DEFNAME, wxColour(0u, 128u, 128u)); // Function or method name definition
m_text->StyleSetBold(wxSTC_P_DEFNAME, true),
m_text->StyleSetForeground(wxSTC_P_OPERATOR, wxColour(255, 0, 0));
m_text->StyleSetForeground(wxSTC_P_OPERATOR, wxColour(255u, 0u, 0u));
m_text->StyleSetBold(wxSTC_P_OPERATOR, true),

m_text->StyleSetForeground(wxSTC_P_IDENTIFIER, wxColour(255, 64, 255)); // function call and almost all defined words in the language, violet
m_text->StyleSetForeground(wxSTC_P_IDENTIFIER, wxColour(255u, 64u, 255u)); // function call and almost all defined words in the language, violet

//add text if the saved file exist
boost::filesystem::path temp_file(Slic3r::data_dir());
Expand Down Expand Up @@ -809,7 +812,7 @@ void FreeCADDialog::create_geometry(wxCommandEvent& event_args) {
temp_file = temp_file / "exec_temp.py";
wxString text = m_text->GetText();
if (text.find("scene().redraw(") == std::string::npos) {
int redraw_pos = text.find("redraw()");
size_t redraw_pos = text.find("redraw()");
if (redraw_pos == std::string::npos) {
text = "scene().redraw(\n" + text + "\n)";
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/slic3r/GUI/FreeCADDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <map>
#include <vector>
#include <regex>

#include "GUI_App.hpp"
#include "GUI_Utils.hpp"
Expand All @@ -14,6 +15,7 @@
#include <wx/textctrl.h>
#include <wx/gbsizer.h>
#include <boost/process.hpp>
#include <boost/asio.hpp>

namespace Slic3r {
namespace GUI {
Expand All @@ -34,7 +36,7 @@ class PyCommand {
PyCommandType type;
wxString tooltip;
std::vector<std::string> args;
PyCommand(wxString lbl, PyCommandType modifier) : name(lbl), type(modifier) { auto lol = { "Z","z" }; }
PyCommand(wxString lbl, PyCommandType modifier) : name(lbl), type(modifier) { }
PyCommand(wxString lbl, uint16_t modifier) : name(lbl), type(PyCommandType(modifier)) {}
PyCommand(wxString lbl, PyCommandType modifier, std::string tooltip) : name(lbl), type(modifier), tooltip(tooltip) {}
PyCommand(wxString lbl, uint16_t modifier, std::string tooltip) : name(lbl), type(PyCommandType(modifier)), tooltip(tooltip) {}
Expand Down

0 comments on commit bf215bb

Please sign in to comment.