Example #1
0
ExpressionEditorWidget::ExpressionEditorWidget(const iscore::DocumentContext& doc, QWidget *parent) :
    QWidget(parent),
    m_context{doc}
{
    m_mainLayout = new iscore::MarginLess<QVBoxLayout>{this};

    auto btnWidg = new QWidget{this};
    auto btnLay = new iscore::MarginLess<QHBoxLayout>{btnWidg};

    auto validBtn = new QPushButton{tr("Ok"), btnWidg};
    auto cancelBtn = new QPushButton{tr("Cancel"),btnWidg};
    btnLay->addWidget(validBtn);
    btnLay->addWidget(cancelBtn);

    m_mainLayout->addWidget(btnWidg);

    connect(validBtn, &QPushButton::clicked,
            this, &ExpressionEditorWidget::on_editFinished);
    connect(cancelBtn, &QPushButton::clicked,
            this, [&] ()
    {
        if(m_expression.isEmpty()) {
            for(auto& elt : m_relations)
            {
                delete elt;
            }
            m_relations.clear();
            addNewTerm();
        }
        else
            setExpression(*State::parseExpression(m_expression));
    });
}
Example #2
0
void ExpressionEditorWidget::setExpression(State::Expression e)
{
    for(auto& elt : m_relations)
    {
        delete elt;
    }
    m_relations.clear();

    exploreExpression(e);
    if(!e.hasChildren())
        addNewTerm();

    m_expression = currentExpr();
}
Example #3
0
void ROI::translate(int dx, int dy)
{
  if(dx == 0 && dy == 0)
    return;
  
  // revert to slower mode if a weighting kernel is used
  if(W_ != NULL)
  {
    anchorx_ += dx;
    anchory_ += dy;
    initialize();
    return;
  }
	
  if(abs(dx) >= width_ || abs(dy) >= height_)
  {
    anchorx_ += dx;
    anchory_ += dy;
    initialize();
    return;
  }
  
  int i, j;
  int il, ir, jt, jb;
  int x, y;
  
  // Subtract old values.
  jt = dy > 0 ? 0:height_ + dy;
  jb = dy > 0 ? dy:height_;
		
  for(j = jt; j < jb; j++)
  {
    for(i = 0; i < width_; i++)
    {
      x = anchorx_ + i;
      y = anchory_ + j;
      
      //coordHandler.clamp(x, y, x, y);
      //if(coordHandler.isInside(x, y))
      subtractOldTerm(x, y);
    }
  }
  
  il = dx > 0 ? 0:width_ + dx;
  ir = dx > 0 ? dx:width_;
  jt = dy > 0 ? dy:0;
  jb = dy > 0 ? height_:height_ + dy;
  
  for(j = jt; j < jb; j++)
  {
    for(i = il; i < ir; i++)
    {
      x = anchorx_ + i;
      y = anchory_ + j;
      
      //coordHandler.clamp(x, y, x, y);
      //if(coordHandler.isInside(x, y))
      subtractOldTerm(x, y);
    }
  }
  
  // Add new values.
  jt = dy > 0 ? height_:dy;
  jb = dy > 0 ? dy:0;
  
  for(j = jt; j < jb; j++)
  {
    for(i = 0; i < width_; i++)
    {
      x = anchorx_ + i;
      y = anchory_ + j;
      
      //coordHandler.clamp(x, y, x, y);
      //if(coordHandler.isInside(x, y))
      addNewTerm(x, y);
    }
  }

  il = dx > 0 ? width_:0;
  ir = dx > 0 ? width_ + dx:dx;
  jt = dy > 0 ? dy:0;
  jb = dy > 0 ? height_:height_ + dy;

  for(j = jt; j < jb; j++)
  {
    for(i = il; i < ir; i++)
    {
      x = anchorx_ + i;
      y = anchory_ + j;
      
      //coordHandler.clamp(x, y, x, y);
      //if(coordHandler.isInside(x, y))
      addNewTerm(x, y);
    }
  }

  anchorx_ += dx;
  anchory_ += dy;
}