Skip to content

Commit

Permalink
renamed graspitGUI to graspitCore. The graspitCore class holds pointe…
Browse files Browse the repository at this point in the history
…rs to ivmgr, mainWindow, world, starts and stops plugins and mainloop
  • Loading branch information
jvarley committed Jun 21, 2016
1 parent a957c78 commit 682464a
Show file tree
Hide file tree
Showing 46 changed files with 315 additions and 325 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ set (GRASPIT_INCLUDEDIR_HEADERS
${GSRC}/include/worldElement.h
${GSRC}/include/worldElementFactory.h
${GSRC}/include/world.h
${GSRC}/include/graspitGUI.h
${GSRC}/include/graspitCore.h
${GSRC}/include/graspitServer.h
${GSRC}/include/graspitApp.h
${GSRC}/include/arch.h
Expand Down Expand Up @@ -341,7 +341,7 @@ set (GRASPIT_CORE_SOURCES
${GSRC}/src/eigenGrasp.cpp
${GSRC}/src/gloveInterface.cpp
${GSRC}/src/grasp.cpp
${GSRC}/src/graspitGUI.cpp
${GSRC}/src/graspitCore.cpp
${GSRC}/src/graspitServer.cpp
${GSRC}/src/graspitApp.cpp
${GSRC}/src/graspRecord.cpp
Expand Down
35 changes: 20 additions & 15 deletions include/graspitGUI.h → include/graspitCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
//
// Author(s): Andrew T. Miller
//
// $Id: graspitGUI.h,v 1.5 2010/08/11 02:45:37 cmatei Exp $
// $Id: graspitCore.h,v 1.5 2010/08/11 02:45:37 cmatei Exp $
//
//######################################################################

/*! \file
\brief Defines a graspit user interface class that contains subpieces of the UI.
\brief Defines the GraspIt! core class. It holds pointers the mainwindow, ivmgr, world.
*/

#ifndef GRASPITGUI_HXX
#ifndef GRASPIT_CORE_H

#include <string>
#include <vector>
Expand Down Expand Up @@ -57,14 +57,17 @@ class World;
This class can also initialize a task dispatcher which is then in charge of
batch execution of tasks based on information form a grasp database.
*/
class GraspItGUI
class GraspitCore
{
//! A pointer to the MainWindow.
MainWindow *mainWindow;

//! A pointer to the IVmgr.
//! A pointer to the IVmgr. This will be NULL if in headless mode.
IVmgr *ivmgr;

//! A pointer to the world
World *world;

//! A pointer to the Task Dispatcher, if any
TaskDispatcher *mDispatch;

Expand All @@ -88,14 +91,13 @@ class GraspItGUI

bool headless;

protected:
int processArgs(int argc, char **argv, cmdline::parser *args);

public:
GraspItGUI(int argc, char **argv, cmdline::parser *args);
~GraspItGUI();
GraspitCore();
~GraspitCore();

int init(int argc, char **argv);

/*! Returns whether the UI pieces were successfully initialized. */
/*! Returns whether GraspIt! was successfully initialized. */
bool terminalFailure() const;

//! Returns the exit code (set internally based on the application)
Expand All @@ -104,8 +106,8 @@ class GraspItGUI
/*! Returns a pointer to the MainWindow. */
MainWindow *getMainWindow() const {return mainWindow;}

/*! Returns a pointer to the World (obtained through the main window) */
World *getMainWorld() const;
/*! Returns a pointer to the World */
World *getWorld() const {return world;}

/*! Returns a pointer to the IVmgr. */
IVmgr *getIVmgr() const {return ivmgr;}
Expand All @@ -129,6 +131,9 @@ class GraspItGUI
void exitMainLoop();

bool isHeadless(){return headless;}

void emptyWorld();

};

#if defined(WIN32) && !defined(__MINGW32__)
Expand All @@ -141,7 +146,7 @@ class GraspItGUI
#define GRASPIT_API
#endif

extern GRASPIT_API GraspItGUI *graspItGUI;
extern GRASPIT_API GraspitCore *graspitCore;

#define GRASPITGUI_HXX
#define GRASPIT_CORE_H
#endif
11 changes: 3 additions & 8 deletions include/ivmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,12 @@ public Q_SLOTS:
void restoreCameraPos();

public:
IVmgr(QWidget *parent=0,const char *name=0,bool headless=false, Qt::WFlags f=0);
IVmgr(World *w, QWidget *parent=0,const char *name=0, Qt::WFlags f=0);
~IVmgr();

void deselectBody(Body *b);
void setWorld(World *w);

/*!
Returns a pointer to the main World that the user interacts with through
this manager.
*/
World *getWorld() const {return world;}
void deselectBody(Body *b);

/*!
Returns a pointer to the Inventor examiner viewer.
Expand All @@ -262,7 +258,6 @@ public Q_SLOTS:
SoSeparator *getPointers() const {return pointers;}

void setTool(ToolType newTool);
void emptyWorld();
void hilightObjContact(int contactNum);
void unhilightObjContact(int contactNum);

Expand Down
3 changes: 3 additions & 0 deletions include/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ class World : public QObject {
//! Sets all world settings to their original default values.
void setDefaults();

//! Sets the ivmgr for the world.
void setIVMgr(IVmgr *ivmgr){myIVmgr = ivmgr;}

//! Sets the world modified flag. Should be done when a change has since the last save.
void setModified() {modified = true;}

Expand Down
4 changes: 2 additions & 2 deletions plugins/openclose/openClosePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "openClosePlugin.h"

#include "mainWindow.h"
#include "graspitGUI.h"
#include "graspitCore.h"
#include "world.h"
#include "robot.h"

Expand Down Expand Up @@ -54,7 +54,7 @@ int OpenClosePlugin::mainLoop()
{
static int direction = 1.0;
std::cout <<"in main loop" << std::endl;
World *world = graspItGUI->getMainWindow()->getMainWorld();
World *world = graspitCore->getWorld();
if (!world) std::cerr << "Open-close plugin main loop: no world?!?\n";
else if (!world->getCurrentHand()) std::cerr << "Open-close plugin main loop: no hand selected\n";
else world->getCurrentHand()->autoGrasp(true, direction);
Expand Down
32 changes: 16 additions & 16 deletions src/DBase/dbaseDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
#include <QDir>
#include <QComboBox>

#include "graspitGUI.h"
#include "graspitCore.h"
#include "ivmgr.h"
#include "robot.h"
#include "world.h"
#include "searchState.h"
#include "grasp.h"
#include "graspitGUI.h"
#include "graspitCore.h"
#include "mainWindow.h"
#include "matvec3D.h"

Expand Down Expand Up @@ -73,7 +73,7 @@ void DBaseDlg::init()
mGraspList.clear();
browserGroup->setEnabled(FALSE);
graspsGroup->setEnabled(FALSE);
mDBMgr = graspItGUI->getIVmgr()->getDBMgr();
mDBMgr = graspitCore->getIVmgr()->getDBMgr();
if (mDBMgr) {
getModelList();
}
Expand All @@ -92,7 +92,7 @@ void DBaseDlg::destroy()
void DBaseDlg::exitButton_clicked(){
if (mCurrentLoadedModel) {
//remove the previously loaded model, but don't delete it
graspItGUI->getIVmgr()->getWorld()->destroyElement(mCurrentLoadedModel->getGraspableBody(), false);
graspitCore->getWorld()->destroyElement(mCurrentLoadedModel->getGraspableBody(), false);
}
//delete and release all the memories occupied by the grasps
deleteVectorElements<db_planner::Grasp*, GraspitDBGrasp*>(mGraspList);
Expand Down Expand Up @@ -146,7 +146,7 @@ void DBaseDlg::getModelList()
void DBaseDlg::connectButton_clicked()
{
delete mDBMgr;
Hand *h = graspItGUI->getIVmgr()->getWorld()->getCurrentHand();
Hand *h = graspitCore->getWorld()->getCurrentHand();

#ifndef ROS_DATABASE_MANAGER
mDBMgr = new db_planner::SqlDatabaseManager(hostLineEdit->text().toStdString(),
Expand Down Expand Up @@ -176,7 +176,7 @@ void DBaseDlg::connectButton_clicked()
delete mDBMgr;
mDBMgr = NULL;
}
graspItGUI->getIVmgr()->setDBMgr(mDBMgr);
graspitCore->getIVmgr()->setDBMgr(mDBMgr);
}

PROF_DECLARE(GET_GRASPS);
Expand All @@ -186,7 +186,7 @@ void DBaseDlg::loadGraspButton_clicked(){
PROF_RESET_ALL;
PROF_START_TIMER(GET_GRASPS);
//get the current hand and check its validity
Hand *hand = graspItGUI->getIVmgr()->getWorld()->getCurrentHand();
Hand *hand = graspitCore->getWorld()->getCurrentHand();
if (!hand) {
DBGA("Load and select a hand before viewing grasps!");
return;
Expand Down Expand Up @@ -236,7 +236,7 @@ void DBaseDlg::loadGraspButton_clicked(){
void DBaseDlg::loadModelButton_clicked(){
if (mCurrentLoadedModel) {
//remove the previously loaded model, but don't delete it
graspItGUI->getIVmgr()->getWorld()->destroyElement(mCurrentLoadedModel->getGraspableBody(), false);
graspitCore->getWorld()->destroyElement(mCurrentLoadedModel->getGraspableBody(), false);
mCurrentLoadedModel = NULL;
}
if(mModelList.empty()){
Expand All @@ -253,7 +253,7 @@ void DBaseDlg::loadModelButton_clicked(){
//check that this model is already loaded into Graspit, if not, load it
if (!model->geometryLoaded()) {
//this loads the actual geometry in the scene graph of the object
if ( model->load(graspItGUI->getIVmgr()->getWorld()) != SUCCESS) {
if ( model->load(graspitCore->getWorld()) != SUCCESS) {
DBGA("Model load failed");
return;
}
Expand All @@ -263,7 +263,7 @@ void DBaseDlg::loadModelButton_clicked(){
//todo: where to dynamic information come from?
//model->getGraspableBody()->initDynamics();
//this adds the object to the graspit world so that we can see it
graspItGUI->getIVmgr()->getWorld()->addBody(model->getGraspableBody());
graspitCore->getWorld()->addBody(model->getGraspableBody());
//and remember it
mCurrentLoadedModel = model;
//model->getGraspableBody()->showAxes(false);
Expand Down Expand Up @@ -296,7 +296,7 @@ void DBaseDlg::plannerButton_clicked(){
return;
}
//check the hand
Hand *h = graspItGUI->getIVmgr()->getWorld()->getCurrentHand();
Hand *h = graspitCore->getWorld()->getCurrentHand();
if(!h){
DBGA("No hand found currently");
return;
Expand Down Expand Up @@ -376,7 +376,7 @@ void DBaseDlg::sortButton_clicked()

//a shortcut for the GWS display
void DBaseDlg::createGWSButton_clicked(){
graspItGUI->getMainWindow()->graspCreateProjection();
graspitCore->getMainWindow()->graspCreateProjection();
}

//trigger when the selection in the model list combo box is changed, display the corresponding new image
Expand Down Expand Up @@ -500,8 +500,8 @@ void DBaseDlg::showGrasp(int i)
if(!static_cast<GraspitDBGrasp*>(mGraspList[i])->getFinalGraspPlanningState())//NULL grasp, return
return;
static_cast<GraspitDBGrasp*>(mGraspList[i])->getFinalGraspPlanningState()->execute();
if(graspItGUI->getIVmgr()->getWorld()->getCurrentHand()->isA("Barrett")){
graspItGUI->getIVmgr()->getWorld()->getCurrentHand()->autoGrasp(true);
if(graspitCore->getWorld()->getCurrentHand()->isA("Barrett")){
graspitCore->getWorld()->getCurrentHand()->autoGrasp(true);
}
}

Expand All @@ -515,8 +515,8 @@ void DBaseDlg::showGrasp(int i)
*/

//update the world and grasp information
graspItGUI->getIVmgr()->getWorld()->findAllContacts();
graspItGUI->getIVmgr()->getWorld()->updateGrasps();
graspitCore->getWorld()->findAllContacts();
graspitCore->getWorld()->updateGrasps();
mCurrentFrame = i;
updateGraspInfo();
}
Expand Down
6 changes: 3 additions & 3 deletions src/DBase/dbasePlannerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "graspit_db_grasp.h"
#include "searchState.h"

#include "graspitGUI.h"
#include "graspitCore.h"
#include "mainWindow.h"

#include "DBPlanner/caching_neighbor_finder.h"
Expand Down Expand Up @@ -211,7 +211,7 @@ void DBasePlannerDlg::nextGraspButton_clicked(){

// shortcut for the GWS display
void DBasePlannerDlg::createGWSButton_clicked(){
graspItGUI->getMainWindow()->graspCreateProjection();
graspitCore->getMainWindow()->graspCreateProjection();
}

// put the entries into the distance function combo box
Expand Down Expand Up @@ -295,7 +295,7 @@ void DBasePlannerDlg::showGrasp(db_planner::Grasp* grasp){
static_cast<GraspitDBModel*>(mPlanningModel)->getGraspableBody()->setTran(transf::IDENTITY);
g->getPreGraspPlanningState()->execute();
if(mHand->isA("Barrett") && testedGraspRadioButton->isChecked()){
graspItGUI->getIVmgr()->getWorld()->getCurrentHand()->autoGrasp(true);
graspitCore->getWorld()->getCurrentHand()->autoGrasp(true);
}
mHand->getWorld()->findAllContacts();
mHand->getWorld()->updateGrasps();
Expand Down
12 changes: 6 additions & 6 deletions src/DBase/dbase_grasp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "dbase_grasp.h"
#include "ivmgr.h"
#include "graspitGUI.h"
#include "graspitCore.h"
#include "world.h"
#include "searchState.h"
#include "egPlanner.h"
Expand All @@ -43,7 +43,7 @@
#include "debug.h"
#include <Inventor/sensors/SoTimerSensor.h>

DBaseBatchPlanner::DBaseBatchPlanner(IVmgr *mgr, GraspItGUI *gui)
DBaseBatchPlanner::DBaseBatchPlanner(IVmgr *mgr, GraspitCore *gui)
{
ivmgr = mgr;
mGui = gui;
Expand Down Expand Up @@ -103,7 +103,7 @@ bool DBaseBatchPlanner::processArguments(int argc, char **argv)

filename = graspitRoot + QString("/models/robots/") + QString(argv[2]) + QString("/")
+ QString(argv[2]) + QString(".xml");
mHand = (Hand*)ivmgr->getWorld()->importRobot(filename);
mHand = (Hand*)graspitCore->getWorld()->importRobot(filename);
if ( !mHand ) {
DBGAF(mLogStream,"DBase planner: failed to load robot name " << argv[2] << ", or it is not a Hand");
return false;
Expand All @@ -116,7 +116,7 @@ bool DBaseBatchPlanner::processArguments(int argc, char **argv)
return false;
}
filename = QString(argv[3]);
mObject = static_cast<GraspableBody*>(ivmgr->getWorld()->importBody("GraspableBody",filename));
mObject = static_cast<GraspableBody*>(graspitCore->getWorld()->importBody("GraspableBody",filename));
((GraspableBody*)mObject)->showAxes(false);

if (!mObject) {
Expand Down Expand Up @@ -281,7 +281,7 @@ void DBaseBatchPlanner::plannerComplete()
DBGAF(mLogStream,"Planner completed; starting shutdown");

if (mType == GRIPPER) {
ivmgr->getWorld()->destroyElement(mHand,false);
graspitCore->getWorld()->destroyElement(mHand,false);
fprintf(stderr,"Taking scans...\n");
takeScans();
}
Expand All @@ -298,7 +298,7 @@ void DBaseBatchPlanner::plannerComplete()
void DBaseBatchPlanner::sensorCB(void *data, SoSensor*)
{
DBaseBatchPlanner *planner = (DBaseBatchPlanner*)data;
GraspItGUI *gui = planner->mGui;
GraspitCore *gui = planner->mGui;
DBGAF(planner->mLogStream,"Shutdown signal received");
delete planner;
gui->exitMainLoop();
Expand Down
6 changes: 3 additions & 3 deletions src/DBase/dbase_grasp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class EGPlanner;
class Hand;
class Body;
class GraspableBody;
class GraspItGUI;
class GraspitCore;
class GraspPlanningState;
class SoSensor;
class SoTimerSensor;
Expand All @@ -60,7 +60,7 @@ class DBaseBatchPlanner : public QObject
GraspableBody *mObject;
Hand *mHand;
IVmgr *ivmgr;
GraspItGUI *mGui;
GraspitCore *mGui;
EGPlanner *mPlanner;
//maybe one day we'll use streams here...
FILE *mResultFile;
Expand Down Expand Up @@ -90,7 +90,7 @@ public Q_SLOTS:
//this one gets called when the inner planner stops
void plannerComplete();
public:
DBaseBatchPlanner(IVmgr *mgr, GraspItGUI *gui);
DBaseBatchPlanner(IVmgr *mgr, GraspitCore *gui);
~DBaseBatchPlanner();
bool processArguments(int argc, char **argv);
bool startPlanner();
Expand Down
Loading

0 comments on commit 682464a

Please sign in to comment.