示例#1
0
文件: CategoryExample.C 项目: Unss/wt
CategoryExample::CategoryExample(WContainerWidget *parent)
  : WContainerWidget(parent)
{
  setContentAlignment(AlignCenter);
  chart_ = new WCartesian3DChart(this);
  chart_->setType(CategoryChart);

  Wt::WCssDecorationStyle style;
  style.setBorder(Wt::WBorder(Wt::WBorder::Solid, Wt::WBorder::Medium, Wt::black));
  chart_->setDecorationStyle(style);

  chart_->resize(600, 600);
  
  // **** Dataset
  WStandardItemModel *isotopeModel_ = readCsvFile(WApplication::appRoot() + "isotope_decay.csv");
  // add some color-roles
  for (int i=1; i<isotopeModel_->rowCount(); i++) {
    for (int j=1; j<isotopeModel_->columnCount(); j++) {
      double value = Wt::asNumber(isotopeModel_->data(i, j));
      if (value < 3)
  	isotopeModel_->setData(i, j, WColor(blue), MarkerBrushColorRole);
    }
  }
  WGridData *isotopes = new WGridData(isotopeModel_);
  isotopes->setType(BarSeries3D);
  
  // **** Dataset
  planeModel_ = readCsvFile(WApplication::appRoot() + "hor_plane.csv");
  WGridData *horPlane = new WGridData(planeModel_);
  horPlane->setType(BarSeries3D);

  // **** Dataset
  randomModel_ = readCsvFile(WApplication::appRoot() + "hor_plane.csv");
  for (int i=1; i<randomModel_->rowCount(); i++) {
    for (int j=1; j<randomModel_->columnCount(); j++) {
      randomModel_->setData(i, j,Wt::asNumber(randomModel_->data(i, j)) + (rand() % 100)/100.0);
    }
  }
  WGridData *randomPlane = new WGridData(randomModel_);
  randomPlane->setType(BarSeries3D);

  // **** Dataset
  yPlaneModel_ = new PlaneData(20, 20, 0, 1, 0, 1, true, 100, 100);
  WEquidistantGridData *yPlaneFunc = new WEquidistantGridData(yPlaneModel_,
							       0, 1, 0, 1);
  yPlaneFunc->setType(BarSeries3D);

  // **** Dataset
  xPlaneModel_ = new PlaneData(20, 20, 0, 1, 0, 1, false, 100, 100);
  WEquidistantGridData *xPlaneFunc = new WEquidistantGridData(xPlaneModel_,
							       0, 1, 0, 1);
  xPlaneFunc->setType(BarSeries3D);

  // **** Dataset
  xPlaneModelColor_ = new PlaneData(20, 20, 0, 1, 0, 1, false, 5, 100);
  WEquidistantGridData *xPlaneFuncColor = new WEquidistantGridData(xPlaneModelColor_,
							       0, 1, 0, 1);
  xPlaneFuncColor->setType(BarSeries3D);
  

  
  // Data configuration widget
  DataConfig *dataconfig = new DataConfig(chart_);
  dataconfig->addDataToCollection("Isotope data (10x10) with ColorRoles", isotopes);
  dataconfig->addDataToCollection("Horizontal Plane (10x10)", horPlane);  
  dataconfig->addDataToCollection("Random Data (10x10)", randomPlane);  
  // dataconfig->addDataToCollection("tilted plane y (20x20)", yPlaneFunc);
  // dataconfig->addDataToCollection("tilted plane x (20x20)", xPlaneFunc);
  // dataconfig->addDataToCollection("tilted plane x (20x20) with ColorRoles", xPlaneFuncColor);
  
  

  WTabWidget *configuration_ = new WTabWidget(this);
  configuration_->addTab(new ChartSettings(chart_), "General Chart Settings", Wt::WTabWidget::PreLoading);
  configuration_->addTab(dataconfig, "Data selection and configuration", Wt::WTabWidget::PreLoading);
}
示例#2
0
文件: ass.c 项目: 0664j35t3r/ESP
int main(int argc, char** argv)
{
  int result;
  
  if(argc != 2)
  { 
    printf("usage: %s file.csv\n", argv[0]);
    return -1;
  }

  result = readCsvFile(argv[1]);
  if(result!=0)
  {
    return printError(result);
  }

  //was passiert sonst?

  
  /* einlesen der gesamten datei in den speicher
  char * buffer;
  fseek(csvfile, 0, SEEK_END);
  long int lSize = ftell(csvfile);
  rewind(csvfile);
  buffer = (char*) malloc (sizeof(char)*lSize);
  if (buffer == NULL) 
  {
    fputs ("error: out of memory",stderr); 
    fclose(csvfile);
    return -2;
  }
  if(fread (buffer,sizeof(char),lSize,csvfile) != lSize) 
  {
    fputs ("error: could not read file",stderr); 
    fclose(csvfile);
    free(buffer);
    return -4;
  }
  */
  
  //CheckCorruption(csvfile);  
  
/*  
  printf("success\n");
  return 0;
  
  
  node *liste, *currentElement;
  liste = (node*) malloc(sizeof(node));
  
  liste->next=NULL;
  //liste->right=NULL;
  currentElement = liste;
  
  

  char csvline[400];
  while((fgets(csvline, 400, csvfile)) != NULL );
  {
   

    
    char semi[] = ";";
    char* prasemic;
    prasemic = strstr(csvline, semi); //liefert einen pointer zurück, wo er es findet
    *prasemic = 0; __attribute__((unused))//überschreiben ; mit NULL
    char* string1 = csvline;
    
     
  currentElement = addElement(currentElement,string1);
  
  char* string3= String2(csvline);
  currentElement = addElement(currentElement,string3);
 
  }
  
  printList(liste);

  StandardPrompt();
  */
 return EXIT_SUCCESS;
}