Пример #1
0
MainWindow::MainWindow() {
  char buf[1024];
  Form1 = this;

  fgColor = vcg2bcc(G_color);

  canvas = new QAbstractScrollArea();
  canvas->viewport()->setBackgroundRole(QPalette::Base);
  canvas->viewport()->setAutoFillBackground(true);
  canvas->viewport()->setFocusPolicy(Qt::StrongFocus);
  canvas->viewport()->installEventFilter(this);
  canvas->verticalScrollBar()->setRange(0, 100);
  canvas->verticalScrollBar()->setValue(50);
  canvas->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  canvas->horizontalScrollBar()->setRange(0, 100);
  canvas->horizontalScrollBar()->setValue(50);
  canvas->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  connect(canvas->verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(scrollAction(int)));
  connect(canvas->horizontalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(scrollAction(int)));
  connect(canvas->verticalScrollBar(), SIGNAL(sliderReleased()), this, SLOT(scrollSliderReleased()));
  connect(canvas->horizontalScrollBar(), SIGNAL(sliderReleased()), this, SLOT(scrollSliderReleased()));
  setCentralWidget(canvas);

  createActions();
  createMenus();
  createToolBars();
  createStatusBar();

  readSettings();

  MOVING_CURSOR = new QCursor(Qt::OpenHandCursor);

  setCurrentFile("");
  setUnifiedTitleAndToolBarOnMac(true);

  update_origin_status();
  set_drawing_rectangle(canvas->size().width() - 4, canvas->size().height() - 4);

  QStringList args = qApp->arguments();

  int argc = args.size();
  char **argv = new char*[argc+1];
  for (int i = 0; i < argc; i++ ) {
    argv[i] = _strdup(args.at(i).toAscii().data());
  }
  argv[argc] = NULL;
  vcg_main(argc, argv);
  display_complete_graph();
  update_zoom_status();
  _snprintf(buf, sizeof(buf), "WinGraph32 - %s", G_title);
  setWindowTitle(buf);
  statistics();
  _snprintf(buf, sizeof(buf), "%d nodes, %d edge segments, %d crossings",
            st_nr_vis_nodes,
            st_nr_vis_edges,
            nr_crossings);
  setNodesValue(buf);

  resize(800, 600);
}
Пример #2
0
bool MainWindow::loadFile(const QString &fileName) {
	char buf[1024];
	char localFileName[800];
	QByteArray pstr;
	
	// convert fileName to localFileName
	// copy localFileName to Dataname
	pstr = fileName.toLatin1();						//possible alt .toAscii().data()
	strncpy(localFileName, pstr.data(), 800-1);
	strncpy(Dataname, localFileName, 800-1);
	parse_part();
	visualize_part();
	display_complete_graph();
	update_zoom_status();
	canvas->viewport()->update();
	_snprintf(buf, sizeof(buf), "WinGraph32 - %s", localFileName);
	setWindowTitle(buf);
	statistics();
	_snprintf(buf, sizeof(buf), "%d nodes, %d edge segments, %d crossings",
            st_nr_vis_nodes,
            st_nr_vis_edges,
            nr_crossings);
	setNodesValue(buf);

	resize(800, 600);
	return true;
}
Пример #3
0
/*
   When using the mouse wheel button to zoom in and out, it is more 
   intuitive to maintain the drawing zoom center-point based on the 
   cursor position. This can help orientation and prevent the drawing 
   from "jumping" around while zooming in and out.
 */
