/*! update snap mode - change the snap mode and the relevant buttons * state after the snap mode button was clicked * \param on - true if the user activate the button. */ void MyWindow::updateSnapMode( bool on ) { // We peform downcasting from QWigdet* to Qt_widget_base_tab*, // as we know that only // Qt_widget_base_tab objects are stored in the tab pages. Qt_widget_base_tab *w_demo_p = static_cast<Qt_widget_base_tab *> (myBar->currentPage()); if (on) { setGridSnapMode->setEnabled( TRUE ); if (w_demo_p->snap_mode == SNAP_GRID) setGridSnapMode->setOn( TRUE ); else { setGridSnapMode->setOn( FALSE ); w_demo_p->snap_mode = SNAP_POINT; } w_demo_p->snap = true; } else { SnapMode old = w_demo_p->snap_mode; setGridSnapMode->setOn( FALSE ); setSnapMode->setOn( FALSE ); setGridSnapMode->setEnabled( FALSE ); w_demo_p->snap = false; w_demo_p->snap_mode = SNAP_NONE; if (old == SNAP_GRID) something_changed(); } }
void MyWindow::open_linear_polygon_file() { QString s = QFileDialog::getOpenFileName(file_name, QString::null, this, "open file dialog", "Choose a file" ); if (s==QString::null) return; file_name=s; std::ifstream in_file(s.ascii()); if (!in_file.is_open()) { QMessageBox::warning( widget,"Open","Can't open file"); return ; } CGAL::Bbox_2 box = CGAL::Bbox_2 (widget->x_min(), widget->y_min(), widget->x_max(), widget->y_max()); QCursor old = widget->cursor(); widget->setCursor(Qt::WaitCursor); widget->lock(); widget->clear_history(); Linear_polygon_2 pgn; in_file >> pgn; if (pgn.is_empty()) { widget->unlock(); widget->setCursor(old); return; } if (pgn.orientation() != CGAL::COUNTERCLOCKWISE) pgn.reverse_orientation(); const Polygon_2& circ_pgn = linear_2_circ(pgn); if (red_active) red_set.join(circ_pgn); else blue_set.join(circ_pgn); box = box + circ_pgn.bbox(); widget->set_window(box.xmin(), box.xmax(), box.ymin(), box.ymax()); widget->unlock(); newtoolbar->reset(); something_changed(); widget->setCursor(old); }
/*! hide the grid (can be applied only when we * are not in a grid snap mode. */ void MyWindow::hideGrid() { // We peform downcasting from QWigdet* to Qt_widget_base_tab*, // as we know that only // Qt_widget_base_tab objects are stored in the tab pages. Qt_widget_base_tab *w_demo_p = dynamic_cast<Qt_widget_base_tab *> (myBar->currentPage()); w_demo_p->grid = false; something_changed(); }
static void gnc_recurrence_init( GncRecurrence *gr ) { GtkVBox *vb; GtkHBox *hb; GtkWidget *w; GtkBuilder *builder; recurrenceSet(&gr->recurrence, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE); /* Open up the builder file */ builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "GCB_PeriodType_liststore"); gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "GSB_Mult_Adj"); gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "RecurrenceEntryVBox"); vb = GTK_VBOX(gtk_builder_get_object (builder, "RecurrenceEntryVBox")); hb = GTK_HBOX(gtk_builder_get_object (builder, "Startdate_hbox")); w = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE); gr->gde_start = w; gtk_box_pack_start (GTK_BOX (hb), w, TRUE, TRUE, 0); gtk_widget_show (w); gtk_widget_set_no_show_all(GTK_WIDGET(gr->gde_start), TRUE); gr->gcb_period = GTK_COMBO_BOX(gtk_builder_get_object (builder, "GCB_PeriodType")); gr->gsb_mult = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, "GSB_Mult")); gr->gcb_eom = GTK_CHECK_BUTTON(gtk_builder_get_object (builder, "GCB_EndOfMonth")); gr->nth_weekday = GTK_CHECK_BUTTON(gtk_builder_get_object (builder, "GCB_NthWeekday")); gtk_widget_set_no_show_all(GTK_WIDGET(gr->gcb_eom), TRUE); gtk_widget_set_no_show_all(GTK_WIDGET(gr->nth_weekday), TRUE); gtk_container_add( GTK_CONTAINER(&gr->widget), GTK_WIDGET(vb) ); gnc_recurrence_set(gr, &gr->recurrence); something_changed( GTK_WIDGET(gr), gr); /* Setup the signals */ g_signal_connect( G_OBJECT(gr->gde_start), "date_changed", G_CALLBACK(something_changed), gr ); g_signal_connect( G_OBJECT(gr->gcb_period), "changed", G_CALLBACK(something_changed), gr ); g_signal_connect( G_OBJECT(gr->gsb_mult), "value-changed", G_CALLBACK(something_changed), gr ); g_signal_connect( G_OBJECT(gr->gcb_eom), "toggled", G_CALLBACK(something_changed), gr ); g_signal_connect( G_OBJECT(gr->nth_weekday), "toggled", G_CALLBACK(something_changed), gr ); gtk_widget_show_all( GTK_WIDGET(&gr->widget) ); gtk_builder_connect_signals(builder, gr); g_object_unref(G_OBJECT(builder)); }
void MyWindow::backGroundColor() { QColor c = QColorDialog::getColor(); /* if the cancel button is pressed (in the modal color dialog that pops up * as a result of ::getColor()) then an invalid color is returned and no * change is made */ if (c.isValid()) { Qt_widget_base_tab *w_base_p = dynamic_cast<Qt_widget_base_tab *> (myBar->currentPage()); w_base_p->change_background_flag=TRUE; w_base_p->fill_face_color=c; TraitsType t = w_base_p->traits_type; switch ( t ) { case SEGMENT_TRAITS: { Qt_widget_demo_tab<Segment_tab_traits> *w_demo_p = static_cast<Qt_widget_demo_tab<Segment_tab_traits> *> (myBar->currentPage()); Seg_face_handle ubf = w_demo_p->m_curves_arr->unbounded_face(); w_demo_p->set_face_color(ubf,c); break; } case POLYLINE_TRAITS: { Qt_widget_demo_tab<Polyline_tab_traits> *w_demo_p = static_cast<Qt_widget_demo_tab<Polyline_tab_traits> *> (myBar->currentPage()); Pol_face_handle ubf = w_demo_p->m_curves_arr->unbounded_face(); w_demo_p->set_face_color(ubf,c); break; } case CONIC_TRAITS: { #ifdef CGAL_USE_CORE Qt_widget_demo_tab<Conic_tab_traits> *w_demo_p = static_cast<Qt_widget_demo_tab<Conic_tab_traits> *> (myBar->currentPage()); Conic_face_handle ubf = w_demo_p->m_curves_arr->unbounded_face(); w_demo_p->set_face_color(ubf,c); #endif break; } } something_changed(); } }
void MyWindow::changeVertexColor() { QColor c = QColorDialog::getColor(); /* if the cancel button is pressed (in the modal color dialog that pops up * as a result of ::getColor()) then an invalid color is returned and no * change is made */ if (c.isValid()) { Qt_widget_base_tab *w_demo_p = dynamic_cast<Qt_widget_base_tab *> (myBar->currentPage()); w_demo_p->vertex_color = c; w_demo_p->change_vertex_color = true; something_changed(); } }
/*! update grid snap mode - we have 2 states of snap * - to grid points * - to closest point in the planar map * \param on - true when we choos grid mode */ void MyWindow::updateGridSnapMode( bool on ) { // We peform downcasting from QWigdet* to Qt_widget_base_tab*, // as we know that only // Qt_widget_base_tab objects are stored in the tab pages. Qt_widget_base_tab *w_demo_p = static_cast<Qt_widget_base_tab *> (myBar->currentPage()); if (on && w_demo_p->snap) w_demo_p->snap_mode = SNAP_GRID; else w_demo_p->snap_mode = SNAP_POINT; something_changed(); }
/*! get_new_object - get a point object from current page * \param obj - a CGAL object */ void MyWindow::get_new_object(CGAL::Object obj) { // We peform downcasting from QWigdet* to Qt_widget_base_tab*, // as we know that only // Qt_widget_base_tab objects are stored in the tab pages. Qt_widget_base_tab *w_demo_p = static_cast<Qt_widget_base_tab *> (myBar->currentPage()); // point location Coord_point p; if(CGAL::assign(p,obj)) w_demo_p->pl_point = p; something_changed(); }
void MyWindow::new_instance() { newtoolbar->deactivate(); widget->lock(); file_name = QString::null; red_set.clear(); blue_set.clear(); widget->clear_history(); widget->set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval widget->unlock(); something_changed(); }
/*! initialize the widget */ void MyWindow::init(Qt_widget_base_tab *widget) { connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_new_object(CGAL::Object))); widget->attach(testlayer); widget->setCursor(QCursor( QPixmap( (const char**)small_draw_xpm))); rayShootingUpMode->setIconSet(QPixmap((const char**)demo_rayshoot_up_xpm )); rayShootingDownMode->setIconSet(QPixmap((const char**)demo_rayshoot_down_xpm )); widget->setBackgroundColor(def_bg_color); tab_number++; number_of_tabs++; // add the new widget to myBar myBar->insertTab( widget, QString("Arr " + QString::number( widget->index + 1 ) ), widget->index ); myBar->setCurrentPage(myBar->indexOf(widget)); update(); something_changed(); }
/*! properties form dialog */ void MyWindow::properties() { Qt_widget_base_tab *w_demo_p = static_cast<Qt_widget_base_tab *> (myBar->currentPage()); PropertiesForm *optionsForm = new PropertiesForm( myBar , this ,number_of_tabs ,w_demo_p , m_scailing_factor , colors_flag); if ( optionsForm->exec() ) { m_width = optionsForm->box1->value(); m_height = optionsForm->box2->value(); w_demo_p->m_line_width = optionsForm->box3->value(); w_demo_p->m_vertex_width = optionsForm->box8->value(); double new_factor = static_cast<double> (optionsForm->box4->value()); QString paint_mode = optionsForm->box5->currentText(); w_demo_p->cube_size = optionsForm->box6->value(); if (strcmp(paint_mode,"Different Colors At Overlay") == 0) colors_flag = true; else colors_flag = false; QString remove_mode = optionsForm->box7->currentText(); if (strcmp(remove_mode,"Remove entire original curve") == 0) w_demo_p->remove_org_curve = true; else w_demo_p->remove_org_curve = false; QString draw_vertex_mode = optionsForm->box9->currentText(); if (strcmp(draw_vertex_mode,"Draw") == 0) w_demo_p->draw_vertex = true; else w_demo_p->draw_vertex = false; m_scailing_factor = (new_factor/10); resize(m_width,m_height); w_demo_p->redraw(); something_changed(); } delete optionsForm; }
void MyWindow::make_res_blue() { if (res_set.is_empty()) { int answer = 0; answer = QMessageBox::warning(this, "Store result", QString( "Result is empty, all polygons will be deleted\n continue anyway?\n" ), "&Yes", "&No", QString::null, 1, 1 ); if (answer == 1) { // answer in 'no' make_res_blue_but->setDown(FALSE); return; } make_res_blue_but->setDown(FALSE); } blue_set = res_set; res_set.clear(); red_set.clear(); newtoolbar->reset(); something_changed(); }
Querytextedit::Querytextedit(QWidget *parent) : QTextEdit(parent) { this->mainwindow = (Mainwindow*) parent; this->highlighter = new MySQLHighlighter(this->document()); this->mainwindow->hist_menu = new QMenu(); this->drinlassen = new QAction(tr("So lassen"), this); this->drinlassen->setCheckable(true); this->einzeln = new QAction(tr("nur eins"), this); this->einzeln->setCheckable(true); this->behavior = new QActionGroup(this); this->behavior->addAction(this->drinlassen); this->behavior->addAction(this->einzeln); this->einzeln->setChecked(true); this->save = new QAction(tr("Save"), this); this->save->setShortcut(QKeySequence::Save); this->load = new QAction(tr("Load"), this); this->load->setShortcut(QKeySequence::Open); this->mainwindow->hist_menu->addAction(this->drinlassen); this->mainwindow->hist_menu->addAction(this->einzeln); this->mainwindow->hist_menu->addSeparator(); this->mainwindow->hist_menu->addAction(this->save); this->mainwindow->hist_menu->addAction(this->load); connect(this->save, SIGNAL(triggered()), this, SLOT(save_query())); connect(this->load, SIGNAL(triggered()), this, SLOT(load_query())); connect(this, SIGNAL(textChanged()), this, SLOT(something_changed())); this->hist_position = 0; hist_something_changed = false; }
/*! update widget mode * \param action - the new widget mode */ void MyWindow::updateMode( QAction *action ) { // We peform downcasting from QWigdet* to Qt_widget_base_tab*, // as we know that only // Qt_widget_base_tab objects are stored in the tab pages. Qt_widget_base_tab *w_demo_p = static_cast<Qt_widget_base_tab *> (myBar->currentPage()); if ( action == insertMode ) { w_demo_p->mode = MODE_INSERT; w_demo_p->setCursor(QCursor( QPixmap( (const char**)small_draw_xpm))); something_changed(); } else if ( action == deleteMode ) { w_demo_p->mode = MODE_DELETE; w_demo_p->setCursor(QCursor( QPixmap( (const char**)delete_xpm))); something_changed(); } else if ( action == pointLocationMode ) { w_demo_p->mode = MODE_POINT_LOCATION; w_demo_p->setCursor(Qt::CrossCursor); current_label = point_location_label; } else if ( action == rayShootingUpMode ) { w_demo_p->mode = MODE_RAY_SHOOTING_UP; w_demo_p->setCursor(QCursor(QPixmap((const char**)demo_arrow_up_xpm))); } else if( action == rayShootingDownMode ) { w_demo_p->mode = MODE_RAY_SHOOTING_DOWN; w_demo_p->setCursor(QCursor(QPixmap((const char**)demo_arrow_down_xpm))); } else if ( action == dragMode ) { w_demo_p->mode = MODE_DRAG; w_demo_p->setCursor(QCursor( QPixmap( (const char**)hand_xpm))); something_changed(); } else if ( action == mergeMode ) { w_demo_p->mode = MODE_MERGE; w_demo_p->setCursor(Qt::IbeamCursor ); something_changed(); } else if ( action == splitMode ) { w_demo_p->mode = MODE_SPLIT; w_demo_p->setCursor(Qt::SplitHCursor ); something_changed(); } else if ( action == fillfaceMode ) { w_demo_p->mode = MODE_FILLFACE; w_demo_p->setCursor(Qt::CrossCursor ); } }
void MyWindow::open_dxf_file() { QString s = QFileDialog::getOpenFileName(file_name, QString::null, this, "open file dialog", "Choose a file" ); if (s==QString::null) return; file_name=s; std::ifstream in_file(s.ascii()); if (!in_file.is_open()) { QMessageBox::warning( widget,"Open","Can't open file"); return ; } bool are_simple; int answer = 0; answer = QMessageBox::question(this, QString("Open file"), QString("Are all polygons simple and without holes?"), QString("Yes"), QString("No"), QString::null, 0 , 0); if (answer == 0) are_simple = true; else are_simple = false; CGAL::Bbox_2 box = CGAL::Bbox_2 (widget->x_min(), widget->y_min(), widget->x_max(), widget->y_max()); QCursor old = widget->cursor(); widget->setCursor(Qt::WaitCursor); widget->lock(); widget->clear_history(); CGAL::Dxf_bsop_reader<Kernel> reader; std::vector<Polygon_2> circ_polygons; std::vector<Polygon_with_holes> circ_polygons_with_holes; reader(in_file, std::back_inserter(circ_polygons), std::back_inserter(circ_polygons_with_holes), !are_simple); if (red_active) { red_set.join(circ_polygons.begin(), circ_polygons.end(), circ_polygons_with_holes.begin(), circ_polygons_with_holes.end()); } else { blue_set.join(circ_polygons.begin(), circ_polygons.end(), circ_polygons_with_holes.begin(), circ_polygons_with_holes.end()); } if (!circ_polygons.empty()) { box = circ_polygons.front().bbox(); } else if (!circ_polygons_with_holes.empty()) { box = circ_polygons_with_holes.front().outer_boundary().bbox(); } std::vector<Polygon_2>::iterator itr1 = circ_polygons.begin(); for(itr1 = circ_polygons.begin(); itr1 != circ_polygons.end(); ++itr1) { box = box + itr1->bbox(); } std::vector<Polygon_with_holes>::iterator itr2; for (itr2 = circ_polygons_with_holes.begin(); itr2 != circ_polygons_with_holes.end(); ++itr2) { box = box + itr2->outer_boundary().bbox(); } widget->set_window(box.xmin(), box.xmax(), box.ymin(), box.ymax()); widget->unlock(); newtoolbar->reset(); something_changed(); widget->setCursor(old); }
void MyWindow::upperEnvelope(bool b) { upper_env = b; something_changed(); }
/*! update traits type * \param action the new traits type */ void MyWindow::updateTraitsType( QAction *action ) { Qt_widget_base_tab *old_widget = static_cast<Qt_widget_base_tab *> (myBar->currentPage()); Qt_widget_base_tab * widget = 0; int old_index = old_widget->index; if (action == setSegmentTraits) { if (old_widget->traits_type == SEGMENT_TRAITS) return; widget = new Qt_widget_demo_tab<Segment_tab_traits> (SEGMENT_TRAITS , this, old_index, old_widget->edge_color); } else if (action == setPolylineTraits) { if (old_widget->traits_type == POLYLINE_TRAITS) return; widget = new Qt_widget_demo_tab<Polyline_tab_traits> (POLYLINE_TRAITS , this, old_index, old_widget->edge_color); } #ifdef CGAL_USE_CORE else if (action == setConicTraits) { if (old_widget->traits_type == CONIC_TRAITS) return; widget = new Qt_widget_demo_tab<Conic_tab_traits> (CONIC_TRAITS , this, old_index, old_widget->edge_color); } #endif if( !old_widget->is_empty() ) // pm is not empty { switch( QMessageBox::warning( this, "Update Traits Type", "This action will destroy the current planar map.\n" "Do you want to continue ?", "Yes", "No", 0, 0, 1 ) ) { case 0: // continue break; case 1: // The user clicked the Quit or pressed Escape update(); something_changed(); return; break; } } int index = myBar->currentPageIndex(); QString label = myBar->label(index); myBar->removePage(myBar->currentPage()); //initialize the new tab widget *widget << CGAL::LineWidth(2); widget->setBackgroundColor(def_bg_color); widget->setMouseTracking(TRUE); connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_new_object(CGAL::Object))); widget->attach(testlayer); widget->m_line_width = 2; widget->index = old_index; widget->setCursor(QCursor( QPixmap( (const char**)small_draw_xpm))); rayShootingUpMode->setIconSet(QPixmap((const char**)demo_rayshoot_up_xpm )); rayShootingDownMode->setIconSet(QPixmap((const char**)demo_rayshoot_down_xpm )); // add the new widget to myBar myBar->insertTab( widget, label , index ); myBar->setCurrentPage(index); update(); something_changed(); }