From 3f0968fb0274956ad7fa84b0fa35de3821e8d114 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 19 Sep 2018 14:54:37 +0200 Subject: Refactoring member variable names for my classes to match our coding style. --- xs/src/libslic3r/PrintExport.hpp | 114 ++++++++++++++--------------- xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 90 +++++++++++------------ xs/src/libslic3r/Rasterizer/Rasterizer.hpp | 4 +- xs/src/slic3r/AppController.cpp | 42 +++++------ xs/src/slic3r/AppController.hpp | 34 +++------ xs/src/slic3r/AppControllerWx.cpp | 96 ++++++++++++------------ xs/src/slic3r/GUI/ProgressIndicator.hpp | 18 ++--- xs/src/slic3r/GUI/ProgressStatusBar.cpp | 76 +++++++++---------- xs/src/slic3r/GUI/ProgressStatusBar.hpp | 12 +-- 9 files changed, 236 insertions(+), 250 deletions(-) (limited to 'xs') diff --git a/xs/src/libslic3r/PrintExport.hpp b/xs/src/libslic3r/PrintExport.hpp index cd6d16f33..917a39e08 100644 --- a/xs/src/libslic3r/PrintExport.hpp +++ b/xs/src/libslic3r/PrintExport.hpp @@ -32,10 +32,10 @@ template class FilePrinter { public: - void printConfig(const Print&); + void print_config(const Print&); // Draw an ExPolygon which is a polygon inside a slice on the specified layer. - void drawPolygon(const ExPolygon& p, unsigned lyr); + void draw_polygon(const ExPolygon& p, unsigned lyr); // Tell the printer how many layers should it consider. void layers(unsigned layernum); @@ -47,26 +47,26 @@ public: * specified layer number than an appropriate number of layers will be * allocated in the printer. */ - void beginLayer(unsigned layer); + void begin_layer(unsigned layer); // Allocate a new layer on top of the last and switch to it. - void beginLayer(); + void begin_layer(); /* * Finish the selected layer. It means that no drawing is allowed on that * layer anymore. This fact can be used to prepare the file system output * data like png comprimation and so on. */ - void finishLayer(unsigned layer); + void finish_layer(unsigned layer); // Finish the top layer. - void finishLayer(); + void finish_layer(); // Save all the layers into the file (or dir) specified in the path argument void save(const std::string& path); // Save only the selected layer to the file specified in path argument. - void saveLayer(unsigned lyr, const std::string& path); + void save_layer(unsigned lyr, const std::string& path); }; template struct VeryFalse { static const bool value = false; }; @@ -112,22 +112,22 @@ template class FilePrinter { // We will save the compressed PNG data into stringstreams which can be done // in parallel. Later we can write every layer to the disk sequentially. - std::vector layers_rst_; - Raster::Resolution res_; - Raster::PixelDim pxdim_; - const Print *print_ = nullptr; - double exp_time_s_ = .0, exp_time_first_s_ = .0; + std::vector m_layers_rst; + Raster::Resolution m_res; + Raster::PixelDim m_pxdim; + const Print *m_print = nullptr; + double m_exp_time_s = .0, m_exp_time_first_s = .0; std::string createIniContent(const std::string& projectname) { - double layer_height = print_? - print_->default_object_config().layer_height.getFloat() : + double layer_height = m_print? + m_print->default_object_config().layer_height.getFloat() : 0.05; using std::string; using std::to_string; - auto expt_str = to_string(exp_time_s_); - auto expt_first_str = to_string(exp_time_first_s_); + auto expt_str = to_string(m_exp_time_s); + auto expt_first_str = to_string(m_exp_time_first_s); auto stepnum_str = to_string(static_cast(800*layer_height)); auto layerh_str = to_string(layer_height); @@ -155,51 +155,51 @@ public: inline FilePrinter(double width_mm, double height_mm, unsigned width_px, unsigned height_px, double exp_time, double exp_time_first): - res_(width_px, height_px), - pxdim_(width_mm/width_px, height_mm/height_px), - exp_time_s_(exp_time), - exp_time_first_s_(exp_time_first) + m_res(width_px, height_px), + m_pxdim(width_mm/width_px, height_mm/height_px), + m_exp_time_s(exp_time), + m_exp_time_first_s(exp_time_first) { } FilePrinter(const FilePrinter& ) = delete; FilePrinter(FilePrinter&& m): - layers_rst_(std::move(m.layers_rst_)), - res_(m.res_), - pxdim_(m.pxdim_) {} + m_layers_rst(std::move(m.m_layers_rst)), + m_res(m.m_res), + m_pxdim(m.m_pxdim) {} - inline void layers(unsigned cnt) { if(cnt > 0) layers_rst_.resize(cnt); } - inline unsigned layers() const { return unsigned(layers_rst_.size()); } + inline void layers(unsigned cnt) { if(cnt > 0) m_layers_rst.resize(cnt); } + inline unsigned layers() const { return unsigned(m_layers_rst.size()); } - void printConfig(const Print& printconf) { print_ = &printconf; } + void print_config(const Print& printconf) { m_print = &printconf; } - inline void drawPolygon(const ExPolygon& p, unsigned lyr) { - assert(lyr < layers_rst_.size()); - layers_rst_[lyr].first.draw(p); + inline void draw_polygon(const ExPolygon& p, unsigned lyr) { + assert(lyr < m_layers_rst.size()); + m_layers_rst[lyr].first.draw(p); } - inline void beginLayer(unsigned lyr) { - if(layers_rst_.size() <= lyr) layers_rst_.resize(lyr+1); - layers_rst_[lyr].first.reset(res_, pxdim_, ORIGIN); + inline void begin_layer(unsigned lyr) { + if(m_layers_rst.size() <= lyr) m_layers_rst.resize(lyr+1); + m_layers_rst[lyr].first.reset(m_res, m_pxdim, ORIGIN); } - inline void beginLayer() { - layers_rst_.emplace_back(); - layers_rst_.front().first.reset(res_, pxdim_, ORIGIN); + inline void begin_layer() { + m_layers_rst.emplace_back(); + m_layers_rst.front().first.reset(m_res, m_pxdim, ORIGIN); } - inline void finishLayer(unsigned lyr_id) { - assert(lyr_id < layers_rst_.size()); - layers_rst_[lyr_id].first.save(layers_rst_[lyr_id].second, + inline void finish_layer(unsigned lyr_id) { + assert(lyr_id < m_layers_rst.size()); + m_layers_rst[lyr_id].first.save(m_layers_rst[lyr_id].second, Raster::Compression::PNG); - layers_rst_[lyr_id].first.reset(); + m_layers_rst[lyr_id].first.reset(); } - inline void finishLayer() { - if(!layers_rst_.empty()) { - layers_rst_.back().first.save(layers_rst_.back().second, + inline void finish_layer() { + if(!m_layers_rst.empty()) { + m_layers_rst.back().first.save(m_layers_rst.back().second, Raster::Compression::PNG); - layers_rst_.back().first.reset(); + m_layers_rst.back().first.reset(); } } @@ -212,14 +212,14 @@ public: writer.next_entry("config.ini"); writer << createIniContent(project); - for(unsigned i = 0; i < layers_rst_.size(); i++) { - if(layers_rst_[i].second.rdbuf()->in_avail() > 0) { + for(unsigned i = 0; i < m_layers_rst.size(); i++) { + if(m_layers_rst[i].second.rdbuf()->in_avail() > 0) { char lyrnum[6]; std::sprintf(lyrnum, "%.5d", i); auto zfilename = project + lyrnum + ".png"; writer.next_entry(zfilename); - writer << layers_rst_[i].second.rdbuf(); - layers_rst_[i].second.str(""); + writer << m_layers_rst[i].second.rdbuf(); + m_layers_rst[i].second.str(""); } } @@ -230,9 +230,9 @@ public: } } - void saveLayer(unsigned lyr, const std::string& path) { + void save_layer(unsigned lyr, const std::string& path) { unsigned i = lyr; - assert(i < layers_rst_.size()); + assert(i < m_layers_rst.size()); char lyrnum[6]; std::sprintf(lyrnum, "%.5d", lyr); @@ -240,19 +240,19 @@ public: std::fstream out(loc, std::fstream::out | std::fstream::binary); if(out.good()) { - layers_rst_[i].first.save(out, Raster::Compression::PNG); + m_layers_rst[i].first.save(out, Raster::Compression::PNG); } else { BOOST_LOG_TRIVIAL(error) << "Can't create file for layer"; } out.close(); - layers_rst_[i].first.reset(); + m_layers_rst[i].first.reset(); } }; // Let's shadow this eigen interface -inline coord_t px(const Point& p) { return p(0); } -inline coord_t py(const Point& p) { return p(1); } +inline coord_t px(const Point& p) { return p(0); } +inline coord_t py(const Point& p) { return p(1); } inline coordf_t px(const Vec2d& p) { return p(0); } inline coordf_t py(const Vec2d& p) { return p(1); } @@ -306,7 +306,7 @@ void print_to(Print& print, FilePrinter printer(width_mm, height_mm, std::forward(args)...); - printer.printConfig(print); + printer.print_config(print); printer.layers(layers.size()); // Allocate space for all the layers @@ -327,7 +327,7 @@ void print_to(Print& print, { LayerPtrs lrange = layers[keys[layer_id]]; - printer.beginLayer(layer_id); // Switch to the appropriate layer + printer.begin_layer(layer_id); // Switch to the appropriate layer for(Layer *lp : lrange) { Layer& l = *lp; @@ -348,7 +348,7 @@ void print_to(Print& print, slice.translate(-px(print_bb.min) + cx, -py(print_bb.min) + cy); - printer.drawPolygon(slice, layer_id); + printer.draw_polygon(slice, layer_id); } /*if(print.has_support_material() && layer_id > 0) { @@ -361,7 +361,7 @@ void print_to(Print& print, } - printer.finishLayer(layer_id); // Finish the layer for later saving it. + printer.finish_layer(layer_id); // Finish the layer for later saving it. auto st = static_cast(layer_id*80.0/layers.size()); m.lock(); diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index b0bf04343..3ff3e0949 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -37,37 +37,37 @@ public: using Origin = Raster::Origin; private: - Raster::Resolution resolution_; - Raster::PixelDim pxdim_; - TBuffer buf_; - TRawBuffer rbuf_; - TPixelRenderer pixfmt_; - TRawRenderer raw_renderer_; - TRendererAA renderer_; - Origin o_; - std::function flipy_ = [](agg::path_storage&) {}; + Raster::Resolution m_resolution; + Raster::PixelDim m_pxdim; + TBuffer m_buf; + TRawBuffer m_rbuf; + TPixelRenderer m_pixfmt; + TRawRenderer m_raw_renderer; + TRendererAA m_renderer; + Origin m_o; + std::function m_flipy = [](agg::path_storage&) {}; public: inline Impl(const Raster::Resolution& res, const Raster::PixelDim &pd, Origin o): - resolution_(res), pxdim_(pd), - buf_(res.pixels()), - rbuf_(reinterpret_cast(buf_.data()), + m_resolution(res), m_pxdim(pd), + m_buf(res.pixels()), + m_rbuf(reinterpret_cast(m_buf.data()), res.width_px, res.height_px, res.width_px*TPixelRenderer::num_components), - pixfmt_(rbuf_), - raw_renderer_(pixfmt_), - renderer_(raw_renderer_), - o_(o) + m_pixfmt(m_rbuf), + m_raw_renderer(m_pixfmt), + m_renderer(m_raw_renderer), + m_o(o) { - renderer_.color(ColorWhite); + m_renderer.color(ColorWhite); // If we would like to play around with gamma // ras.gamma(agg::gamma_power(1.0)); clear(); - if(o_ == Origin::TOP_LEFT) flipy_ = [this](agg::path_storage& path) { - path.flip_y(0, resolution_.height_px); + if(m_o == Origin::TOP_LEFT) m_flipy = [this](agg::path_storage& path) { + path.flip_y(0, m_resolution.height_px); }; } @@ -76,35 +76,35 @@ public: agg::scanline_p8 scanlines; auto&& path = to_path(poly.contour); - flipy_(path); + m_flipy(path); ras.add_path(path); for(auto h : poly.holes) { auto&& holepath = to_path(h); - flipy_(holepath); + m_flipy(holepath); ras.add_path(holepath); } - agg::render_scanlines(ras, scanlines, renderer_); + agg::render_scanlines(ras, scanlines, m_renderer); } inline void clear() { - raw_renderer_.clear(ColorBlack); + m_raw_renderer.clear(ColorBlack); } - inline TBuffer& buffer() { return buf_; } + inline TBuffer& buffer() { return m_buf; } - inline const Raster::Resolution resolution() { return resolution_; } + inline const Raster::Resolution resolution() { return m_resolution; } - inline Origin origin() const /*noexcept*/ { return o_; } + inline Origin origin() const /*noexcept*/ { return m_o; } private: double getPx(const Point& p) { - return p(0) * SCALING_FACTOR/pxdim_.w_mm; + return p(0) * SCALING_FACTOR/m_pxdim.w_mm; } double getPy(const Point& p) { - return p(1) * SCALING_FACTOR/pxdim_.h_mm; + return p(1) * SCALING_FACTOR/m_pxdim.h_mm; } agg::path_storage to_path(const Polygon& poly) { @@ -124,57 +124,57 @@ const Raster::Impl::TPixel Raster::Impl::ColorWhite = Raster::Impl::TPixel(255); const Raster::Impl::TPixel Raster::Impl::ColorBlack = Raster::Impl::TPixel(0); Raster::Raster(const Resolution &r, const PixelDim &pd, Origin o): - impl_(new Impl(r, pd, o)) {} + m_impl(new Impl(r, pd, o)) {} Raster::Raster() {} Raster::~Raster() {} Raster::Raster(Raster &&m): - impl_(std::move(m.impl_)) {} + m_impl(std::move(m.m_impl)) {} void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd) { // Free up the unnecessary memory and make sure it stays clear after // an exception - auto o = impl_? impl_->origin() : Origin::TOP_LEFT; + auto o = m_impl? m_impl->origin() : Origin::TOP_LEFT; reset(r, pd, o); } void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd, Raster::Origin o) { - impl_.reset(); - impl_.reset(new Impl(r, pd, o)); + m_impl.reset(); + m_impl.reset(new Impl(r, pd, o)); } void Raster::reset() { - impl_.reset(); + m_impl.reset(); } Raster::Resolution Raster::resolution() const { - if(impl_) return impl_->resolution(); + if(m_impl) return m_impl->resolution(); return Resolution(0, 0); } void Raster::clear() { - assert(impl_); - impl_->clear(); + assert(m_impl); + m_impl->clear(); } void Raster::draw(const ExPolygon &poly) { - assert(impl_); - impl_->draw(poly); + assert(m_impl); + m_impl->draw(poly); } void Raster::save(std::ostream& stream, Compression comp) { - assert(impl_); + assert(m_impl); switch(comp) { case Compression::PNG: { @@ -188,7 +188,7 @@ void Raster::save(std::ostream& stream, Compression comp) wr.write_info(); - auto& b = impl_->buffer(); + auto& b = m_impl->buffer(); auto ptr = reinterpret_cast( b.data() ); unsigned stride = sizeof(Impl::TBuffer::value_type) * resolution().width_px; @@ -201,12 +201,12 @@ void Raster::save(std::ostream& stream, Compression comp) } case Compression::RAW: { stream << "P5 " - << impl_->resolution().width_px << " " - << impl_->resolution().height_px << " " + << m_impl->resolution().width_px << " " + << m_impl->resolution().height_px << " " << "255 "; - stream.write(reinterpret_cast(impl_->buffer().data()), - impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); + stream.write(reinterpret_cast(m_impl->buffer().data()), + m_impl->buffer().size()*sizeof(Impl::TBuffer::value_type)); } } } diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp index cbb39bc6b..b6406b770 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.hpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.hpp @@ -18,7 +18,7 @@ class ExPolygon; */ class Raster { class Impl; - std::unique_ptr impl_; + std::unique_ptr m_impl; public: /// Supported compression types @@ -65,7 +65,7 @@ public: /** * Release the allocated resources. Drawing in this state ends in - * unspecified behaviour. + * unspecified behavior. */ void reset(); diff --git a/xs/src/slic3r/AppController.cpp b/xs/src/slic3r/AppController.cpp index c9029f2be..f9c126286 100644 --- a/xs/src/slic3r/AppController.cpp +++ b/xs/src/slic3r/AppController.cpp @@ -30,15 +30,15 @@ public: }; AppControllerBoilerplate::AppControllerBoilerplate() - :pri_data_(new PriData(std::this_thread::get_id())) {} + :m_pri_data(new PriData(std::this_thread::get_id())) {} AppControllerBoilerplate::~AppControllerBoilerplate() { - pri_data_.reset(); + m_pri_data.reset(); } bool AppControllerBoilerplate::is_main_thread() const { - return pri_data_->ui_thread == std::this_thread::get_id(); + return m_pri_data->ui_thread == std::this_thread::get_id(); } namespace GUI { @@ -58,9 +58,9 @@ AppControllerBoilerplate::ProgresIndicatorPtr AppControllerBoilerplate::global_progress_indicator() { ProgresIndicatorPtr ret; - pri_data_->m.lock(); - ret = global_progressind_; - pri_data_->m.unlock(); + m_pri_data->m.lock(); + ret = m_global_progressind; + m_pri_data->m.unlock(); return ret; } @@ -68,9 +68,9 @@ AppControllerBoilerplate::global_progress_indicator() { void AppControllerBoilerplate::global_progress_indicator( AppControllerBoilerplate::ProgresIndicatorPtr gpri) { - pri_data_->m.lock(); - global_progressind_ = gpri; - pri_data_->m.unlock(); + m_pri_data->m.lock(); + m_global_progressind = gpri; + m_pri_data->m.unlock(); } PrintController::PngExportData @@ -104,11 +104,11 @@ PrintController::query_png_export_data(const DynamicPrintConfig& conf) void PrintController::slice(AppControllerBoilerplate::ProgresIndicatorPtr pri) { - print_->set_status_callback([pri](int st, const std::string& msg){ + m_print->set_status_callback([pri](int st, const std::string& msg){ pri->update(unsigned(st), msg); }); - print_->process(); + m_print->process(); } void PrintController::slice() @@ -156,7 +156,7 @@ void PrintController::slice_to_png() auto exd = query_png_export_data(conf); if(exd.zippath.empty()) return; - Print *print = print_; + Print *print = m_print; try { print->apply_config(conf); @@ -252,7 +252,7 @@ void PrintController::slice_to_png() const PrintConfig &PrintController::config() const { - return print_->config(); + return m_print->config(); } void ProgressIndicator::message_fmt( @@ -286,13 +286,13 @@ void AppController::arrange_model() { using Coord = libnest2d::TCoord; - if(arranging_.load()) return; + if(m_arranging.load()) return; // to prevent UI reentrancies - arranging_.store(true); + m_arranging.store(true); unsigned count = 0; - for(auto obj : model_->objects) count += obj->instances.size(); + for(auto obj : m_model->objects) count += obj->instances.size(); auto pind = global_progress_indicator(); @@ -305,7 +305,7 @@ void AppController::arrange_model() pind->max(count); pind->on_cancel([this](){ - arranging_.store(false); + m_arranging.store(false); }); } @@ -326,7 +326,7 @@ void AppController::arrange_model() // TODO: from Sasha from GUI hint.type = arr::BedShapeType::WHO_KNOWS; - arr::arrange(*model_, + arr::arrange(*m_model, min_obj_distance, bed, hint, @@ -336,7 +336,7 @@ void AppController::arrange_model() pind->update(count - rem, L("Arranging objects...")); process_events(); - }, [this] () { return !arranging_.load(); }); + }, [this] () { return !m_arranging.load(); }); } catch(std::exception& e) { std::cerr << e.what() << std::endl; report_issue(IssueType::ERR, @@ -348,13 +348,13 @@ void AppController::arrange_model() // Restore previous max value if(pind) { pind->max(pmax); - pind->update(0, arranging_.load() ? L("Arranging done.") : + pind->update(0, m_arranging.load() ? L("Arranging done.") : L("Arranging canceled.")); pind->on_cancel(/*remove cancel function*/); } - arranging_.store(false); + m_arranging.store(false); } } diff --git a/xs/src/slic3r/AppController.hpp b/xs/src/slic3r/AppController.hpp index c9ab6f15d..df506c05b 100644 --- a/xs/src/slic3r/AppController.hpp +++ b/xs/src/slic3r/AppController.hpp @@ -42,7 +42,7 @@ private: class PriData; // Some structure to store progress indication data // Pimpl data for thread safe progress indication features - std::unique_ptr pri_data_; + std::unique_ptr m_pri_data; public: @@ -67,7 +67,7 @@ public: * It should display a file chooser dialog in case of a UI application. * @param title Title of a possible query dialog. * @param extensions Recognized file extensions. - * @return Returns a list of paths choosed by the user. + * @return Returns a list of paths chosen by the user. */ PathList query_destination_paths( const std::string& title, @@ -162,7 +162,7 @@ protected: // This is a global progress indicator placeholder. In the Slic3r UI it can // contain the progress indicator on the statusbar. - ProgresIndicatorPtr global_progressind_; + ProgresIndicatorPtr m_global_progressind; }; class Zipper { @@ -186,18 +186,10 @@ public: * @brief Implementation of the printing logic. */ class PrintController: public AppControllerBoilerplate { - Print *print_ = nullptr; - std::function rempools_; + Print *m_print = nullptr; + std::function m_rempools; protected: - void make_skirt() {} - void make_brim() {} - void make_wipe_tower() {} - - void make_perimeters(PrintObject *pobj) {} - void infill(PrintObject *pobj) {} - void gen_support_material(PrintObject *pobj) {} - // Data structure with the png export input data struct PngExportData { std::string zippath; // output zip file @@ -215,20 +207,14 @@ protected: PngExportData query_png_export_data(const DynamicPrintConfig&); // The previous export data, to pre-populate the dialog - PngExportData prev_expdata_; - - /** - * @brief Slice one pront object. - * @param pobj The print object. - */ - void slice(PrintObject *pobj); + PngExportData m_prev_expdata; void slice(ProgresIndicatorPtr pri); public: // Must be public for perl to use it - explicit inline PrintController(Print *print): print_(print) {} + explicit inline PrintController(Print *print): m_print(print) {} PrintController(const PrintController&) = delete; PrintController(PrintController&&) = delete; @@ -256,9 +242,9 @@ public: * @brief Top level controller. */ class AppController: public AppControllerBoilerplate { - Model *model_ = nullptr; + Model *m_model = nullptr; PrintController::Ptr printctl; - std::atomic arranging_; + std::atomic m_arranging; public: /** @@ -275,7 +261,7 @@ public: * @param model A raw pointer to the model object. This can be used from * perl. */ - void set_model(Model *model) { model_ = model; } + void set_model(Model *model) { m_model = model; } /** * @brief Set the print object from perl. diff --git a/xs/src/slic3r/AppControllerWx.cpp b/xs/src/slic3r/AppControllerWx.cpp index 7de2a424f..9f52e52d2 100644 --- a/xs/src/slic3r/AppControllerWx.cpp +++ b/xs/src/slic3r/AppControllerWx.cpp @@ -103,18 +103,18 @@ bool AppControllerBoilerplate::report_issue( wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent); struct Zipper::Impl { - wxFileName m_fpath; - wxFFileOutputStream m_zipfile; - wxZipOutputStream m_zipstream; - wxStdOutputStream m_pngstream; + wxFileName fpath; + wxFFileOutputStream zipfile; + wxZipOutputStream zipstream; + wxStdOutputStream pngstream; Impl(const std::string& zipfile_path): - m_fpath(zipfile_path), - m_zipfile(zipfile_path), - m_zipstream(m_zipfile), - m_pngstream(m_zipstream) + fpath(zipfile_path), + zipfile(zipfile_path), + zipstream(zipfile), + pngstream(zipstream) { - if(!m_zipfile.IsOk()) + if(!zipfile.IsOk()) throw std::runtime_error(L("Cannot create zip file.")); } }; @@ -128,23 +128,23 @@ Zipper::~Zipper() {} void Zipper::next_entry(const std::string &fname) { - m_impl->m_zipstream.PutNextEntry(fname); + m_impl->zipstream.PutNextEntry(fname); } std::string Zipper::get_name() const { - return m_impl->m_fpath.GetName().ToStdString(); + return m_impl->fpath.GetName().ToStdString(); } std::ostream &Zipper::stream() { - return m_impl->m_pngstream; + return m_impl->pngstream; } void Zipper::close() { - m_impl->m_zipstream.Close(); - m_impl->m_zipfile.Close(); + m_impl->zipstream.Close(); + m_impl->zipfile.Close(); } namespace { @@ -156,26 +156,26 @@ namespace { class GuiProgressIndicator: public ProgressIndicator, public wxEvtHandler { - wxProgressDialog gauge_; + wxProgressDialog m_gauge; using Base = ProgressIndicator; - wxString message_; - int range_; wxString title_; - bool is_asynch_ = false; + wxString m_message; + int m_range; wxString m_title; + bool m_is_asynch = false; - const int id_ = wxWindow::NewControlId(); + const int m_id = wxWindow::NewControlId(); // status update handler void _state( wxCommandEvent& evt) { unsigned st = evt.GetInt(); - message_ = evt.GetString(); + m_message = evt.GetString(); _state(st); } // Status update implementation void _state( unsigned st) { - if(!gauge_.IsShown()) gauge_.ShowModal(); + if(!m_gauge.IsShown()) m_gauge.ShowModal(); Base::state(st); - if(!gauge_.Update(static_cast(st), message_)) { + if(!m_gauge.Update(static_cast(st), m_message)) { cancel(); } } @@ -183,25 +183,25 @@ class GuiProgressIndicator: public: /// Setting whether it will be used from the UI thread or some worker thread - inline void asynch(bool is) { is_asynch_ = is; } + inline void asynch(bool is) { m_is_asynch = is; } /// Get the mode of parallel operation. - inline bool asynch() const { return is_asynch_; } + inline bool asynch() const { return m_is_asynch; } inline GuiProgressIndicator(int range, const wxString& title, const wxString& firstmsg) : - gauge_(title, firstmsg, range, wxTheApp->GetTopWindow(), + m_gauge(title, firstmsg, range, wxTheApp->GetTopWindow(), wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT), - message_(firstmsg), - range_(range), title_(title) + m_message(firstmsg), + m_range(range), m_title(title) { Base::max(static_cast(range)); Base::states(static_cast(range)); Bind(PROGRESS_STATUS_UPDATE_EVENT, &GuiProgressIndicator::_state, - this, id_); + this, m_id); } virtual void state(float val) override { @@ -210,27 +210,27 @@ public: void state(unsigned st) { // send status update event - if(is_asynch_) { - auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_); + if(m_is_asynch) { + auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, m_id); evt->SetInt(st); - evt->SetString(message_); + evt->SetString(m_message); wxQueueEvent(this, evt); } else _state(st); } virtual void message(const std::string & msg) override { - message_ = _(msg); + m_message = _(msg); } virtual void messageFmt(const std::string& fmt, ...) { va_list arglist; va_start(arglist, fmt); - message_ = wxString::Format(_(fmt), arglist); + m_message = wxString::Format(_(fmt), arglist); va_end(arglist); } virtual void title(const std::string & title) override { - title_ = _(title); + m_title = _(title); } }; } @@ -261,20 +261,20 @@ AppControllerBoilerplate::create_progress_indicator( namespace { class Wrapper: public ProgressIndicator, public wxEvtHandler { - ProgressStatusBar *sbar_; + ProgressStatusBar *m_sbar; using Base = ProgressIndicator; - wxString message_; - AppControllerBoilerplate& ctl_; + wxString m_message; + AppControllerBoilerplate& m_ctl; void showProgress(bool show = true) { - sbar_->show_progress(show); + m_sbar->show_progress(show); } void _state(unsigned st) { if( st <= ProgressIndicator::max() ) { Base::state(st); - sbar_->set_status_text(message_); - sbar_->set_progress(st); + m_sbar->set_status_text(m_message); + m_sbar->set_progress(st); } } @@ -289,10 +289,10 @@ public: inline Wrapper(ProgressStatusBar *sbar, AppControllerBoilerplate& ctl): - sbar_(sbar), ctl_(ctl) + m_sbar(sbar), m_ctl(ctl) { - Base::max(static_cast(sbar_->get_range())); - Base::states(static_cast(sbar_->get_range())); + Base::max(static_cast(m_sbar->get_range())); + Base::states(static_cast(m_sbar->get_range())); Bind(PROGRESS_STATUS_UPDATE_EVENT, &Wrapper::_state, @@ -305,13 +305,13 @@ public: virtual void max(float val) override { if(val > 1.0) { - sbar_->set_range(static_cast(val)); + m_sbar->set_range(static_cast(val)); ProgressIndicator::max(val); } } void state(unsigned st) { - if(!ctl_.is_main_thread()) { + if(!m_ctl.is_main_thread()) { auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_); evt->SetInt(st); wxQueueEvent(this, evt); @@ -321,20 +321,20 @@ public: } virtual void message(const std::string & msg) override { - message_ = _(msg); + m_message = _(msg); } virtual void message_fmt(const std::string& fmt, ...) override { va_list arglist; va_start(arglist, fmt); - message_ = wxString::Format(_(fmt), arglist); + m_message = wxString::Format(_(fmt), arglist); va_end(arglist); } virtual void title(const std::string & /*title*/) override {} virtual void on_cancel(CancelFn fn) override { - sbar_->set_cancel_callback(fn); + m_sbar->set_cancel_callback(fn); Base::on_cancel(fn); } diff --git a/xs/src/slic3r/GUI/ProgressIndicator.hpp b/xs/src/slic3r/GUI/ProgressIndicator.hpp index 0cf8b4a17..280ba63ac 100644 --- a/xs/src/slic3r/GUI/ProgressIndicator.hpp +++ b/xs/src/slic3r/GUI/ProgressIndicator.hpp @@ -14,31 +14,31 @@ public: using CancelFn = std::function; // Cancel function signature. private: - float state_ = .0f, max_ = 1.f, step_; - CancelFn cancelfunc_ = [](){}; + float m_state = .0f, m_max = 1.f, m_step; + CancelFn m_cancelfunc = [](){}; public: inline virtual ~ProgressIndicator() {} /// Get the maximum of the progress range. - float max() const { return max_; } + float max() const { return m_max; } /// Get the current progress state - float state() const { return state_; } + float state() const { return m_state; } /// Set the maximum of the progress range - virtual void max(float maxval) { max_ = maxval; } + virtual void max(float maxval) { m_max = maxval; } /// Set the current state of the progress. - virtual void state(float val) { state_ = val; } + virtual void state(float val) { m_state = val; } /** * @brief Number of states int the progress. Can be used instead of giving a * maximum value. */ virtual void states(unsigned statenum) { - step_ = max_ / statenum; + m_step = m_max / statenum; } /// Message shown on the next status update. @@ -51,13 +51,13 @@ public: virtual void message_fmt(const std::string& fmt, ...); /// Set up a cancel callback for the operation if feasible. - virtual void on_cancel(CancelFn func = CancelFn()) { cancelfunc_ = func; } + virtual void on_cancel(CancelFn func = CancelFn()) { m_cancelfunc = func; } /** * Explicitly shut down the progress indicator and call the associated * callback. */ - virtual void cancel() { cancelfunc_(); } + virtual void cancel() { m_cancelfunc(); } /// Convenience function to call message and status update in one function. void update(float st, const std::string& msg) { diff --git a/xs/src/slic3r/GUI/ProgressStatusBar.cpp b/xs/src/slic3r/GUI/ProgressStatusBar.cpp index 363e34cb2..0ca86084b 100644 --- a/xs/src/slic3r/GUI/ProgressStatusBar.cpp +++ b/xs/src/slic3r/GUI/ProgressStatusBar.cpp @@ -14,117 +14,117 @@ namespace Slic3r { ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id): self(new wxStatusBar(parent ? parent : GUI::get_main_frame(), id == -1? wxID_ANY : id)), - timer_(new wxTimer(self)), - prog_ (new wxGauge(self, + m_timer(new wxTimer(self)), + m_prog (new wxGauge(self, wxGA_HORIZONTAL, 100, wxDefaultPosition, wxDefaultSize)), - cancelbutton_(new wxButton(self, + m_cancelbutton(new wxButton(self, -1, "Cancel", wxDefaultPosition, wxDefaultSize)) { - prog_->Hide(); - cancelbutton_->Hide(); + m_prog->Hide(); + m_cancelbutton->Hide(); self->SetFieldsCount(3); int w[] = {-1, 150, 155}; self->SetStatusWidths(3, w); self->Bind(wxEVT_TIMER, [this](const wxTimerEvent&) { - if (prog_->IsShown()) timer_->Stop(); - if(is_busy()) prog_->Pulse(); + if (m_prog->IsShown()) m_timer->Stop(); + if(is_busy()) m_prog->Pulse(); }); self->Bind(wxEVT_SIZE, [this](wxSizeEvent& event){ wxRect rect; self->GetFieldRect(1, rect); auto offset = 0; - cancelbutton_->Move(rect.GetX() + offset, rect.GetY() + offset); - cancelbutton_->SetSize(rect.GetWidth() - offset, rect.GetHeight()); + m_cancelbutton->Move(rect.GetX() + offset, rect.GetY() + offset); + m_cancelbutton->SetSize(rect.GetWidth() - offset, rect.GetHeight()); self->GetFieldRect(2, rect); - prog_->Move(rect.GetX() + offset, rect.GetY() + offset); - prog_->SetSize(rect.GetWidth() - offset, rect.GetHeight()); + m_prog->Move(rect.GetX() + offset, rect.GetY() + offset); + m_prog->SetSize(rect.GetWidth() - offset, rect.GetHeight()); event.Skip(); }); - cancelbutton_->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) { - if(cancel_cb_) cancel_cb_(); + m_cancelbutton->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) { + if(m_cancel_cb) m_cancel_cb(); m_perl_cancel_callback.call(); - cancelbutton_->Hide(); + m_cancelbutton->Hide(); }); } ProgressStatusBar::~ProgressStatusBar() { - if(timer_->IsRunning()) timer_->Stop(); + if(m_timer->IsRunning()) m_timer->Stop(); } int ProgressStatusBar::get_progress() const { - return prog_->GetValue(); + return m_prog->GetValue(); } void ProgressStatusBar::set_progress(int val) { - if(!prog_->IsShown()) show_progress(true); + if(!m_prog->IsShown()) show_progress(true); - if(val == prog_->GetRange()) { - prog_->SetValue(0); + if(val == m_prog->GetRange()) { + m_prog->SetValue(0); show_progress(false); } else { - prog_->SetValue(val); + m_prog->SetValue(val); } } int ProgressStatusBar::get_range() const { - return prog_->GetRange(); + return m_prog->GetRange(); } void ProgressStatusBar::set_range(int val) { - if(val != prog_->GetRange()) { - prog_->SetRange(val); + if(val != m_prog->GetRange()) { + m_prog->SetRange(val); } } void ProgressStatusBar::show_progress(bool show) { - prog_->Show(show); - prog_->Pulse(); + m_prog->Show(show); + m_prog->Pulse(); } void ProgressStatusBar::start_busy(int rate) { - busy_ = true; + m_busy = true; show_progress(true); - if (!timer_->IsRunning()) { - timer_->Start(rate); + if (!m_timer->IsRunning()) { + m_timer->Start(rate); } } void ProgressStatusBar::stop_busy() { - timer_->Stop(); + m_timer->Stop(); show_progress(false); - prog_->SetValue(0); - busy_ = false; + m_prog->SetValue(0); + m_busy = false; } void ProgressStatusBar::set_cancel_callback(ProgressStatusBar::CancelFn ccb) { - cancel_cb_ = ccb; - if(ccb) cancelbutton_->Show(); - else cancelbutton_->Hide(); + m_cancel_cb = ccb; + if(ccb) m_cancelbutton->Show(); + else m_cancelbutton->Hide(); } void ProgressStatusBar::run(int rate) { - if(!timer_->IsRunning()) { - timer_->Start(rate); + if(!m_timer->IsRunning()) { + m_timer->Start(rate); } } @@ -141,12 +141,12 @@ void ProgressStatusBar::set_status_text(const wxString& txt) void ProgressStatusBar::show_cancel_button() { - cancelbutton_->Show(); + m_cancelbutton->Show(); } void ProgressStatusBar::hide_cancel_button() { - cancelbutton_->Hide(); + m_cancelbutton->Hide(); } } diff --git a/xs/src/slic3r/GUI/ProgressStatusBar.hpp b/xs/src/slic3r/GUI/ProgressStatusBar.hpp index 9a7f58eee..0d8560d3b 100644 --- a/xs/src/slic3r/GUI/ProgressStatusBar.hpp +++ b/xs/src/slic3r/GUI/ProgressStatusBar.hpp @@ -24,9 +24,9 @@ namespace Slic3r { */ class ProgressStatusBar { wxStatusBar *self; // we cheat! It should be the base class but: perl! - wxTimer *timer_; - wxGauge *prog_; - wxButton *cancelbutton_; + wxTimer *m_timer; + wxGauge *m_prog; + wxButton *m_cancelbutton; public: /// Cancel callback function type @@ -42,7 +42,7 @@ public: void show_progress(bool); void start_busy(int = 100); void stop_busy(); - inline bool is_busy() const { return busy_; } + inline bool is_busy() const { return m_busy; } void set_cancel_callback(CancelFn = CancelFn()); inline void remove_cancel_callback() { set_cancel_callback(); } void run(int rate); @@ -55,8 +55,8 @@ public: PerlCallback m_perl_cancel_callback; private: - bool busy_ = false; - CancelFn cancel_cb_; + bool m_busy = false; + CancelFn m_cancel_cb; }; namespace GUI { -- cgit v1.2.3