Files
OrcaSlicer/src/slic3r/GUI/AuxiliaryDataViewModel.hpp
T
HanifKoh 4895bc03b4 Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced (#16099)
* 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
2026-10-05 16:47:17 +08:00

161 lines
4.1 KiB
C++

#ifndef slic3r_GUI_AuxiliaryDataViewModel_hpp_
#define slic3r_GUI_AuxiliaryDataViewModel_hpp_
#include "wx/wxprec.h"
#include "wx/dataview.h"
#include "wx/hashmap.h"
#include "wx/vector.h"
#include <boost/filesystem.hpp>
#include <wx/dynarray.h>
#include <boost/filesystem/path.hpp>
#include <cstddef>
#include <wx/string.h>
#include <wx/arrstr.h>
#include <wx/variant.h>
class AuxiliaryModelNode;
WX_DEFINE_ARRAY_PTR(AuxiliaryModelNode*, AuxiliaryModelNodePtrArray);
namespace fs = boost::filesystem;
class AuxiliaryModelNode
{
public:
AuxiliaryModelNode()
{
m_parent = NULL;
name = "";
m_container = true;
m_root = true;
}
AuxiliaryModelNode(AuxiliaryModelNode* parent, const wxString& abs_path, bool is_container)
{
m_parent = parent;
m_container = is_container;
m_root = false;
path = abs_path;
boost::filesystem::path path_obj(path.ToStdWstring());
name = path_obj.filename().generic_wstring();
parent->Append(this);
}
~AuxiliaryModelNode()
{
// free all our children nodes
size_t count = m_children.GetCount();
for (size_t i = 0; i < count; i++)
{
AuxiliaryModelNode* child = m_children[i];
delete child;
}
}
bool IsContainer() const
{
return m_container;
}
AuxiliaryModelNode* GetParent()
{
return m_parent;
}
void SetParent(AuxiliaryModelNode* parent)
{
m_parent = parent;
}
AuxiliaryModelNodePtrArray& GetChildren()
{
return m_children;
}
AuxiliaryModelNode* GetNthChild(unsigned int n)
{
return m_children.Item(n);
}
void Insert(AuxiliaryModelNode* child, unsigned int n)
{
m_children.Insert(child, n);
}
void Append(AuxiliaryModelNode* child)
{
m_children.Add(child);
}
unsigned int GetChildCount() const
{
return m_children.GetCount();
}
public:
wxString name;
wxString path;
private:
AuxiliaryModelNode* m_parent;
AuxiliaryModelNodePtrArray m_children;
bool m_container;
bool m_root;
};
class AuxiliaryModel : public wxDataViewModel
{
public:
AuxiliaryModel();
~AuxiliaryModel();
// helper methods to change the model
wxDataViewItem CreateFolder(wxString name = wxEmptyString);
wxDataViewItemArray ImportFile(AuxiliaryModelNode* sel, wxArrayString file_paths);
void Delete(const wxDataViewItem& item);
void MoveItem(const wxDataViewItem& dropped_item, const wxDataViewItem& dragged_item);
bool IsOrphan(const wxDataViewItem& item);
bool Rename(const wxDataViewItem& item, const wxString& name);
AuxiliaryModelNode* GetParent(AuxiliaryModelNode* node) const;
void Reparent(AuxiliaryModelNode* node, AuxiliaryModelNode* new_parent);
void Init(wxString aux_path);
void Reload(wxString aux_path);
// override sorting to always sort branches ascendingly
int Compare(const wxDataViewItem& item1, const wxDataViewItem& item2,
unsigned int column, bool ascending) const wxOVERRIDE;
// implementation of base class virtuals to define model
virtual unsigned int GetColumnCount() const wxOVERRIDE
{
return 1;
}
virtual wxString GetColumnType(unsigned int col) const wxOVERRIDE
{
return "string";
}
virtual void GetValue(wxVariant& variant,
const wxDataViewItem& item, unsigned int col) const wxOVERRIDE;
virtual bool SetValue(const wxVariant& variant,
const wxDataViewItem& item, unsigned int col) wxOVERRIDE;
virtual bool IsEnabled(const wxDataViewItem& item,
unsigned int col) const wxOVERRIDE;
virtual wxDataViewItem GetParent(const wxDataViewItem& item) const wxOVERRIDE;
virtual bool IsContainer(const wxDataViewItem& item) const wxOVERRIDE;
virtual unsigned int GetChildren(const wxDataViewItem& parent,
wxDataViewItemArray& array) const wxOVERRIDE;
private:
AuxiliaryModelNode* m_root;
wxString m_root_dir;
};
#endif // slic3r_GUI_AuxiliaryDataViewModel_hpp_