void
ddisplay_zoom_centered(DDisplay *ddisp, Point *point, real magnify)
{
  Rectangle *visible;
  real width, height;
  /* cursor position ratios */
  real rx,ry;

  if ((ddisp->zoom_factor <= DDISPLAY_MIN_ZOOM) && (magnify<=1.0))
    return;
  if ((ddisp->zoom_factor >= DDISPLAY_MAX_ZOOM) && (magnify>=1.0))
    return;

  visible = &ddisp->visible;

  /* calculate cursor position ratios */
  rx = (point->x-visible->left)/(visible->right - visible->left);
  ry = (point->y-visible->top)/(visible->bottom - visible->top);

  width = (visible->right - visible->left)/magnify;
  height = (visible->bottom - visible->top)/magnify;

  ddisp->zoom_factor *= magnify;

  /* set new origin based on the calculated ratios before zooming */
  ddisplay_set_origo(ddisp, point->x-(width*rx),point->y-(height*ry));

  ddisplay_update_scrollbars(ddisp);
  ddisplay_add_update_all(ddisp);
  ddisplay_flush(ddisp);

  update_zoom_status (ddisp);
}
Пример #4
0
void 
ddisplay_update_statusbar(DDisplay *ddisp)
{
  update_zoom_status (ddisp);
  update_snap_grid_status (ddisp);
  update_mainpoint_status (ddisp);
}
Пример #5
0
void MainWindow::cartFixed() {
  polarAct->setChecked(false);
  polarFixedAct->setChecked(false);
  cartAct->setChecked(false);
  cartFixedAct->setChecked(true);
  normalAct->setChecked(false);
  m_validate_fe(3);
  update_zoom_status();
  canvas->viewport()->update();
}
Пример #6
0
void MainWindow::normal() {
  //   normalAct->setIcon(QIcon(":/images/normalViewDown.png"));
  polarAct->setChecked(false);
  polarFixedAct->setChecked(false);
  cartAct->setChecked(false);
  cartFixedAct->setChecked(false);
  normalAct->setChecked(true);
  m_validate_fe(4);
  update_zoom_status();
  canvas->viewport()->update();
}
Пример #7
0
void
ddisplay_zoom(DDisplay *ddisp, Point *point, real magnify)
{
  Rectangle *visible;
  real width, height, old_zoom;

  visible = &ddisp->visible;

  if ((ddisp->zoom_factor <= DDISPLAY_MIN_ZOOM) && (magnify<=1.0))
    return;
  if ((ddisp->zoom_factor >= DDISPLAY_MAX_ZOOM) && (magnify>=1.0))
    return;

  old_zoom = ddisp->zoom_factor;
  ddisp->zoom_factor = old_zoom * magnify;

  /* clip once more */
  if (ddisp->zoom_factor < DDISPLAY_MIN_ZOOM)
    ddisp->zoom_factor = DDISPLAY_MIN_ZOOM;
  else if (ddisp->zoom_factor > DDISPLAY_MAX_ZOOM)
    ddisp->zoom_factor = DDISPLAY_MAX_ZOOM;

  /* the real one used - after clipping */
  magnify = ddisp->zoom_factor / old_zoom;
  width = (visible->right - visible->left)/magnify;
  height = (visible->bottom - visible->top)/magnify;


  ddisplay_set_origo(ddisp, point->x - width/2.0, point->y - height/2.0);
  
  ddisplay_update_scrollbars(ddisp);
  ddisplay_add_update_all(ddisp);
  ddisplay_flush(ddisp);

  update_zoom_status (ddisp);
}
Пример #8
0
void MainWindow::fitAll() {
  display_complete_graph();
  update_zoom_status();
  canvas->viewport()->update();
}
Пример #9
0
void MainWindow::zoomNormal() {
  set_fe_scaling(1, 1);
  update_zoom_status();
  canvas->viewport()->update();
}
Пример #10
0
void MainWindow::zoomOut() {
  change_fe_scaling(2, 3);
  update_zoom_status();
  canvas->viewport()->update();
}
Пример #11
0
void
display_set_active(DDisplay *ddisp)
{
  if (ddisp != active_display) {
    active_display = ddisp;

    /* perform notification here (such as switch layers dialog) */
    layer_dialog_set_diagram(ddisp ? ddisp->diagram : NULL);
    diagram_properties_set_diagram(ddisp ? ddisp->diagram : NULL);

    if (ddisp) {
      if (ddisp->is_standalone_window)
      {
        display_update_menu_state(ddisp);

        if (prefs.toolbox_on_top) {
          gtk_window_set_transient_for(GTK_WINDOW(interface_get_toolbox_shell()),
                                       GTK_WINDOW(ddisp->shell));
        } else {
          gtk_window_set_transient_for(GTK_WINDOW(interface_get_toolbox_shell()),
                                       NULL);
        }
      } else {
        GtkNotebook *notebook = g_object_get_data (G_OBJECT (ddisp->shell), 
                                                   DIA_MAIN_NOTEBOOK);
        /* Find the page with ddisp then set the label on the tab */
        gint num_pages = gtk_notebook_get_n_pages (notebook);
        gint num;
        GtkWidget *page;
        for (num = 0 ; num < num_pages ; num++)
        {
          page = gtk_notebook_get_nth_page (notebook,num);
          if (g_object_get_data (G_OBJECT (page), "DDisplay") == ddisp)
          {
            gtk_notebook_set_current_page (notebook,num);
            break;
          }
        }
        /* synchronize_ui_to_active_display (ddisp); */
        /* updates display title, etc */
        diagram_modified(ddisp->diagram);

        /* ZOOM */
        update_zoom_status (ddisp);

        /* Snap to grid */
        ddisplay_set_snap_to_grid (ddisp, ddisp->grid.snap); /* menus */

        /* Object snapping */
        ddisplay_set_snap_to_objects (ddisp, ddisp->mainpoint_magnetism);

        display_update_menu_state (ddisp);

        gtk_window_present (GTK_WINDOW(ddisp->shell));
      }
    } else {
      /* TODO: Prevent gtk_window_set_transient_for() in Integrated UI case */
      gtk_window_set_transient_for(GTK_WINDOW(interface_get_toolbox_shell()),
                                   NULL);
    }
  }
}