All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Attributes | Properties
SciFigs::ImageWidget Class Reference

The ImageWidget is a widget that contains an image and that can be printed. More...

#include <ImageWidget.h>

Inheritance diagram for SciFigs::ImageWidget:
SciFigs::GraphicObject QGpGuiTools::PropertyContext QGpGuiTools::PropertyItem QGpCoreTools::XMLClass

List of all members.

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

Detailed Description

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).


Constructor & Destructor Documentation

SciFigs::ImageWidget::ImageWidget ( QWidget *  parent = 0)

References TRACE.

{
  TRACE;
}

Member Function Documentation

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;}

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]

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.


Member Data Documentation

const QString SciFigs::ImageWidget::xmlImageWidgetTag = "ImageWidget" [static]

Property Documentation

QString SciFigs::ImageWidget::imageFile [read, write]
QString SciFigs::ImageWidget::imageFormat [read, write]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines