PythonInterpreter.cc 27.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
*                                                                            *
\*===========================================================================*/


#include <pybind11/include/pybind11/pybind11.h>
#include <pybind11/include/pybind11/embed.h>


#include "PyLogHook.h"

#include "PythonInterpreter.hh"

51 52 53
#include <QMetaObject>
#include <QMetaMethod>

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
namespace py = pybind11;

static Core* core_;

static pybind11::module mainModule_;

static PythonInterpreter* interpreter_ = nullptr;

/** \brief Stores a clean dictionary for interpreter reset
 *
 */
static PyObject* global_dict_clean_ = nullptr;


void setCorePointer( Core* _core ) {
  core_ = _core;
}

PythonInterpreter* PythonInterpreter::getInstance() {

  if (interpreter_ == nullptr)
  {
    interpreter_ = new PythonInterpreter();
  }

  return interpreter_;

}

83 84 85
PythonInterpreter::PythonInterpreter() :
    externalLogging_(false)
{
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181

}

PythonInterpreter::~PythonInterpreter() {

}

bool PythonInterpreter::modulesInitialized() {
  ///@TODO: Why does this work?
  return static_cast<bool>(mainModule_);
}

void PythonInterpreter::initPython() {
  if (Py_IsInitialized()  )
    return;

  std::cerr << "A" << std::endl;
  py::initialize_interpreter();

  std::cerr << "B" << std::endl;

  PyEval_InitThreads();

  std::cerr << "C" << std::endl;

  if (!modulesInitialized()) {
    std::cerr << "D" << std::endl;

    //dlopen("libpython3.5m.so.1.0", RTLD_LAZY | RTLD_GLOBAL);
    py::module main{ py::module::import("__main__") };

    // redirect python output
    tyti::pylog::redirect_stderr([this](const char*w) {this->pyError(w); });
    tyti::pylog::redirect_stdout([this](const char* w) {this->pyOutput(w); });

    std::cerr << "E" << std::endl;

    // add openflipper module
    py::object main_namespace = main.attr("__dict__");

    std::cerr << "F" << std::endl;

    py::module of_module(py::module::import("openflipper"));
    main_namespace["openflipper"] = of_module;

    std::cerr << "G" << std::endl;

    global_dict_clean_ = PyDict_Copy(PyModule_GetDict(main.ptr()));

    std::cerr << "H" << std::endl;

    // set the main module member to a validate state, shows, that all modules are successfully initialized
    mainModule_ = std::move(main);

    std::cerr << "I" << std::endl;

    // Do not release the GIL until all modules are initalzed
    PyEval_SaveThread();

    std::cerr << "J" << std::endl;

  }

}

void PythonInterpreter::resetInterpreter()
{
    if (!Py_IsInitialized() || !modulesInitialized())
        return;

    PyGILState_STATE state = PyGILState_Ensure();
    PyObject* dict = PyModule_GetDict(mainModule_.ptr());
    PyDict_Clear(dict);
    PyDict_Update(dict, global_dict_clean_);
    PyGILState_Release(state);
}


bool PythonInterpreter::runScript(QString _script) {

  std::cerr << "runScript" << std::endl;

  // init
  try
  {
    std::cerr << "Run Init Python" << std::endl;
    initPython();
    std::cerr << ".. Done" << std::endl;
  }
  catch (py::error_already_set &e)
  {
    pyError(e.what());
    return false;
  }

  PyGILState_STATE state = PyGILState_Ensure();
Jan Möbius's avatar
Jan Möbius committed
182
  //PyThreadState* tstate = PyGILState_GetThisThreadState();
183 184 185 186 187 188 189 190

  auto locals = mainModule_.attr("__dict__");

  bool result = true;

  try
  {

191 192 193
    std::cerr << "Now executing script:" << std::endl;
    std::cerr << _script.toStdString() << std::endl;

194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    py::exec((const char*)_script.toLatin1(), py::globals(), locals);

    std::cerr << "Finished successfully" << std::endl;
  }
  catch (py::error_already_set &e)
  {
    pyError(e.what());
    e.restore();
    result = false;
  }
  catch (const std::runtime_error &e)
  {
    pyError(e.what());
    pyOutput("Restarting Interpreter.");
    resetInterpreter();
    result = false;
    state = PyGILState_Ensure();
  }

  PyGILState_Release(state);

  return result;
}

