11 #define signals Q_SIGNALS
17 #include <QMainWindow>
22 #include <pybind11/pybind11.h>
23 #include <pybind11/stl.h>
24 #include <pybind11/stl_bind.h>
26 #include "../../wrapper/pycc/src/casters.h"
29 using namespace pybind11::literals;
38 throw std::runtime_error(
"Bad argument");
40 throw std::runtime_error(
"Unknown file");
42 throw std::runtime_error(
"Wrong file type");
44 throw std::runtime_error(
"Error when writing");
46 throw std::runtime_error(
"Error when reading");
48 throw std::runtime_error(
"Nothing to save");
50 throw std::runtime_error(
"Nothing to load");
52 throw std::runtime_error(
"Bad entity type");
54 throw std::runtime_error(
"Canceled by user");
56 throw std::runtime_error(
"Not enough memory");
58 throw std::runtime_error(
"Malformed File");
60 throw std::runtime_error(
"The error has been logged in the console");
62 throw std::runtime_error(
"Broken dependency");
64 throw std::runtime_error(
"File was written by unknown plugin");
66 throw std::runtime_error(
"Third party lib failure");
68 throw std::runtime_error(
"Third party lib exception");
70 throw std::runtime_error(
"Internal error");
72 throw std::runtime_error(
"Not implemented");
80 throw std::invalid_argument(
"nullptr received for the app");
86 return m_app->getMainWindow();
91 return m_app->haveSelection();
96 return m_app->haveOneSelection();
101 return m_app->getSelectedEntities();
106 m_app->setSelectedInDB(obj, selected);
118 m_app->addToDB(newGroup);
127 bool autoExpandDBTree,
128 bool checkDimensions,
133 auto *
const hobj = obj.cast<
ccHObject *>();
134 m_app->addToDB(hobj, updateZoom, autoExpandDBTree, checkDimensions, autoRedraw);
137 catch (
const pybind11::cast_error &)
139 throw std::runtime_error(
"Cannot add to the DB a type that does not sub class ccHObject");
147 auto *
const hobj = obj.cast<
ccHObject *>();
151 m_app->removeFromDB(hobj,
false );
152 Q_ASSERT(obj.ref_count() >= 2);
155 catch (
const pybind11::cast_error &)
157 throw std::runtime_error(
158 "Cannot remove from the DB a type that does not sub class ccHObject");
164 return m_app->dbRootObject();
169 m_app->redrawAll(only2D);
174 m_app->refreshAll(only2D);
194 m_app->freezeUI(state);
203 py::class_<ccGuiPythonInstance>(m,
206 Class to interact with the running GUI of ACloudViewer.
208 The methods allow you to get/add objects to GUI DB Tree.
209 Refresh/freeze/update the UI and display.
210 Get selected objects, deselect/set selected state for entities...
212 .def("getMainWindow",
214 py::return_value_policy::reference)
215 .def(
"haveSelection",
217 R
"(Returns true if at least one entity is selected in the GUI DB Tree)")
218 .def("haveOneSelection",
220 R
"(Returns True if exactly one entity is selected in the GUI DB Tree)")
221 .def("getSelectedEntities",
223 py::return_value_policy::reference,
224 R
"(Returns the list of selected entities in the GUI DB Tree)")
225 .def("setSelectedInDB",
229 R
"(Set the selection state of the object in the GUI DB Tree)")
232 py::return_value_policy::reference,
233 R
"(Returns the root of the GUI DB Tree)")
238 "updateZoom"_a =
false,
239 "autoExpandDBTree"_a =
true,
240 "checkDimensions"_a =
false,
241 "autoRedraw"_a =
true,
242 R
"(Adds the object to the GUI DB Tree)")
253 py::return_value_policy::reference,
257 Loads the file located at the filepath.
259 Adds the file content of the file into the DBTree
260 and then returns loaded object handle.
262 raises RuntimeError in case of error)");
CC_FILE_ERROR
Typical I/O filter errors.
@ CC_FERR_CANCELED_BY_USER
@ CC_FERR_THIRD_PARTY_LIB_FAILURE
@ CC_FERR_THIRD_PARTY_LIB_EXCEPTION
@ CC_FERR_NOT_IMPLEMENTED
@ CC_FERR_BROKEN_DEPENDENCY_ERROR
@ CC_FERR_BAD_ENTITY_TYPE
@ CC_FERR_FILE_WAS_WRITTEN_BY_UNKNOWN_PLUGIN
@ CC_FERR_NOT_ENOUGH_MEMORY
@ CC_FERR_WRONG_FILE_TYPE
void define_ccGUIPythonInstance(py::module &m)
static void ThrowForFileError(CC_FILE_ERROR error)
static ccHObject * LoadFromFile(const QString &filename, LoadParameters ¶meters, Shared filter, CC_FILE_ERROR &result)
Loads one or more entities from a file with a known filter.
bool haveOneSelection() const
ccHObject * dbRootObject()
ecvMainAppInterface * app()
void removeFromDB(pybind11::object &obj)
QMainWindow * getMainWindow()
void redrawAll(bool only2D=false)
void setSelectedInDB(ccHObject *obj, bool selected)
bool haveSelection() const
ccGuiPythonInstance(ecvMainAppInterface *app) noexcept(false)
void freezeUI(bool state)
void refreshAll(bool only2D=false)
ccHObject * loadFile(const char *filename, FileIOFilter::LoadParameters ¶meters)
void addToDB(pybind11::object &obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)
const ccHObject::Container & getSelectedEntities() const
Hierarchical CLOUDVIEWER Object.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Main application interface (for plugins)
static void error(char *msg)
Generic loading parameters.