示例#1
0
void main_window_t::wheelEvent(QWheelEvent * e)
{
   double old_zoom = zoom_;

   int delta = e->delta() / 8 / 15;
   if (delta > 0)
   {
      for (int i = 0; i != delta; ++i)
         zoom_ *= 1.1;
   }
   else if (delta < 0)
   {
      for (int i = 0; i != delta; --i)
         zoom_ /= 1.1;
   }

   point_2f pos(e->pos().x(), e->pos().y());
   point_2f sz(size().width() / 2, size().height() / 2);

   vector_2f diff = pos - sz;

   center_ += (old_zoom - zoom_) * vector_2f(diff.x, -diff.y);
   center_ = limit(center_);

   e->accept();

   viewer_->on_move(limit(screen_to_global(e->pos())));

   resize_impl(size().width(), size().height());
   updateGL();
}
示例#2
0
   void print(cg::visualization::printer_type & p) const
   {
      p.corner_stream() << "double-click to clear." << cg::visualization::endl
                        << "press mouse rbutton for add vertex (click to first point to complete contour)" << cg::visualization::endl
                        << "move vertex with rbutton" << cg::visualization::endl
                        << "eps:" << eps << cg::visualization::endl;


      for (size_t i = 0; i < points_.size(); ++i)
      {
         p.global_stream((point_2f)points_[i] + vector_2f(5, 0)) << i;
      }
   }
示例#3
0
void main_window_t::resize_impl(int screen_w, int screen_h)
{
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   vector_2f size = (zoom_ / 2) * vector_2f(screen_w, screen_h);

   point_2f left_bottom = center_ + (-size);
   point_2f right_top   = center_ + size;

   glOrtho(left_bottom.x, right_top.x, left_bottom.y, right_top.y, -1.0, 1.0);
   glViewport(0, 0, screen_w, screen_h);
}
示例#4
0
   void print(cg::visualization::printer_type & p) const
   {
      p.corner_stream() << "double-click to clear." << cg::visualization::endl
                        << "press mouse rbutton for add vertex (click to first point to complete contour)" << cg::visualization::endl
                        << "move vertex with rbutton" << cg::visualization::endl
                        << "yellow contour -- not ccw or convex" << cg::visualization::endl
                        << "green contour -- contains cursor" << cg::visualization::endl
                        << "red contour -- don't contains cursor" << cg::visualization::endl;

      for (size_t i = 0; i < points_.size(); ++i)
      {
         p.global_stream((point_2f)points_[i] + vector_2f(5, 0)) << i;
      }
   }