mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Finish stubbing out the path compiler class.
This commit is contained in:
parent
0f526fe67e
commit
6f6fdbe3e4
@ -25,8 +25,89 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "pathcompiler.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "waypoint.h"
|
||||
#include "homelocation.h"
|
||||
|
||||
PathCompiler::PathCompiler(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
Waypoint *waypoint = NULL;
|
||||
HomeLocation *homeLocation = NULL;
|
||||
|
||||
/* Connect the object updates */
|
||||
waypoint = Waypoint::GetInstance(getObjectManger());
|
||||
Q_ASSERT(waypoint);
|
||||
if(waypoint)
|
||||
connect(waypoint, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(doUpdateFromUAV()));
|
||||
|
||||
homeLocation = HomeLocation::GetInstance(getObjectManager());
|
||||
Q_ASSERT(homeLocation);
|
||||
if(homeLocation)
|
||||
connect(homeLocation, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(doUpdateFromUAV()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the uavobjectamanger
|
||||
*/
|
||||
UAVObjectManager * PathCompiler::getObjectManager()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = NULL;
|
||||
UAVObjectUtilManager *objMngr = NULL;
|
||||
|
||||
pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
if(pm)
|
||||
objMngr = pm->getObject<UAVObjectUtilManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
|
||||
return objMngr;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method opens a dialog (if filename is null) and saves the path
|
||||
* @param filename The file to save the path to
|
||||
* @returns -1 for failure, 0 for success
|
||||
*/
|
||||
int PathCompiler::savePath(QString filename = null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method opens a dialog (if filename is null) and loads the path
|
||||
* @param filename The file to load from
|
||||
* @returns -1 for failure, 0 for success
|
||||
*/
|
||||
int PathCompiler::loadPath(QString filename = null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a waypoint
|
||||
* @param waypoint the new waypoint to add
|
||||
* @param position which position to insert it to, defaults to end
|
||||
*/
|
||||
void PathCompiler::doAddWaypoint(struct PathCompiler::waypoint, int position = -1)
|
||||
{
|
||||
emit visualizationChanged(waypoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a waypoint
|
||||
* @param index which waypoint to delete
|
||||
*/
|
||||
void PathCompiler::doDelWaypoint(int index)
|
||||
{
|
||||
emit visualizationChanged(waypoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* When the UAV waypoints change trigger the pathcompiler to
|
||||
* get the latest version and then update the visualization
|
||||
*/
|
||||
void PathCompiler::doUpdateFromUAV()
|
||||
{
|
||||
emit visualizationChanged(waypoints);
|
||||
}
|
||||
|
@ -29,6 +29,10 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <uavobject.h>
|
||||
#include <uavobjectmanager.h>
|
||||
|
||||
// TODO: Make this a singleton class and separate from map library. Not sure of the proper design pattern in Qt.
|
||||
// factory? static variables?
|
||||
|
||||
/**
|
||||
* This class is a two way adapter between a visualization of a path and the
|
||||
@ -54,6 +58,13 @@ public:
|
||||
float longitude;
|
||||
};
|
||||
|
||||
private:
|
||||
//! Helper method to get uavobject manager
|
||||
UAVObjectManager * getObjectManager();
|
||||
|
||||
//! The internal list of waypoints
|
||||
QList <struct waypoint> waypoints;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Indicates something changed the waypoints and the map should
|
||||
|
Loading…
x
Reference in New Issue
Block a user