2018-02-14 19:38:03 +00:00
|
|
|
#ifndef slic3r_GCode_PreviewData_hpp_
|
|
|
|
#define slic3r_GCode_PreviewData_hpp_
|
|
|
|
|
|
|
|
#include "../libslic3r.h"
|
|
|
|
#include "../ExtrusionEntity.hpp"
|
2018-11-26 13:41:58 +00:00
|
|
|
#include "../Point.hpp"
|
2018-02-14 19:38:03 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class GCodePreviewData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
float rgba[4];
|
|
|
|
|
|
|
|
Color();
|
|
|
|
Color(float r, float g, float b, float a);
|
|
|
|
|
|
|
|
std::vector<unsigned char> as_bytes() const;
|
|
|
|
|
|
|
|
static const Color Dummy;
|
|
|
|
};
|
|
|
|
|
2018-12-19 13:47:16 +00:00
|
|
|
// Color mapping from a <min, max> range into a smooth rainbow of 10 colors.
|
2018-02-14 19:38:03 +00:00
|
|
|
struct Range
|
|
|
|
{
|
|
|
|
static const unsigned int Colors_Count = 10;
|
|
|
|
static const Color Default_Colors[Colors_Count];
|
|
|
|
|
|
|
|
Color colors[Colors_Count];
|
|
|
|
float min;
|
|
|
|
float max;
|
|
|
|
|
|
|
|
Range();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
bool empty() const;
|
|
|
|
void update_from(float value);
|
2018-03-06 11:12:00 +00:00
|
|
|
void update_from(const Range& other);
|
2018-02-14 19:38:03 +00:00
|
|
|
void set_from(const Range& other);
|
|
|
|
float step_size() const;
|
|
|
|
|
2018-04-27 07:54:21 +00:00
|
|
|
Color get_color_at(float value) const;
|
2018-02-14 19:38:03 +00:00
|
|
|
};
|
|
|
|
|
2018-03-06 11:12:00 +00:00
|
|
|
struct Ranges
|
|
|
|
{
|
2018-12-19 13:47:16 +00:00
|
|
|
// Color mapping by layer height.
|
2018-03-06 11:12:00 +00:00
|
|
|
Range height;
|
2018-12-19 13:47:16 +00:00
|
|
|
// Color mapping by extrusion width.
|
2018-03-06 11:12:00 +00:00
|
|
|
Range width;
|
2018-12-19 13:47:16 +00:00
|
|
|
// Color mapping by feedrate.
|
2018-03-06 11:12:00 +00:00
|
|
|
Range feedrate;
|
2018-12-19 13:47:16 +00:00
|
|
|
// Color mapping by volumetric extrusion rate.
|
2018-03-21 09:03:10 +00:00
|
|
|
Range volumetric_rate;
|
2018-03-06 11:12:00 +00:00
|
|
|
};
|
|
|
|
|
2018-02-14 19:38:03 +00:00
|
|
|
struct LegendItem
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
Color color;
|
|
|
|
|
|
|
|
LegendItem(const std::string& text, const Color& color);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<LegendItem> LegendItemsList;
|
|
|
|
|
|
|
|
struct Extrusion
|
|
|
|
{
|
|
|
|
enum EViewType : unsigned char
|
|
|
|
{
|
|
|
|
FeatureType,
|
|
|
|
Height,
|
|
|
|
Width,
|
|
|
|
Feedrate,
|
2018-03-21 09:03:10 +00:00
|
|
|
VolumetricRate,
|
2018-02-14 19:38:03 +00:00
|
|
|
Tool,
|
2018-11-26 15:07:09 +00:00
|
|
|
ColorPrint,
|
2018-02-14 19:38:03 +00:00
|
|
|
Num_View_Types
|
|
|
|
};
|
|
|
|
|
|
|
|
static const unsigned int Num_Extrusion_Roles = (unsigned int)erMixed + 1;
|
|
|
|
static const Color Default_Extrusion_Role_Colors[Num_Extrusion_Roles];
|
|
|
|
static const std::string Default_Extrusion_Role_Names[Num_Extrusion_Roles];
|
|
|
|
static const EViewType Default_View_Type;
|
|
|
|
|
|
|
|
struct Layer
|
|
|
|
{
|
|
|
|
float z;
|
|
|
|
ExtrusionPaths paths;
|
|
|
|
|
|
|
|
Layer(float z, const ExtrusionPaths& paths);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<Layer> LayersList;
|
|
|
|
|
|
|
|
EViewType view_type;
|
|
|
|
Color role_colors[Num_Extrusion_Roles];
|
|
|
|
std::string role_names[Num_Extrusion_Roles];
|
|
|
|
LayersList layers;
|
|
|
|
unsigned int role_flags;
|
|
|
|
|
|
|
|
void set_default();
|
|
|
|
bool is_role_flag_set(ExtrusionRole role) const;
|
|
|
|
|
2018-12-18 14:55:45 +00:00
|
|
|
// Return an estimate of the memory consumed by the time estimator.
|
|
|
|
size_t memory_used() const;
|
|
|
|
|
2018-02-14 19:38:03 +00:00
|
|
|
static bool is_role_flag_set(unsigned int flags, ExtrusionRole role);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Travel
|
|
|
|
{
|
|
|
|
enum EType : unsigned char
|
|
|
|
{
|
|
|
|
Move,
|
|
|
|
Extrude,
|
|
|
|
Retract,
|
|
|
|
Num_Types
|
|
|
|
};
|
|
|
|
|
|
|
|
static const float Default_Width;
|
|
|
|
static const float Default_Height;
|
|
|
|
static const Color Default_Type_Colors[Num_Types];
|
|
|
|
|
|
|
|
struct Polyline
|
|
|
|
{
|
|
|
|
enum EDirection
|
|
|
|
{
|
|
|
|
Vertical,
|
|
|
|
Generic,
|
|
|
|
Num_Directions
|
|
|
|
};
|
|
|
|
|
|
|
|
EType type;
|
|
|
|
EDirection direction;
|
|
|
|
float feedrate;
|
|
|
|
unsigned int extruder_id;
|
|
|
|
Polyline3 polyline;
|
|
|
|
|
|
|
|
Polyline(EType type, EDirection direction, float feedrate, unsigned int extruder_id, const Polyline3& polyline);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<Polyline> PolylinesList;
|
|
|
|
|
|
|
|
PolylinesList polylines;
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
Color type_colors[Num_Types];
|
|
|
|
bool is_visible;
|
2018-11-26 15:07:09 +00:00
|
|
|
size_t color_print_idx;
|
2018-02-14 19:38:03 +00:00
|
|
|
|
|
|
|
void set_default();
|
2018-12-18 14:55:45 +00:00
|
|
|
|
|
|
|
// Return an estimate of the memory consumed by the time estimator.
|
|
|
|
size_t memory_used() const;
|
2018-02-14 19:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Retraction
|
|
|
|
{
|
|
|
|
static const Color Default_Color;
|
|
|
|
|
|
|
|
struct Position
|
|
|
|
{
|
2018-08-21 20:14:47 +00:00
|
|
|
Vec3crd position;
|
2018-02-14 19:38:03 +00:00
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
|
2018-08-21 20:14:47 +00:00
|
|
|
Position(const Vec3crd& position, float width, float height);
|
2018-02-14 19:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<Position> PositionsList;
|
|
|
|
|
|
|
|
PositionsList positions;
|
|
|
|
Color color;
|
|
|
|
bool is_visible;
|
|
|
|
|
|
|
|
void set_default();
|
2018-12-18 14:55:45 +00:00
|
|
|
|
|
|
|
// Return an estimate of the memory consumed by the time estimator.
|
|
|
|
size_t memory_used() const;
|
2018-02-14 19:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Shell
|
|
|
|
{
|
|
|
|
bool is_visible;
|
|
|
|
|
|
|
|
void set_default();
|
|
|
|
};
|
|
|
|
|
|
|
|
Extrusion extrusion;
|
|
|
|
Travel travel;
|
|
|
|
Retraction retraction;
|
|
|
|
Retraction unretraction;
|
|
|
|
Shell shell;
|
2018-03-07 08:17:59 +00:00
|
|
|
Ranges ranges;
|
2018-02-14 19:38:03 +00:00
|
|
|
|
|
|
|
GCodePreviewData();
|
|
|
|
|
|
|
|
void set_default();
|
|
|
|
void reset();
|
2018-02-14 20:57:46 +00:00
|
|
|
bool empty() const;
|
2018-02-14 19:38:03 +00:00
|
|
|
|
2018-05-11 10:28:31 +00:00
|
|
|
Color get_extrusion_role_color(ExtrusionRole role) const;
|
2018-04-27 07:54:21 +00:00
|
|
|
Color get_height_color(float height) const;
|
|
|
|
Color get_width_color(float width) const;
|
|
|
|
Color get_feedrate_color(float feedrate) const;
|
|
|
|
Color get_volumetric_rate_color(float rate) const;
|
2018-02-14 19:38:03 +00:00
|
|
|
|
|
|
|
void set_extrusion_role_color(const std::string& role_name, float red, float green, float blue, float alpha);
|
|
|
|
void set_extrusion_paths_colors(const std::vector<std::string>& colors);
|
|
|
|
|
|
|
|
std::string get_legend_title() const;
|
2018-11-28 11:32:43 +00:00
|
|
|
LegendItemsList get_legend_items(const std::vector<float>& tool_colors, const std::vector</*double*/std::pair<double, double>>& cp_values) const;
|
2018-12-18 14:55:45 +00:00
|
|
|
|
|
|
|
// Return an estimate of the memory consumed by the time estimator.
|
|
|
|
size_t memory_used() const;
|
2019-01-29 14:11:29 +00:00
|
|
|
|
|
|
|
static const std::vector<std::string>& ColorPrintColors();
|
2018-02-14 19:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GCodePreviewData::Color operator + (const GCodePreviewData::Color& c1, const GCodePreviewData::Color& c2);
|
|
|
|
GCodePreviewData::Color operator * (float f, const GCodePreviewData::Color& color);
|
|
|
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif /* slic3r_GCode_PreviewData_hpp_ */
|