[TD]load images at correct size
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ViewProviderImage.h"
|
||||
#include "QGCustomImage.h"
|
||||
#include "QGCustomClip.h"
|
||||
#include "QGIViewImage.h"
|
||||
@@ -117,9 +118,21 @@ void QGIViewImage::draw()
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage*>(getViewObject()) );
|
||||
if (!viewImage)
|
||||
return;
|
||||
QRectF newRect(0.0,0.0,viewImage->Width.getValue(),viewImage->Height.getValue());
|
||||
m_cliparea->setRect(newRect);
|
||||
|
||||
auto vp = static_cast<ViewProviderImage*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
bool crop = vp->Crop.getValue();
|
||||
|
||||
drawImage();
|
||||
if (crop) {
|
||||
QRectF cropRect(0.0,0.0,Rez::guiX(viewImage->Width.getValue()),Rez::guiX(viewImage->Height.getValue()));
|
||||
m_cliparea->setRect(cropRect);
|
||||
} else {
|
||||
QRectF cropRect(0.0, 0.0, m_imageItem->imageSize().width(), m_imageItem->imageSize().height());
|
||||
m_cliparea->setRect(cropRect);
|
||||
}
|
||||
m_cliparea->centerAt(0.0,0.0);
|
||||
|
||||
QGIView::draw();
|
||||
|
||||
@@ -49,6 +49,8 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderImage, TechDrawGui::ViewProviderDrawing
|
||||
ViewProviderImage::ViewProviderImage()
|
||||
{
|
||||
sPixmap = "actions/techdraw-image";
|
||||
|
||||
ADD_PROPERTY_TYPE(Crop ,(false),"Image", App::Prop_None, "Crop image to Width x Height");
|
||||
}
|
||||
|
||||
ViewProviderImage::~ViewProviderImage()
|
||||
@@ -79,6 +81,25 @@ void ViewProviderImage::updateData(const App::Property* prop)
|
||||
ViewProviderDrawingView::updateData(prop);
|
||||
}
|
||||
|
||||
void ViewProviderImage::onChanged(const App::Property *prop)
|
||||
{
|
||||
App::DocumentObject* obj = getObject();
|
||||
if (!obj || obj->isRestoring()) {
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop == &Crop) {
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
}
|
||||
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
|
||||
TechDraw::DrawViewImage* ViewProviderImage::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewImage*>(pcObject);
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderImage();
|
||||
|
||||
App::PropertyBool Crop; //crop to feature width x height
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual void onChanged(const App::Property *prop);
|
||||
|
||||
virtual TechDraw::DrawViewImage* getViewObject() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user