Sidebar: Info box: Fixed value of the "Volume"
+ Hidden "Materials" item
This commit is contained in:
parent
e419285147
commit
02c18dbc52
@ -1,3 +1,4 @@
|
|||||||
|
#include "Model.hpp"
|
||||||
#include "libslic3r.h"
|
#include "libslic3r.h"
|
||||||
#include "Exception.hpp"
|
#include "Exception.hpp"
|
||||||
#include "Model.hpp"
|
#include "Model.hpp"
|
||||||
@ -1701,9 +1702,6 @@ std::string ModelObject::get_export_filename() const
|
|||||||
|
|
||||||
TriangleMeshStats ModelObject::get_object_stl_stats() const
|
TriangleMeshStats ModelObject::get_object_stl_stats() const
|
||||||
{
|
{
|
||||||
if (this->volumes.size() == 1)
|
|
||||||
return this->volumes[0]->mesh().stats();
|
|
||||||
|
|
||||||
TriangleMeshStats full_stats;
|
TriangleMeshStats full_stats;
|
||||||
full_stats.volume = 0.f;
|
full_stats.volume = 0.f;
|
||||||
|
|
||||||
@ -1718,7 +1716,8 @@ TriangleMeshStats ModelObject::get_object_stl_stats() const
|
|||||||
|
|
||||||
// another used satistics value
|
// another used satistics value
|
||||||
if (volume->is_model_part()) {
|
if (volume->is_model_part()) {
|
||||||
full_stats.volume += stats.volume;
|
Transform3d trans = instances[0]->get_matrix() * volume->get_matrix();
|
||||||
|
full_stats.volume += stats.volume * std::fabs(trans.matrix().block(0, 0, 3, 3).determinant());
|
||||||
full_stats.number_of_parts += stats.number_of_parts;
|
full_stats.number_of_parts += stats.number_of_parts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
|||||||
// grid_sizer->AddGrowableCol(3, 1);
|
// grid_sizer->AddGrowableCol(3, 1);
|
||||||
|
|
||||||
auto init_info_label = [parent, grid_sizer](wxStaticText **info_label, wxString text_label) {
|
auto init_info_label = [parent, grid_sizer](wxStaticText **info_label, wxString text_label) {
|
||||||
auto *text = new wxStaticText(parent, wxID_ANY, text_label+":");
|
auto *text = new wxStaticText(parent, wxID_ANY, text_label + (text_label.empty() ? "" : ":"));
|
||||||
text->SetFont(wxGetApp().small_font());
|
text->SetFont(wxGetApp().small_font());
|
||||||
*info_label = new wxStaticText(parent, wxID_ANY, "");
|
*info_label = new wxStaticText(parent, wxID_ANY, "");
|
||||||
(*info_label)->SetFont(wxGetApp().small_font());
|
(*info_label)->SetFont(wxGetApp().small_font());
|
||||||
@ -177,7 +177,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
|||||||
init_info_label(&info_size, _L("Size"));
|
init_info_label(&info_size, _L("Size"));
|
||||||
label_volume = init_info_label(&info_volume, _L("Volume"));
|
label_volume = init_info_label(&info_volume, _L("Volume"));
|
||||||
init_info_label(&info_facets, _L("Facets"));
|
init_info_label(&info_facets, _L("Facets"));
|
||||||
label_materials = init_info_label(&info_materials, _L("Materials"));
|
label_materials = init_info_label(&info_materials, /*_L("Materials")*/"");
|
||||||
Add(grid_sizer, 0, wxEXPAND);
|
Add(grid_sizer, 0, wxEXPAND);
|
||||||
|
|
||||||
info_manifold = new wxStaticText(parent, wxID_ANY, "");
|
info_manifold = new wxStaticText(parent, wxID_ANY, "");
|
||||||
@ -1199,32 +1199,47 @@ void Sidebar::update_objects_list_extruder_column(size_t extruders_count)
|
|||||||
|
|
||||||
void Sidebar::show_info_sizer()
|
void Sidebar::show_info_sizer()
|
||||||
{
|
{
|
||||||
if (!p->plater->is_single_full_object_selection() ||
|
Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||||
m_mode < comExpert ||
|
ModelObjectPtrs objects = p->plater->model().objects;
|
||||||
p->plater->model().objects.empty()) {
|
int obj_idx = selection.get_object_idx();
|
||||||
|
|
||||||
|
if (m_mode < comExpert || objects.empty() || obj_idx < 0 || obj_idx > 1000 ||
|
||||||
|
objects[obj_idx]->volumes.empty() || // hack to avoid crash when deleting the last object on the bed
|
||||||
|
(selection.is_single_full_object() && objects[obj_idx]->instances.size()> 1) ||
|
||||||
|
!(selection.is_single_full_instance() || selection.is_single_volume())) {
|
||||||
p->object_info->Show(false);
|
p->object_info->Show(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int obj_idx = p->plater->get_selected_object_idx();
|
const ModelObject* model_object = objects[obj_idx];
|
||||||
|
|
||||||
const ModelObject* model_object = p->plater->model().objects[obj_idx];
|
int inst_idx = selection.get_instance_idx();
|
||||||
// hack to avoid crash when deleting the last object on the bed
|
assert(inst_idx >= 0);
|
||||||
if (model_object->volumes.empty())
|
|
||||||
{
|
|
||||||
p->object_info->Show(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||||
double koef = imperial_units ? ObjectManipulation::mm_to_in : 1.0f;
|
double koef = imperial_units ? ObjectManipulation::mm_to_in : 1.0f;
|
||||||
|
|
||||||
auto size = model_object->bounding_box().size();
|
ModelVolume* vol = nullptr;
|
||||||
p->object_info->info_size->SetLabel(wxString::Format("%.2f x %.2f x %.2f",size(0)*koef, size(1)*koef, size(2)*koef));
|
Transform3d t;
|
||||||
p->object_info->info_materials->SetLabel(wxString::Format("%d", static_cast<int>(model_object->materials_count())));
|
if (selection.is_single_volume()) {
|
||||||
|
std::vector<int> obj_idxs, vol_idxs;
|
||||||
|
wxGetApp().obj_list()->get_selection_indexes(obj_idxs, vol_idxs);
|
||||||
|
assert(vol_idxs.size() == 1);
|
||||||
|
vol = model_object->volumes[vol_idxs[0]];
|
||||||
|
t = model_object->instances[inst_idx]->get_matrix() * vol->get_matrix();
|
||||||
|
}
|
||||||
|
|
||||||
const auto& stats = model_object->get_object_stl_stats();
|
Vec3d size = vol ? vol->mesh().transformed_bounding_box(t).size() : model_object->instance_bounding_box(inst_idx).size();
|
||||||
p->object_info->info_volume->SetLabel(wxString::Format("%.2f", stats.volume*pow(koef,3)));
|
p->object_info->info_size->SetLabel(wxString::Format("%.2f x %.2f x %.2f", size(0)*koef, size(1)*koef, size(2)*koef));
|
||||||
|
// p->object_info->info_materials->SetLabel(wxString::Format("%d", static_cast<int>(model_object->materials_count())));
|
||||||
|
|
||||||
|
const TriangleMeshStats& stats = vol ? vol->mesh().stats() : model_object->get_object_stl_stats();
|
||||||
|
|
||||||
|
double volume_val = stats.volume;
|
||||||
|
if (vol)
|
||||||
|
volume_val *= std::fabs(t.matrix().block(0, 0, 3, 3).determinant());
|
||||||
|
|
||||||
|
p->object_info->info_volume->SetLabel(wxString::Format("%.2f", volume_val * pow(koef,3)));
|
||||||
p->object_info->info_facets->SetLabel(format_wxstr(_L_PLURAL("%1% (%2$d shell)", "%1% (%2$d shells)", stats.number_of_parts),
|
p->object_info->info_facets->SetLabel(format_wxstr(_L_PLURAL("%1% (%2$d shell)", "%1% (%2$d shells)", stats.number_of_parts),
|
||||||
static_cast<int>(model_object->facets_count()), stats.number_of_parts));
|
static_cast<int>(model_object->facets_count()), stats.number_of_parts));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user