/*! 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(); }
/*! 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(); }
// constructor MyWindow::MyWindow(int w, int h) : red_active(false), red_set(*(new Polygon_set)), blue_set(*(new Polygon_set)), res_set(*(new Polygon_set)) { widget = new CGAL::Qt_widget(this); //Constructs a widget which is a child of this window /* Sets the central widget for this main window to w. * The central widget is surrounded by the left, top, right and bottom dock areas. * The menu bar is above the top dock area */ setCentralWidget(widget); file_name= QString::null; //create a timer for checking if somthing changed QTimer *timer = new QTimer( this ); // constructs a timer whose parent is this window connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); // connects the timer to the window timer->start( 200, FALSE ); // Starts the timer with a msec milliseconds timeout // file menu QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( "&File", file ); file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); file->insertSeparator(); file->insertItem("&Open Linear Polygon file", this, SLOT(open_linear_polygon_file()),CTRL+Key_O); file->insertItem("&Open DXF file", this, SLOT(open_dxf_file()),CTRL+Key_D); file->insertSeparator(); //file->insertItem("&Save",this ,SLOT(save_file()),CTRL+Key_S); //file->insertItem("&Save as",this ,SLOT(save_file_as())); file->insertSeparator(); file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); file->insertSeparator(); file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); // help menu QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertItem( "&Help", help ); help->insertItem("How To", this, SLOT(howto()), Key_F1); help->insertSeparator(); help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); help->insertItem("About &Qt", this, SLOT(aboutQt()) ); //the standard toolbar stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); radiotoolbar = new QToolBar(this, "polygon type"); blue_pgn = new QRadioButton ("Blue", radiotoolbar); blue_pgn->toggle(); red_pgn = new QRadioButton("Red", radiotoolbar); radio_group = new QVButtonGroup(this,"Radios"); radio_group->insert(blue_pgn); radio_group->insert(red_pgn); radio_group->setRadioButtonExclusive(true); connect(blue_pgn, SIGNAL(toggled (bool)), this, SLOT(radio_selected())); connect(red_pgn, SIGNAL(toggled (bool)), this, SLOT(radio_selected())); //layers //widget->attach(&testlayer); //the new tools toolbar newtoolbar = new Tools_toolbar(widget, this); // voronoi toolbar bops_toolbar = new QToolBar(this, "Boolean operations"); QIconSet set0(QPixmap( (const char**)intersection_xpm ), QPixmap( (const char**)intersection_xpm )); intersection_but = new QToolButton(bops_toolbar, "Boolean operations"); intersection_but->setAutoRaise(TRUE); intersection_but->setIconSet(set0); intersection_but->setTextLabel("Intersection "); connect(intersection_but,SIGNAL(pressed()), this, SLOT(perform_intersection())); QIconSet set1(QPixmap( (const char**)union_xpm ), QPixmap( (const char**)union_xpm )); bops_toolbar->addSeparator(); union_but = new QToolButton(bops_toolbar, "Boolean operations"); union_but->setAutoRaise(TRUE); union_but->setIconSet(set1); union_but->setTextLabel("Union "); connect(union_but,SIGNAL(pressed()), this, SLOT(perform_union())); QIconSet set2(QPixmap( (const char**)diff_PQ_xpm ), QPixmap( (const char**)diff_PQ_xpm )); bops_toolbar->addSeparator(); diff_but2 = new QToolButton(bops_toolbar, "Boolean operations"); diff_but2->setAutoRaise(TRUE); diff_but2->setIconSet(set2); diff_but2->setTextLabel("Difference between Blue and Red"); connect(diff_but2, SIGNAL(pressed()), this, SLOT(perform_diff2())); QIconSet set3(QPixmap( (const char**)diff_QP_xpm ), QPixmap( (const char**)diff_QP_xpm )); bops_toolbar->addSeparator(); diff_but = new QToolButton(bops_toolbar, "Boolean operations"); diff_but->setAutoRaise(TRUE); diff_but->setIconSet(set3); diff_but->setTextLabel("Difference between Red and Blue"); connect(diff_but, SIGNAL(pressed()), this, SLOT(perform_diff())); QIconSet set4(QPixmap( (const char**)symm_diff_xpm ), QPixmap( (const char**)symm_diff_xpm )); bops_toolbar->addSeparator(); symm_diff_but = new QToolButton(bops_toolbar, "Boolean operations"); symm_diff_but->setAutoRaise(TRUE); symm_diff_but->setIconSet(set4); symm_diff_but->setTextLabel("Symmetric Difference "); connect(symm_diff_but, SIGNAL(pressed()), this, SLOT(perform_symm_diff())); QIconSet set12(QPixmap( (const char**)mink_sum_xpm ), QPixmap( (const char**)mink_sum_xpm )); bops_toolbar->addSeparator(); mink_sum_but = new QToolButton(bops_toolbar, "Boolean operations"); mink_sum_but->setAutoRaise(TRUE); mink_sum_but->setIconSet(set12); mink_sum_but->setTextLabel("Minkowski Sum "); connect(mink_sum_but, SIGNAL(pressed()), this, SLOT(perform_mink_sum())); QIconSet set5(QPixmap( (const char**)comp_P_xpm ), QPixmap( (const char**)comp_P_xpm )); bops_toolbar->addSeparator(); blue_complement_but = new QToolButton(bops_toolbar, "Boolean operations"); blue_complement_but->setAutoRaise(TRUE); blue_complement_but->setIconSet(set5); blue_complement_but->setTextLabel("Blue Complement "); connect(blue_complement_but, SIGNAL(pressed()), this, SLOT(perform_blue_complement())); QIconSet set6(QPixmap( (const char**)comp_Q_xpm ), QPixmap( (const char**)comp_Q_xpm )); bops_toolbar->addSeparator(); red_complement_but = new QToolButton(bops_toolbar, "Boolean operations"); red_complement_but->setAutoRaise(TRUE); red_complement_but->setIconSet(set6); red_complement_but->setTextLabel("Red Complement "); connect(red_complement_but, SIGNAL(pressed()), this, SLOT(perform_red_complement())); QIconSet set7(QPixmap( (const char**)make_P_xpm ), QPixmap( (const char**)make_P_xpm )); bops_toolbar->addSeparator(); make_res_blue_but = new QToolButton(bops_toolbar, "Boolean operations"); make_res_blue_but->setAutoRaise(TRUE); make_res_blue_but->setIconSet(set7); make_res_blue_but->setTextLabel("Make Result Blue"); connect(make_res_blue_but,SIGNAL(pressed()), this, SLOT(make_res_blue())); QIconSet set8(QPixmap( (const char**)make_Q_xpm ), QPixmap( (const char**)make_Q_xpm )); bops_toolbar->addSeparator(); make_res_red_but = new QToolButton(bops_toolbar, "Boolean operations"); make_res_red_but->setAutoRaise(TRUE); make_res_red_but->setIconSet(set8); make_res_red_but->setTextLabel("Make Result Red"); connect(make_res_red_but,SIGNAL(pressed()), this, SLOT(make_res_red())); QIconSet set9(QPixmap( (const char**)refresh_xpm ), QPixmap( (const char**)refresh_xpm )); bops_toolbar->addSeparator(); refresh_but = new QToolButton(bops_toolbar, "Boolean operations"); refresh_but->setAutoRaise(TRUE); refresh_but->setIconSet(set9); refresh_but->setTextLabel("Refresh "); connect(refresh_but,SIGNAL(pressed()), this, SLOT(refresh())); QIconSet set10(QPixmap( (const char**)del_P_xpm ), QPixmap( (const char**)del_P_xpm )); bops_toolbar->addSeparator(); delete_blue_but = new QToolButton(bops_toolbar, "Boolean operations"); delete_blue_but->setAutoRaise(TRUE); delete_blue_but->setIconSet(set10); delete_blue_but->setTextLabel("Delete Blue Polygons"); connect(delete_blue_but,SIGNAL(pressed()), this, SLOT(delete_blue_polygons())); QIconSet set11(QPixmap( (const char**)del_Q_xpm ), QPixmap( (const char**)del_Q_xpm )); bops_toolbar->addSeparator(); delete_red_but = new QToolButton(bops_toolbar, "Boolean operations"); delete_red_but->setAutoRaise(TRUE); delete_red_but->setIconSet(set11); delete_red_but->setTextLabel("Delete Red Polygons"); connect(delete_red_but,SIGNAL(pressed()), this, SLOT(delete_red_polygons())); *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor (CGAL::BLACK); resize(w,h); widget->set_window(-1, 1, -1, 1); widget->setMouseTracking(TRUE); //connect the widget to the main function that receives the objects connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_new_object(CGAL::Object))); //application flag stuff old_state = 0; current_state = 1; red_active = false; red_set.clear(); blue_set.clear(); res_set.clear(); }