Пример #1
0
/*! Deletes the old connection to the database and creates a new one based
	on the current settings in the dialog box. The new connection is then
	set as the one an only Database Manager that the rest of GraspIt had
	acces to.

	After connecting, it also reads the model list form the database and
	displays it.
*/
void DBaseDlg::connectButton_clicked()
{
	delete mDBMgr;
	Hand *h = graspItGUI->getIVmgr()->getWorld()->getCurrentHand();

#ifndef ROS_DATABASE_MANAGER	
	mDBMgr = new db_planner::SqlDatabaseManager(hostLineEdit->text().toStdString(),
						    atoi(portLineEdit->text().latin1()),
						    usernameLineEdit->text().toStdString(),
						    passwordLineEdit->text().toStdString(),
						    databaseLineEdit->text().toStdString(),
						    new GraspitDBModelAllocator(),
						    new GraspitDBGraspAllocator(h));
#else
	mDBMgr = new db_planner::RosDatabaseManager(hostLineEdit->text().toStdString(),
						    portLineEdit->text().toStdString(),
						    usernameLineEdit->text().toStdString(),
						    passwordLineEdit->text().toStdString(),
						    databaseLineEdit->text().toStdString(),
						    new GraspitDBModelAllocator(),
						    new GraspitDBGraspAllocator(h));
        //use the special allocator for models that get geometry directly from the database
        GeomGraspitDBModelAllocator* allocator = new GeomGraspitDBModelAllocator(mDBMgr);
        mDBMgr->SetModelAllocator(allocator);
#endif

	if (mDBMgr->isConnected()) {
		getModelList();
	} else {
		DBGA("DBase Browser: Connection failed");
		delete mDBMgr;
		mDBMgr = NULL;
	}
	graspItGUI->getIVmgr()->setDBMgr(mDBMgr);
}
Пример #2
0
// Re-implemented from Basic3DViewerWidget, since we have to handle
// texture/downsampling stuff from the beginning.
void Error3DViewerWidget::rebuildList()
{
  GLenum glerr;
  GLuint list = getModelList();

  checkGLErrors("rebuildList() start");
 // Get a display list, if we don't have one yet.
  if (list == 0) {
    list=glGenLists(1);
    if (list == 0) {
      QMessageBox::critical(this,"GL error",
                            "No OpenGL display list available.\n"
                            "Cannot display model!");
      return;
    }
  }
  
  setModelList(list);

  switch (error_mode) {
  case VERTEX_ERROR:
    glDisable(GL_TEXTURE_2D);
    glShadeModel(GL_SMOOTH);
    glNewList(list, GL_COMPILE);
    drawVertexErrorT();
    glEndList();
    break;
  case MEAN_FACE_ERROR:
    glDisable(GL_TEXTURE_2D);
    glShadeModel(GL_FLAT);
    glNewList(list, GL_COMPILE);
    drawMeanFaceErrorT();
    glEndList();
    break;
  case SAMPLE_ERROR:
    if (etex_id == NULL) 
      genErrorTextures();
    glEnable(GL_TEXTURE_2D);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glNewList(list, GL_COMPILE);
    drawTexSampleErrorT();
    glEndList();
    break;
  default:
    fprintf(stderr,"Invalid error mode!\n");
  }
  // Check for errors in display list generation
  while ((glerr = glGetError()) != GL_NO_ERROR) {
    if (glerr == GL_OUT_OF_MEMORY) {
      QMessageBox::critical(this,"GL error",
                            "Out of memory generating display list.\n"
                            "Cannot display");
      glDeleteLists(list, 1);
      setModelList(0);
    } else {
      fprintf(stderr,"ERROR: OpenGL error while generating display list:\n%s",
              gluErrorString(glerr));
    }
  }
}
Пример #3
0
/*! Initializes the dialog and also gets the one and only manager from the
	GraspitGUI. If this manager is already set, it also loads the model 
	list from the database and initializes it.
*/
void DBaseDlg::init()
{
	mModelList.clear();
	mGraspList.clear();
	mGraspList.clear();
	browserGroup->setEnabled(FALSE);
	graspsGroup->setEnabled(FALSE);
	mDBMgr = graspItGUI->getIVmgr()->getDBMgr();
	if (mDBMgr) {
		getModelList();
	}
}
Пример #4
0
/*! Initializes the dialog and also gets the one and only manager from the
	GraspitGUI. If this manager is already set, it also loads the model 
	list from the database and initializes it.
*/
void DBaseDlg::init()
{
	mModelList.clear();
	mGraspList.clear();
	mGraspList.clear();
	browserGroup->setEnabled(FALSE);
	graspsGroup->setEnabled(FALSE);
	mDBMgr = graspItGUI->getIVmgr()->getDBMgr();
	if (mDBMgr) {
		getModelList();
	}
	sortBox->insertItem("Epsilon");
	sortBox->insertItem("Volume");
	sortBox->insertItem("Energy");
}
Пример #5
0
/*! Deletes the old connection to the database and creates a new one based
	on the current settings in the dialog box. The new connection is then
	set as the one an only Database Manager that the rest of GraspIt had
	acces to.

	After connecting, it also reads the model list form the database and
	displays it.
*/
void DBaseDlg::connectButton_clicked()
{
	delete mDBMgr;
	Hand *h = graspItGUI->getIVmgr()->getWorld()->getCurrentHand();
	mDBMgr = new db_planner::SqlDatabaseManager(hostLineEdit->text().toStdString(),
												atoi(portLineEdit->text().latin1()),
												usernameLineEdit->text().toStdString(),
												passwordLineEdit->text().toStdString(),
												databaseLineEdit->text().toStdString(),
												new GraspitDBModelAllocator(),
												new GraspitDBGraspAllocator(h));
	if (mDBMgr->isConnected()) {
		getModelList();
	} else {
		DBGA("DBase Browser: Connection failed");
		delete mDBMgr;
		mDBMgr = NULL;
	}
	graspItGUI->getIVmgr()->setDBMgr(mDBMgr);
}
Пример #6
0
void testCalcInstances(unsigned * numPasses, unsigned * numErrors) {
    char n[81];
    char description[81];
    long optsFlags, reqFlags, prefFlags, instanceHandle1, instanceHandle2;
    long prefFlags0, reqFlags0;
    int rc;
    int recNum;
    unsigned i, numModels;
    const DSCTModelObj ** modArray = 0L;
    if (gVerbose)
        fprintf(stderr, "Testing CalcInstances\n");
    i = getNumComputationalResources();
    fprintf(stderr, "%d computational resource(s) available\n", i);
    if (i == 0) {
        *numErrors += 1;
        fprintf(stderr, "%d computational resources available\n", i);
    }
    else
        *numPasses += 1;
    
    for (recNum = 0; recNum < i ; ++recNum) {
        rc = getComputationalResourceDetails(recNum, n, description, &optsFlags, &reqFlags);
        if (rc == 0) {
            *numPasses += 1;
            if (gVerbose)
                fprintf(stderr, "Resource details for resource %d:\n  name = %s\n  desc = %s\n  optFlags  = %ld\n  reqFlags = %ld\n", recNum, n, description, optsFlags, reqFlags);
        }
        else {
            *numErrors += 1;
            fprintf(stderr, "getComputationalResourceDetails returned %d\n", rc);
        }
        if (recNum == 0) {
            prefFlags0 = prefFlags0;
            reqFlags0 = reqFlags;
        }
    }
    rc = getComputationalResourceDetails(i, n, description, &optsFlags, &reqFlags);
    if (rc != 0) {
        *numPasses += 1;
    }
    else {
        *numErrors += 1;
        fprintf(stderr, "getComputationalResourceDetails did not return an error code when resource %d was used as an arg.\n", i);
    }


    instanceHandle1 = createLikelihoodCalcInstance(4, /* leaves*/
            10, /* patterns */
            0L, /* pattern weights*/
            4, /* states */
            4, /* stateCodeArrays */
            10,  /* partials */
            1, /* distinct models (q-matrices) to allocated */
            0L, /* ASRVObj array */
            10, /* transition probability matrices */ 
            2, /* num of eigen solutions stored */ 
            1, /* num rescalers */
            0, /* the index of the computational resource to use */
            prefFlags0,
            reqFlags0); /* the beagle flags (see above) required of the computational resource */
    if (instanceHandle1 >= 0) {
        *numPasses += 1;
        fprintf(stderr, "createLikelihoodCalcInstance succeeded %d.\n", i);
    }
    else {
        *numErrors += 1;
        fprintf(stderr, "createLikelihoodCalcInstance returned error code %d.\n", i);
    }
    instanceHandle2 = createLikelihoodCalcInstance(4, /* leaves*/
            10, /* patterns */
            0L, /* pattern weights*/
            4, /* states */
            4, /* stateCodeArrays */
            10,  /* partials */
            1, /* distinct models (q-matrices) to allocated */
            0L, /* ASRVObj array */
            10, /* transition probability matrices */ 
            2, /* num of eigen solutions stored */ 
            1, /* num rescalers */
            -1, /* -1 should mean "use any resoure" */
            prefFlags,
            reqFlags); /* the beagle flags (see above) required of the computational resource */
    if (instanceHandle2 >= 0) {
        *numPasses += 1;
    }
    else {
        *numErrors += 1;
        fprintf(stderr, "createLikelihoodCalcInstance returned error code %d.\n", i);
    }
    if (instanceHandle2 != instanceHandle1) {
        *numPasses += 1;
    }
    else {
        *numErrors += 1;
        fprintf(stderr, "duplicate instance handles returned by createLikelihoodCalcInstance.\n");
    }

    modArray = getModelList(instanceHandle1, &numModels);
    if (modArray == 0L || numModels != 1) {
            *numErrors += 1;
            fprintf(stderr, "could not obtain model list.\n");
    }
    else {
        *numPasses += 1;
    }

    
    
    if (instanceHandle1 >= 0) {
        if (freeLikeCalculatorInstance(instanceHandle1) < 0) {
            *numErrors += 1;
            fprintf(stderr, "freeLikeCalculatorInstance failed.\n");
        }   
        else
            *numPasses += 1;
    }
    if (instanceHandle2 >= 0) {
        if (freeLikeCalculatorInstance(instanceHandle2) < 0) {
            *numErrors += 1;
            fprintf(stderr, "freeLikeCalculatorInstance failed.\n");
        }   
        else
            *numPasses += 1;
    }
    if (instanceHandle1 >= 0) {
        if (freeLikeCalculatorInstance(instanceHandle1) >= 0) {
            *numErrors += 1;
            fprintf(stderr, "double call to freeLikeCalculatorInstance did not fail.\n");
        }
        else
            *numPasses += 1;
    }
    
}