示例#1
0
Qt_widget::Qt_widget(QWidget *parent, const char *name) :
  QWidget(parent, name), set_scales_to_be_done(false), Locked(0),
  _pointSize(4), _pointStyle(DISC) 
{ 
  setCaption("CGAL::Qt_widget");

  // initialize ranges and scales
  xmin_old = xmin = -1;
  xmax_old = xmax = 1;
  ymin_old = ymin = -1;
  ymax_old = ymax = 1;
  constranges=false;
  set_scales();
  emit(rangesChanged());

  // initialize the pixmap and the painter
  painter = new QPainter;
  printer = new QPrinter;
  pixmap = new QPixmap;
  matrix = new QWMatrix;

  pixmap->resize(size());
  painter->begin(pixmap);
  painter->setWorldMatrix(*matrix);

  // set properties
  painter->setRasterOp(CopyROP);
  setBackgroundColor(Qt::white);
  painter->setPen(QPen(Qt::black,2));

  clear();
}
示例#2
0
void QSLPlotArea::addPlotable(QSLPlotable *plt)
{
    if (mPlots.size() == 0) {
        mXminData = plt->xMin();
        mXmaxData = plt->xMax();
        mYminData = plt->yMin();
        mYmaxData = plt->yMax();
    } else {
        if (plt->xMin() < mXminData) mXminData = plt->xMin();
        if (plt->xMax() > mXmaxData) mXmaxData = plt->xMax();
        if (plt->yMin() < mYminData) mYminData = plt->yMin();
        if (plt->yMax() > mYmaxData) mYmaxData = plt->yMax();
    }

    QObject::connect(plt, SIGNAL(appearenceChanged()), this, SLOT(repaint()));
    QObject::connect(plt, SIGNAL(dataChanged()), this, SLOT(replot()));
    QObject::connect(plt, SIGNAL(rangesChanged()), this, SLOT(rescale()));

    plt->mParentPlot = this;
    mPlots.append(plt);

    setXrange(mXminData,mXmaxData);
    setYrange(mYminData,mYmaxData);

    emit plotsChanged();
}
示例#3
0
void Qt_widget::move_center(const double distx, const double disty)
{
  xmin += distx; xmin_old += distx;
  xmax += distx; xmax_old += distx;
  ymin += disty; ymin_old += disty;
  ymax += disty; ymax_old += disty;
  redraw();
  emit(rangesChanged());
}
示例#4
0
void QSLPlotCartesianSet::updateDataBounds()
{
    mXmin = mXmax = mX[0];
    mYmin = mYmax = mY[0];
    for (int i=0; i<mX.size(); i++) {
        if (mX[i] < mXmin) mXmin=mX[i];
        if (mX[i] > mXmax) mXmax=mX[i];
        if (mY[i] < mYmin) mYmin=mY[i];
        if (mY[i] > mYmax) mYmax=mY[i];
    }
    emit rangesChanged();
}
示例#5
0
void Qt_widget::set_window(const double x_min, const double x_max,
			   const double y_min, const double y_max,
			   bool const_ranges)
{
  xmin_old = xmin = x_min;
  xmax_old = xmax = x_max;
  ymin_old = ymin = y_min;
  ymax_old = ymax = y_max;
  constranges = const_ranges;
  set_scales();
  redraw();
  emit(rangesChanged());
}
示例#6
0
Qt_widget_history::Qt_widget_history(Qt_widget* parent, const char* name):
  QObject(parent, name), widget(parent)
{
  it = history_list.begin();

  connect(widget, SIGNAL(rangesChanged()),
	  this, SLOT(save()));
  
  // backward compatibility with CGAL-2.4
  connect(parent, SIGNAL(internal_back()),
	  this, SLOT(backward()));
  connect(parent, SIGNAL(internal_forth()),
	  this, SLOT(forward()));
  connect(parent, SIGNAL(internal_add_to_history()),
	  this, SLOT(save()));
  connect(parent, SIGNAL(internal_clear_history()),
	  this, SLOT(clear()));
};
示例#7
0
void Qt_widget::set_center(const double x, const double y)
{
  if (set_scales_to_be_done) return;

  if(xscal<1) {
    xmin = x - (int)(width()/xscal)/2;
    xmax = x + (int)(width()/xscal)/2;
    ymin = y - (int)(height()/yscal)/2;
    ymax = y + (int)(height()/yscal)/2;
  } else {
    xmin = x - (width()/xscal)/2;
    xmax = x + (width()/xscal)/2;
    ymin = y - (height()/yscal)/2;
    ymax = y + (height()/yscal)/2;
  }
  xmin_old = xmin;
  xmax_old = xmax;
  ymin_old = ymin;
  ymax_old = ymax;  
  redraw();
  emit(rangesChanged());
}