ViewConfigurationDialog::ViewConfigurationDialog(Project *project, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ViewConfigurationDialog),
    mProject(project)
{
    ui->setupUi(this);

    mViewModel = new ViewsModel(mProject);
    ui->viewView->setModel( mViewModel );

    mTabsModel = 0;
    mItemsModel = 0;
    mPhrasalGlossesModel = 0;

    mView = 0;
    mTab = 0;

    connect(ui->addView, SIGNAL(clicked()), this, SLOT(addView()) );
    connect(ui->removeView, SIGNAL(clicked()), this, SLOT(removeView()) );

    connect(ui->addTab, SIGNAL(clicked()), this, SLOT(addTab()) );
    connect(ui->removeTab, SIGNAL(clicked()), this, SLOT(removeTab()) );

    connect(ui->addItem, SIGNAL(clicked()), this, SLOT(addItem()) );
    connect(ui->removeItem, SIGNAL(clicked()), this, SLOT(removeItem()) );
    connect(ui->itemView, SIGNAL(activated(QModelIndex)), this, SLOT(editItem(QModelIndex)) );

    connect(ui->addPhrasalGloss, SIGNAL(clicked()), this, SLOT(addPhrasalGloss()) );
    connect(ui->removePhrasalGloss, SIGNAL(clicked()), this, SLOT(removePhrasalGloss()) );
    connect(ui->phrasalGlossView, SIGNAL(activated(QModelIndex)), this, SLOT(editPhrasalGloss(QModelIndex)) );

    connect(ui->viewView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(viewChanged(QItemSelection,QItemSelection)));
    connect(ui->itemWritingSystemsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(indexLanguageChanged(int)));

    connect(ui->viewUp, SIGNAL(clicked()), this, SLOT(viewUp()));
    connect(ui->viewDown, SIGNAL(clicked()), this, SLOT(viewDown()));
    connect(ui->tabUp, SIGNAL(clicked()), this, SLOT(tabUp()));
    connect(ui->tabDown, SIGNAL(clicked()), this, SLOT(tabDown()));
    connect(ui->itemUp, SIGNAL(clicked()), this, SLOT(itemUp()));
    connect(ui->itemDown, SIGNAL(clicked()), this, SLOT(itemDown()));
    connect(ui->phrasalGlossUp, SIGNAL(clicked()), this, SLOT(phrasalGlossUp()));
    connect(ui->phrasalGlossDown, SIGNAL(clicked()), this, SLOT(phrasalGlossDown()));

    setTabWidgetsEnabled(false);
    setItemWidgetsEnabled(false);
}
Beispiel #2
0
Camera::Camera(Vertice posicao, Vertice lookAt)
{
    vector<float> vUp;
    Vertice viewUp(lookAt.getX(), lookAt.getY() + 1, lookAt.getZ());
    Calc m;

    this->posicao = posicao.getPos();
    this->lookAt = lookAt;

    vUp = m.verticesParaVetor(viewUp, posicao);

    this->k = m.verticesParaVetor(posicao, lookAt);
    m.transVetUnitario(this->k);

    this->i = m.produtoVetorial(vUp, this->k);
    m.transVetUnitario(this->i);

    this->j = m.produtoVetorial(this->k, this->i);

}
Beispiel #3
0
int main(int argc, char *argv[])
{
  // Initialize OSPRay.
  ospInit(&argc, (const char **) argv);

  // Initialize Qt.
  QApplication *app = new QApplication(argc, argv);

  // Print the command line usage.
  if (argc < 2) {

    std::cerr << " "                                                                                        << std::endl;
    std::cerr << "  USAGE:  " << argv[0] << " <filename> [filename] ... [options]"                          << std::endl;
    std::cerr << " "                                                                                        << std::endl;
    std::cerr << "  Options:"                                                                               << std::endl;
    std::cerr << " "                                                                                        << std::endl;
    std::cerr << "    -benchmark <warm-up frames> <frames> : run benchmark and report overall frame rate"   << std::endl;
    std::cerr << "    -dt <dt>                             : use ray cast sample step size 'dt'"            << std::endl;
    std::cerr << "    -module <moduleName>                 : load the module 'moduleName'"                  << std::endl;
    std::cerr << "    -ply <filename>                      : load PLY geometry from 'filename'"             << std::endl;
    std::cerr << "    -rotate <rate>                       : automatically rotate view according to 'rate'" << std::endl;
    std::cerr << "    -showframerate                       : show the frame rate in the window title bar"   << std::endl;
    std::cerr << "    -fullscreen                          : enter fullscreen mode"                         << std::endl;
    std::cerr << "    -ownmodelperobject                   : create a separate model for each object"       << std::endl;
    std::cerr << "    -slice <filename>                    : load volume slice from 'filename'"             << std::endl;
    std::cerr << "    -transferfunction <filename>         : load transfer function from 'filename'"        << std::endl;
    std::cerr << "    -viewsize <width>x<height>           : force OSPRay view size to 'width'x'height'"    << std::endl;
    std::cerr << "    -viewup <x> <y> <z>                  : set viewport up vector to ('x', 'y', 'z')"     << std::endl;
    std::cerr << "    -writeframes <filename>              : emit frames to 'filename_xxxxx.ppm'"           << std::endl;
    std::cerr << " "                                                                                        << std::endl;

    return 1;
  }

  // // Parse the OSPRay object file filenames.
  // std::vector<std::string> objectFileFilenames;

  // for (size_t i=1 ; (i < argc) && (argv[i][0] != '-') ; i++)
  //   objectFileFilenames.push_back(std::string(argv[i]));

  // Default values for the optional command line arguments.
  float dt = 0.0f;
  std::vector<std::string> plyFilenames;
  float rotationRate = 0.0f;
  std::vector<std::string> sliceFilenames;
  std::string transferFunctionFilename;
  int benchmarkWarmUpFrames = 0;
  int benchmarkFrames = 0;
  int viewSizeWidth = 0;
  int viewSizeHeight = 0;
  ospcommon::vec3f viewUp(0.f);
  ospcommon::vec3f viewAt(0.f), viewFrom(0.f);
  bool showFrameRate = false;
  bool fullScreen = false;
  bool ownModelPerObject = false;
  std::string renderer = "dvr";
  std::string writeFramesFilename;

  std::vector<std::string> inFileName;
  // Parse the optional command line arguments.
  for (int i=// objectFileFilenames.size() + 
         1 ; i < argc ; i++) {

    const std::string arg = argv[i];

    if (arg == "-dt") {

      if (i + 1 >= argc) throw std::runtime_error("missing <dt> argument");
      dt = atof(argv[++i]);
      std::cout << "got dt = " << dt << std::endl;

    } else if (arg == "-ply") {

      // Note: we use "-ply" since "-geometry" gets parsed elsewhere...
      if (i + 1 >= argc) throw std::runtime_error("missing <filename> argument");
      plyFilenames.push_back(std::string(argv[++i]));
      std::cout << "got PLY filename = " << plyFilenames.back() << std::endl;

    } else if (arg == "-rotate") {

      if (i + 1 >= argc) throw std::runtime_error("missing <rate> argument");
      rotationRate = atof(argv[++i]);
      std::cout << "got rotationRate = " << rotationRate << std::endl;

    } else if (arg == "-slice") {

      if (i + 1 >= argc) throw std::runtime_error("missing <filename> argument");
      sliceFilenames.push_back(std::string(argv[++i]));
      std::cout << "got slice filename = " << sliceFilenames.back() << std::endl;

    } else if (arg == "-showframerate" || arg == "-fps") {

      showFrameRate = true;
      std::cout << "set show frame rate" << std::endl;

    } else if (arg == "-fullscreen") {

      fullScreen = true;
      std::cout << "go full screen" << std::endl;

    } else if (arg == "-ownmodelperobject") {

      ownModelPerObject = true;

    } else if (arg == "-transferfunction") {

      if (i + 1 >= argc) throw std::runtime_error("missing <filename> argument");
      transferFunctionFilename = std::string(argv[++i]);
      std::cout << "got transferFunctionFilename = " << transferFunctionFilename << std::endl;

    } else if (arg == "-benchmark") {

      if (i + 2 >= argc) throw std::runtime_error("missing <warm-up frames> <frames> arguments");
      benchmarkWarmUpFrames = atoi(argv[++i]);
      benchmarkFrames = atoi(argv[++i]);
      std::cout << "got benchmarkWarmUpFrames = " << benchmarkWarmUpFrames << ", benchmarkFrames = " << benchmarkFrames << std::endl;

    }  else if (arg == "-r" || arg == "-renderer") {

      renderer = argv[++i];

    } else if (arg == "-viewsize") {

      if (i + 1 >= argc) throw std::runtime_error("missing <width>x<height> argument");
      std::string arg2(argv[++i]);
      size_t pos = arg2.find("x");

      if (pos != std::string::npos) {

        arg2.replace(pos, 1, " ");
        std::stringstream ss(arg2);
        ss >> viewSizeWidth >> viewSizeHeight;
        std::cout << "got viewSizeWidth = " << viewSizeWidth << ", viewSizeHeight = " << viewSizeHeight << std::endl;

      } else throw std::runtime_error("improperly formatted <width>x<height> argument");

    } else if (arg == "-viewup" || arg == "-vu") {
Beispiel #4
0
//! [1]
void MainWidget::timerEvent(QTimerEvent *)
{
	float alpha = .05;
	float d = cameraPosition.length();
	for (unsigned idx = 0; idx < planets.size(); ++idx)
		d = std::min(d, cameraPosition.distanceToPoint(planets[idx]->statePosition));
	float delta = std::max(d / 10, .000001f);
	QVector3D direct = getDirection();
	if (holdedKeys.count(Qt::Key_W))
		viewForward(delta);

	if (holdedKeys.count(Qt::Key_S))
		viewForward(-delta);

	if (holdedKeys.count(Qt::Key_D)) {
		QVector3D d = QVector3D::normal(direct, direct + QVector3D(0, 1, 0));
		cameraPosition += d * delta;
	}

	if (holdedKeys.count(Qt::Key_A)) {
		QVector3D d = QVector3D::normal(direct, direct + QVector3D(0, 1, 0));
		cameraPosition -= d * delta;
	}

	if (holdedKeys.count(Qt::Key_Up))
		viewUp(alpha);

	if (holdedKeys.count(Qt::Key_Down))
		viewUp(-alpha);

	if (holdedKeys.count(Qt::Key_Right))
		viewRight(alpha);

	if (holdedKeys.count(Qt::Key_Left))
		viewRight(-alpha);

	for (char num = '0'; num <= '9'; ++num)
		if (holdedKeys.count(num)) {
			QVector3D move = -cameraPosition;
			float soNear = theSun->radius;
			if (PlanetConfig::modeSurvey)
				soNear = aSun->radius;
			if (num != '0') {
				move = planets[num - '1']->statePosition - cameraPosition;
				soNear = planets[num - '1']->radius;
			}
			float x = std::atan2(move.x(), -move.z());
			float y = std::atan2(move.y(), std::pow(move.x() * move.x() + move.z() * move.z(), .5f));
			if (x == cameraDirection.x() && y == cameraDirection.y()) {
				viewForward(delta);
			} else {
				viewRight(x - cameraDirection.x());
				viewUp(y - cameraDirection.y());
			}
		}

	if (modeFps) {
		QPoint pos = QCursor::pos() - mapToGlobal(QPoint(width() / 2, height() / 2));
		viewUp(-pos.y() * .01);
		viewRight(pos.x() * .01);
		QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
	}

	if (holdedKeys.count(Qt::Key_Plus))
		modifyAngle(1);
	if (holdedKeys.count(Qt::Key_Minus))
		modifyAngle(-1);
	if (holdedKeys.count('/'))
		modifyAngle(viewAngle - 45);

	if (holdedKeys.count(Qt::Key_C))
		changeDeltaTime(deltaTime * 2);
	if (holdedKeys.count(Qt::Key_Z))
		changeDeltaTime(deltaTime / 2);
	if (holdedKeys.count(Qt::Key_X))
		changeDeltaTime(0);

	// // Decrease angular speed (friction)
	// angularSpeed *= 0.99;

	// // Stop rotation when speed goes below threshold
	// if (angularSpeed < 0.01) {
	// 	angularSpeed = 0.0;
	// } else {
	// 	// Update rotation
	// 	rotation = QQuaternion::fromAxisAndAngle(rotationAxis, angularSpeed) * rotation;

	// 	// Update scene
	// }

	QDateTime now = QDateTime::currentDateTimeUtc();
	if (action)
		shiftedTime = shiftedTime.addMSecs(deltaTime * prevTime.msecsTo(now));
	for (unsigned idx = 0; idx < planets.size(); ++idx)
		planets[idx]->changeTime(shiftedTime);
	prevTime = now;
	updateGL();
}
// ****************************************************************************
// Method: QvisXRayImageQueryWidget::GetQueryParameters
//
// Purpose:
//   Retrieves values from this form and stores them in the MapNode in 
//   a manner in keeping with this query.
//
// Arguments:
//   params :  The MapNode in which to store the parameters.
//
// Returns:    True if it worked.
//
// Programmer: Kathleen Biagas 
// Creation:   June 17, 2011
//
// Modifications:
//   Kathleen Biagas, Wed Sep  7 08:40:22 PDT 2011
//   Return output_type as string instead of int.
// 
//   Kathleen Biagas, Wed Oct 17 12:12:29 PDT 2012
//   Added upVector.
//
//   Eric Brugger, Fri May 22 15:52:32 PDT 2015
//   I updated the window to use the new view description and support the
//   recently added background intensity parameter.
//
//   Eric Brugger, Wed May 27 17:30:15 PDT 2015
//   I added an option to family output files.
//
//   Eric Brugger, Thu Jun  4 17:26:57 PDT 2015
//   I added an option to enable outputting the ray bounds to a vtk file.
//
// ****************************************************************************
bool
QvisXRayImageQueryWidget::GetQueryParameters(MapNode &params)
{
    doubleVector backgroundIntensities;
    doubleVector normal(3);
    doubleVector focus(3);
    doubleVector viewUp(3);
    double       viewAngle, parallelScale, nearPlane, farPlane;
    doubleVector imagePan(2);
    double       imageZoom;
    intVector    imageSize(2);

    bool noerrors = true;

    if (!GetDoubleValues(0, backgroundIntensities))
        noerrors = false;
    if (backgroundIntensities.size() == 0)
        noerrors = false;

    if (noerrors && !GetDoubleValues(1, 3, &normal[0]))
        noerrors = false;

    if (noerrors && !GetDoubleValues(2, 3, &focus[0]))
        noerrors = false;

    if (noerrors && !GetDoubleValues(3, 3, &viewUp[0]))
        noerrors = false;

    if (noerrors && !GetDoubleValues(4, 1, &viewAngle))
        noerrors = false;

    if (noerrors && !GetDoubleValues(5, 1, &parallelScale))
        noerrors = false;

    if (noerrors && !GetDoubleValues(6, 1, &nearPlane))
        noerrors = false;

    if (noerrors && !GetDoubleValues(7, 1, &farPlane))
        noerrors = false;

    if (noerrors && !GetDoubleValues(8, 2, &imagePan[0]))
        noerrors = false;

    if (noerrors && !GetDoubleValues(9, 1, &imageZoom))
        noerrors = false;

    if (noerrors && !GetIntValues(10, &imageSize[0]))
        noerrors = false;

    if (noerrors)
    {
        params["output_type"] = imageFormat->currentText().toStdString();
        params["divide_emis_by_absorb"] = (int)divideFlag->isChecked();
        if (backgroundIntensities.size() == 1)
            params["background_intensity"] = backgroundIntensities[0];
        else
            params["background_intensities"] = backgroundIntensities;
        params["normal"] = normal;
        params["focus"] = focus;
        params["view_up"] = viewUp;
        params["view_angle"] = viewAngle;
        params["parallel_scale"] = parallelScale;
        params["near_plane"] = nearPlane;
        params["far_plane"] = farPlane;
        params["image_pan"] = imagePan;
        params["image_zoom"] = imageZoom;
        params["perspective"] = (int)perspective->isChecked();
        params["family_files"] = (int)family->isChecked();
        params["output_ray_bounds"] = (int)outputRayBounds->isChecked();
        params["image_size"] = imageSize;
    }
    return noerrors; 
}