예제 #1
0
double getTime(TString logfile, TString module) {

    gSystem->Exec("grep TimeReport "+logfile+" | grep "+module+" | tail -1 >& tmp1.log");
    gSystem->Exec("echo >> tmp1.log");

    ifstream inlimits("tmp1.log");
    string line;
    double imas = 0;
    if (inlimits.is_open()) {
        while ( inlimits.good() ) {
            getline (inlimits,line);
            TString myline(line);
            if ((*myline.Tokenize(' ')).GetEntries()<8) continue;
            TString value( ((TObjString*) (*myline.Tokenize(' '))[5])->GetString().Data() );
            imas = value.Atof();
            //cout << line << endl;
        }
        inlimits.close();
    }
    gSystem->Exec("rm tmp1.log");
    //cout << "inlimits.is_open(): " << inlimits.is_open() << endl;
    //cout<<"returning: " << imas << endl;
    return imas;

}
예제 #2
0
char *readLongString(FILE *infile){
  /* readLongString() reads a string of arbitrary length from the given
   * file and returns it as a newly allocated string
   *
   * The technique is to use your myline() function, always asking for
   * a new buffer.
   *
   * The caller is responsible for freeing the allocated string
   *
   * returns
   *   on success: a pointer to the newly allocated string.
   *   on EOF without reading something or read-error: NULL
   */
  size_t len = 0;
  char *buff = 0;
  char *ans;
  int ret;

  ret = myline(&buff, &len, infile);
  if (ret <= 0) {
    /* 357 : free the buffer when an EOF is input */
    free(buff);
    /* End 357 */
    return NULL;
  } else {
    ans = strdup(buff);
    free(buff);
    return ans;
  }
}
예제 #3
0
파일: menu.cpp 프로젝트: rohit-95/Graphics
void clip_lp_menu() {
    cleardevice();
    clearmouseclick(WM_RBUTTONDOWN);

    outtext((char*)"Left click mouse to add points to polygon and right click to finish adding points");
    std::vector<Point2D> poly;
    std::cout<<"\n\nPolygon";

    poly = mk_poly();

    std::cout<<"\n\nLine";
    cleardevice();
    outtext((char*)"Click and drag to define line");
    mypoly(poly);

    Point2D a(100, 100), b(700, 700);
    outP(a);outP(b);
    setcolor(RED);
    myline(a, b);
    getch();

    setcolor(WHITE);
    clip_line_poly(poly, a, b, NULL);
    getch();
}
예제 #4
0
파일: menu.cpp 프로젝트: rohit-95/Graphics
void clip_cs_menu() {
    cleardevice();
    outtext((char*)"Click and drag mouse to define rectangular clipping region");

    mouseInput(x1, y1, x2, y2);

    Point2D pMin(std::min(x1,x2), std::min(y1,y2)), pMax(std::max(x1,x2), std::max(y1,y2));
    std::vector<Point2D> rect;
    rect.push_back(pMin); rect.push_back(Point2D(pMin.x, pMax.y));
    rect.push_back(pMax); rect.push_back(Point2D(pMax.x, pMin.y));

    cleardevice();

    mypoly(rect);
    outtext((char*)"Click and drag mouse to make lines to be clipped, right click to EXIT");
    clearmouseclick(WM_RBUTTONDOWN);

    while(!ismouseclick(WM_RBUTTONDOWN)) {
        Point2D p1, p2;
        mouseLine(p1, p2);

        setcolor(RED);
        myline(p1, p2);

        setcolor(WHITE);
        clip_line_cs(pMin, pMax, p1, p2);
    }
}
예제 #5
0
void quant(int x, int y, int& xleft, int& xright, int& yboth, int printnum, double level, col color)
{
    printtext("", printnum, x, y);
    int r = 12;
    float dx = 8-level;
    xright = x + r * dx;
    yboth = y + r * 2.5;
    xleft = x - r * dx;
    if (color == col::red)  glColor3f(1, 0, 0);
    else glColor3f(0, 0, 0);
    mycircle(x, y, r);
    if (printnum != 0)
    {
    glColor3f(0, 0, 0);
    mycircle(xright, yboth, r);
    mycircle(xleft, yboth, r);
    myline(x + 0.8 * r, y + 0.6 * r, xright - 0.3 * r, yboth - 0.9 * r);
    myline(x - 0.8 * r, y + 0.6 * r, xleft + 0.3 * r, yboth - 0.9 * r);
    }
}
예제 #6
0
파일: menu.cpp 프로젝트: rohit-95/Graphics
void myfunc_menu() {
    cleardevice();
    clearmouseclick(WM_RBUTTONDOWN);
    Point2D a, b;
    outtext((char*)"Click and drag to make a circle and show its radius, RIGHT CLICK TO EXIT");
    do {
        mouseLine(a, b);
        int r = rnd(sqrt(pow((b.x - a.x), 2) + pow((b.y - a.y), 2)));
        myline(a, b);
        mycircle(a, r);
    }while(!ismouseclick(WM_RBUTTONDOWN));
}
예제 #7
0
int main(void)
{
    char *buffer = NULL;
    int readLength;
    int writeLength;
    size_t length;
    FILE *fp;

    fp = stdin;
    if(fp == NULL)
    {
        exit(EXIT_FAILURE);
    }

    while((readLength = myline(&buffer, &length, fp)) > 0)
    {
        printf("readLength: %d\n", readLength);
        printf("length: %d\n", length);
        printf("buffer: ");
        if((writeLength = fwrite(buffer, 1, readLength, stdout)) != readLength)
        {
            if(writeLength >= 0)
            {
                fputs("Short fwrite to stdout\n", stderr);
            }
            else
            {
                perror("write to stdout");
            }
            exit(EXIT_FAILURE);
        }
    }

    if(buffer)
    {
        free(buffer);
    }


    return 0;
}
예제 #8
0
/*! \COININTERNAL
  Called when dragger is selected (picked) by the user.
*/
void
SoHandleBoxDragger::dragStart(void)
{
  SoHandleBoxDragger_invalidate_surroundscale(this);

  static const char translatorname[] = "translator";
  static const char extrudername[] = "extruder";
  static const char uniformname[] = "uniform";

  const SoPath *pickpath = this->getPickPath();

  SbBool found = FALSE;
  this->whatkind = WHATKIND_NONE;
  this->whatnum = 0;

  int i;
  SbString str;
  if (!found) {
    for (i = 1; i <= 6; i++) {
      str.sprintf("%s%d", translatorname, i);
      if (pickpath->findNode(this->getNodeFieldNode(str.getString())) >= 0||
          this->getSurrogatePartPickedName() == str.getString()) break;
    }
    if (i <= 6) {
      found = TRUE;
      this->whatkind = WHATKIND_TRANSLATOR;
      this->whatnum = i;
    }
  }

  if (!found) {
    for (i = 1; i <= 6; i++) {
      str.sprintf("%s%d", extrudername, i);
      if (pickpath->findNode(this->getNodeFieldNode(str.getString()))>= 0 ||
          this->getSurrogatePartPickedName() == str.getString()) break;
    }
    if (i <= 6) {
      found = TRUE;
      this->whatkind = WHATKIND_EXTRUDER;
      this->whatnum = i;
    }
  }
  if (!found) {
    for (i = 1; i <= 8; i++) {
      str.sprintf("%s%d", uniformname, i);
      if (pickpath->findNode(this->getNodeFieldNode(str.getString()))>= 0 ||
          this->getSurrogatePartPickedName() == str.getString()) break;
    }
    if (i <= 8) {
      found = TRUE;
      this->whatkind = WHATKIND_UNIFORM;
      this->whatnum = i;
    }
  }
  assert(found);
  if (!found) return;

  SbVec3f startPt = this->getLocalStartingPoint();

  switch(this->whatkind) {
  case WHATKIND_TRANSLATOR:
    {
      SbVec3f n;
      if (this->whatnum <= 2) {
        n = SbVec3f(0.0f, 1.0f, 0.0f);
      }
      else if (this->whatnum <= 4) {
        n = SbVec3f(1.0f, 0.0f, 0.0f);
      }
      else {
        n = SbVec3f(0.0f, 0.0f, 1.0f);
      }
      SbVec3f localPt;
      {
        SbMatrix mat, inv;
        this->getSurroundScaleMatrices(mat, inv);
        inv.multVecMatrix(startPt, localPt);
      }
      this->planeProj->setPlane(SbPlane(n, startPt));
      SbLine myline(SbVec3f(0.0f, 0.0f, 0.0f), n);
      SoTranslation *t = SO_GET_ANY_PART(this, "arrowTranslation", SoTranslation);
      t->translation = myline.getClosestPoint(localPt);
      if (this->getEvent()->wasShiftDown()) {
        this->getLocalToWorldMatrix().multVecMatrix(startPt, this->worldRestartPt);
        this->constraintState = CONSTRAINT_WAIT;
      }
    }
    break;
  case WHATKIND_EXTRUDER:
    this->lineProj->setLine(SbLine(this->getDraggerCenter(), startPt));
    this->ctrlOffset = this->calcCtrlOffset(startPt);
    break;
  case WHATKIND_UNIFORM:
    this->lineProj->setLine(SbLine(this->getDraggerCenter(), startPt));
    this->ctrlOffset = this->calcCtrlOffset(startPt);
    break;
  }
  this->ctrlDown = this->getEvent()->wasCtrlDown();
  this->updateSwitches();
}