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

The GraphicSheet is a working sheet where any set of GraphicObject can be displayed. More...

#include <GraphicSheet.h>

Inheritance diagram for SciFigs::GraphicSheet:
QGpGuiTools::PropertyContext QGpGuiTools::PropertyItem QGpCoreTools::XMLClass Results

List of all members.

Public Slots

Q_SCRIPTABLE void addLayers ()
GraphicObjectaddObject ()
Q_SCRIPTABLE void addSelect (GraphicObject *obj)
Q_SCRIPTABLE void addSelectNextChild ()
Q_SCRIPTABLE void alignBottom ()
Q_SCRIPTABLE void alignHCenter ()
Q_SCRIPTABLE void alignLeft ()
Q_SCRIPTABLE void alignRight ()
Q_SCRIPTABLE void alignTop ()
Q_SCRIPTABLE void alignVCenter ()
Q_SCRIPTABLE void alignX (double localPosition)
Q_SCRIPTABLE void alignY (double localPosition)
Q_SCRIPTABLE void clear ()
Q_SCRIPTABLE void copy ()
Q_SCRIPTABLE void copyImage ()
Q_SCRIPTABLE void copyMakeUp ()
Q_SCRIPTABLE void cut ()
virtual Q_SCRIPTABLE void deepUpdate ()
Q_SCRIPTABLE void exportFile (QString fileName=QString::null, QString fileFormat=QString::null, int dpi=0)
Q_SCRIPTABLE void exportImage (QString fileName=QString::null, QString imageFormat=QString::null, int dpi=0)
Q_SCRIPTABLE void fileNew ()
Q_SCRIPTABLE void fileOpen ()
Q_SCRIPTABLE void fileOpen (QString fileName, double dx=0, double dy=0)
Q_SCRIPTABLE void fileSave ()
Q_SCRIPTABLE void fileSave (QString fileName)
Q_SCRIPTABLE void fileSaveAs ()
Q_SCRIPTABLE QPixmap image (int dpi=0)
Q_SCRIPTABLE void lowerSelection ()
void moveObject (GraphicObject *obj=0)
Q_SCRIPTABLE GraphicObjectobject (QString objectName)
Q_SCRIPTABLE GraphicObjectobject (int index)
Q_SCRIPTABLE void paste ()
Q_SCRIPTABLE void pasteMakeUp ()
Q_SCRIPTABLE void print (int dpi=0)
Q_SCRIPTABLE void print (bool outputToFile, QString name, int dpi)
Q_SCRIPTABLE void raiseSelection ()
Q_SCRIPTABLE void redo ()
Q_SCRIPTABLE bool removeObject (GraphicObject *obj)
void resizeObject ()
Q_SCRIPTABLE void restoreMakeUp (QString fileName=QString::null)
Q_SCRIPTABLE void saveLayers (QString fileName=QString::null)
Q_SCRIPTABLE void saveMakeUp (QString fileName=QString::null)
Q_SCRIPTABLE void select (GraphicObject *obj)
Q_SCRIPTABLE void selectAll ()
Q_SCRIPTABLE bool selectAll (QString actionTitle)
Q_SCRIPTABLE void selectNextChild ()
Q_SCRIPTABLE void selectObjects (GraphicObject *obj, Qt::KeyboardModifiers m=Qt::NoModifier)
Q_SCRIPTABLE void setPreferences ()
Q_SCRIPTABLE void showOrderIndex (bool isOn)
Q_SCRIPTABLE void showProperties ()
void startDragging ()
Q_SCRIPTABLE void undo ()
Q_SCRIPTABLE void unSelectAll ()
virtual Q_SCRIPTABLE void update ()
void updatePageLimits (QPrinter &p)

Signals

void activeSelectionChanged (GraphicObject *obj)
void currentFileChanged (const QString &fileName)

Public Member Functions

GraphicObjectactiveObject (const char *inherits=0)
void addEditActions (QMenu *m, QToolBar *tb, bool shortcuts=true)
void addFileActions (QMenu *m, QToolBar *tb, bool shortcuts=true)
void addFormatActions (QMenu *m, bool shortcuts=true)
void addInsertActions (QMenu *m, QToolBar *tb, bool shortcuts=true)
void addMenu (QMenu *m)
void addObject (GraphicObject *obj)
void addProperties (PropertyProxy *pp)
SelectionWidgetaddSelection (GraphicObject *obj)
void autoResizeContent ()
void clear (bool force)
Point2D currentOrigin ()
GraphicObjectfindObject (QString tag, QString name)
 GraphicSheet (QWidget *parent=0)
bool isOrderIndex () const
int maximumResolution ()
virtual QSize minimumSizeHind () const
int objectCount ()
QString objectList () const
int paletteCount ()
void print (QPrinter &printer)
double printBottom ()
double printRight ()
virtual void properties (PropertyWidget *w) const
bool removeObject (GraphicObject *obj, bool force)
void removeProperties (PropertyProxy *pp)
template<typename T >
QList< T > selectedObjects () const
void setObjectList (QString list)
void setObjectOrder (QString list)
void setOrderIndex (GraphicObject *obj)
virtual void setProperty (uint wid, int pid, QVariant val)
void setStatusBar (QStatusBar *s)
void setTransparency (int val)
void setTransparentMask (bool val)
void showAllObjects ()
void showObject (GraphicObject *obj)
QStatusBar * statusBar ()
int transparency () const
bool transparentMask () const
QString uniqueName (GraphicObject *obj, QString newName)
virtual const QString & xml_tagName () const
 ~GraphicSheet ()

Static Public Attributes

static const QString xmlGraphicSheetTag = "GraphicSheet"

Protected Member Functions

void addActions ()
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual void xml_polish (XML_POLISH_ARGS)
virtual void xml_polishChild (XML_POLISHCHILD_ARGS)
virtual bool xml_setProperty (XML_SETPROPERTY_ARGS)
virtual void xml_writeChildren (XML_WRITECHILDREN_ARGS) const

Properties

 DUMMY_PROPERTIES
QString name
int objectCount
QString objectList
QString objectName
QString objectOrder
bool orderIndex
int transparency
bool transparentMask

Detailed Description

The GraphicSheet is a working sheet where any set of GraphicObject can be displayed.


Constructor & Destructor Documentation

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

References addActions(), addSelectNextChild(), selectNextChild(), QGpGuiTools::setWidgetColor(), and TRACE.

                                          :
    QScrollArea(parent)
{
  TRACE;
  setAttribute(Qt::WA_OpaquePaintEvent);
  setWidgetColor(viewport(), Qt::white);
  setWidget(new QWidget(this));
  _statusBar=0;
  _currentActiveSelection=0;
  new QShortcut(Qt::Key_Tab, this, SLOT(selectNextChild()));
  new QShortcut(Qt::Key_Tab + Qt::SHIFT, this, SLOT(addSelectNextChild()));
  _orderIndex=-1;
  _transparency=255;
  _transparentMask=false;
  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  _dragDelay.setSingleShot(true);
  _dragDelay.setInterval(50);
  connect(&_dragDelay, SIGNAL(timeout()), this, SLOT(dragObjectsDelayed()));
  addActions();
}

Member Function Documentation

GraphicObject * SciFigs::GraphicSheet::activeObject ( const char *  className = 0)

Used only by GraphContent::zoom, GraphContent::unzoom and GraphicObject::keyPopupMenu() These functions are not used in general. Some general code review may eventuelly remove this function.

References TRACE, and SciFigs::SelectionWidget::widget().

Referenced by SciFigs::GraphicObject::activeObject().

{
  TRACE;
  if(_currentActiveSelection) {
    GraphicObject * obj=_currentActiveSelection->widget();
    if(!className || obj->inherits(className))
      return obj;
  }
  return 0;
}

Referenced by selectObjects().

void SciFigs::GraphicSheet::addActions ( ) [protected]

Initialize context menu

References showProperties(), QGpCoreTools::tr(), and TRACE.

Referenced by GraphicSheet().

{
  TRACE;
  QAction * a;

  a=new QAction(tr("&Properties"), this);
  a->setObjectName("Properties");
  a->setToolTip(tr("Set properties of object"));
  connect(a, SIGNAL(triggered(bool)) , this, SLOT(showProperties()));
  QWidget::addAction(a);
}
void SciFigs::GraphicSheet::addEditActions ( QMenu *  m,
QToolBar *  tb,
bool  shortcuts = true 
)

References copy(), copyImage(), cut(), paste(), selectAll(), showOrderIndex(), QGpCoreTools::tr(), and TRACE.

Referenced by SciFigs::GraphicSheetMenu::addActions(), and DinverDCGui::DCModelViewer::addActions().

