mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-08 00:01:09 +00:00
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes. clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer. * Remove Unused Project Includes From Files With Platform-Specific Code A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block. * Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass The platform-file pass treated pchheader.hpp as an ordinary header and emptied it, and left GUI_Preview.hpp and 14 other files relying on headers they no longer reached directly. * Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call * Include Headers That Files Reached Through Ones the Cleanup Removed * Drop Includes Duplicated by the Cleanup or by Main's Own Additions * Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
180 lines
4.6 KiB
C++
180 lines
4.6 KiB
C++
#ifndef SKIPPARTCANVAS_H
|
|
#define SKIPPARTCANVAS_H
|
|
#include <wx/event.h>
|
|
#include <array>
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include <wx/gdicmn.h>
|
|
#include <opencv2/core/mat.hpp>
|
|
#include <unordered_map>
|
|
#include <opencv2/core/types.hpp>
|
|
#include <wx/wx.h>
|
|
#include <wx/glcanvas.h>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <wx/textctrl.h>
|
|
#include <vector>
|
|
#include <expat.h>
|
|
#include <libslic3r/Color.hpp>
|
|
#include <boost/thread/mutex.hpp>
|
|
#include "PartSkipCommon.hpp"
|
|
|
|
class wxGLContext;
|
|
class wxTextCtrl;
|
|
class wxWindow;
|
|
|
|
wxDECLARE_EVENT(EVT_ZOOM_PERCENT, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_CANVAS_PART, wxCommandEvent);
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
|
|
using Coord = float;
|
|
using FloatPoint = std::array<Coord, 2>;
|
|
|
|
|
|
struct ObjectInfo {
|
|
std::string name{""};
|
|
int identify_id{-1};
|
|
PartState state{psUnCheck};
|
|
};
|
|
|
|
class SkipPartCanvas : public wxGLCanvas
|
|
{
|
|
union SkipIdHelper
|
|
{
|
|
uint32_t value = 0;
|
|
|
|
struct
|
|
{
|
|
uint8_t b;
|
|
uint8_t g;
|
|
uint8_t r;
|
|
uint8_t _padding;
|
|
};
|
|
|
|
uint8_t bytes[4];
|
|
|
|
SkipIdHelper() = default;
|
|
|
|
SkipIdHelper(uint8_t red, uint8_t green, uint8_t blue)
|
|
: r(red), g(green), b(blue), _padding(0) {}
|
|
|
|
SkipIdHelper(uint32_t val): value(val){}
|
|
void reverse() {
|
|
uint8_t tmp{r};
|
|
r = b;
|
|
b = tmp;
|
|
}
|
|
};
|
|
public:
|
|
SkipPartCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs);
|
|
~SkipPartCanvas() = default;
|
|
|
|
void SetParentBackground(const ColorRGB& color) {
|
|
parent_color_ = color;
|
|
}
|
|
|
|
void LoadPickImage(const std::string& path);
|
|
void ZoomIn(const int zoom_percent);
|
|
void ZoomOut(const int zoom_percent);
|
|
void SwitchDrag(const bool drag_on);
|
|
void UpdatePartsInfo(const PartsInfo& parts);
|
|
void SetZoomPercent(const int value);
|
|
void SetOffset(const wxPoint &value);
|
|
|
|
wxTextCtrl* log_ctrl;
|
|
protected:
|
|
void OnPaint(wxPaintEvent& event);
|
|
void OnSize(wxSizeEvent& event);
|
|
void OnMouseLeftDown(wxMouseEvent& event);
|
|
void OnMouseLeftUp(wxMouseEvent& event);
|
|
void OnMouseRightDown(wxMouseEvent& event);
|
|
void OnMouseRightUp(wxMouseEvent& event);
|
|
void OnMouseMotion(wxMouseEvent& event);
|
|
void OnMouseWheel(wxMouseEvent& event);
|
|
private:
|
|
wxGLContext* context_;
|
|
cv::Mat pick_image_;
|
|
std::unordered_map < uint32_t, std::vector<std::vector<FloatPoint>>> parts_triangles_;
|
|
std::unordered_map < uint32_t, std::vector<std::vector<cv::Point>>> pick_parts_;
|
|
std::unordered_map<uint32_t, PartState> parts_state_;
|
|
int zoom_percent_{100};
|
|
wxPoint offset_{0,0};
|
|
wxPoint drag_start_offset_{0,0};
|
|
wxPoint drag_start_pt_{0,0};
|
|
bool is_draging_{false};
|
|
bool fixed_draging_{false};
|
|
bool left_down_{false};
|
|
ColorRGB parent_color_ = ColorRGB();
|
|
int hover_id_{-1};
|
|
double image_view_scale_{1};
|
|
|
|
void SendSelectEvent(int id, PartState state);
|
|
void SendZoomEvent(int zoom_percent);
|
|
|
|
inline double Zoom() const;
|
|
inline wxPoint ViewPtToImagePt(const wxPoint& view_pt) const;
|
|
uint32_t GetIdAtImagePt(const wxPoint& image_pt) const;
|
|
inline uint32_t GetIdAtViewPt(const wxPoint& view_pt) const;
|
|
|
|
void ProcessHover(const wxPoint& mouse_pt);
|
|
void AutoSetCursor();
|
|
void StartDrag(const wxPoint& mouse_pt);
|
|
void ProcessDrag(const wxPoint& mouse_pt);
|
|
void EndDrag();
|
|
|
|
void Render();
|
|
|
|
void DebugLogLine(std::string str);
|
|
};
|
|
|
|
class _BBS_3MF_Base
|
|
{
|
|
mutable boost::mutex mutex;
|
|
mutable std::vector<std::string> m_errors;
|
|
|
|
protected:
|
|
void add_error(const std::string& error) const;
|
|
void clear_errors();
|
|
|
|
public:
|
|
void log_errors();
|
|
};
|
|
|
|
struct PlateInfo
|
|
{
|
|
int index{-1};
|
|
std::vector<ObjectInfo> objects;
|
|
bool label_object_enabled = false;
|
|
};
|
|
|
|
class ModelSettingHelper : public _BBS_3MF_Base
|
|
{
|
|
struct ParseContext
|
|
{
|
|
std::vector<PlateInfo> plates;
|
|
PlateInfo current_plate;
|
|
ObjectInfo temp_object;
|
|
bool in_plate = false;
|
|
};
|
|
|
|
public:
|
|
ModelSettingHelper(const std::string &path);
|
|
|
|
bool Parse();
|
|
std::vector<ObjectInfo> GetPlateObjects(int plate_idx);
|
|
bool GetLabelObjectEnabled(int plate_idx);
|
|
|
|
private:
|
|
std::string path_;
|
|
ParseContext context_;
|
|
|
|
static void XMLCALL StartElementHandler(void *userData, const XML_Char *name, const XML_Char **atts);
|
|
static void XMLCALL EndElementHandler(void *userData, const XML_Char *name);
|
|
void DataHandler(const XML_Char *s, int len);
|
|
};
|
|
|
|
}
|
|
}
|
|
#endif //SKIPPARTCANVAS_H
|