Merge pull request #8955 from wwmayer/issue_8556

Move image loading to core
This commit is contained in:
Chris Hennes
2023-03-22 16:00:43 -05:00
committed by GitHub
154 changed files with 2162 additions and 15980 deletions

View File

@@ -94,6 +94,7 @@
#include "FeaturePython.h"
#include "GeoFeature.h"
#include "GeoFeatureGroupExtension.h"
#include "ImagePlane.h"
#include "InventorObject.h"
#include "Link.h"
#include "LinkBaseExtensionPy.h"
@@ -2053,12 +2054,13 @@ void Application::initTypes()
App::DocumentObjectGroup ::init();
App::DocumentObjectGroupPython ::init();
App::DocumentObjectFileIncluded::init();
App::ImagePlane ::init();
App::InventorObject ::init();
App::VRMLObject ::init();
App::Annotation ::init();
App::AnnotationLabel ::init();
App::MeasureDistance ::init();
App ::MaterialObject ::init();
App::MaterialObject ::init();
App::MaterialObjectPython ::init();
App::TextDocument ::init();
App::Placement ::init();

View File

@@ -147,6 +147,7 @@ SET(Document_CPP_SRCS
GeoFeature.cpp
GeoFeatureGroupExtensionPyImp.cpp
GeoFeatureGroupExtension.cpp
ImagePlane.cpp
OriginGroupExtensionPyImp.cpp
OriginGroupExtension.cpp
PartPyImp.cpp
@@ -192,6 +193,7 @@ SET(Document_HPP_SRCS
FeatureTest.h
GeoFeature.h
GeoFeatureGroupExtension.h
ImagePlane.h
OriginGroupExtension.h
Part.h
Origin.h

60
src/App/ImagePlane.cpp Normal file
View File

@@ -0,0 +1,60 @@
/***************************************************************************
* Copyright (c) 2011 Jürgen Riegel (juergen.riegel@web.de) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "ImagePlane.h"
using namespace App;
PROPERTY_SOURCE(App::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");
}
int ImagePlane::getXSizeInPixel()
{
return int(XSize.getValue() * XPixelsPerMeter / 1000);
}
int ImagePlane::getYSizeInPixel()
{
return int(YSize.getValue() * YPixelsPerMeter / 1000);
}
void ImagePlane::setXSizeInPixel(int value)
{
XSize.setValue(double(value) * 1000.0 / XPixelsPerMeter);
}
void ImagePlane::setYSizeInPixel(int value)
{
YSize.setValue(double(value) * 1000.0 / YPixelsPerMeter);
}

63
src/App/ImagePlane.h Normal file
View File

@@ -0,0 +1,63 @@
/***************************************************************************
* Copyright (c) 2011 Jürgen Riegel (juergen.riegel@web.de) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef App_ImagePlane_H
#define App_ImagePlane_H
#include <App/GeoFeature.h>
#include <App/PropertyFile.h>
#include <App/PropertyUnits.h>
namespace App
{
class AppExport ImagePlane : public App::GeoFeature
{
PROPERTY_HEADER_WITH_OVERRIDE(App::ImagePlane);
public:
/// Constructor
ImagePlane();
~ImagePlane() override = default;
App::PropertyFileIncluded ImageFile;
App::PropertyLength XSize;
App::PropertyLength YSize;
int getXSizeInPixel();
int getYSizeInPixel();
void setXSizeInPixel(int);
void setYSizeInPixel(int);
double XPixelsPerMeter;
double YPixelsPerMeter;
/// returns the type name of the ViewProvider
const char* getViewProviderName() const override {
return "Gui::ViewProviderImagePlane";
}
};
} //namespace App
#endif // App_ImagePlane_H