The ImageWidget is a widget that contains an image and that can be printed. More...
#include <ImageWidget.h>
Public Member Functions | |
| virtual void | addProperties (PropertyProxy *pp) |
| QString | fileName () const |
| ImageWidget (QWidget *parent=0) | |
| void | loadImage () |
| virtual void | properties (PropertyWidget *w) const |
| virtual void | removeProperties (PropertyProxy *pp) |
| void | setFileName (QString s) |
| virtual void | setProperty (uint wid, int pid, QVariant val) |
| virtual const QString & | xml_tagName () const |
| ~ImageWidget () | |
Static Public Attributes | |
| static const QString | xmlImageWidgetTag = "ImageWidget" |
Properties | |
| bool | fixedXYRatio |
| QString | imageFile |
| QString | imageFormat |
The ImageWidget is a widget that contains an image and that can be printed.
It is usually docked in GraphicSheet to construct complex figures including results from other software not producing results complying with SciFigs strandards (".page" or similar files).
| SciFigs::ImageWidget::ImageWidget | ( | QWidget * | parent = 0 | ) |
References SciFigs::GraphicObject::setConstantWidthHeightRatio(), and TRACE.
:
GraphicObject(parent)
{
TRACE;
setConstantWidthHeightRatio(true);
}
| void SciFigs::ImageWidget::addProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Setup property editor
Reimplemented from SciFigs::GraphicObject.
References QGpGuiTools::PropertyProxy::addCategory(), QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::setCurrentCategory(), QGpGuiTools::PropertyProxy::setCurrentTab(), QGpCoreTools::tr(), and TRACE.
{
TRACE;
GraphicObject::addProperties(pp);
if( !pp->setCurrentCategory(_category) ) {
pp->addCategory(_category, tr("Image"), QIcon( ":/images/ImageWidget.png"));
}
if(pp->setCurrentTab(_tabLink)) {
pp->addReference(this);
} else {
ImageWidgetProperties * w=new ImageWidgetProperties;
pp->addTab(_tabLink, tr("Link"), w, this);
}
}
| QString SciFigs::ImageWidget::fileName | ( | ) | const [inline] |
Referenced by properties().
{return _fileName;}
| void SciFigs::ImageWidget::loadImage | ( | ) |
References SciFigs::GraphicObject::_printHeight, SciFigs::GraphicObject::_printWidth, SciFigs::GraphicObject::setPrintResolution(), SciFigs::GraphicObject::sizeChanged(), QGpCoreTools::tr(), and TRACE.
Referenced by setProperty().
{
TRACE;
if(_fileName.length() > 0) {
QFileInfo fi(_fileName);
if(!fi.exists()) {
QString fn=Application::instance()->translatePath(_fileName, tr("Open an existing image"),
tr( "Image file (%1)" ));
if(fn.isEmpty()) return;
fi.setFile(fn);
}
if(fi.exists()) {
_fileName=fi.absoluteFilePath();
_trueImage.load(_fileName);
// With Qt4, even for a PNG the deduced resolution is always the ScreenResolution
double xResol=(double) _trueImage.dotsPerMeterX() * 0.01;
double yResol=(double) _trueImage.dotsPerMeterY() * 0.01;
if(xResol==0.0) xResol=118.11; // 300 dpi converted in dot/cm
if(yResol==0.0) yResol=118.11; // 300 dpi converted in dot/cm
_printWidth=(double) _trueImage.width()/xResol;
_printHeight=(double) _trueImage.height()/yResol;
double maxResol=xResol;
if(yResol > maxResol) maxResol=yResol;
setPrintResolution(( int) floor(maxResol * 2.54 + 0.5) ); // in dpi
emit sizeChanged();
update();
}
}
}
| void SciFigs::ImageWidget::properties | ( | PropertyWidget * | w | ) | const [virtual] |
Reimplemented from SciFigs::GraphicObject.
References fileName(), QGpGuiTools::PropertyWidget::id(), SciFigs::ImageWidgetProperties::ImageFile, QGpGuiTools::PropertyWidget::setValue(), and TRACE.
{
TRACE;
if(w->id()==_tabLink) {
w->setValue(ImageWidgetProperties::ImageFile, fileName());
} else {
GraphicObject::properties(w);
}
}
| void SciFigs::ImageWidget::removeProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Cleanup property editor
Reimplemented from SciFigs::GraphicObject.
References QGpGuiTools::PropertyProxy::removeTab(), QGpGuiTools::PropertyProxy::setCurrentCategory(), and TRACE.
{
TRACE;
GraphicObject::removeProperties(pp);
if(pp->setCurrentCategory(_category) ) {
pp->removeTab(_tabLink, this);
}
}
| void SciFigs::ImageWidget::setFileName | ( | QString | s | ) | [inline] |
Referenced by setProperty().
{_fileName=s;}
| void SciFigs::ImageWidget::setProperty | ( | uint | wid, |
| int | pid, | ||
| QVariant | val | ||
| ) | [virtual] |
Set value val to property id, after a user action in property editor
Reimplemented from SciFigs::GraphicObject.
References SciFigs::ImageWidgetProperties::ImageFile, loadImage(), setFileName(), and TRACE.
{
TRACE;
if(wid==_tabLink) {
switch(pid) {
case ImageWidgetProperties::ImageFile:
setFileName(val.toString());
loadImage();
break;
}
} else {
GraphicObject::setProperty(wid, pid, val);
}
}
| virtual const QString& SciFigs::ImageWidget::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::GraphicObject.
{return xmlImageWidgetTag;}
const QString SciFigs::ImageWidget::xmlImageWidgetTag = "ImageWidget" [static] |
bool SciFigs::ImageWidget::fixedXYRatio [read, write] |
QString SciFigs::ImageWidget::imageFile [read, write] |
QString SciFigs::ImageWidget::imageFormat [read, write] |