Exemplo n.º 1
0
void
QcViewport::pan(const QcVectorDouble & translation)
{
  // Fixme: translation unit are screen px
  QcVectorDouble position = projected_center_coordinate() + from_px(translation) * QcVectorDouble(1., -1.);
  set_center(from_projected_coordinate(position));
}
Exemplo n.º 2
0
void
QcViewport::set_projection(const QcProjection * projection)
{
  if (!m_projection or *projection != *m_projection) {
    m_projection = projection; // Fixme: passing ‘const QcProjection’ as ‘this’ argument discards qualifiers
    m_is_web_mercator = *projection == QcWebMercatorCoordinate().cls_projection;
    QcWgsCoordinate coordinate(projection->wgs84_origin());
    set_center(coordinate);
  }
}
Exemplo n.º 3
0
void
QcViewport::zoom_at(const QcWgsCoordinate & coordinate, unsigned int zoom_level)
{
  // qInfo() << coordinate << zoom_level;
  if (zoom_level != m_state.zoom_level() and m_zoom_level_interval.contains(zoom_level)) {
    begin_state_transaction();
    m_state.set_zoom_level(zoom_level);
    set_center(coordinate); // move and scale polygon
    end_state_transaction();
  }
}
Exemplo n.º 4
0
void set_second(void){
     int new_w = (((ttyclock->option.second = !ttyclock->option.second)) ? SECFRAMEW : NORMFRAMEW);
     int y_adj;

     for(y_adj = 0; (ttyclock->geo.y - y_adj) > (COLS - new_w - 1); ++y_adj);

     clock_move(ttyclock->geo.x, (ttyclock->geo.y - y_adj), new_w, ttyclock->geo.h);

     set_center(ttyclock->option.center);

     return;
}
Exemplo n.º 5
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);
  }
}
Exemplo n.º 6
0
void
QcViewport::stable_zoom(const QcVectorDouble & screen_position, unsigned int zoom_level)
{
  // qInfo() << screen_position << zoom_level;

  // Fixme: (from map_gesture_area) event position == pre_zoom_point ???

  if (!m_zoom_level_interval.contains(zoom_level))
    return;

  begin_state_transaction(); // Fixme: ok ?

  // Fixme: ???
  QcWgsCoordinate coordinate = screen_to_coordinate(screen_position, false);
  QcVectorDouble pre_zoom_point = coordinate_to_screen(coordinate, false);
  if (!isnan(pre_zoom_point.x()))
    qWarning() << "pre is undefined";

  set_zoom_level(zoom_level);

  QcVectorDouble post_zoom_point = coordinate_to_screen(coordinate, false);
  if (!isnan(post_zoom_point.x()))
    qWarning() << "post is undefined";

  // qInfo() << coordinate << screen_position << '\n' << pre_zoom_point << '\n' << post_zoom_point;
  if (!isnan(pre_zoom_point.x()) and !isnan(post_zoom_point.x()) and pre_zoom_point != post_zoom_point) {
    // Keep location under pointer
    QcVectorDouble delta_px = post_zoom_point - pre_zoom_point;
    // Fixme: improve
    QcVectorDouble map_center_point = QcVectorDouble(width(), height()) * .5 + delta_px;
    QcWgsCoordinate center_coordinate = screen_to_coordinate(map_center_point, false);
    set_center(center_coordinate);
  }

  end_state_transaction();
}
Exemplo n.º 7
0
void
key_event(void)
{
     int i, c;

     struct timespec length = { 0, ttyclock->option.delay };

     switch(c = wgetch(stdscr))
     {
     case KEY_UP:
     case 'k':
     case 'K':
          if(ttyclock->geo.x >= 1
             && !ttyclock->option.center)
               clock_move(ttyclock->geo.x - 1, ttyclock->geo.y, ttyclock->geo.w, ttyclock->geo.h);
          break;

     case KEY_DOWN:
     case 'j':
     case 'J':
          if(ttyclock->geo.x <= (LINES - ttyclock->geo.h - DATEWINH)
             && !ttyclock->option.center)
               clock_move(ttyclock->geo.x + 1, ttyclock->geo.y, ttyclock->geo.w, ttyclock->geo.h);
          break;

     case KEY_LEFT:
     case 'h':
     case 'H':
          if(ttyclock->geo.y >= 1
             && !ttyclock->option.center)
               clock_move(ttyclock->geo.x, ttyclock->geo.y - 1, ttyclock->geo.w, ttyclock->geo.h);
          break;

     case KEY_RIGHT:
     case 'l':
     case 'L':
          if(ttyclock->geo.y <= (COLS - ttyclock->geo.w - 1)
             && !ttyclock->option.center)
               clock_move(ttyclock->geo.x, ttyclock->geo.y + 1, ttyclock->geo.w, ttyclock->geo.h);
          break;

     case 'q':
     case 'Q':
          ttyclock->running = False;
          break;

     case 's':
     case 'S':
          set_second();
          break;

     case 't':
     case 'T':
          ttyclock->option.twelve = !ttyclock->option.twelve;
          /* Set the new ttyclock->date.datestr to resize date window */
          update_hour();
          clock_move(ttyclock->geo.x, ttyclock->geo.y, ttyclock->geo.w, ttyclock->geo.h);
          break;

     case 'c':
     case 'C':
          set_center(!ttyclock->option.center);
          break;

     case 'b':
     case 'B':
          set_bottom(!ttyclock->option.bottom);
          break;

     case 'r':
     case 'R':
          ttyclock->option.rebound = !ttyclock->option.rebound;
          if(ttyclock->option.rebound && ttyclock->option.center)
               ttyclock->option.center = False;
          break;
     default:
          nanosleep(&length, NULL);
          for(i = 0; i < 8; ++i)
               if(c == (i + '0'))
               {
                    ttyclock->option.color = i;
                    init_pair(1, ttyclock->bg, i);
                    init_pair(2, i, ttyclock->bg);
               }
          break;
     }

     return;
}
Exemplo n.º 8
0
void
init(void)
{
     struct sigaction sig;
     ttyclock->bg = COLOR_BLACK;

     /* Init ncurses */
     initscr();
     cbreak();
     noecho();
     keypad(stdscr, True);
     start_color();
     curs_set(False);
     clear();

     /* Init default terminal color */
     if(use_default_colors() == OK)
          ttyclock->bg = -1;

     /* Init color pair */
     init_pair(0, ttyclock->bg, ttyclock->bg);
     init_pair(1, ttyclock->bg, ttyclock->option.color);
     init_pair(2, ttyclock->option.color, ttyclock->bg);
     refresh();

     /* Init signal handler */
     sig.sa_handler = signal_handler;
     sig.sa_flags   = 0;
     sigaction(SIGWINCH, &sig, NULL);
     sigaction(SIGTERM,  &sig, NULL);
     sigaction(SIGINT,   &sig, NULL);
     sigaction(SIGSEGV,  &sig, NULL);

     /* Init global struct */
     ttyclock->running = True;
     if(!ttyclock->geo.x)
          ttyclock->geo.x = 0;
     if(!ttyclock->geo.y)
          ttyclock->geo.y = 0;
     if(!ttyclock->geo.a)
          ttyclock->geo.a = 1;
     if(!ttyclock->geo.b)
          ttyclock->geo.b = 1;
     ttyclock->geo.w = (ttyclock->option.second) ? SECFRAMEW : NORMFRAMEW;
     ttyclock->geo.h = 7;
     ttyclock->tm = localtime(&(ttyclock->lt));
     ttyclock->lt = time(NULL);
     update_hour();

     /* Create clock win */
     ttyclock->framewin = newwin(ttyclock->geo.h,
                                 ttyclock->geo.w,
                                 ttyclock->geo.x,
                                 ttyclock->geo.y);
     box(ttyclock->framewin, 0, 0);

     /* Create the date win */
     if (ttyclock->option.date)
     {
          ttyclock->datewin = newwin(DATEWINH, strlen(ttyclock->date.datestr) + 2,
                                     ttyclock->geo.x + ttyclock->geo.h - 1,
                                     ttyclock->geo.y + (ttyclock->geo.w / 2) -
                                     (strlen(ttyclock->date.datestr) / 2) - 1);
          box(ttyclock->datewin, 0, 0);
          clearok(ttyclock->datewin, True);
     }

     set_center(ttyclock->option.center);
     set_bottom(ttyclock->option.bottom);

     nodelay(stdscr, True);

     if (ttyclock->option.date)
     {
          wrefresh(ttyclock->datewin);
     }

     wrefresh(ttyclock->framewin);

     return;
}
Exemplo n.º 9
0
void init(void){
     struct sigaction sig;
     ttyclock->bg = COLOR_BLACK;

     /* Init ncurses */
     if (ttyclock->tty) {
	     FILE *ftty = fopen(ttyclock->tty, "r+");
	     if (!ftty) {
		     fprintf(stderr, "tty-clock: error: '%s' couldn't be opened: %s.\n",
				     ttyclock->tty, strerror(errno));
		     exit(EXIT_FAILURE);
	     }
	     ttyclock->ttyscr = newterm(NULL, ftty, ftty);
	     assert(ttyclock->ttyscr != NULL);
	     set_term(ttyclock->ttyscr);
     } else
	     initscr();

     cbreak();
     noecho();
     keypad(stdscr, True);
     start_color();
     curs_set(False);
     clear();

     /* Init default terminal color */
     if(use_default_colors() == OK)
          ttyclock->bg = -1;

     /* Init color pair */
     init_pair(0, ttyclock->bg, ttyclock->bg);
     init_pair(1, ttyclock->bg, ttyclock->option.color);
     init_pair(2, ttyclock->option.color, ttyclock->bg);
     refresh();

     /* Init signal handler */
     sig.sa_handler = signal_handler;
     sig.sa_flags   = 0;
     sigaction(SIGWINCH, &sig, NULL);
     sigaction(SIGTERM,  &sig, NULL);
     sigaction(SIGINT,   &sig, NULL);
     sigaction(SIGSEGV,  &sig, NULL);

     /* Init global struct */
     ttyclock->running = True;
     if(!ttyclock->geo.x)
          ttyclock->geo.x = 0;
     if(!ttyclock->geo.y)
          ttyclock->geo.y = 0;
     if(!ttyclock->geo.a)
          ttyclock->geo.a = 1;
     if(!ttyclock->geo.b)
          ttyclock->geo.b = 1;
     ttyclock->geo.w = (ttyclock->option.second) ? SECFRAMEW : NORMFRAMEW;
     ttyclock->geo.h = 7;
     ttyclock->tm = localtime(&(ttyclock->lt));
     if(ttyclock->option.utc) {
         ttyclock->tm = gmtime(&(ttyclock->lt));
     }
     ttyclock->lt = time(NULL);
     update_hour();

     /* Create clock win */
     ttyclock->framewin = newwin(ttyclock->geo.h,
                                 ttyclock->geo.w,
                                 ttyclock->geo.x,
                                 ttyclock->geo.y);
     if(ttyclock->option.box) {
           box(ttyclock->framewin, 0, 0);
     }

     if (ttyclock->option.bold)
     {
          wattron(ttyclock->framewin, A_BLINK);
     }

     /* Create the date win */
     ttyclock->datewin = newwin(DATEWINH, strlen(ttyclock->date.datestr) + 2,
                                ttyclock->geo.x + ttyclock->geo.h - 1,
                                ttyclock->geo.y + (ttyclock->geo.w / 2) -
                                (strlen(ttyclock->date.datestr) / 2) - 1);
     if(ttyclock->option.box) {
          box(ttyclock->datewin, 0, 0);
     }
     clearok(ttyclock->datewin, True);

     set_center(ttyclock->option.center);

     nodelay(stdscr, True);

     if (ttyclock->option.date)
     {
          wrefresh(ttyclock->datewin);
     }

     wrefresh(ttyclock->framewin);

     /* Initialize the start timer */
     start_time = time(0);

     return;
}
Exemplo n.º 10
0
/**
 * @brief Updates the movement.
 */
