OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GridCellIconRenderer Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GUI_ObjectTable.hpp>

Inheritance diagram for Slic3r::GUI::GridCellIconRenderer:
Collaboration diagram for Slic3r::GUI::GridCellIconRenderer:

Public Member Functions

virtual void Draw (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) wxOVERRIDE
virtual wxSize GetBestSize (wxGrid &WXUNUSED(grid), wxGridCellAttr &attr, wxDC &dc, int WXUNUSED(row), int WXUNUSED(col)) wxOVERRIDE
virtual GridCellIconRenderer * Clone () const wxOVERRIDE

Detailed Description

Member Function Documentation

◆ Clone()

GridCellIconRenderer * Slic3r::GUI::GridCellIconRenderer::Clone ( ) const
virtual
152{
153 return new GridCellIconRenderer();
154}

◆ Draw()

void Slic3r::GUI::GridCellIconRenderer::Draw ( wxGrid & grid,
wxGridCellAttr & attr,
wxDC & dc,
const wxRect & rect,
int row,
int col,
bool isSelected )
virtual
93{
94 ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
95
96 wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
97 if (table) {
98 ObjectGridTable::ObjectGridCol* grid_col = table->get_grid_col(col);
99 if (!grid_col || !grid_col->b_icon) {
100 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": cell (%1%, %2%) not icon type") %row %col;
101 return;
102 }
103 ObjectGridTable::ObjectGridRow* grid_row = table->get_grid_row(row - 1);
104 ConfigOption& orig_option = (*grid_row)[(ObjectGridTable::GridColType)col];
105 ConfigOption& cur_option = (*grid_row)[(ObjectGridTable::GridColType)(col-1)];
106 if (cur_option == orig_option) {
107 //not changed
108 return;
109 }
110 //if (!table->m_icon_col_width) {
111 table->m_icon_row_height = grid.GetRowSize(row);
112 table->m_icon_col_width = grid.GetColSize(col);
113 //}
114 wxBitmap& bitmap = table->get_undo_bitmap();
115 int bitmap_width = bitmap.GetWidth();
116 int bitmap_height = bitmap.GetHeight();
117 int offset_x = (table->m_icon_col_width - bitmap_width)/2;
118 int offset_y = (table->m_icon_row_height - bitmap_height)/2;
119
120 #ifdef __WXOSX_COCOA__
121 auto lock_pos = wxPoint(rect.x + offset_x, rect.y + offset_y);
122 auto left = (28 - 12) / 2;
123 auto top = (32 - 12) / 2;
124 lock_pos.x += left;
125 lock_pos.y += top;
126 dc.DrawBitmap(bitmap, lock_pos);
127 #else
128 dc.DrawBitmap(bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
129 #endif
130
131 //dc.SetPen(*wxGREEN_PEN);
132 //dc.SetBrush(*wxTRANSPARENT_BRUSH);
133 //dc.DrawEllipse(rect);
134 }
135 else {
136 //should not happen
137 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": no table found, should not happen" << std::endl;
138 }
139}
GridColType
Definition GUI_ObjectTable.hpp:294
std::vector< ArithmeticOnly< T > > grid(const T &start, const T &stop, const T &stride)
A set of equidistant values starting from 'start' (inclusive), ending in the closest multiple of 'str...
Definition MTUtils.hpp:127
@ left
Definition MarchingSquares.hpp:188

References Slic3r::GUI::ObjectGridTable::ObjectGridCol::b_icon, Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), Slic3r::GUI::ObjectGridTable::get_undo_bitmap(), Slic3r::grid(), Slic3r::GUI::ObjectGridTable::m_icon_col_width, and Slic3r::GUI::ObjectGridTable::m_icon_row_height.

Here is the call graph for this function:

◆ GetBestSize()

wxSize Slic3r::GUI::GridCellIconRenderer::GetBestSize ( wxGrid & WXUNUSEDgrid,
wxGridCellAttr & attr,
wxDC & dc,
int WXUNUSEDrow,
int WXUNUSEDcol )
virtual
146{
147 wxSize size{32, 30};
148 return size;
149}

References Slic3r::grid().

Here is the call graph for this function:

The documentation for this class was generated from the following files: