Exemple #1
0
QPointF Shape2DRing::getShapeControlPoint(size_t i) const
{
  RectF rect = m_inner_shape->getBoundingRect();
  switch(i)
  {
  case 0: return QPointF(rect.center().x(), rect.y1());
  case 1: return QPointF(rect.center().x(), rect.y0());
  case 2: return QPointF(rect.x0(),rect.center().y());
  case 3: return QPointF(rect.x1(),rect.center().y());
  }
  return QPointF();
}
/**
  * Slot responding on a change of a masking shape.
  */
void InstrumentWindowMaskTab::shapeChanged()
{
  if (!m_left) return; // check that everything is ok
  m_userEditing = false; // this prevents resetting shape proeprties by doubleChanged(...)
  RectF rect = m_instrWindow->getSurface()->getCurrentBoundingRect();
  m_doubleManager->setValue(m_left,rect.x0());
  m_doubleManager->setValue(m_top,rect.y1());
  m_doubleManager->setValue(m_right,rect.x1());
  m_doubleManager->setValue(m_bottom,rect.y0());
  for(QMap<QtProperty *,QString>::iterator it = m_doublePropertyMap.begin(); it != m_doublePropertyMap.end(); ++it)
  {
    m_doubleManager->setValue(it.key(),m_instrWindow->getSurface()->getCurrentDouble(it.value()));
  }
  for(QMap<QString,QtProperty *>::iterator it = m_pointPropertyMap.begin(); it != m_pointPropertyMap.end(); ++it)
  {
    QtProperty* prop = it.value();
    QList<QtProperty*> subs = prop->subProperties();
    if (subs.size() != 2) continue;
    QPointF p = m_instrWindow->getSurface()->getCurrentPoint(it.key());
    m_doubleManager->setValue(subs[0],p.x());
    m_doubleManager->setValue(subs[1],p.y());
  }
  m_userEditing = true;
}