void CircleMovement::update() {

  Movement::update();

  if (center_entity != NULL && center_entity->is_being_removed()) {
    set_center(Rectangle(
          center_entity->get_x() + center_point.get_x(),
          center_entity->get_y() + center_point.get_y()));
  }

  if (is_suspended()) {
    return;
  }

  bool update_needed = false;
  uint32_t now = System::now();

  // maybe it is time to stop or to restart
  if (current_radius != 0 && duration != 0 && now >= end_movement_date && wanted_radius != 0) {
    stop();
  }
  else if (current_radius == 0 && loop_delay != 0 && now >= restart_date && wanted_radius == 0) {
    set_radius(previous_radius);
    start();
  }

  // update the angle
  if (is_started()) {
    while (now >= next_angle_change_date) {

      current_angle += angle_increment;
      current_angle = (360 + current_angle) % 360;
      if (current_angle == initial_angle) {
        nb_rotations++;

        if (nb_rotations == max_rotations) {
          stop();
        }
      }

      next_angle_change_date += angle_change_delay;
      update_needed = true;
    }
  }

  // update the radius
  while (current_radius != wanted_radius && now >= next_radius_change_date) {

    current_radius += radius_increment;

    next_radius_change_date += radius_change_delay;
    update_needed = true;
  }

  // the center may have moved
  if (center_entity != NULL) {
    update_needed = true;
  }

  if (update_needed) {
    recompute_position();
  }
}
Exemplo n.º 11
0
void GL_widget_2::zoom(double ratio, double xc, double yc) {  
	xscal = xscal*ratio; yscal = yscal*ratio;
	set_center(xc, yc);
}
Exemplo n.º 12
0
		TITANIUM_PROPERTY_SETTER(Animation, center)
		{
			TITANIUM_ASSERT(argument.IsObject());
			set_center(js_to_Point(static_cast<JSObject>(argument)));
			return true;
		}
void
QcMapItem::set_center_qt(const QGeoCoordinate & coordinate)
{
  set_center(QcWgsCoordinate(coordinate));
}