Ejemplo n.º 1
0
// Draws the data in a new window.
void ImageData::Display() const {
#ifndef GRAPHICS_DISABLED
  const int kTextSize = 64;
  // Draw the image.
  Pix* pix = GetPix();
  if (pix == NULL) return;
  int width = pixGetWidth(pix);
  int height = pixGetHeight(pix);
  ScrollView* win = new ScrollView("Imagedata", 100, 100,
                                   2 * (width + 2 * kTextSize),
                                   2 * (height + 4 * kTextSize),
                                   width + 10, height + 3 * kTextSize, true);
  win->Image(pix, 0, height - 1);
  pixDestroy(&pix);
  // Draw the boxes.
  win->Pen(ScrollView::RED);
  win->Brush(ScrollView::NONE);
  win->TextAttributes("Arial", kTextSize, false, false, false);
  for (int b = 0; b < boxes_.size(); ++b) {
    boxes_[b].plot(win);
    win->Text(boxes_[b].left(), height + kTextSize, box_texts_[b].string());
    TBOX scaled(boxes_[b]);
    scaled.scale(256.0 / height);
    scaled.plot(win);
  }
  // The full transcription.
  win->Pen(ScrollView::CYAN);
  win->Text(0, height + kTextSize * 2, transcription_.string());
  // Add the features.
  win->Pen(ScrollView::GREEN);
  win->Update();
  window_wait(win);
#endif
}
Ejemplo n.º 2
0
// Draws the data in a new window.
void ImageData::Display() const {
  const int kTextSize = 64;
  int x_max, y_max;
  WordFeature::ComputeSize(features_, &x_max, &y_max);
  ScrollView* win = new ScrollView("Imagedata", 100, 100,
                                   2 * (x_max + 2 * kTextSize),
                                   2 * (y_max + 4 * kTextSize),
                                   x_max + 10, y_max + 3 * kTextSize, true);
  // Draw the image.
  Pix* pix = GetPix();
  int height = 256;
  if (pix != NULL) {
    height = pixGetHeight(pix);
    win->Image(pix, 0, height - 1);
    pixDestroy(&pix);
  }
  // Draw the boxes.
  win->Pen(ScrollView::RED);
  win->Brush(ScrollView::NONE);
  win->TextAttributes("Arial", kTextSize, false, false, false);
  for (int b = 0; b < boxes_.size(); ++b) {
    boxes_[b].plot(win);
    win->Text(boxes_[b].left(), y_max + kTextSize, box_texts_[b].string());
    TBOX scaled(boxes_[b]);
    scaled.scale(256.0 / height);
    scaled.plot(win);
  }
  // The full transcription.
  win->Pen(ScrollView::CYAN);
  win->Text(0, y_max + kTextSize * 2, transcription_.string());
  // Add the features.
  win->Pen(ScrollView::GREEN);
  WordFeature::Draw(features_, win);
  win->Update();
  window_wait(win);
}
Ejemplo n.º 3
0
// Takes care of the SVET_CLICK events.
// Depending on the click_mode_ we are in, either do Point-to-Point drawing,
// point drawing, or draw text.
void SVPaint::ClickHandler(const SVEvent* sv_event) {
  switch (click_mode_) {
  case 1: //Point to Point
    if (has_start_point_) { window_->DrawTo(sv_event->x, sv_event->y);
    } else {
        has_start_point_ = true; 
        window_->SetCursor(sv_event->x, sv_event->y);
    }
    break;
  case 2: //Point Drawing..simulated by drawing a 1 pixel line.
    window_->Line(sv_event->x, sv_event->y, sv_event->x, sv_event->y);
    break;
  case 3: //Text
    // We show a modal input dialog on our window, then draw the input and
    // finally delete the input pointer.
    char* p = window_->ShowInputDialog("Text:");
    window_->Text(sv_event->x, sv_event->y, p);
    delete p;
    break;
  }
}