예제 #1
0
void MainWindow::graphMoveEvent(QMouseEvent *event)
{
  if (!(event->buttons() & Qt::LeftButton))  return;

  if (((event->pos() - dragStartPosition).manhattanLength()) < QApplication::startDragDistance()) return;

  BoxChecked(true);
  
  QPoint dis = (event->pos() - dragStartPosition);
  double xdis = dis.x();
  double ydis = dis.y();
  
  double x = M_PI*event->pos().x()/600.0;
  double y = event->pos().y()/400.0;
  
  double m = get_mag(x);
  bool in_passband = (m>-3);
	
  double y_db = -100.0*y + 10;
  bool above_stop = (-y_db < m);
  
  if (fabs(xdis) > fabs(ydis)) {
	// Bandpass or Bandstop
	if (get_filter_type() > 1) {
	  set_center(xdis);
	} else {
	  horiz_swipe(xdis,in_passband);
	}
  } else {
	vertical_swipe(-ydis,in_passband,above_stop);
  }

  order = get_order();
  ui->order->setText(QApplication::translate("MainWindow", std::to_string(order).c_str(), 0));
  ui->ripple->setText(QApplication::translate("MainWindow", std::to_string(ripple()).c_str(), 0));
  ui->fc->setText(QApplication::translate("MainWindow", std::to_string(fc()).c_str(), 0));
  
  QCPGraph* ptr = GetPtr();
  dragStartPosition = event->pos();
  if (ptr != NULL) {
	ui->customPlot->graph()->clearData();
	plot3(ui->customPlot);
  }
}
예제 #2
0
void MainWindow::graphMoveEvent(QMouseEvent *event)
{
  if (!(event->buttons() & Qt::LeftButton))  return;

  if (((event->pos() - dragStartPosition).manhattanLength()) 
	  < QApplication::startDragDistance()) return;

  QPoint dis = (event->pos() - dragStartPosition);
  double xdis = dis.x();
  double ydis = dis.y();

  if (std::abs(xdis) > std::abs(ydis)) {
    horiz_swipe(xdis,true);
  } else {
    vertical_swipe(-ydis,true,true);
  }
  QCPGraph* ptr = GetPtr();
  dragStartPosition = event->pos();
  if (ptr != NULL) {
	ui->customPlot->graph()->clearData();
	plot3(ui->customPlot);
  }
}