Core: support to load old project files containing image planes
See forum: https://forum.freecad.org/viewtopic.php?p=670545#p670545
This commit is contained in:
@@ -217,6 +217,18 @@ init_freecad_module(void)
|
||||
return PyModule_Create(&FreeCADModuleDef);
|
||||
}
|
||||
|
||||
PyMODINIT_FUNC
|
||||
init_image_module()
|
||||
{
|
||||
static struct PyModuleDef ImageModuleDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"Image", "", -1,
|
||||
nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr
|
||||
};
|
||||
return PyModule_Create(&ImageModuleDef);
|
||||
}
|
||||
|
||||
Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
: _mConfig(mConfig), _pActiveDoc(nullptr), _isRestoring(false),_allowPartial(false)
|
||||
, _isClosingAll(false), _objCount(-1), _activeTransactionID(0)
|
||||
@@ -254,6 +266,10 @@ void Application::setupPythonTypes()
|
||||
};
|
||||
PyObject* pConsoleModule = PyModule_Create(&ConsoleModuleDef);
|
||||
|
||||
// fake Image module
|
||||
PyObject* imageModule = init_image_module();
|
||||
PyDict_SetItemString(modules, "Image", imageModule);
|
||||
|
||||
// introducing additional classes
|
||||
|
||||
// NOTE: To finish the initialization of our own type objects we must
|
||||
@@ -2054,7 +2070,7 @@ void Application::initTypes()
|
||||
App::DocumentObjectGroup ::init();
|
||||
App::DocumentObjectGroupPython ::init();
|
||||
App::DocumentObjectFileIncluded::init();
|
||||
App::ImagePlane ::init();
|
||||
Image::ImagePlane ::init();
|
||||
App::InventorObject ::init();
|
||||
App::VRMLObject ::init();
|
||||
App::Annotation ::init();
|
||||
|
||||
@@ -25,18 +25,18 @@
|
||||
#include "ImagePlane.h"
|
||||
|
||||
|
||||
using namespace App;
|
||||
using namespace Image;
|
||||
|
||||
PROPERTY_SOURCE(App::ImagePlane, App::GeoFeature)
|
||||
PROPERTY_SOURCE(Image::ImagePlane, App::GeoFeature)
|
||||
|
||||
|
||||
ImagePlane::ImagePlane()
|
||||
: XPixelsPerMeter{1000.0}
|
||||
, YPixelsPerMeter{1000.0}
|
||||
{
|
||||
ADD_PROPERTY_TYPE( ImageFile,(nullptr) , "ImagePlane",Prop_None,"File of the image");
|
||||
ADD_PROPERTY_TYPE( XSize, (100), "ImagePlane",Prop_None,"Size of a pixel in X");
|
||||
ADD_PROPERTY_TYPE( YSize, (100), "ImagePlane",Prop_None,"Size of a pixel in Y");
|
||||
ADD_PROPERTY_TYPE( ImageFile,(nullptr) , "ImagePlane",App::Prop_None,"File of the image");
|
||||
ADD_PROPERTY_TYPE( XSize, (100), "ImagePlane",App::Prop_None,"Size of a pixel in X");
|
||||
ADD_PROPERTY_TYPE( YSize, (100), "ImagePlane",App::Prop_None,"Size of a pixel in Y");
|
||||
}
|
||||
|
||||
int ImagePlane::getXSizeInPixel()
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include <App/PropertyFile.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
|
||||
namespace App
|
||||
namespace Image
|
||||
{
|
||||
|
||||
class AppExport ImagePlane : public App::GeoFeature
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(App::ImagePlane);
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(Image::ImagePlane);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace App
|
||||
} //namespace Image
|
||||
|
||||
|
||||
#endif // App_ImagePlane_H
|
||||
|
||||
Reference in New Issue
Block a user