void MainWindow::connectSignals() {
    //connect command buttons
    connect(s_button.addCurve,SIGNAL(clicked()),SLOT(newCurve()));
    connect(s_button.removeCurve,SIGNAL(clicked()),SLOT(removeCurve()));
    connect(s_button.duplicateCurves,SIGNAL(clicked()),SLOT(duplicateCurves()));

#ifdef COMPLETE_FAST_SELECTION
    connect(s_button.removeAllCurves,SIGNAL(clicked()),SLOT(removeAllCurvesWithDialog()));
    connect(s_button.exportDigest,SIGNAL(clicked()),SLOT(exportDigestCurve()));
    connect(s_button.exportXML ,SIGNAL(clicked()),SLOT(exportXML()));
    connect(s_button.importXML,SIGNAL(clicked()),SLOT(importXML()));
    connect(s_button.showXML ,SIGNAL(clicked()),SLOT(showXML()));
#endif

    //If the sample rate change i need to reset the audio stream
   // connect(m_plotTime->getDigestCurve(),SIGNAL(sampleRateChanged(qreal)),this,SLOT(sampleRateChange(qreal)));

    //connect digest curve to handle update in the plots
    Q_ASSERT(connect(m_plotTime->getDigestCurve(),SIGNAL(dataChanged()),this,SLOT(digestCurveChanged())));

    //Connect position slider
    Q_ASSERT(connect(m_audioPlayer,SIGNAL(streamTimePositionChanged(qreal)) ,this,SLOT(streamPositionUpdate(qreal))));
}
PlotControlWindow::PlotControlWindow(const int plotId, PlotArea *parent) :
    QMainWindow(parent),
    ui(new Ui::PlotControlWindow)
{
    ui->setupUi(this);
    mPlot = parent->getPlotWidget();
    mPlotId = plotId;

    init();
    initFromConfig();

    // Dialog
    connect(this->ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(this->ui->buttonBox, SIGNAL(accepted()), this, SLOT(close()));
    connect(this->ui->buttonBox, SIGNAL(accepted()), parent, SLOT(plotConfigChanged()));
    connect(this->ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
    QPushButton* applyButton = ui->buttonBox->button(QDialogButtonBox::Apply);
    connect(applyButton, SIGNAL(clicked()), this, SLOT(apply()));
    connect(ui->autoOrdinate, SIGNAL(toggled(bool)), this, SLOT(autoOrdinateChecked(bool)));

    // Curve page
    connect(ui->newCurveButton, SIGNAL(clicked()), this, SLOT(newCurve()));
    connect(ui->curveSelection, SIGNAL(doubleClicked ( const QModelIndex &)), this, SLOT(editCurve(const QModelIndex &)));
    connect(ui->deleteCurveButton, SIGNAL(clicked()), this, SLOT(deleteSelectedCurve()));

    // Function page
    connect(ui->functionNew, SIGNAL(clicked()), this, SLOT(newFunction()));
    connect(ui->functionHierarchicalNew, SIGNAL(clicked()), this, SLOT(newHierarachicalFunction()));
    connect(ui->functionIntegralNew, SIGNAL(clicked()), this, SLOT(newIntegralFunction()));
    connect(ui->functionDifferentialNew, SIGNAL(clicked()), this, SLOT(newDifferentialFunction()));
    connect(ui->functionView, SIGNAL(doubleClicked ( const QModelIndex &)), this, SLOT(editFunction(const QModelIndex &)));
    connect(ui->functionDelete, SIGNAL(clicked()), this, SLOT(deleteFunction()));
    connect(ui->functionEditCurve, SIGNAL(clicked()), this, SLOT(editFunctionCurve()));

    setWindowModality(Qt::NonModal);
}
void MainWindow::connectMenusAndShortcut() {
       // connect(ui-> ,SIGNAL(triggered()),this,SLOT );
    //---------File menu
    {
        //NEW
        Q_ASSERT(connect(ui->actionNew_Project,SIGNAL(triggered()),this,SLOT(newProject())));
        //LOAD
        Q_ASSERT(connect(ui->actionLoad_Project ,SIGNAL(triggered()),this,SLOT(load())));
        //SAVE
        Q_ASSERT(connect(ui->actionSave_project,SIGNAL(triggered()),this,SLOT(save())));
        //SAVE AS
        Q_ASSERT(connect(ui->actionSave_as,SIGNAL(triggered()),this,SLOT(saveAs())));
        //Import curve
        Q_ASSERT(connect(ui->actionImport_curve,SIGNAL(triggered()),this,SLOT( importCurve())));
        //EXPORT AUDIO FILE
        Q_ASSERT(connect(ui->actionExport_audio_file,SIGNAL(triggered()),this,SLOT(exportDigestCurve())));
    }

    //---------Curves menu
    {
        //NEW CURVE
        Q_ASSERT(connect(ui->actionAdd_curve,SIGNAL(triggered()),this,SLOT(newCurve())));
        //DUPLICATE
        connect(ui->actionDuplicate_curves,SIGNAL(triggered()),this,SLOT(duplicateCurves()));
        //REMOVE ALL
        Q_ASSERT(connect(ui->actionRemove_all_curves,SIGNAL(triggered()),this,SLOT(removeAllCurvesWithDialog())));
        //REMOVE ONE
        Q_ASSERT(connect(ui->actionRemove_curve ,SIGNAL(triggered()),this,SLOT(removeCurve())));
    }

    //---------Show menu
    // connect(ui->actionShow_Proj_struct,SIGNAL(triggered()),this,SLOT(showXML()));

    //---------About menu

}
Beispiel #4
0
static void read_curves_and_surfaces(int argc, char *argv[])
{
  xscale=yscale=zscale=1.0;
  int ref=DEFAULT_REF; // Number of new knots between old ones.
  int maxref=DEFAULT_MAX_REF; // Maximal number of coeffs in any given direction.
  // (n, n) makes sure new knots are inserted close to max limit = n...
  int i;

  //
  // This must be reset every time we change control vertices, since
  // the discretization is done in the drawing routine.
  //
  for (i=0; i<curves; i++) {
    if (discr_curve[i]!=NULL) {
      delete discr_curve[i];
      discr_curve[i]=NULL;
    }
  }

  // @HH@
  // @HH@ Use the following optional command line options:
  // @HH@
  
  surfaces=0;
  curves=0;



  for (i=1; i<argc; i++) {
    switch (argv[i][0]) {
    case 's': {
      // Next string is filename for surface. (One surface.)
	    
      puts("Reading surfaces");
      // surface[surfaces-1]=read_nurbs_sf(argv[i+1]); // old format    

      std::vector<SISLSurf*> tmp;
      std::ifstream is(argv[i+1]);
      if (!is) {
	CRIT_ERR(printf("Could not open file: '%s'.\n", argv[i+1]));
      }
      try {
	eatwhite(is);
	while (!is.eof()) {
	  //surface[surfaces-1] = readGoSurface(is);
	  tmp.push_back(readGoSurface(is));
	  eatwhite(is);
	}
      } catch (std::exception& e) {
	CRIT_ERR(printf("Error occured while reading surface: %s\n", e.what()));
      }
      is.close();
      int num_surfaces = tmp.size();
      if (surfaces + num_surfaces > MAX_SURFACES) {
	CRIT_ERR(puts("Increase MAX_SURFACES."));
      }
	    
      for (int k = 0; k < num_surfaces; ++k) {
	//
	// 010116: This should be a quick fix for periodic
	//         surfaces...
	//
	if (tmp[k] == NULL) {
	  CRIT_ERR(printf("Couldn't read SISLSurf '%s'.\n", argv[i+1]));	    
	}

	if ((tmp[k]->cuopen_1 == SISL_CRV_PERIODIC ||
	     tmp[k]->cuopen_2 == SISL_CRV_PERIODIC)) {
	  int kstat;
	  SISLSurf *tmp_surf;
	  make_sf_kreg(tmp[k], &tmp_surf, &kstat);
	  if (kstat < 0) {
	    CRIT_ERR(printf("make_sf_kreg failed!\n"));
	  }
	  freeSurf(tmp[k]);
	  tmp[k] = tmp_surf;
	}
	if (tmp[k]->idim != 3) {
	  CRIT_ERR(printf("Dimension of surface is %d and not 3!\n",
			  tmp[k]->idim));
	}
		
	if (surface[surfaces]) {
	  // deleting old surface
	  freeSurf(surface[surfaces]);
	}
	surface[surfaces] = tmp[k];
	surface_name[surfaces] = argv[i+1];
	surf_enabled[surfaces] = 1;

	// Generating an approximating polygon.
	lower_degree_and_subdivide(surface + surfaces, ref, maxref);

	// evaluating normals (normalized)
	delete normal[surfaces];
	compute_surface_normals(surface[surfaces], normal + surfaces);
		
	++surfaces;
      }
    }
      i++;
      break;
      
    case 'c': {
      // Next string is filename for file containing 1 curve.
	    
      printf("Reading a single curve into slot %d.\n", curves);

      std::vector<SISLCurve*> tmp;
	    
      //n=get_curve_set(argv[i+1], &tmp, &stat);
      //get_single_curve(argv[i+1], &tmp, &stat); // old format
      std::ifstream is(argv[i+1]);
      if (!is) {
	CRIT_ERR(printf("Could not open file: '%s'.\n", argv[i+1]));
      }
      try {
	eatwhite(is);
	while (!is.eof()) {
	  tmp.push_back(readGoCurve(is));
	  eatwhite(is);
	}
      } catch (std::exception& e) {
	CRIT_ERR(printf("Error occured while reading curve: %s\n", e.what()));
      }
      is.close();
      int num_curves = tmp.size();

      if (curves + num_curves > MAX_CURVES) {
	CRIT_ERR(puts("Increase MAX_CURVES."));
      }
	    
      for(int k = 0; k < num_curves; ++k) {
	if (curve[curves + k] != NULL) {
	  freeCurve(curve[curves + k]);
	}
	curve[curves + k] = tmp[k];
		
	//
	// 001206: If the dimension is 2, we set up a
	//         new curve, filling in zeros.
	//
	if (curve[curves + k]->idim==2) {
		    
	  double *new_coeffs=
	    new double[3*curve[curves + k]->in];
	  if (new_coeffs==NULL)
	    CRIT_ERR(puts("Couldn't allocate memory."));
	  int j;
		    
	  for (j=0; j<curve[curves + k]->in; j++) {
	    new_coeffs[3*j+0]= curve[curves + k]->ecoef[2*j+0];
	    new_coeffs[3*j+1]= curve[curves + k]->ecoef[2*j+1];
	    new_coeffs[3*j+2]=0.0;
	  }
	  SISLCurve *tmp2=curve[curves + k];
	  curve[curves + k]= newCurve(tmp2->in, tmp2->ik, tmp2->et,
				      new_coeffs, tmp2->ikind, 3, 1);
	  freeCurve(tmp2);
	}
		
	if (curve[curves + k]->idim!=3) {
	  CRIT_ERR(printf("Dimension of curve is %d and not 3?!\n",
			  curve[curves + k]->idim));
	}

	curve_name[curves + k]=argv[i+1];
	curve_enabled[curves + k]=1;
      }
      curves+=num_curves;
    }
      i++;
      break;
	    
    case 'p': {
      // Next string is filename for file containing a point cloud.
	    
      printf("Reading a point cloud.\n");

      std::ifstream is(argv[i+1]);
      if (!is) {
	CRIT_ERR(printf("Could not open file: '%s'.\n", argv[i+1]));
      }
      try {
	  vector<double> coords;
	  readGoPoints(coords, is);
	  int num_points = int(coords.size()) / 3;
	  printf("Number of vertices: %d\n", num_points);
	  for (int i = 0; i < num_points; ++i) {
	      pcloud.push_back(vector3t<float>(coords[3 * i], 
					       coords[3 * i + 1], 
					       coords[3 * i + 2]));
	  }
// 	eatwhite(is);
// 	int tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	is >> tmp;
// 	eatwhite(is);
// 	is >> tmp;
// 	printf("Number of vertices: %d\n", tmp);
// 	while (!is.eof()) {
// 	  double x, y, z;
// 	  is >> x;
// 	  is >> y;
// 	  is >> z;
// 	  //printf("point: %f %f %f\n", x, y, z);
// 	  pcloud.push_back(vector3t<float>(x, y, z));
// 	  eatwhite(is);
//      }
      } catch (std::exception& e) {
	  CRIT_ERR(printf("Error occured while reading curve: %s\n", e.what()));
      }
      is.close();
      printf("pcloud size is now %d\n", pcloud.size());
    }
	i++;
      break;
	    
// 	case 'r':
// 	    // Set refinement factor. Default value is ???.
	    
// 	    puts("Reading surface refinement factor");
// 	    ref=atoi(argv[i+1]);
// 	    i++;
// 	    break;
	    
//	case 'R': 
    case 'r':
      // Set max refinement factor. Default value is ???.
	    
      puts("Reading upper bound for surface refinement.");
      maxref=atoi(argv[i+1]);
      i++;
      break;
	    
    case 'e': 
      // String with keypresses to execute follows. Not
      // everything will work!
	    
      printf("Executing '%s'.\n", argv[i+1]);
      strncpy(init_key_string, argv[i+1], 1000);
      i++;
      break;
	    
    default:
      puts("Huh?! Unknown option.");
      exit(0);
	    
    }
  }
}
/**
 * 隧道管理界面类实现
 * 继承自QWidget
 * @author fanxiang
 * @version 1.0.0
 * @date 2013-08-18
 */
ManageTunnelWidget::ManageTunnelWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ManageTunnelWidget)
{
    ui->setupUi(this);

    mapper = new QDataWidgetMapper(this);

    linesModel = NULL;
    tunnelsModel = NULL;
    curvesModel = NULL;

    loadLinesData();
    loadTunnelData();

    /* 开始选中查找模式为学号模式 */
    ui->radioButton->click();

    /* 开始不能修改 */
    currentRow = 0;
    changed = false;
    saveType = Save_Modify;
    cannotModify();

    /* 线路及隧道数据列表更新信号槽 */
    connect(ui->linesView, SIGNAL(clicked(QModelIndex)), this, SLOT(updateTunnelsView(const QModelIndex &)));
    // 【作废】updateCurvesView已在setCurrentMapper中调用
    //connect(ui->tunnelsView, SIGNAL(clicked(QModelIndex)), this, SLOT(updateCurvesView(const QModelIndex &)));

    /* 添加删除隧道槽 */
    connect(ui->newTunnelButton, SIGNAL(clicked()), this, SLOT(newTunnel()));
    connect(ui->deleteTunnelButton, SIGNAL(clicked()), this, SLOT(deleteTunnel()));
    /* 添加删除隧道对应曲线槽 */
    //connect(ui->curvesView, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(changeCurveData()));
    connect(ui->newCurveButton, SIGNAL(clicked()), this, SLOT(newCurve()));
    connect(ui->deleteCurveButton, SIGNAL(clicked()), this, SLOT(deleteCurve()));

    /* 刷新线路隧道 */
    connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refreshLinesView()));

    /* 具体隧道信息信号槽 */
    connect(ui->tunnelsView, SIGNAL(clicked(QModelIndex)), this, SLOT(showTunnelDetail(const QModelIndex &)));
    //connect(ui->stumajorcombobox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(updateStuClasses(const QString &)));

    /* 修改隧道信息信号槽 */
    connect(ui->lineEdit_tunnelid, SIGNAL(textChanged(QString)), this, SLOT(canSave()));
    connect(ui->lineEdit_name, SIGNAL(textChanged(QString)), this, SLOT(canSave()));
    connect(ui->lineEdit_IDstd, SIGNAL(textChanged(QString)), this, SLOT(canSave()));
    connect(ui->lineEdit_startPoint, SIGNAL(textChanged(QString)), this, SLOT(canSave()));
    connect(ui->lineEdit_endPoint, SIGNAL(textChanged(QString)), this, SLOT(canSave()));
    connect(ui->combobox_isNewLine, SIGNAL(currentIndexChanged(int)), this, SLOT(canSave()));
    connect(ui->combobox_lineType, SIGNAL(currentIndexChanged(int)), this, SLOT(canSave()));
    connect(ui->radioButton_isDoubleLine, SIGNAL(clicked()), this, SLOT(canSave()));
    connect(ui->radioButton_isSingleLine, SIGNAL(clicked()), this, SLOT(canSave()));
    connect(ui->radioButton_isUpLink, SIGNAL(clicked()), this, SLOT(canSave()));
    connect(ui->radioButton_isDownLink, SIGNAL(clicked()), this, SLOT(canSave()));
    connect(ui->radioButton_isBridge, SIGNAL(clicked()), this, SLOT(canSave()));
    connect(ui->radioButton_notBridge, SIGNAL(clicked()), this, SLOT(canSave()));

    // 隧道中的曲线界面双击修改后,也可点击保存按钮
    connect(ui->curvesView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(canSave()));

    connect(ui->firstButton, SIGNAL(clicked()), this, SLOT(toFirst()));
    connect(ui->previousButton, SIGNAL(clicked()), this, SLOT(toPrevious()));
    connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(toNext()));
    connect(ui->lastButton, SIGNAL(clicked()), this, SLOT(toLast()));

    connect(ui->modifyButton, SIGNAL(clicked()), this, SLOT(canModify()));

    /* 查找隧道槽 */
    connect(ui->findButton, SIGNAL(clicked()), this, SLOT(findTunnel()));
    connect(ui->findEdit,SIGNAL(textEdited(QString)),this,SLOT(showAllLines()));
    /* 编辑桥梁槽 */
    connect(ui->editBridgeClearanceButton, SIGNAL(clicked()), this, SLOT(editBridgeClearance()));
}