218 219 220 221 222 223 224 225
QString PythonInterpreter::runScriptOutput(QString _script) {
  LogOut.clear();
  LogErr.clear();
  externalLogging_ = false;
  runScript(_script);
  externalLogging_ = true;
  return LogOut + LogErr;
}
226 227 228 229 230


// Python callback functions
void PythonInterpreter::pyOutput(const char* w)
{
231 232 233 234 235 236
  if (externalLogging_) {
    std::cerr << "Python output:\n " << w << std::endl;
    Q_EMIT log(LOGOUT, QString(w));
  } else {
    LogOut += QString::fromUtf8(w);
  }
237 238 239 240
}

void PythonInterpreter::pyError(const char* w)
{
241 242 243 244 245 246
  if (externalLogging_) {
    std::cerr << "Python error:\n " << w << std::endl;
    Q_EMIT log(LOGERR, QString(w));
  } else {
    LogErr += QString::fromUtf8(w);
  }
247 248
}

Jan Möbius's avatar
Jan Möbius committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
namespace pybind11 { namespace detail {
    template <> struct type_caster<QString> {
    public:
        /**
         * This macro establishes the name 'str' in
         * function signatures and declares a local variable
         * 'value' of type QVariant
         */
        PYBIND11_TYPE_CASTER(QString, _("str"));

        /**
         * Conversion part 1 (Python->C++): convert a PyObject into a inty
         * instance or return false upon failure. The second argument
         * indicates whether implicit conversions should be applied.
         */
        bool load(handle src, bool ) {
            /* Extract PyObject from handle */
            PyObject *source = src.ptr();

            if (!PyUnicode_Check(source))
              return false;

271
            Py_ssize_t size;
Jan Möbius's avatar
Jan Möbius committed
272
            const char *ptr = PyUnicode_AsUTF8AndSize(source, &size);
Jan Möbius's avatar
Jan Möbius committed
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297

            if (!ptr) {
                return NULL;
            }


            /* Now try to convert into a C++ int */
            value = QString::fromUtf8(ptr, size);

            /* Ensure return code was OK (to avoid out-of-range errors etc) */
            return ( !PyErr_Occurred() );
        }

        /**
         * Conversion part 2 (C++ -> Python): convert an QVariant instance into
         * a Python object. The second and third arguments are used to
         * indicate the return value policy and parent object (for
         * ``return_value_policy::reference_internal``) and are generally
         * ignored by implicit casters.
         */
        static handle cast(QString src, return_value_policy /* policy */, handle /* parent */) {
            return (PyUnicode_FromString( src.toUtf8().data()) );
        }
    };
}} // namespace pybind11::detail
298 299