{
  TRACE;
  QAction * a;

  /*a=new QAction(QIcon(":/images/editundo.png"), tr("&Undo"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+Z"));
  }
  a->setStatusTip(tr("Undo last operation"));
  connect(a, SIGNAL(triggered()), this, SLOT(undo()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(QIcon(":/images/editredo.png"), tr("Re&do"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+Shift+Z"));
  }
  a->setStatusTip(tr("Redo last operation"));
  connect(a, SIGNAL(triggered()), this, SLOT(redo()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  if(m)
    m->addSeparator();
  if(tb)
    tb->addSeparator();*/

  a=new QAction(QIcon(":/images/editcut.png"), tr("Cu&t"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+X"));
  }
  a->setStatusTip(tr("Cut the current selection's contents to the "
                       "clipboard"));
  connect(a, SIGNAL(triggered()), this, SLOT(cut()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(QIcon(":/images/editcopy.png"), tr("&Copy"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+C"));
  }
  a->setStatusTip(tr("Copy the current selection's contents to the "
                       "clipboard"));
  connect(a, SIGNAL(triggered()), this, SLOT(copy()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(tr("Copy &image"), this);
  if(shortcuts) {
    a->setStatusTip(tr("Copy the sheet as an image to the clipboard"));
  }
  connect(a, SIGNAL(triggered()), this, SLOT(copyImage()));
  if(m)
    m->addAction(a);

  a=new QAction(QIcon(":/images/editpaste.png"), tr("&Paste"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+V"));
  }
  a->setStatusTip(tr("Paste the clipboard's contents in the sheet"));
  connect(a, SIGNAL(triggered()), this, SLOT(paste()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  if(m)
    m->addSeparator();
  if(tb)
    tb->addSeparator();

  a=new QAction(tr("&Select all"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+A"));
  }
  a->setStatusTip(tr("Select all object of the sheet"));
  connect(a, SIGNAL(triggered()), this, SLOT(selectAll()));
  if(m)
    m->addAction(a);

  a=new QAction(QIcon(":/images/ordertool.png"), tr("&Order"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+O"));
  }
  a->setStatusTip(tr("Order objects of the sheet"));
  a->setCheckable(true);
  connect(a, SIGNAL(toggled(bool)), this, SLOT(showOrderIndex(bool)));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);
}
void SciFigs::GraphicSheet::addFileActions ( QMenu *  m,
QToolBar *  tb,
bool  shortcuts = true 
)

References exportImage(), fileNew(), fileOpen(), fileSave(), fileSaveAs(), print(), setPreferences(), QGpCoreTools::tr(), and TRACE.

Referenced by SciFigs::GraphicSheetMenu::addActions(), and DinverDCGui::DCModelViewer::addActions().

{
  TRACE;
  QAction * a;

  a=new QAction(QIcon(":/images/filenew.png"), tr("&New"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+N"));
  }
  a->setStatusTip(tr("Empty sheet"));
  connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(QIcon(":/images/fileopen.png"), tr("&Open"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+O"));
  }
  a->setStatusTip(tr("Open an existing sheet and add it to the current one (*.page files)"));
  connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(QIcon(":/images/filesave.png"), tr("&Save"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+S"));
  }
  a->setStatusTip(tr("Save sheet to disk"));
  connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(tr("Save &As..."), this);
  a->setStatusTip(tr("Save sheet to disk under a new name"));
  connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
  if(m)
    m->addAction(a);

  if(m)
    m->addSeparator();

  a=new QAction(tr("&Preferences"), this);
  a->setStatusTip(tr("Customize SciFigs"));
  connect(a, SIGNAL(triggered()), this, SLOT(setPreferences()));
  m->addAction(a);


  if(m)
    m->addSeparator();

  a=new QAction(QIcon(":/images/fileprint.png"), tr("&Print"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+P"));
  }
  a->setStatusTip(tr("Print sheet"));
  connect(a, SIGNAL(triggered()), this, SLOT(print()));
  if(m)
    m->addAction(a);
  if(tb)
    tb->addAction(a);

  a=new QAction(tr("&Export image"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+E"));
  }
  a->setStatusTip(tr("Export sheet as image"));
  connect(a, SIGNAL(triggered()), this, SLOT(exportImage()));
  if(m)
    m->addAction(a);

  if(m)
    m->addSeparator();
}
void SciFigs::GraphicSheet::addFormatActions ( QMenu *  m,
bool  shortcuts = true 
)

References addLayers(), copyMakeUp(), pasteMakeUp(), restoreMakeUp(), saveLayers(), saveMakeUp(), showProperties(), QGpCoreTools::tr(), and TRACE.

Referenced by SciFigs::GraphicSheetMenu::addActions(), and DinverDCGui::DCModelViewer::addActions().

{
  TRACE;
  QAction * a;

  a=new QAction(tr("&Copy make-up"), this);
  a->setStatusTip(tr("Copy the sheet format to the clipboard"));
  connect(a, SIGNAL(triggered()), this, SLOT(copyMakeUp()));
  if(m)
    m->addAction(a);

  a=new QAction(tr("&Paste make-up"), this);
  a->setStatusTip(tr("Set the sheet format from the clipboard"));
  connect(a, SIGNAL(triggered()), this, SLOT(pasteMakeUp()));
  if(m)
    m->addAction(a);

  a=new QAction(tr("&Save make-up"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+U"));
  }
  connect(a, SIGNAL(triggered()), this, SLOT(saveMakeUp()));
  if(m)
    m->addAction(a);

  a=new QAction(tr("&Restore make-up"), this);
  if(shortcuts) {
    a->setShortcut(tr("Ctrl+Y"));
  }
  connect(a, SIGNAL(triggered()), this, SLOT(restoreMakeUp()));
  if(m)
    m->addAction(a);

  if(m) m->addSeparator();

  a=new QAction(tr("&Save layers"), this);
  a->setToolTip(tr("Save all layers of selected plots in multiple .layer files"));
  connect(a, SIGNAL(triggered(bool)) , this, SLOT(saveLayers()));
  if(m)
    m->addAction(a);

  a=new QAction(tr("&Add layers"), this);
  a->setToolTip(tr("Add layers to the selected plots from multiple .layer files"));
  connect(a, SIGNAL(triggered(bool)) , this, SLOT(addLayers()));
  if(m)
    m->addAction(a);

  if(m) m->addSeparator();

  a=new QAction(tr("&Properties"), this);
  connect(a, SIGNAL(triggered()), this, SLOT(showProperties()));
  if(m)
    m->addAction(a);
}
void SciFigs::GraphicSheet::addInsertActions ( QMenu *  m,
QToolBar *  tb,
bool  shortcuts = true 
)

References addObject(), SciFigs::GraphicObjectFactory::creator(), SciFigs::GraphicObjectCreator::icon(), SciFigs::GraphicObjectFactory::instance(), SciFigs::GraphicObjectCreator::menuTitle(), QGpCoreTools::XMLClassFactory::registeredTags(), SciFigs::GraphicObjectCreator::shortcut(), SciFigs::GraphicObjectCreator::tagName(), SciFigs::GraphicObjectCreator::toolTip(), and TRACE.

Referenced by SciFigs::GraphicSheetMenu::addActions(), and DinverDCGui::DCModelViewer::addActions().

{
  TRACE;
  QAction * a;
  // Automatic detection of available GraphicObject's
  QStringList tagList=GraphicObjectFactory::instance()->registeredTags();
  QString tag;
  foreach(tag, tagList) {
    GraphicObjectCreator * c=GraphicObjectFactory::instance()->creator(tag);
    a=new QAction(c->icon(), c->menuTitle(), this);
    if(shortcuts) {
      a->setShortcut(c->shortcut());
    }
    a->setStatusTip(c->toolTip());
    a->setData(c->tagName());
    connect(a, SIGNAL(triggered()), this, SLOT(addObject()));
    if(m)
      m->addAction(a);
    if(tb)
      tb->addAction(a);
  }
}

Add layers to selected axiswindows

References MSG_ID, selectAll(), QGpCoreTools::tr(), and TRACE.

Referenced by addFormatActions().

{
  TRACE;
  QList<AxisWindow *> objectList=selectedObjects<AxisWindow *>();
  if(objectList.isEmpty()) {
    if(!selectAll(tr("Add layers"))) return;
    objectList=selectedObjects<AxisWindow *>();
  }
  QStringList fileNames;
  fileNames=Message::getOpenFileNames(tr("Add layers"),
                                            tr("Graph layers (*.layer)"));
  if(!fileNames.isEmpty()) {
    int n=objectList.count();
    if(fileNames.count()!=n) {
      if(Message::warning(MSG_ID, tr("Add layers"), tr("The number of selected graphs (%1) is not the same as the number "
                                "of files (%2). Do you want to continue?").arg(n).arg(fileNames.count()),
                                Message::yes(), Message::no())==Message::Answer1) return;
      if(n>fileNames.count()) n=fileNames.count();
    }
    qSort(fileNames);
    for(int i=0; i<n; i++) {
      objectList.at(i)->graphContent()->addLayers(fileNames.at(i));
    }
  }
}
void SciFigs::GraphicSheet::addMenu ( QMenu *  m)

Populate context menu with submenus

This is mainly used by GraphicSheetMenu to copy the contextual menu bar to the context menu. Under Mac OS X, the contextual menu bar is not allowed, and Mac users have no access to the sheet actions. It gives the user an interface like in GIMP for Linux and Windows.

References TRACE.

Referenced by SciFigs::GraphicSheetMenu::addActions(), SciFigs::GraphicSheetMenu::addMenu(), and DinverDCGui::DCModelViewer::addMenu().

{
  TRACE;
  QAction * a;

  if(actions().count()==1) {
    a=new QAction(this);
    a->setSeparator(true);
    QWidget::addAction(a);
  }

  a=new QAction(m->title(), this);
  a -> setMenu(m);
  QWidget::addAction(a);
}

This slot create and add an object according to the sender. It must be a QAction and the data must contain a pointer to a GraphicObjectCreator structure.

References autoResizeContent(), SciFigs::GraphicObjectFactory::create(), currentOrigin(), SciFigs::GraphicObjectFactory::instance(), SciFigs::GraphicObject::setPrintAnchor(), SciFigs::GraphicObject::setRemovable(), and TRACE.

Referenced by addInsertActions(), and xml_member().

{
  TRACE;
  QAction * a=qobject_cast<QAction *>(sender());
  if(!a || a->data().type()!=QVariant::String) return 0;
  GraphicObject * obj=GraphicObjectFactory::instance()->create(a->data().toString());
  if(!obj) {
    qWarning("Unkwown class name %s", a->data().toString().toAscii().data());
    return 0;
  }
  obj->setPrintAnchor(currentOrigin() + Point2D(1.0, 1.0));
  obj->setRemovable(true);
  addObject(obj);
  autoResizeContent();
  return obj;
}

References QGpGuiTools::PropertyProxy::addCategory(), QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::setCurrentCategory(), QGpGuiTools::PropertyProxy::setCurrentTab(), QGpCoreTools::tr(), TRACE, and w.

Referenced by showProperties().

{
  TRACE;
  if(!pp->setCurrentCategory(_category)) {
    pp->addCategory(_category, tr("Sheet"), QIcon(":/images/graphicsheet.png"));
  }
  if(pp->setCurrentTab(_tabPrint)) {
    pp->addReference(this);
  } else {
    GraphicSheetProperties * w=new GraphicSheetProperties;
    pp->addTab(_tabPrint, tr("Print"), w, this);
  }
}
Q_SCRIPTABLE void SciFigs::GraphicSheet::addSelect ( GraphicObject obj) [inline, slot]
{selectObjects(obj, Qt::ShiftModifier);}

References SciFigs::SelectionWidget::height(), TRACE, SciFigs::SelectionWidget::width(), SciFigs::SelectionWidget::x(), and SciFigs::SelectionWidget::y().

Referenced by SciFigs::GraphicObject::enterEvent(), and selectObjects().

{
  TRACE;
  SelectionWidget * selObj=new SelectionWidget(obj, this);
  selObj->setParent(widget());
  selObj->move(selObj->x(obj->x()), selObj->y(obj->y()));
  selObj->resize(selObj->width(), selObj->height());
  selObj->stackUnder(obj);
  return selObj;
}

Select next child (in the stack order, just after the current object). Compared to selectNextChild(), the current object remains selected. This function is called after a SHIFT+TAB action.

References selectObjects(), TRACE, and SciFigs::SelectionWidget::widget().

Referenced by GraphicSheet().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  if(objectList.isEmpty()) return;
  GraphicObject * cur;
  if(_currentActiveSelection)
    cur=_currentActiveSelection->widget();
  else
    cur=0;
  QList<GraphicObject *>::iterator it;
  for(it=objectList.begin(); it!=objectList.end(); ++it) {
    if(*it==cur) {++it;break;}
  }
  if(it!=objectList.end()) {
    selectObjects(*it, Qt::ShiftModifier);
  } else {
    selectObjects(objectList.first(), Qt::ShiftModifier);
  }
}
Q_SCRIPTABLE void SciFigs::GraphicSheet::alignBottom ( ) [inline, slot]
{alignY(1.0);}
Q_SCRIPTABLE void SciFigs::GraphicSheet::alignHCenter ( ) [inline, slot]
{alignX(0.5);}
Q_SCRIPTABLE void SciFigs::GraphicSheet::alignLeft ( ) [inline, slot]
{alignX(0.0);}
Q_SCRIPTABLE void SciFigs::GraphicSheet::alignRight ( ) [inline, slot]
{alignX(1.0);}
Q_SCRIPTABLE void SciFigs::GraphicSheet::alignTop ( ) [inline, slot]
{alignY(0.0);}
Q_SCRIPTABLE void SciFigs::GraphicSheet::alignVCenter ( ) [inline, slot]
{alignY(0.5);}
void SciFigs::GraphicSheet::alignX ( double  localPosition) [slot]

Align two objects with repect to a relative position along X axis

localPosition should be between 0 (left) and 1 (right)

References moveObject(), SciFigs::GraphicObject::printLeft(), SciFigs::GraphicObject::printWidth, SciFigs::GraphicObject::setPrintXAnchor(), TRACE, and SciFigs::SelectionWidget::widget().

{
  TRACE;
  if(!_currentActiveSelection)
    return ;
  GraphicObject * obj=_currentActiveSelection->widget();
  double refPos=obj->printLeft() + localPosition * obj->printWidth();
  QList<GraphicObject *> objectList=selectedObjects<GraphicObject *>();
  foreach(obj, objectList) {
    obj->setPrintXAnchor(refPos - localPosition * obj->printWidth());
    moveObject(obj);
  }
}
void SciFigs::GraphicSheet::alignY ( double  localPosition) [slot]

Align two objects with repect to a relative position along Y axis

localPosition should be between 0 (bottom) and 1 (top)

References moveObject(), SciFigs::GraphicObject::printHeight, SciFigs::GraphicObject::printTop(), SciFigs::GraphicObject::setPrintYAnchor(), TRACE, and SciFigs::SelectionWidget::widget().

{
  TRACE;
  if(!_currentActiveSelection)
    return ;
  GraphicObject * obj=_currentActiveSelection->widget();
  double refPos=obj->printTop() + localPosition * obj->printHeight();
  QList<GraphicObject *> objectList=selectedObjects<GraphicObject *>();
  foreach(obj, objectList) {
    obj->setPrintYAnchor(refPos - localPosition * obj->printHeight());
    moveObject(obj);
  }
}

References objectList(), SciFigs::GraphicObject::printBottomMargin, SciFigs::GraphicObject::printRightMargin, SciFigs::SciFigsGlobal::screenResolution(), and TRACE.

Referenced by addObject(), createBands(), createCircles(), createManyCurves(), DinverDCGui::DCModelViewer::initGraphs(), CurvesThread::initResultsGraphs(), MagnetoTelluricThread::initResultsGraphs(), DispersionGridThread::initResultsGraphs(), moveObject(), removeObject(), resizeObject(), and xml_polish().

{
  TRACE;
  // greatest right-bottom coordinates of child graphs;
  // iterate on all graphs
  QList<GraphicObject *> objectList=graphicObjects();
  int maxRight=-(int) RAND_MAX, maxBottom=-(int) RAND_MAX;
  GraphicObject * obj;
  foreach(obj, objectList) {
    int right=obj->x() + obj->width() + (int) (obj->printRightMargin() * SciFigsGlobal::screenResolution());
    int bottom=obj->y() + obj->height() + (int) (obj->printBottomMargin() * SciFigsGlobal::screenResolution());
    if(right > maxRight)
      maxRight=right;
    if(bottom > maxBottom)
      maxBottom=bottom;
  }
  if(maxRight > 0)
    widget() ->resize(maxRight, maxBottom);
}
void SciFigs::GraphicSheet::clear ( bool  force)

Remove all objects of the sheet.

If force is true, remove all objects even those not removable (default value is true).

References MSG_ID, removeObject(), QGpCoreTools::tr(), and TRACE.

Referenced by AutocorrTargetWidget::clear().

{
  TRACE;
  QList<GraphicObject *> wList=graphicObjects();
  int nRemoved=wList.count();
  for(QList<GraphicObject *>::iterator it=wList.begin();it!=wList.end();++it) {
    if(removeObject(*it, force))
      nRemoved--;
  }
  switch(nRemoved) {
  case 0:
    break;
  case 1:
    Message::warning(MSG_ID, tr("Clearing sheet"), tr("1 object is not removable"), Message::ok());
    break;
  default:
    Message::warning(MSG_ID, tr("Clearing sheet"), tr("%1 objects are not removable").arg(nRemoved), Message::ok());
  }
}
Q_SCRIPTABLE void SciFigs::GraphicSheet::clear ( ) [inline, slot]

References clear().

Referenced by clear(), and fileNew().

{clear(false);}
void SciFigs::GraphicSheet::copy ( ) [slot]

References SciFigs::XMLSciFigs::Page, SciFigs::XMLSciFigs::saveByteArray(), SciFigs::XMLSciFigs::Selection, and TRACE.

Referenced by addEditActions(), and cut().

{
  TRACE;
  QClipboard * cb=QApplication::clipboard();
  XMLSciFigs s;
  QByteArray selObjects=s.saveByteArray(this, XMLSciFigs::Page | XMLSciFigs::Selection);
  QMimeData * mime=new QMimeData;
  mime->setData("XMLSciFigs::Page", selObjects);
  cb->setMimeData(mime, QClipboard::Clipboard);
}

References image(), and TRACE.

Referenced by addEditActions().

{
  TRACE;
  QClipboard * cb=QApplication::clipboard();
  QPixmap pixmap=image();
  cb->setPixmap(pixmap, QClipboard::Clipboard);
}

Copy all properties of the sheet and included objects to the clipboard

References SciFigs::XMLSciFigs::MakeUp, SciFigs::MakeUpFilter::saveByteArray(), SciFigs::XMLSciFigs::saveString(), SciFigs::MakeUpFilter::setXml(), and TRACE.

Referenced by addFormatActions().

{
  TRACE;
  XMLSciFigs s;
  MakeUpFilter * d=new MakeUpFilter(this);
  d->setXml(s.saveString(this, XMLSciFigs::MakeUp));
  if(d->exec()==QDialog::Accepted) {
    QClipboard * cb=QApplication::clipboard();
    QMimeData * mime=new QMimeData;
    mime->setData("XMLSciFigs::SheetMakeUp", d->saveByteArray());
    cb->setMimeData(mime, QClipboard::Clipboard);
  }
  delete d;
}
void SciFigs::GraphicSheet::currentFileChanged ( const QString &  fileName) [signal]

Returns the coordinates of the current top left visible corner Used for example in Makepage to insert new objects at the top of the visible part and not at the top of the sheet.

References SciFigs::SciFigsGlobal::screenResolution(), QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), and TRACE.

Referenced by addObject(), PSViewer::addPlot(), and paste().

{
  TRACE;
  Point2D o;
  if(widget() ->width() > 0) {
    o.setX(-widget() ->x()/SciFigsGlobal::screenResolution());
    o.setY(-widget() ->y()/SciFigsGlobal::screenResolution());
  } else {
    o.setX(0);
    o.setY(0);
  }
  return o;
}
void SciFigs::GraphicSheet::cut ( ) [slot]

References copy(), SciFigs::GraphicObject::deleteObject(), TRACE, and SciFigs::SelectionWidget::widget().

Referenced by addEditActions().

{
  TRACE;
  copy();
  if(_currentActiveSelection) {
    _currentActiveSelection->widget()->deleteObject();
  }
}
void SciFigs::GraphicSheet::deepUpdate ( ) [virtual, slot]

Redraw all parts of all objects if autoDeepUpdate() is switched on, else do a normal update.

References SciFigs::GraphicObject::deepUpdate(), SciFigs::GraphicObject::selectionWidget(), and TRACE.

Referenced by DinverDCGui::DCModelViewer::loadModels(), pasteMakeUp(), DinverDCGui::DCModelViewer::setLimits(), PSViewer::setLimits(), MonoStation::AbstractSummary::setStations(), and PSViewer::synchronize().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  foreach(obj, objectList) {
    obj->deepUpdate();
    if(obj->selectionWidget())
      obj->selectionWidget() ->update();
  }
}
void SciFigs::GraphicSheet::exportFile ( QString  fileName = QString::null,
QString  fileFormat = QString::null,
int  dpi = 0 
) [slot]

Export all objects of the sheet to a file, fileFormat may be any of the format accepted by QImage, PS, PDF, PAGE or LAYER.

If dpi is different from 0, it override the resolution specified in object properties.

References exportImage(), fileSave(), saveLayers(), selectAll(), and TRACE.

Referenced by main().

{
  TRACE;
  if(fileFormat.toLower()=="page") {
    fileSave(fileName);
  } else if(fileFormat.toLower()=="layer") {
    selectAll();
    saveLayers(fileName);
  } else {
    exportImage(fileName, fileFormat.toAscii().data(), dpi);
  }
}
void SciFigs::GraphicSheet::exportImage ( QString  fileName = QString::null,
QString  imageFormat = QString::null,
int  dpi = 0 
) [slot]

Export all objects of the sheet to an image file, imageFormat may be any of the format accepted by QImage. Additionally, the 'PS' and 'PDF' are accepted.

If dpi is different from 0, it override the resolution specified in object properties.

References SciFigs::GraphicObject::allImageFilter, image(), maximumResolution(), MSG_ID, print(), DinverCore::qHash(), QGpCoreTools::tr(), and TRACE.

Referenced by addFileActions(), and exportFile().

{
  TRACE;
  if(fileName.isEmpty()) {
    fileName=Message::getSaveFileName(tr("Export image as ..."), GraphicObject::allImageFilter);
  }
  if(!fileName.isEmpty()) {
    if(imageFormat.isEmpty()) {
      imageFormat=Settings::getFilter("filter-" + QString::number(qHash(GraphicObject::allImageFilter))).
                    section(' ', 0, 0);
    }
    if(imageFormat =="PS" || imageFormat =="PDF") {
      QPrinter printer(QPrinter::HighResolution);
      if(dpi==0)
        printer.setResolution((int) maximumResolution());
      else
        printer.setResolution(dpi);
      printer.setFullPage(true);
      printer.setOutputFileName(fileName);
      printer.setOutputFormat(imageFormat =="PDF" ? QPrinter::PdfFormat : QPrinter::PostScriptFormat);
      QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
      print(printer);
    } else if(imageFormat =="SVG") {
      printSvg(fileName, dpi);
    } else { // Pixel based image format
      QPixmap pixmap=image(dpi);
      if(!pixmap.isNull()) {
        // Save pixmap to disk
        if(!pixmap.save(fileName, imageFormat.toAscii().data())) {
          Message::warning(MSG_ID, tr("Exporting as image"), tr("Failed to export image to file %1 with format %2")
                              .arg(fileName).arg(imageFormat.toAscii().data()));
        }
      }
    }
  }
}

References clear(), currentFileChanged(), and TRACE.

Referenced by addFileActions().

{
  TRACE;
  clear(false);
  _currentFile="";
  emit currentFileChanged(_currentFile);
}

References QGpCoreTools::tr(), and TRACE.

Referenced by addFileActions(), PSViewer::fileOpenPS(), and main().

{
  TRACE;
  QString fileName=Message::getOpenFileName(tr("Open an existing document"), tr("Page file (*.page)"));
  // Opening a file may take some time, refresh quickly after dialog disappeared
  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
  fileOpen(fileName);
}
void SciFigs::GraphicSheet::fileOpen ( QString  fileName,
double  dx = 0,
double  dy = 0 
) [slot]

Load the .page file with a shift of dx and dy (in cm)

References currentFileChanged(), QGpCoreTools::XMLErrorReport::exec(), fileName, moveObject(), SciFigs::XMLSciFigs::Page, SciFigs::GraphicObject::printXAnchor(), SciFigs::GraphicObject::printYAnchor(), SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), QGpCoreTools::XMLErrorReport::setTitle(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  if(fileName.length() > 0) {
    QFileInfo fi(fileName);
    fileName=fi.absoluteFilePath();
    if(_statusBar)
      _statusBar->showMessage(tr("Loading file ..."));
    _loadedObjects.clear();
    XMLSciFigs s;
    XMLErrorReport xmler(XMLErrorReport::Read);
    xmler.setTitle(tr("Open page file"));
    xmler.setFileName(fileName);
    if(xmler.exec(s.restoreFile(fileName, this, XMLSciFigs::Page))) {
      // Move all loaded object by dx and dy
      if(dx!=0 || dy!=0) {
        GraphicObject * obj;
        foreach (obj, _loadedObjects) {
          obj->setPrintXAnchor(obj->printXAnchor() + dx);
          obj->setPrintYAnchor(obj->printYAnchor() + dy);
          moveObject(obj);
        }
      }
      _loadedObjects.clear();
      if(_currentFile.isEmpty()) {
        _currentFile=fileName;
        emit currentFileChanged(_currentFile);
      }
    }
    if(_statusBar) {
      _statusBar->showMessage(tr("Loading finished"));
    }
  }
}

References fileSaveAs(), SciFigs::XMLSciFigs::Page, SciFigs::XMLSciFigs::saveFile(), and TRACE.

Referenced by addFileActions(), exportFile(), fileSave(), fileSaveAs(), and PSViewer::fileSavePS().

{
  TRACE;
  if(_currentFile.isEmpty()) {
    fileSaveAs();
    return ;
  }
  // Save current file
  XMLSciFigs s;
  s.saveFile(_currentFile, this, XMLSciFigs::Page);
}
void SciFigs::GraphicSheet::fileSave ( QString  fileName) [slot]

References currentFileChanged(), fileName, fileSave(), and TRACE.

{
  TRACE;
  _currentFile=fileName;
  fileSave();
  emit currentFileChanged(_currentFile);
}

References currentFileChanged(), fileName, fileSave(), QGpCoreTools::tr(), and TRACE.

Referenced by addFileActions(), fileSave(), and PSViewer::fileSaveAsPS().

{
  TRACE;
  QString fileName=Message::getSaveFileName(tr("Save page as ..."), tr("Page file (*.page)"));
  if(fileName.isEmpty())
    return ;
  _currentFile=fileName;
  fileSave();
  emit currentFileChanged(_currentFile);
}
GraphicObject * SciFigs::GraphicSheet::findObject ( QString  tag,
QString  name 
)

References SciFigs::GraphicObject::objectName, TRACE, w, and SciFigs::GraphicObject::xml_tagName().

Referenced by xml_member().

{
  TRACE;
  QList<GraphicObject *> wList=graphicObjects();
  GraphicObject * w;
  foreach(w, wList) {
    if(w->xml_tagName()==tagName &&
         (objectName.isNull() || objectName==w->objectName()))
      return w;
  }
  return 0;
}
QPixmap SciFigs::GraphicSheet::image ( int  dpi = 0) [slot]

References SciFigs::GraphicObject::colorMask(), QGpCoreTools::endl(), maximumResolution(), MSG_ID, SciFigs::GraphicObject::objectName, SciFigs::GraphicObject::print(), SciFigs::GraphicObject::restoreScaleFonts(), SciFigs::GraphicObject::scaleFonts(), SciFigs::SciFigsGlobal::screenResolution(), SciFigs::GraphicObject::setPrintSize(), QGpCoreTools::tr(), TRACE, SciFigs::GraphicObject::transparentMask, and SciFigs::GraphicObject::updateMask().

Referenced by copyImage(), and exportImage().

{
  TRACE;
  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
  QProgressDialog * progress=0;
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  int nObjects=objectList.count();
  if(nObjects==0) {
    Message::warning(MSG_ID, tr("Drawing image"), tr("No object in sheet, nothing to draw."), Message::cancel());
    return QPixmap();
  }
  progress=new QProgressDialog(tr("Drawing ..."), QString::null, 0, objectList.count(), this);
  progress->setWindowTitle(tr("Please wait"));
  progress->setMaximum(nObjects-1);

  if(dpi==0) dpi=maximumResolution();
  double resolution=dpi/2.54;
  double factor=resolution/SciFigsGlobal::screenResolution();
  // Find limits of actual sheet
  double x0, y0, x1, y1, mx0, my0, mx1, my1;
  // Scale fonts and eventually adjust size of object for printing
  int ** originalFonts=new int*[objectList.count()];
  for(int i=0; i<nObjects; i++) {
    obj=objectList.at(i);
    originalFonts[i]=obj->scaleFonts(factor);
    obj->setPrintSize(resolution);
  }
  printSize(x0, y0, x1, y1, mx0, my0, mx1, my1);
  int totalw=(int) ((mx1-mx0)*resolution);
  int totalh=(int) ((my1-my0)*resolution);
  QPixmap pixmap;
  if(totalw>0 && totalh>0) {
    pixmap=QPixmap(totalw, totalh);
    QPainter p;
    p.begin(&pixmap);
    p.eraseRect(0, 0, totalw, totalh);
    p.save();
    p.translate(-mx0 * resolution, -my0 * resolution);
    // send print command to all graph positionning correctly like on the screen
    // iterate on all graphs
    for(int i=0; i<nObjects; i++) {
      obj=objectList.at(i);
      //App::stream() << tr("---- Drawing %1").arg(obj->objectName()) << endl;
      obj->print(p, resolution, 0, 0, false);
      if(progress) progress->setValue(i);
    }
    p.restore();
    //SciFigsGlobal::footprint(p, resolution, totalw, totalh);
    p.end();
    if(_transparentMask) {
      progress->reset();
      QBitmap mask=GraphicObject::colorMask(pixmap, 0xFFFFFFFF);
      p.begin(&mask);
      p.translate(-mx0 * resolution, -my0 * resolution);
      for(int i=0; i<nObjects; i++) {
        obj=objectList.at(i);
        App::stream() << tr("---- Setting mask %1").arg(obj->objectName()) << endl;
        obj->print(p, resolution, 0, 0, true);
        if(obj->transparentMask())
          obj->updateMask();
        if(progress) progress->setValue(i);
      }
    }
  } else {
    Message::warning(MSG_ID, tr("Drawing image"), tr("Null size for image (%1, %2).").arg(totalw).arg(totalh), Message::cancel());
  }
  // Restore fonts and eventually screen size of objects
  for(int i=0; i<nObjects; i++) {
    obj=objectList.at(i);
    obj->restoreScaleFonts(originalFonts[i]);
    obj->setPrintSize(SciFigsGlobal::screenResolution());
  }
  delete [] originalFonts;
  if(progress) {
    delete progress;
  }
  return pixmap;
}
bool SciFigs::GraphicSheet::isOrderIndex ( ) const [inline]
{return _orderIndex >= 0;}

Send to back all selected objects. It works also for stand-alone object because it is a classical re-organization of the children stack of a Qwidget.

References SciFigs::GraphicObject::selectionWidget(), showOrderIndex(), and TRACE.

{
  TRACE;
  QList<GraphicObject *> objectList=selectedObjects<GraphicObject *>();
  GraphicObject * obj;
  foreach(obj, objectList) {
    obj->lower();
    obj->selectionWidget() ->lower();
  }
  if(_orderIndex >= 0)
    showOrderIndex(true);
}

References SciFigs::GraphicObject::printResolution, and TRACE.

Referenced by exportImage(), image(), and print().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  int printResolution=0;
  foreach(obj, objectList) {
    int val=obj->printResolution();
    if(printResolution < val)
      printResolution=val;
  }
  return printResolution;
}
virtual QSize SciFigs::GraphicSheet::minimumSizeHind ( ) const [inline, virtual]
{return QSize(100,100);}
void SciFigs::GraphicSheet::mousePressEvent ( QMouseEvent *  e) [protected, virtual]

References TRACE.

{
  TRACE;
  switch (e->button()) {
  case Qt::RightButton: {
      QMenu m;
      m.addActions(actions());
      m.exec(mapToGlobal(e->pos()));
    }
    break;
  default:
    break;
  }
}
void SciFigs::GraphicSheet::mouseReleaseEvent ( QMouseEvent *  e) [protected, virtual]

References selectObjects(), and TRACE.

{
  TRACE;
  switch (e->button()) {
  case Qt::LeftButton:
    selectObjects(0, e->modifiers());
    break;
  default:
    break;
  }
}

Move one object to its new position on screen and extend viewport if necessary. Coordinates are read from object data.

References autoResizeContent(), SciFigs::GraphicObject::printLeft(), SciFigs::GraphicObject::printTop(), QGpGuiTools::PropertyContext::proxy(), SciFigs::SciFigsGlobal::screenResolution(), SciFigs::GraphicObject::selectionWidget(), TRACE, SciFigs::GraphicObject::updateGeometryProperties(), SciFigs::SelectionWidget::x(), and SciFigs::SelectionWidget::y().

Referenced by addPlot(), alignX(), alignY(), createBands(), createCircles(), fileOpen(), paste(), and showObject().

{
  TRACE;
  if(!obj)
    obj=(GraphicObject *) sender();
  if(obj) {
    obj->move((int) (obj->printLeft() * SciFigsGlobal::screenResolution()),
               (int) (obj->printTop() * SciFigsGlobal::screenResolution()));
    if(proxy()) {
       obj->updateGeometryProperties(proxy());
    }
    SelectionWidget * selObj=obj->selectionWidget();
    if(selObj)
      selObj->move(selObj->x(obj->x()), selObj->y(obj->y()));
    //if(obj->_orderTip) obj->_orderTip->move(obj->x()-widget()->x(),obj->y()-widget()->y());
    autoResizeContent();
    //ASSERT(false);
  }
}
GraphicObject * SciFigs::GraphicSheet::object ( QString  objectName) [slot]

References objectName, and TRACE.

{
  TRACE;
  return findChild<GraphicObject *>(objectName);;
}

References TRACE.

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  QList<GraphicObject *>::iterator it;
  if(index>=0 && index<(int)objectList.count()) {
    return objectList.at(index);
  } else {
    qWarning("Index out of bounds (%i)\n", index);
    return 0;
  }
}

References currentOrigin(), moveObject(), SciFigs::XMLSciFigs::Page, SciFigs::GraphicObject::printHeight, SciFigs::GraphicObject::printLeft(), SciFigs::GraphicObject::printTop(), SciFigs::GraphicObject::printWidth, SciFigs::GraphicObject::printXAnchor(), SciFigs::GraphicObject::printYAnchor(), SciFigs::XMLSciFigs::restoreByteArray(), SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), TRACE, QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().

Referenced by addEditActions().

{
  TRACE;
  QClipboard * cb=QApplication::clipboard();
  const QMimeData * mime=cb->mimeData(QClipboard::Clipboard);
  QByteArray objects;
  if(mime->hasFormat("XMLSciFigs::Page")) {
    objects=mime->data("XMLSciFigs::Page");
  } else if(mime->hasFormat("XMLSciFigs")) {        // Compatibility
    objects=mime->data("XMLSciFigs");
  } else {
    return;
  }
  XMLSciFigs s;
  _loadedObjects.clear();
  s.restoreByteArray(objects, this, XMLSciFigs::Page);
  // Move all pasted objects to current visible area
  // First first the to left corner of the pasted objects
  Point topLeft(1e99,1e99);
  GraphicObject * obj;
  foreach (obj, _loadedObjects) {
    Point p(obj->printLeft(obj->printWidth()), obj->printTop(obj->printHeight()));
    if(p.x()<topLeft.x()) topLeft.setX(p.x());
    if(p.y()<topLeft.y()) topLeft.setY(p.y());
  }
  double dx=currentOrigin().x() - topLeft.x() + 1;
  double dy=currentOrigin().y() - topLeft.y() + 1;
  foreach (obj, _loadedObjects) {
    obj->setPrintXAnchor(obj->printXAnchor() + dx);
    obj->setPrintYAnchor(obj->printYAnchor() + dy);
    moveObject(obj);
  }
  _loadedObjects.clear();
}

Paste properties from the clipboard if there are

References deepUpdate(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::XMLSciFigs::MakeUp, SciFigs::XMLSciFigs::restoreByteArray(), QGpCoreTools::XMLErrorReport::setTitle(), QGpCoreTools::tr(), and TRACE.

Referenced by addFormatActions().

{
  TRACE;
  static QString title=tr("Paste make-up");
  QClipboard * cb=QApplication::clipboard();
  const QMimeData * mime=cb->mimeData(QClipboard::Clipboard);
  if(mime->hasFormat("XMLSciFigs::SheetMakeUp")) {
    QByteArray makeup=mime->data("XMLSciFigs::SheetMakeUp");
    XMLErrorReport xmler(XMLErrorReport::Read);
    xmler.setTitle(title);
    XMLSciFigs s;
    xmler.exec(s.restoreByteArray(makeup, this, XMLSciFigs::MakeUp));
    deepUpdate();
  }
}
void SciFigs::GraphicSheet::print ( QPrinter &  printer)

References SciFigs::GraphicObject::print(), SciFigs::SciFigsGlobal::screenResolution(), QGpCoreTools::tr(), TRACE, and updatePageLimits().

Referenced by addFileActions(), exportImage(), and print().

{
  TRACE;
  updatePageLimits(printer);
  QPainter p;
  p.begin(&printer);
  // send print command to all graph positionning correctly like on the screen
  // iterate on all graphs to plot new points
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  // Get page area and number of pages in x and y direction
  int wScrPage=(int) ((double) printer.widthMM() * SciFigsGlobal::screenResolution() * 0.1);
  int hScrPage=(int) ((double) printer.heightMM() * SciFigsGlobal::screenResolution() * 0.1);
  int wPtrPage=(int) ((double) printer.widthMM() * printer.resolution()/25.4);
  int hPtrPage=(int) ((double) printer.heightMM() * printer.resolution()/25.4);
  if(wScrPage==0 || hScrPage==0) {
    printer.abort();
    return ;
  }
  int xpages=1 + widget() ->width()/wScrPage;
  int ypages=1 + widget() ->height()/hScrPage;
  QProgressDialog * progress=0;
  // TODO Batch hidden mode
  //if(!app.qsa().hiddenMode()) {
    progress=new QProgressDialog(tr("Printing ..."), QString::null, 0, objectList.count() * xpages * ypages, this);
    progress->setWindowTitle(tr("Please wait"));
  //}
  int iprogress=0;
  double dotpercm=(double) printer.resolution()/2.54;
  for(int ix=0;ix < xpages;ix++) {
    for(int iy=0;iy < ypages;iy++) {
      if(ix > 0 || iy > 0)
        printer.newPage();
      QRect r(ix * wScrPage, iy * hScrPage, wScrPage, hScrPage);
      foreach(obj, objectList) {
        if(r.intersects(obj->geometry())) {
          obj->print(p, dotpercm, ix * wPtrPage, iy * hPtrPage, false);
        }
        if(progress) {
          ++iprogress;
          progress->setValue(iprogress);
        }
      }
    }
  }
  p.end();
  if(progress) {
    progress->setValue(iprogress);
    delete progress;
  }
}
void SciFigs::GraphicSheet::print ( int  dpi = 0) [slot]

References maximumResolution(), print(), and TRACE.

{
  TRACE;
  QPrinter printer(QPrinter::HighResolution);
  if(dpi==0)
    printer.setResolution((int) maximumResolution());
  else
    printer.setResolution(dpi);
  printer.setFullPage(true);
  if(Settings::printSetup(printer)) {
    QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
    print(printer);
  }
}
void SciFigs::GraphicSheet::print ( bool  outputToFile,
QString  name,
int  dpi 
) [slot]

References maximumResolution(), print(), and TRACE.

{
  TRACE;
  QPrinter printer(QPrinter::HighResolution);
  if(dpi==0) printer.setResolution((int)maximumResolution());
  else printer.setResolution(dpi);
  printer.setFullPage(true);
  if(outputToFile) printer.setOutputFileName(name);
  else printer.setPrinterName(name);
  print(printer);
}

Return the bottom of the sheet in cm. It is the maximum bottom of all objects.

References objectList(), SciFigs::GraphicObject::printBottom(), and TRACE.

Referenced by MonoStation::WinResults::loadResults(), HVRotateWinResults::setStations(), and SpectrumRotateWinResults::setStations().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  double maxv=0.0;
  GraphicObject * obj;
  foreach(obj, objectList) {
    double v=obj->printBottom();
    if(v > maxv)
      maxv=v;
  }
  return maxv;
}

Return the right of the sheet in cm. It is the maximum right of all objects.

References objectList(), SciFigs::GraphicObject::printRight(), and TRACE.

Referenced by Seismic1DThread::initModelGraphs(), MagnetoTelluricThread::initModelGraphs(), CurvesThread::initResultsGraphs(), MagnetoTelluricThread::initResultsGraphs(), and DispersionGridThread::initResultsGraphs().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  double maxv=0.0;
  GraphicObject * obj;
  foreach(obj, objectList) {
    double v=obj->printRight();
    if(v > maxv)
      maxv=v;
  }
  return maxv;
}
void SciFigs::GraphicSheet::properties ( PropertyWidget w) const [virtual]

Bring to front all selected objects. It works also for stand-alone object because it is a classical re-organization of the children stack of a Qwidget.

References SciFigs::GraphicObject::selectionWidget(), showOrderIndex(), and TRACE.

{
  TRACE;
  QList<GraphicObject *> objectList=selectedObjects<GraphicObject *>();
  GraphicObject * obj;
  foreach(obj, objectList) {
    obj->raise();
    if(obj->selectionWidget())
      obj->selectionWidget() ->stackUnder(obj);
  }
  if(_orderIndex >= 0)
    showOrderIndex(true);
}
void SciFigs::GraphicSheet::redo ( ) [slot]

References TRACE.

{
  TRACE;
}
bool SciFigs::GraphicSheet::removeObject ( GraphicObject obj,
bool  force 
)

Remove object obj from the sheet.

If object is not removable (see QObject::isRemovable()), it will be removed only if force is true (default value is true).

Return true if object correctly removed.

References autoResizeContent(), SciFigs::GraphicObject::isRemovable(), QGpGuiTools::PropertyContext::proxy(), SciFigs::GraphicObject::removeProperties(), SciFigs::GraphicObject::selectionWidget(), SciFigs::GraphicObject::setSelected(), TRACE, and SciFigs::SelectionWidget::widget().

Referenced by clear(), SciFigs::GraphicObject::deleteObject(), and SciFigs::GraphicSheetMenu::removeObject().

{
  TRACE;
  if(force || obj->isRemovable()) {
    SelectionWidget * tmp=obj->selectionWidget();
    if(proxy()) obj->removeProperties(proxy());
    if(_currentActiveSelection==tmp)
      _currentActiveSelection=0;
    if(tmp) {
      tmp->widget() ->setSelected(0);
      tmp->deleteLater();
    }
    obj->close();
    autoResizeContent();
    return true;
  } else
    return false;
}
Q_SCRIPTABLE bool SciFigs::GraphicSheet::removeObject ( GraphicObject obj) [inline, slot]

References removeObject().

Referenced by removeObject().

{return removeObject (obj, false);}

Resize one object and extend viewport if necessary. Size is read from object data.

References autoResizeContent(), SciFigs::SelectionWidget::height(), SciFigs::GraphicObject::printHeight, SciFigs::GraphicObject::printWidth, SciFigs::SciFigsGlobal::screenResolution(), SciFigs::GraphicObject::selectionWidget(), TRACE, and SciFigs::SelectionWidget::width().

Referenced by showObject().

{
  TRACE;
  GraphicObject * obj=(GraphicObject *) sender();
  obj->QWidget::resize((int) (obj->printWidth() * SciFigsGlobal::screenResolution()),
                        (int) (obj->printHeight() * SciFigsGlobal::screenResolution()));
  SelectionWidget * selObj=obj->selectionWidget();
  if(selObj)
    selObj->resize(selObj->width(), selObj->height());
  autoResizeContent();
}
void SciFigs::GraphicSheet::restoreMakeUp ( QString  fileName = QString::null) [slot]

Restore all properties of the sheet and included objects from fileName

References QGpCoreTools::XMLErrorReport::exec(), SciFigs::XMLSciFigs::MakeUp, SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), QGpCoreTools::XMLErrorReport::setTitle(), QGpCoreTools::tr(), and TRACE.

Referenced by addFormatActions(), main(), and MonoStation::StatisticResults::studentTest().

{
  TRACE;
  static QString title=tr("Open an exisiting make-up");
  if(fileName.isEmpty()) {
    fileName=Message::getOpenFileName(title, tr("Sheet make-up (*.mkup)"));
  }
  if(fileName.length() > 0) {
    MessageContext mc;
    XMLErrorReport xmler(XMLErrorReport::Read);
    xmler.setTitle(title);
    xmler.setFileName(fileName);
    QFileInfo fi(fileName);
    XMLSciFigs s;
    xmler.exec(s.restoreFile(fileName, this, XMLSciFigs::MakeUp));
  }
}
void SciFigs::GraphicSheet::saveLayers ( QString  fileName = QString::null) [slot]

Save layers of selected axiswindows

References selectAll(), QGpCoreTools::tr(), and TRACE.

Referenced by addFormatActions(), and exportFile().

{
  TRACE;
  QList<AxisWindow *> objectList=selectedObjects<AxisWindow *>();
  if(objectList.isEmpty()) {
    if(!selectAll(tr("Save layers"))) return;
    objectList=selectedObjects<AxisWindow *>();
  }
  if(fileName.isEmpty()) {
    fileName=Message::getSaveFileName(tr("Save layers as..."),
                                            tr("Graph layers (*.layer)"));
  }
  if(fileName.length() > 0) {
    if(objectList.count()==1) {
      objectList.first()->graphContent()->saveLayers(fileName);
    } else {
      QFileInfo fi(fileName);
      QDir d(fi.absolutePath());
      QString baseName;
      if(fi.suffix()=="layer") {
        baseName=d.absoluteFilePath(fi.completeBaseName() + "_%1.layer");
      } else {
        baseName=d.absoluteFilePath(fi.fileName() + "_%1");
      }
      for(int i=0; i<objectList.count(); i++) {
        objectList.at(i)->graphContent()->saveLayers(baseName.arg(i, 4, 10, QChar('0')));
      }
    }
  }
}
void SciFigs::GraphicSheet::saveMakeUp ( QString  fileName = QString::null) [slot]

Save all properties of the sheet and included objects

References SciFigs::XMLSciFigs::MakeUp, SciFigs::MakeUpFilter::saveFile(), SciFigs::XMLSciFigs::saveString(), SciFigs::MakeUpFilter::setXml(), QGpCoreTools::tr(), and TRACE.

Referenced by addFormatActions().

{
  TRACE;
  XMLSciFigs s;
  MakeUpFilter * d=new MakeUpFilter(this);
  d->setXml(s.saveString(this, XMLSciFigs::MakeUp));
  if(d->exec()==QDialog::Accepted) {
    if(fileName.isEmpty()) {
      fileName=Message::getSaveFileName(tr("Save make-up as ..."),
                                              tr("Sheet make-up (*.mkup)"));
    }
    if(fileName.length() > 0) {
      d->saveFile(fileName);
    }
  }
  delete d;
}
Q_SCRIPTABLE void SciFigs::GraphicSheet::select ( GraphicObject obj) [inline, slot]
{selectObjects(obj, Qt::NoModifier);}

References QGpGuiTools::PropertyProxy::blockUpdates(), QGpGuiTools::PropertyContext::proxy(), QGpGuiTools::PropertyProxy::saveStates(), selectObjects(), and TRACE.

Referenced by addEditActions(), addLayers(), exportFile(), saveLayers(), MonoStation::WinResults::selectAll(), and selectAll().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  if(proxy()) {
    proxy()->saveStates();
    proxy()->blockUpdates(true);
  }
  foreach(obj, objectList) selectObjects(obj, Qt::ShiftModifier);
  if(proxy()) proxy()->blockUpdates(false);
}
bool SciFigs::GraphicSheet::selectAll ( QString  actionTitle) [slot]

If not graph is selected, warns user and select all graphs if confirmed by user. It returns false if user answer no (cancel).

References MSG_ID, selectAll(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  if(Message::question(MSG_ID, actionTitle, tr("No graph is currently selected. The action you choose apply only "
                            "to the selected graphs. Do you want to select all of them?"),
                            Message::yes(), Message::no())==Message::Answer1) return false;
  selectAll();
  return true;
}
template<typename T >
QList< T > SciFigs::GraphicSheet::selectedObjects ( ) const

References SciFigs::SelectionWidget::Hoover, and w.

Referenced by SciFigs::GraphicObject::deleteObject().

{
  QList<T> wList;
  QList<SelectionWidget *> wSelList=findChildren<SelectionWidget *>();
  SelectionWidget * wSel;
  foreach(wSel, wSelList) {
    if(wSel->state()!=SelectionWidget::Hoover) {
      GraphicObject * w=wSel->widget();
      T castedW=qobject_cast<T>(w);
      if(castedW)
        wList << castedW;
    }
  }
  return wList;
}

Select next child (in the stack order, just after the current object). This function is called after a TAB action.

References selectObjects(), TRACE, and SciFigs::SelectionWidget::widget().

Referenced by GraphicSheet().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  if(objectList.isEmpty()) return;
  GraphicObject * cur;
  if(_currentActiveSelection)
    cur=_currentActiveSelection->widget();
  else
    cur=0;
  QList<GraphicObject *>::iterator it;
  for(it=objectList.begin(); it!=objectList.end(); ++it) {
    if(*it==cur) {++it;break;}
  }
  if(it!=objectList.end()) {
    selectObjects(*it, Qt::NoModifier);
  } else {
    selectObjects(objectList.first(), Qt::NoModifier);
  }
}
void SciFigs::GraphicSheet::selectObjects ( GraphicObject obj,
Qt::KeyboardModifiers  m = Qt::NoModifier 
) [slot]

References SciFigs::SelectionWidget::Activated, activeSelectionChanged(), SciFigs::GraphicObject::addProperties(), addSelection(), QGpGuiTools::PropertyContext::proxy(), QGpGuiTools::PropertyProxy::restoreStates(), QGpGuiTools::PropertyProxy::saveStates(), SciFigs::SelectionWidget::Selected, SciFigs::GraphicObject::selectionWidget(), SciFigs::GraphicObject::setSelected(), SciFigs::SelectionWidget::setState(), QGpGuiTools::PropertyProxy::setValues(), QGpCoreTools::tr(), TRACE, update(), and SciFigs::SelectionWidget::widget().

Referenced by addObject(), addSelectNextChild(), mouseReleaseEvent(), selectAll(), selectNextChild(), and ~GraphicSheet().

{
  TRACE;
  if(proxy()) proxy()->saveStates();
  SelectionWidget * selObj;
  if(obj)
    selObj=obj->selectionWidget();
  else
    selObj=0;
  if(obj && !obj->selectionWidget()) {
    selObj=addSelection(obj);
    selObj->show(); // Here and not in addSelection(), bug observed with Qt 4.6 under Mac, show() calls GraphicObject::enterEvent()
    if(proxy()) obj->addProperties(proxy());
  } else if(selObj) {
    selObj->setState(SelectionWidget::Activated);
    emit activeSelectionChanged(obj);
    if(proxy()) obj->addProperties(proxy());
  }
  if(!(m & Qt::ShiftModifier)) {
    // Unselect all
    QList<SelectionWidget *> wList=findChildren<SelectionWidget *>();
    SelectionWidget * tmp;
    foreach(tmp, wList) {
      if(tmp!=selObj) {
        tmp->widget()->setSelected(0);
        if(proxy()) tmp->widget()->removeProperties(proxy());
        delete tmp;
      }
    }
    // Bug fixed 28/10/04, if no shift key, all selection widgets are removed
    // Object eventually pointed by current avtive selection is deleted.
    _currentActiveSelection=0;
    // Bug fixed for Qt 4.3 : selection mark remains visible if sheet not updated
#if(QT_VERSION < QT_VERSION_CHECK(4, 4, 0))
    update();
#endif
    // Bug fixed with Qt 4.4: update makes the selection quite slow with a lot of objects
  }
  if(_currentActiveSelection && _currentActiveSelection!=selObj) {
    _currentActiveSelection->setState(SelectionWidget::Selected);
  }
  _currentActiveSelection=selObj;
  if(_currentActiveSelection && _statusBar)
    _statusBar->showMessage(tr("Hit CTRL+M to display popup menu of the active object"));
  if(proxy()) {
    proxy()->restoreStates();
    proxy()->setValues();
  }
}
void SciFigs::GraphicSheet::setObjectList ( QString  list)
void SciFigs::GraphicSheet::setObjectOrder ( QString  list)

References SciFigs::GraphicObject::selectionWidget(), showOrderIndex(), and TRACE.

Referenced by SciFigs::GraphicObject::mouseReleaseEvent().

{
  TRACE;
  if(_orderIndex >= 0) {
    QList<GraphicObject *> objectList=graphicObjects();
    QList<GraphicObject *>::iterator it;
    int i=0;
    for(it=objectList.begin();it!=objectList.end();++it, i++) {
      if(i==_orderIndex)
        break;
    }
    if(it==objectList.end()) {
      it=objectList.begin();
      _orderIndex=0;
    }
    GraphicObject * objAbove=*it;
    if(objAbove) {
      obj->stackUnder(objAbove);
      if(obj->selectionWidget())
        obj->selectionWidget() ->stackUnder(obj);
      _orderIndex++;
    }
    showOrderIndex(true);
  }
}

References SciFigs::SciFigsPreferences::savePluginList(), and TRACE.

Referenced by addFileActions().

{
  TRACE;
  SciFigsPreferences * d=new SciFigsPreferences(this);
  Settings::getWidget(d);
  if(d->exec()==QDialog::Accepted) {
    Settings::setWidget(d);
    d->savePluginList();
  }
  delete d;
}
void SciFigs::GraphicSheet::setProperty ( uint  wid,
int  pid,
QVariant  val 
) [virtual]
void SciFigs::GraphicSheet::setStatusBar ( QStatusBar *  s) [inline]
void SciFigs::GraphicSheet::setTransparency ( int  val) [inline]

Referenced by setProperty().

{_transparency=val;}

References TRACE.

Referenced by setProperty().

{
  TRACE;
  _transparentMask=val;
  //if(!val) clearMask();
}

References TRACE, and w.

Referenced by main().

{
  TRACE;
  QList<GraphicObject *> wList=graphicObjects();
  GraphicObject * w;
  foreach(w, wList) w->show();
}

References moveObject(), SciFigs::GraphicObject::printHeight, SciFigs::GraphicObject::printLeft(), SciFigs::GraphicObject::printTop(), SciFigs::GraphicObject::printWidth, resizeObject(), SciFigs::SciFigsGlobal::screenResolution(), showOrderIndex(), startDragging(), and TRACE.

Referenced by SciFigs::GraphicSheetMenu::addGraph(), addObject(), PSViewer::addPlot(), SciFigs::GraphicSheetMenu::addText(), DinverDCGui::DCModelViewer::addText(), ResultsThread::createLegend(), TFAResults::createObjects(), DinverDCGui::DCModelViewer::initGraphs(), Seismic1DThread::initModelGraphs(), MagnetoTelluricThread::initModelGraphs(), CurvesThread::initResultsGraphs(), MagnetoTelluricThread::initResultsGraphs(), DispersionGridThread::initResultsGraphs(), and xml_polishChild().

{
  TRACE;
  connect(obj, SIGNAL(positionChanged()), this, SLOT(moveObject()));
  connect(obj, SIGNAL(wantToStartDragging()), this, SLOT(startDragging()));
  connect(obj, SIGNAL(dragged(Point2D)), this, SLOT(dragObjects(Point2D)));
  connect(obj, SIGNAL(sizeChanged()), this, SLOT(resizeObject()));
  obj->setParent(widget());
  obj->QWidget::move((int) (obj->printLeft() * SciFigsGlobal::screenResolution()),
                      (int) (obj->printTop() * SciFigsGlobal::screenResolution()));
  obj->resize((int) (obj->printWidth() * SciFigsGlobal::screenResolution()),
               (int) (obj->printHeight() * SciFigsGlobal::screenResolution()));
  // TODO Batch hidden mode
  //if(app.qsa().hiddenMode()) {
  //  obj->polish();
  //  obj->updateGeometry();
  //} else {
    obj->show();
  //}
  if(_orderIndex >= 0)
    showOrderIndex(true);
}
void SciFigs::GraphicSheet::showOrderIndex ( bool  isOn) [slot]

References SciFigs::GraphicObject::setOrderIndex(), QGpCoreTools::tr(), and TRACE.

Referenced by addEditActions(), lowerSelection(), raiseSelection(), setOrderIndex(), and showObject().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  if(isOn) {
    if(_statusBar)
      _statusBar->showMessage(tr("Select objects to change their order"));
    if(_orderIndex < 0)
      _orderIndex=0;
    for(int i=0; i < objectList.count(); i++) {
      obj=objectList.at(i);
      obj->setOrderIndex(i + 1);
    }
  } else {
    if(_statusBar)
      _statusBar->showMessage("");
    _orderIndex=-1;
    foreach(obj, objectList) obj->setOrderIndex(-1);
  }
}

References addProperties(), SciFigs::GraphicObject::addProperties(), QGpGuiTools::PropertyContext::initProxy(), QGpGuiTools::PropertyContext::proxy(), QGpGuiTools::PropertyContext::raiseEditor(), QGpGuiTools::PropertyProxy::restoreStates(), QGpGuiTools::PropertyProxy::saveStates(), QGpGuiTools::PropertyContext::setPropertyTitle(), QGpGuiTools::PropertyProxy::setValues(), TRACE, and SciFigs::SelectionWidget::widget().

Referenced by addActions(), addFormatActions(), and SciFigs::GraphicObject::showProperties().

{
  TRACE;
  initProxy();
  proxy()->saveStates();
  addProperties(proxy());
  QList<GraphicObject *> wList=selectedObjects<GraphicObject *>();
  GraphicObject * curObj;
  if(_currentActiveSelection)
    curObj=_currentActiveSelection->widget();
  else
    curObj=0;
  for(int i=wList.count()-1; i>=0; i--) {
    GraphicObject * obj=wList.at(i);
    if(obj!= curObj) obj->addProperties(proxy());
  }
  if(curObj) curObj->addProperties(proxy());
  setPropertyTitle(this);
  raiseEditor();
  proxy()->restoreStates();
  proxy()->setValues();
}

References TRACE, and w.

Referenced by showObject().

{
  TRACE;
  QList<GraphicObject *> selWList=selectedObjects<GraphicObject *>();
  GraphicObject * w;
  foreach(w, selWList) w->startDragging();
}
QStatusBar* SciFigs::GraphicSheet::statusBar ( ) [inline]
{return _statusBar;}
int SciFigs::GraphicSheet::transparency ( ) const [inline]

Referenced by properties().

{return _transparency;}
bool SciFigs::GraphicSheet::transparentMask ( ) const [inline]

Referenced by properties().

{return _transparentMask;}
void SciFigs::GraphicSheet::undo ( ) [slot]

References TRACE.

{
  TRACE;
}
QString SciFigs::GraphicSheet::uniqueName ( GraphicObject obj,
QString  newName 
)

References SciFigs::GraphicObject::objectName, and TRACE.

Referenced by SciFigs::GraphicObject::setObjectName().

{
  TRACE;
  QList<GraphicObject *> wList=graphicObjects();
  QList<GraphicObject *>::iterator it;
  for(it=wList.begin();it!=wList.end();++it) {
    if(namedW!=*it && newName==(*it) ->objectName()) {
      int i=newName.lastIndexOf('_');
      int n;
      if(i > -1) {
        bool ok;
        n=newName.right(newName.length() - i - 1).toInt(&ok) + 1;
        if(ok)
          newName=newName.left(i);
        else
          n=0;
      } else
        n=0;
      newName=(newName + "_") + QString::number(n);
      it=wList.begin();
    }
  }
  return newName;
}
Q_SCRIPTABLE void SciFigs::GraphicSheet::unSelectAll ( ) [inline, slot]
{selectObjects(0, Qt::NoModifier);}
void SciFigs::GraphicSheet::update ( ) [virtual, slot]

Redraw only some parts of the objects, generally not including the slow drawing actions.

Use deepUpdate() or deepUpdateNow() to redraw all parts.

References SciFigs::GraphicObject::selectionWidget(), TRACE, and SciFigs::GraphicObject::update().

Referenced by selectObjects(), and xml_polish().

{
  TRACE;
  QList<GraphicObject *> objectList=graphicObjects();
  GraphicObject * obj;
  foreach(obj, objectList) {
    obj->update();
    if(obj->selectionWidget())
      obj->selectionWidget() ->update();
  }
}
void SciFigs::GraphicSheet::updatePageLimits ( QPrinter &  p) [slot]

Refresh the limits of pages

References SciFigs::PageLimit::Horizontal, SciFigs::SciFigsGlobal::screenResolution(), TRACE, and SciFigs::PageLimit::Vertical.

Referenced by print().

{
  TRACE;
  // Remove all existing limits
  PageLimit * limit;
  QList<PageLimit *> pageList=findChildren<PageLimit *>();
  foreach(limit, pageList) delete limit;
  // Create new limits
  int wpage=(int) ((double) p.widthMM() * SciFigsGlobal::screenResolution() * 0.1);
  int hpage=(int) ((double) p.heightMM() * SciFigsGlobal::screenResolution() * 0.1);
  int w=wpage, h=hpage;
  while(w < widget() ->width()) {
    limit=new PageLimit(PageLimit::Vertical, widget());
    limit->move(w, 0);
    limit->show();
    w += wpage;
  }
  while(h < widget() ->height()) {
    limit=new PageLimit(PageLimit::Horizontal, widget());
    limit->move(0, h);
    limit->show();
    h += hpage;
  }
}

Re-implement this function to offer XML restore (children and properties) support to your class.

From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):

    static const QString tmp("childrenName");
    XMLRestoreAttributeIterator it=map.find(tmp);
    if(it!=map.end()) {
      // found attribute "childrenName"
    }

If the map of attributes is not used:

    Q_UNUSED(attributes);
    if(tag=="x1") return XMLMember(0);
    else if(tag=="y1") return XMLMember(1);
    else if(tag=="x2") return XMLMember(2);
    else if(tag=="y2") return XMLMember(3);
    else return XMLMember(XMLMember::Unknown);

Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.

    if(tag=="anInteger") return XMLMember(0);
    else if(tag=="aString") return XMLMember(1);
    else if(tag=="aDouble") return XMLMember(2);
    return AbstractLine::xml_member(tag, attributes, context)+3;

For the arguments of this function use Macro XML_MEMBER_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

References addObject(), SciFigs::GraphicObjectFactory::create(), SciFigs::XMLSciFigs::data(), QGpCoreTools::endl(), findObject(), SciFigs::GraphicObjectFactory::instance(), SciFigs::XMLSciFigs::makeUp(), MSG_ID, SciFigs::GraphicObject::objectName, QGpCoreTools::XMLClass::qobject_member(), SciFigs::GraphicObject::setRemovable(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  static const QString tmp("objectName");
  XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
  XMLRestoreAttributeIterator it=attributes.find(tmp);
  if(it!=attributes.end()) {
    if(scifigsContext->data()) {
      GraphicObject * obj=GraphicObjectFactory::instance()->create(tag.toString());
      if(obj) {
        obj->setRemovable(true);
        addObject(obj);
        return XMLMember(obj);
      } else {
        App::stream() << tr("Unknown object type %1").arg(tag.toString()) << endl;
        return XMLMember(XMLMember::Unknown);
      }
    } else {
      GraphicObject * obj=findObject(tag.toString(), it.value().toString());
      if(obj) return XMLMember(obj);
      else {
        obj=findObject(tag.toString(),0);
        if(obj) {
          if(Message::warning(MSG_ID,"Restore",
                                   tr("Cannot find an object of type %1 and named %2,\n"
                                      "but an object of type %3 and named %4 has been found.\n"
                                      "Do you want to restore properties to this object?").
                                   arg(tag.toString()).arg(it.value().toString()).
                                   arg(tag.toString()).arg(obj->objectName()),
                                   Message::yes(),Message::no(), true)==Message::Answer0) {
            return XMLMember(obj);
          } else return XMLMember(XMLMember::Unknown);
        } else {
          App::stream() << tr("Cannot find an object of type %1").arg(tag.toString()) << endl;
          return XMLMember(XMLMember::Unknown);
        }
      }
    }
  } else if(scifigsContext->makeUp()) {
    return qobject_member(this, tag, attributes, context);
  }
  return XMLMember(XMLMember::Unknown);
}
void SciFigs::GraphicSheet::xml_polish ( XML_POLISH_ARGS  ) [protected, virtual]

Reimplemented from QGpCoreTools::XMLClass.

References autoResizeContent(), TRACE, and update().

{
  TRACE;
  Q_UNUSED(context);
  autoResizeContent();
  update();
}

Reimplemented from QGpCoreTools::XMLClass.

References showObject(), and TRACE.

{
  TRACE;
  Q_UNUSED(context);
  showObject(static_cast<GraphicObject *>(child));
  _loadedObjects.append(static_cast<GraphicObject *>(child));
}
virtual bool SciFigs::GraphicSheet::xml_setProperty ( XML_SETPROPERTY_ARGS  ) [inline, protected, virtual]

Re-implement this function to offer XML restore properties support to your class.

From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).

For a general case:

  Q_UNUSED(attributes);
  double val=content.toDouble();
  switch (memberID) {
  case 0:
    _x1=val;
    return true;
  case 1:
    _y1=val;
    return true;
  case 2:
    _x2=val;
    return true;
  case 3:
    _y2=val;
    return true;
  default:
    return false;
  }

For classes inheriting other classes (see also xml_member())

  switch (memberID) {
  case 0:
    _anInteger=content.toString();
    return true;
  case 1:
    _aString=content.toInt();
    return true;
  case 2:
    _aDouble=content.toDouble();
    return true;
  default:
    return AbstractLine::xml_setProperty(memberID-3, map, content);

For the arguments of this function use Macro XML_SETPROPERTY_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

{return qobject_setProperty(this, memberID, tag, attributes, content, context);}
virtual const QString& SciFigs::GraphicSheet::xml_tagName ( ) const [inline, virtual]

Reimplemented from QGpCoreTools::XMLClass.

References QGpCoreTools::XMLSaveAttributes::add(), objectList(), SciFigs::GraphicObject::objectName, SciFigs::XMLSciFigs::selection(), TRACE, and QGpCoreTools::XMLClass::xml_save().

{
  TRACE;
  QList<GraphicObject *> objectList;
  XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
  if(scifigsContext->selection())
    objectList=selectedObjects<GraphicObject *>();
  else
    objectList=graphicObjects();
  GraphicObject * obj;
  static const QString key("objectName");
  XMLSaveAttributes att;
  QString& value=att.add(key);
  foreach (obj, objectList) {
    value=obj->objectName();
    obj->xml_save(s, context, att);
  }
}

Member Data Documentation

const QString SciFigs::GraphicSheet::xmlGraphicSheetTag = "GraphicSheet" [static]

Property Documentation

QString SciFigs::GraphicSheet::name [read, write]

Count the number of objects currently in the sheet. This function is not inlined and should not be used directly in a loop. If possible, it is better to store the returned value before entering a loop.

QString SciFigs::GraphicSheet::objectList [read, write]
QString SciFigs::GraphicSheet::objectName [read, write]

Referenced by object().

QString SciFigs::GraphicSheet::objectOrder [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