mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
PathActionEditor: added more buttons, always highlight active waypoint and pathaction
This commit is contained in:
parent
298b6233ed
commit
df67a3e631
@ -31,6 +31,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonNewWaypoint">
|
||||
<property name="text">
|
||||
<string>New Waypoint</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSaveFile">
|
||||
<property name="text">
|
||||
<string>Save to File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonLoadFile">
|
||||
<property name="text">
|
||||
<string>Load from File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -57,10 +57,14 @@ PathActionEditorGadgetWidget::PathActionEditorGadgetWidget(QWidget *parent) : QL
|
||||
Q_ASSERT(objManager != NULL);
|
||||
pathactionObj = PathAction::GetInstance(objManager);
|
||||
Q_ASSERT(pathactionObj != NULL);
|
||||
waypointObj = Waypoint::GetInstance(objManager);
|
||||
Q_ASSERT(waypointObj != NULL);
|
||||
|
||||
// Connect the signals
|
||||
connect(m_pathactioneditor->buttonNewPathAction, SIGNAL(clicked()),
|
||||
this, SLOT(addInstance()));
|
||||
this, SLOT(addPathActionInstance()));
|
||||
connect(m_pathactioneditor->buttonNewWaypoint, SIGNAL(clicked()),
|
||||
this, SLOT(addWaypointInstance()));
|
||||
}
|
||||
|
||||
PathActionEditorGadgetWidget::~PathActionEditorGadgetWidget()
|
||||
@ -72,7 +76,7 @@ void PathActionEditorGadgetWidget::pathactionChanged(UAVObject *)
|
||||
{
|
||||
}
|
||||
|
||||
void PathActionEditorGadgetWidget::addInstance()
|
||||
void PathActionEditorGadgetWidget::addPathActionInstance()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm != NULL);
|
||||
@ -87,6 +91,21 @@ void PathActionEditorGadgetWidget::addInstance()
|
||||
qDebug() << "Instances after: " << objManager->getNumInstances(pathactionObj->getObjID());
|
||||
}
|
||||
|
||||
void PathActionEditorGadgetWidget::addWaypointInstance()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm != NULL);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager != NULL);
|
||||
|
||||
qDebug() << "Instances before: " << objManager->getNumInstances(waypointObj->getObjID());
|
||||
Waypoint *obj = new Waypoint();
|
||||
quint32 newInstId = objManager->getNumInstances(waypointObj->getObjID());
|
||||
obj->initialize(newInstId,obj->getMetaObject());
|
||||
objManager->registerObject(obj);
|
||||
qDebug() << "Instances after: " << objManager->getNumInstances(waypointObj->getObjID());
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTreeView>
|
||||
#include "pathaction.h"
|
||||
#include "waypoint.h"
|
||||
#include "pathactioneditortreemodel.h"
|
||||
|
||||
class Ui_PathActionEditor;
|
||||
@ -47,12 +48,14 @@ signals:
|
||||
|
||||
protected slots:
|
||||
void pathactionChanged(UAVObject *);
|
||||
void addInstance();
|
||||
void addPathActionInstance();
|
||||
void addWaypointInstance();
|
||||
|
||||
private:
|
||||
Ui_PathActionEditor * m_pathactioneditor;
|
||||
PathActionEditorTreeModel *m_model;
|
||||
PathAction *pathactionObj;
|
||||
Waypoint *waypointObj;
|
||||
};
|
||||
|
||||
#endif /* PathActionEditorGADGETWIDGET_H_ */
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtCore/QDebug>
|
||||
#include "waypoint.h"
|
||||
#include "waypointactive.h"
|
||||
#include "pathaction.h"
|
||||
|
||||
PathActionEditorTreeModel::PathActionEditorTreeModel(QObject *parent) :
|
||||
@ -50,6 +51,7 @@ PathActionEditorTreeModel::PathActionEditorTreeModel(QObject *parent) :
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
connect(objManager, SIGNAL(newInstance(UAVObject*)), this, SLOT(newInstance(UAVObject*)));
|
||||
connect(objManager->getObject("WaypointActive"),SIGNAL(objectUpdated(UAVObject*)), this, SLOT(objUpdated(UAVObject*)));
|
||||
|
||||
setupModelData(objManager);
|
||||
}
|
||||
@ -324,8 +326,8 @@ void PathActionEditorTreeModel::updateHighlight(TreeItem *item)
|
||||
searchItem = searchItem->parent();
|
||||
}
|
||||
if (objItem) {
|
||||
item->apply();
|
||||
objItem->apply();
|
||||
item->apply();
|
||||
objItem->apply();
|
||||
UAVObject *obj = objItem->object();
|
||||
Q_ASSERT(obj);
|
||||
obj->updated();
|
||||
@ -336,11 +338,11 @@ void PathActionEditorTreeModel::highlightUpdatedObject(UAVObject *obj)
|
||||
{
|
||||
Q_ASSERT(obj);
|
||||
if (obj->getName().compare("Waypoint")==0) {
|
||||
m_waypointsTree->update();
|
||||
//emit dataChanged(index(m_waypointsTree), index(m_waypointsTree));
|
||||
m_waypointsTree->update();
|
||||
//emit dataChanged(index(m_waypointsTree), index(m_waypointsTree));
|
||||
} else if (obj->getName().compare("PathAction")==0) {
|
||||
m_pathactionsTree->update();
|
||||
//emit dataChanged(index(m_pathactionsTree), index(m_pathactionsTree));
|
||||
m_pathactionsTree->update();
|
||||
//emit dataChanged(index(m_pathactionsTree), index(m_pathactionsTree));
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,11 +350,37 @@ void PathActionEditorTreeModel::newInstance(UAVObject *obj)
|
||||
{
|
||||
|
||||
if (obj->getName().compare("Waypoint")==0) {
|
||||
addInstance(obj,m_waypointsTree);
|
||||
m_waypointsTree->update();
|
||||
addInstance(obj,m_waypointsTree);
|
||||
m_waypointsTree->update();
|
||||
} else if (obj->getName().compare("PathAction")==0) {
|
||||
addInstance(obj,m_pathactionsTree);
|
||||
m_pathactionsTree->update();
|
||||
addInstance(obj,m_pathactionsTree);
|
||||
m_pathactionsTree->update();
|
||||
}
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void PathActionEditorTreeModel::objUpdated(UAVObject *obj)
|
||||
{
|
||||
if (obj->getName().compare("WaypointActive")==0) {
|
||||
qint16 index = obj->getField("Index")->getValue().toInt();
|
||||
qint16 action;
|
||||
foreach (TreeItem *child,m_waypointsTree->treeChildren()) {
|
||||
ObjectTreeItem *objItem = dynamic_cast<ObjectTreeItem*>(child);
|
||||
if (index == objItem->object()->getInstID()) {
|
||||
child->setActive(true);
|
||||
action = objItem->object()->getField("Action")->getValue().toInt();
|
||||
} else {
|
||||
child->setActive(false);
|
||||
}
|
||||
}
|
||||
foreach (TreeItem *child,m_pathactionsTree->treeChildren()) {
|
||||
ObjectTreeItem *objItem = dynamic_cast<ObjectTreeItem*>(child);
|
||||
if (action == objItem->object()->getInstID()) {
|
||||
child->setActive(true);
|
||||
} else {
|
||||
child->setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
void newInstance(UAVObject *obj);
|
||||
void objUpdated(UAVObject *obj);
|
||||
|
||||
private slots:
|
||||
void highlightUpdatedObject(UAVObject *obj);
|
||||
|
@ -105,10 +105,17 @@ void TreeItem::apply() {
|
||||
}
|
||||
|
||||
void TreeItem::setHighlight(bool highlight) {
|
||||
m_highlight = highlight;
|
||||
//m_highlight = highlight;
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
void TreeItem::setActive(bool highlight) {
|
||||
m_highlight = highlight;
|
||||
foreach(TreeItem *child, treeChildren())
|
||||
child->setActive(highlight);
|
||||
}
|
||||
|
||||
|
||||
void TreeItem::removeHighlight() {
|
||||
m_highlight = false;
|
||||
update();
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
|
||||
inline bool highlighted() { return m_highlight; }
|
||||
void setHighlight(bool highlight);
|
||||
void setActive(bool highlight);
|
||||
|
||||
inline bool changed() { return m_changed; }
|
||||
inline void setChanged(bool changed) { m_changed = changed; if(changed) emit updateHighlight(this); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user