300 301
PYBIND11_EMBEDDED_MODULE(openflipper, m) {

302 303 304 305 306 307 308 309 310 311
  // Export our core. Make sure that the c++ worlds core objet is not deleted if
  // the python side gets deleted!!
  py::class_<Core,std::unique_ptr<Core, py::nodelete>> core(m, "core");

  // On the c++ side we will just return the existing core instance
  // and prevent the system to recreate a new core as we need
  // to work on the existing one.
  core.def(py::init([]() { return core_; }));


312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510

  core.def("updateView", &Core::updateView, QCoreApplication::translate("PythonDocCore","Redraw the contents of the viewer.").toLatin1().data() );
  core.def("blockScenegraphUpdates", &Core::blockScenegraphUpdates, QCoreApplication::translate("PythonDocCore","Disable Scenegraph Updates (e.g. before loading or adding a large number of files)").toLatin1().data() );
  core.def("updateUI", &Core::updateUI, QCoreApplication::translate("PythonDocCore","Process events during script execution to keep the ui alive").toLatin1().data() );
  core.def("clearAll", &Core::clearAll, QCoreApplication::translate("PythonDocCore","Clear all data objects.").toLatin1().data() );
  core.def("deleteObject", &Core::deleteObject, QCoreApplication::translate("PythonDocCore","Delete an object from the scene.").toLatin1().data() ,
                                       py::arg( QCoreApplication::translate("PythonDocCore","Id of the object to delete.").toLatin1().data() ) );

//  void setObjectComment(int objId, QString key, QString comment);
//  void clearObjectComment(int objId, QString key);
//  void clearAllComments(int objId);

  core.def("fullscreen", &Core::fullscreen, QCoreApplication::translate("PythonDocCore","Enable or disable fullscreen mode.").toLatin1().data() ,
                                   py::arg( QCoreApplication::translate("PythonDocCore","Enable or disable?").toLatin1().data() ) );

  core.def("showViewModeControls", &Core::deleteObject, QCoreApplication::translate("PythonDocCore","Show or hide the view mode control box").toLatin1().data() ,
                                               py::arg( QCoreApplication::translate("PythonDocCore","Visible?").toLatin1().data() ) );

  core.def("loggerState", &Core::loggerState, QCoreApplication::translate("PythonDocCore","Change the logger window state").toLatin1().data() ,
                                     py::arg( QCoreApplication::translate("PythonDocCore","0 = In Scene , 1 = Normal, 2 = Hidden").toLatin1().data() ) );

  core.def("enableOpenMeshErrorLog", &Core::enableOpenMeshErrorLog, QCoreApplication::translate("PythonDocCore","Enable or disable OpenMesh error logging").toLatin1().data() ,
                                                           py::arg( QCoreApplication::translate("PythonDocCore","Enable or Disable").toLatin1().data() ) );

  core.def("showToolbox", &Core::showToolbox, QCoreApplication::translate("PythonDocCore","Show or hide toolbox").toLatin1().data() ,
                                     py::arg( QCoreApplication::translate("PythonDocCore","Visible?").toLatin1().data() ) );

  core.def("showStatusBar", &Core::showStatusBar, QCoreApplication::translate("PythonDocCore","Show or hide status bar").toLatin1().data() ,
                                         py::arg( QCoreApplication::translate("PythonDocCore","Visible?").toLatin1().data() ) );

  core.def("multiViewMode", &Core::multiViewMode, QCoreApplication::translate("PythonDocCore","Switch MultiView Mode").toLatin1().data() ,
                                         py::arg( QCoreApplication::translate("PythonDocCore","0: One Viewer, 1: Double Viewer, 2: Grid, 3: Horizontal split").toLatin1().data() ) );

  core.def("restrictFrameRate", &Core::restrictFrameRate, QCoreApplication::translate("PythonDocCore","Restrict maximal rendering FrameRate to MaxFrameRate").toLatin1().data() ,
                                                 py::arg( QCoreApplication::translate("PythonDocCore","Restrict Framerate?").toLatin1().data() ) );

  core.def("setMaxFrameRate", &Core::setMaxFrameRate, QCoreApplication::translate("PythonDocCore","Set the maximal framerate (automatically enables framerate restriction)").toLatin1().data() ,
                                             py::arg( QCoreApplication::translate("PythonDocCore","Maximum frameRate").toLatin1().data() ) );

  core.def("snapshotBaseFileName", &Core::snapshotBaseFileName, QCoreApplication::translate("PythonDocCore","Set a base filename for storing snapshots. This setting is viewer dependent").toLatin1().data() ,
                                                       py::arg( QCoreApplication::translate("PythonDocCore","Base filename").toLatin1().data()),
                                                       py::arg( QCoreApplication::translate("PythonDocCore","Viewer ID to set the filename for").toLatin1().data() ) );

  core.def("snapshotFileType", &Core::snapshotFileType, QCoreApplication::translate("PythonDocCore","Set a filetype for storing snapshots.").toLatin1().data() ,
                                               py::arg( QCoreApplication::translate("PythonDocCore","Image type as string (e.g. jpg )").toLatin1().data()),
                                               py::arg( QCoreApplication::translate("PythonDocCore","Viewer ID to set the filetype for").toLatin1().data() ) );

  core.def("snapshotCounterStart", &Core::snapshotCounterStart, QCoreApplication::translate("PythonDocCore","Set the starting number for the snapshot counter.").toLatin1().data() ,
                                                       py::arg( QCoreApplication::translate("PythonDocCore","Starting number for the counter").toLatin1().data() ),
                                                       py::arg( QCoreApplication::translate("PythonDocCore","Viewer ID to set the counter for").toLatin1().data() ) );


  core.def("snapshot", &Core::snapshot, QCoreApplication::translate("PythonDocCore",   "Make a snapshot of the viewer with id viewerId.\n"
                                                                                       "Pass 0 as viewerId parameter to capture the current viewer. \n"
                                                                                       "The captured image will have the specified dimensions. \n"
                                                                                       "If 0 is passed as either width or height parameter, the value will \n"
                                                                                       "automatically be set to hold the right aspect ratio, respectively. \n"
                                                                                       "If 0 is passed for both width and height values, the viewport's current \n"
                                                                                       "dimension is used. Set alpha to true if you want the background to be transparent. \n"
                                                                                       "The fifth parameter is used to hide the coordinate system in the upper right corner of the screen. \n"
                                                                                       "If no filename was set using snapshotBaseFileName() the snapshot is stored \n"
                                                                                       "in snap.png in the current directory. For every snapshot \n"
                                                                                       "a counter is added to the filename.").toLatin1().data() ,
                               py::arg( QCoreApplication::translate("PythonDocCore","Id of viewer").toLatin1().data() ) = 0,
                               py::arg( QCoreApplication::translate("PythonDocCore","Width of image").toLatin1().data() )= 0,
                               py::arg( QCoreApplication::translate("PythonDocCore","Height of image").toLatin1().data() )= 0,
                               py::arg( QCoreApplication::translate("PythonDocCore","Transparent background?").toLatin1().data() ) = false,
                               py::arg( QCoreApplication::translate("PythonDocCore","Hide coordinate system?").toLatin1().data() ) = false ,
                               py::arg( QCoreApplication::translate("PythonDocCore","Number of samples per pixel").toLatin1().data() ) =1  );


  core.def("applicationSnapshot", &Core::applicationSnapshot, QCoreApplication::translate("PythonDocCore","Create a snapshot of the whole application").toLatin1().data() );

  core.def("applicationSnapshotName", &Core::applicationSnapshotName, QCoreApplication::translate("PythonDocCore","Set the baseName for the application snapshot").toLatin1().data() ,
                                                             py::arg( QCoreApplication::translate("PythonDocCore","BaseName for full application snapshots").toLatin1().data() ) );

  core.def("viewerSnapshot", static_cast<void (Core::*)()>(&Core::viewerSnapshot), QCoreApplication::translate("PythonDocCore","Take a snapshot from all viewers").toLatin1().data() );


//     /// Scriptable snapshot method offering full control
//     void viewerSnapshot(QString file_name, bool store_comments,
//             bool comments_visible_only, bool comments_targeted_only,
//             bool store_material_info, int snapshot_width, int snapshot_height,
//             bool snapshot_transparent, bool hide_coord_sys,
//             int snapshot_multisampling, bool store_view);
//
//     /// resize the examinerViewer
//     void resizeViewers(int _width, int _height );
//
//     /// resize the whole Application
//     void resizeApplication(int _width, int _height );
//
//     /// write the current versions of all plugins to ini file
//     void writeVersionNumbers(QString _filename);
//
//     /// return the list of available object that has the given selection and type
//     QList<int> objectList (QString _selection, QStringList _types);
//
//     /// Block the scenegraph updates
//     void blockSceneGraphUpdates();
//
//     /// Unblock the scenegraph updates
//     void unblockSceneGraphUpdates();
//
//     void setView(QString view);
//     void setViewAndWindowGeometry(QString view);


  //    emit setSlotDescription("deleteObject(int)", tr("Delete an object from the scene."), QStringList("ObjectId"), QStringList(tr("Id of the object to delete")));

//
//  emit slotSetSlotDescriptionGlobalFunction("printToFile(QString,QString)", tr("Print a message to a file"), QStringList(QString("Filename;Values").split(";")), QStringList(QString("Filename to print into;Arbitrary number of arguments").split(";")));
//    emit slotSetSlotDescriptionGlobalFunction("help(QString)", tr("Print help about something"), QStringList("Help Entry"), QStringList("help about what?"));
//
//


//    emit setSlotDescription("exitApplication()", tr("Quit OpenFlipper"), QStringList(), QStringList());

//    emit setSlotDescription("resizeViewer(int,int)", tr("Resize the viewer"),
//                             QString(tr("width,height")).split(","),
//                             QString(tr("new width for the viewer,new height for the viewer")).split(","));
//    emit setSlotDescription("writeVersionNumbers(QString)", tr("write the current versions of all plugins to INI file"),
//                             QStringList(tr("filename")),
//                             QStringList(tr("fullpath to a file where the versions should be written to.")));
//    //save slots
//    emit setSlotDescription("saveObject(int,QString)", tr("Save object to file. If the file exists it will be overwritten."),
//                             QString(tr("object-id,filename")).split(","),
//                             QString(tr("id of the object, complete path and filename")).split(","));
//    emit setSlotDescription("saveObjectTo(int,QString)", tr("Save object to file. The location can be chosen in a dialog. "
//                            "(only works if GUI is available)"),
//                             QString(tr("object-id,filename")).split(","),
//                             QString(tr("id of the object, initial filename for the dialog")).split(","));
//    emit setSlotDescription("saveAllObjects()", tr("Saves all target objects. "
//                            "If no filename is available a dialog is shown. (only works if GUI is available)"),QStringList(), QStringList());
//    emit setSlotDescription("saveAllObjectsTo()", tr("Saves all target objects. The locations can be chosen in dialogs. "
//                            "(only works if GUI is available)"),QStringList(), QStringList());
//    emit setSlotDescription("saveSettings()", tr("Show the dialog to save the current setting. (only works if GUI is available)"),QStringList(), QStringList());
//    emit setSlotDescription("saveSettings(QString, bool, bool, bool, bool, bool, bool)", tr("Save the current setting to the supplied file."),
//                            QStringList(tr("filePath,is_saveObjectInfo,is_targetOnly,is_saveAll,is_askOverwrite,is_saveProgramSettings,is_savePluginSettings").split(",")),
//                            QStringList(tr("Path of the file to save the settings to.;Save objects in current setting.;Restrict to targeted objects.;<no idea what this parameter does>;Prompt before overwriting files that already exist (gui mode only).;Save " TOSTRING( PRODUCT_NAME ) " program settings.;Save plugin settings.").split(";")));
//    //load slots
//    emit setSlotDescription("loadObject()", tr("Show the dialog to load an object. (only works if GUI is available)"),QStringList(), QStringList());
//    emit setSlotDescription("loadObject(QString)", tr("Load an object specified in file filename. This automatically determines which file plugin to use."),
//                            QStringList(tr("filename")), QStringList(tr("Filename")));
//    emit setSlotDescription("getObjectId(QString)", tr("Return identifier of object with specified name. Returns -1 if object was not found."),QStringList(), QStringList());
//    emit setSlotDescription("loadSettings()", tr("Show the dialog to load settings. (only works if GUI is available)"),QStringList(), QStringList());
//    emit setSlotDescription("loadSettings(QString)", tr("load settings from file."),QStringList(), QStringList());
//
//    emit setSlotDescription("createWidget(QString,QString)", tr("Create a widget from an ui file"),
//                            QString(tr("Object name,ui file")).split(","),
//                            QString(tr("Name of the new widget in script,ui file to load")).split(","));
//
//    emit setSlotDescription("addToolbox(QString,QWidget*)", tr("Add a widget as a toolbox"),
//                            QString(tr("Toolbox Entry name,Widget")).split(","),
//                            QString(tr("Name of the new widget in the toolbox,Pointer to the new widget")).split(","));
//
//    emit setSlotDescription("addToolbox(QString,QWidget*,QIcon*)", tr("Add a widget as a toolbox"),
//                            QString(tr("Toolbox Entry name,Widget,Icon")).split(","),
//                            QString(tr("Name of the new widget in the toolbox,Pointer to the new widget,Pointer to icon")).split(","));
//
//    emit setSlotDescription("serializeMaterialProperties(int)", tr("Serialize and return the material properties of the supplied object."),
//                            QString(tr("ObjectId")).split(","),
//                            QString(tr("ID of the object")).split(","));
//
//    emit setSlotDescription("deserializeMaterialProperties(int, QString)", tr("Deserialize the supplied material properties into the supplied object."),
//                            QString(tr("ObjectId, SerializedProps")).split(","),
//                            QString(tr("ID of the object,The serialized material properties.")).split(","));
//
//    emit setSlotDescription("addViewModeToolboxes(QString,QString)", tr("Set toolboxes for a viewmode (This automatically adds the view mode if it does not exist)"),
//                            QString(tr("Name,Toolbox List")).split(","),
//                            QString(tr("Name of the Viewmode,seperated list of toolboxes visible in this viewmode")).split(","));
//
//    emit setSlotDescription("addViewModeToolbars(QString,QString)", tr("Set toolbars for a viewmode (This automatically adds the view mode if it does not exist)"),
//                            QString(tr("Name,Toolbar List")).split(","),
//                            QString(tr("Name of the Viewmode,seperated list of toolbars visible in this viewmode")).split(","));
//
//    emit setSlotDescription("addViewModeContextMenus(QString,QString)", tr("Set context Menus for a viewmode (This automatically adds the view mode if it does not exist)"),
//                            QString(tr("Name,Context Menu List")).split(","),
//                            QString(tr("Name of the Viewmode,seperated list of Context Menus visible in this viewmode")).split(","));
//
//    emit setSlotDescription("addViewModeIcon(QString,QString)", tr("Set Icon for a viewmode (This automatically adds the view mode if it does not exist)"),
//                            QString(tr("Name,Icon filename")).split(","),
//                            QString(tr("Name of the Viewmode,filename of the icon (will be taken from OpenFlippers icon directory)")).split(","));
//
//    emit setSlotDescription("objectList(QString,QStringList)", tr("Returns object list"),
//                            QString(tr("Selection type,Object types")).split(","),
//                            QString(tr("Type of object selection (all,source,target),Object type (All,PolyMesh,TriangleMesh,...)")).split(";"));
//
//    emit setSlotDescription("setToolBoxSide(QString)", tr("Determine whether the toolboxes should be displayed on the right or on the left side."),
//                            QStringList(tr("side")), QStringList(tr("The desired side of the toolboxes (either 'left' or 'right')")));
//
//    emit setSlotDescription("getToolbox(QString,QString)", tr("Returns a pointer to the requested toolbox widget if it was found, nullptr, otherwise."),
//                            tr("Plugin Name\rToolbox Name").split("\r"),
//                            tr("The plugin which the requested toolbox belongs to.\rThe name of the requested toolbox.").split("\r"));
//

//    emit setSlotDescription("unblockSceneGraphUpdates()", tr("Enable Scenegraph Updates (e.g. before loading or adding a large number of files)"),QStringList(), QStringList());
//    emit setSlotDescription("setView", tr("Set the encoded view for the primary viewport."), QStringList(tr("view")), QStringList(tr("The encoded view. (You can obtain one through \"Copy View\" in the context menu of the coordinates.)")));
511

512 513


Jan Möbius's avatar
Jan Möbius committed
514
  core.def("writeVersionNumbers", &Core::writeVersionNumbers);
515 516
}