Commit 15b283bb authored by Sören Schwertfeger's avatar Sören Schwertfeger
Browse files

quite good already

parent 188a932e
......@@ -21,7 +21,7 @@
//Qt
#include <QtGui>
#include <QFileDialog>
#include <QInputDialog>
#include "sttl.h"
......@@ -71,10 +71,41 @@ void qTransformsPlugin::getActions(QActionGroup& group)
//connect appropriate signal
connect(m_actionSaveTransform, SIGNAL(triggered()), this, SLOT(saveTransforms()));
m_changeUserAction = new QAction("Change User Name: ",this);
m_changeUserAction->setToolTip("Change the user name...");
m_changeUserAction->setIcon(getIcon());
connect(m_changeUserAction, SIGNAL(triggered()), this, SLOT(changeUser()));
m_changeMethodAction = new QAction("Change Registration Method: ",this);
m_changeMethodAction->setToolTip("Change the method used for registration...");
m_changeMethodAction->setIcon(getIcon());
connect(m_changeMethodAction, SIGNAL(triggered()), this, SLOT(changeMethod()));
m_changeDetailsAction = new QAction("Change Method Details",this);
m_changeDetailsAction->setToolTip("Change some details about the registration...");
m_changeDetailsAction->setIcon(getIcon());
connect(m_changeDetailsAction, SIGNAL(triggered()), this, SLOT(changeDetails()));
m_frameNameLength = 8;
QString txt("Change Frame Name Length: %1");
txt = txt.arg(m_frameNameLength);
m_changeFrameNameLengthAction = new QAction(txt,this);
m_changeFrameNameLengthAction->setToolTip("Change some details about the registration...");
m_changeFrameNameLengthAction->setIcon(getIcon());
connect(m_changeFrameNameLengthAction, SIGNAL(triggered()), this, SLOT(changeFrameNameLength()));
}
group.addAction(m_action);
//group.addAction(m_action);
group.addAction(m_changeUserAction);
group.addAction(m_changeMethodAction);
group.addAction(m_changeDetailsAction);
group.addAction(m_changeFrameNameLengthAction);
QAction * sep = new QAction(this);
sep->setSeparator(true);
group.addAction(sep);
group.addAction(m_actionLoadTransform);
group.addAction(m_actionSaveTransform);
}
......@@ -111,7 +142,18 @@ void qTransformsPlugin::recTravTree(ccHObject * obj, sttl::Transform * parent){
if(obj->getClassID() == CC_TYPES::POINT_CLOUD){
// this is a point cloud - will be a new parent...
sttl::Transform transform;
transform.frameName = obj->getName().toStdString();
transform.program = "Cloudcompare";
transform.byUser = m_user.toStdString();
transform.method = m_method.toStdString();
transform.details = m_detials.toStdString();
transform.time = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss").toStdString();
//std::list<Id> history; // ToDo: History filling...
transform.frameName = obj->getName().toStdString().substr(0,m_frameNameLength);
//ccGLMatrix transf;
//obj->getAbsoluteGLTransformation(transf);
......@@ -190,8 +232,6 @@ void qTransformsPlugin::applyFrames(ccHObject * obj, std::list<sttl::Frame> &fra
m_app->refreshAll();
}
void qTransformsPlugin::loadTransforms(){
......@@ -215,8 +255,13 @@ void qTransformsPlugin::loadTransforms(){
}
void qTransformsPlugin::saveTransforms(){
while(m_user.isEmpty()) changeUser();
while(m_method.isEmpty()) changeMethod();
ccHObject * root = getMainAppInterface()->dbRootObject();
recTravTree(root, QString(""));
......@@ -238,6 +283,47 @@ void qTransformsPlugin::saveTransforms(){
}
void qTransformsPlugin::changeUser(){
bool ok;
QString name = QInputDialog::getText(0, "Provide the user Name (currently "+m_user+")", "New user name:",QLineEdit::Normal, m_user, &ok);
if(ok && !name.isEmpty()) {
m_user = name;
m_changeUserAction->setText("Change User Name: "+m_user);
}
}
void qTransformsPlugin::changeMethod(){
QStringList list;
list << sttl::METHOD_MANUAL.c_str() << sttl::METHOD_POINT_PAIRS.c_str() << sttl::METHOD_ICP.c_str();
bool ok;
QString method = QInputDialog::getItem(0, "Registration Method", "Method:", list, 0, true, &ok);
if(ok && !method.isEmpty()) {
m_method = method;
m_changeMethodAction->setText("Change Registration Method: "+m_method);
}
}
void qTransformsPlugin::changeDetails(){
bool ok;
QString details = QInputDialog::getText(0, "Change Details", "Details:", QLineEdit::Normal, m_detials, &ok);
if(ok && !details.isEmpty()) {
m_detials = details;
}
}
void qTransformsPlugin::changeFrameNameLength(){
bool ok;
int len = QInputDialog::getInt(0, "Provide the frame name length", "New frame name length:", m_frameNameLength, 1, 255, 1, &ok);
if(ok) {
m_frameNameLength = len;
QString txt("Change Frame Name Length: %1");
txt = txt.arg(m_frameNameLength);
m_changeFrameNameLengthAction->setText(txt);
}
}
//This is an example of an action's slot called when the corresponding action
//is triggered (i.e. the corresponding icon or menu entry is clicked in CC's
......
......@@ -66,6 +66,11 @@ protected slots:
void loadTransforms();
void saveTransforms();
void changeUser();
void changeMethod();
void changeDetails();
void changeFrameNameLength();
protected:
//! Default action
......@@ -85,6 +90,16 @@ protected:
QAction* m_action;
QAction* m_actionLoadTransform;
QAction* m_actionSaveTransform;
QAction* m_changeUserAction;
QAction* m_changeMethodAction;
QAction* m_changeDetailsAction;
QAction* m_changeFrameNameLengthAction;
QString m_user;
QString m_method;
QString m_detials;
int m_frameNameLength;
};
#endif
......@@ -39,6 +39,18 @@ bool readJson(sttl::Transform & transform, Json::Value & node){
transform.referenceFrameName = node["referenceFrame"].asString();
transform.id.fromString(node["id"].asString());
transform.byUser = node["user"].asString();
transform.method = node["method"].asString();
transform.program = node["program"].asString();
transform.details = node["details"].asString();
transform.time = node["time"].asString();
for(int i=0; i<node["history"].size(); ++i){
sttl::Transform::Id id;
if(id.fromString(node["history"][i].asString())){
transform.history.push_back(id);
}
}
if(node["transform"].size()!=4){
std::cerr<<"transform does not have 4 elements!"<<std::endl;
......@@ -55,7 +67,6 @@ bool readJson(sttl::Transform & transform, Json::Value & node){
}
}
transform.hasCovariance = false;
if(node.isMember("covariance")){
transform.hasCovariance = true;
......@@ -110,6 +121,18 @@ bool fillJson(const sttl::Transform & transform, Json::Value & node){
node["referenceFrame"] = transform.referenceFrameName;
node["id"] = transform.id.toString();
node["user"] = transform.byUser;
node["method"] = transform.method;
node["program"] = transform.program;
node["details"] = transform.details;
node["time"] = transform.time;
node["history"] = Json::Value(Json::arrayValue);
for(std::list<sttl::Transform::Id>::const_iterator itr = transform.history.begin(); itr != transform.history.end(); ++itr){
node["history"].append(itr->toString());
}
return true;
}
......@@ -194,12 +217,16 @@ bool sttl::loadList(std::list<sttl::Transform> & transfs, const std::string &fil
std::cerr<<"Error opening file "<<file<<std::endl;
return false;
}
std::cerr<<" reading JSON from "<<file<<std::endl;
Json::Value root;
fs >> root;
std::cerr<<" iterating through JSON tree ..."<<std::endl;
for(int i = 0 ; i < root.size() ; ++i){
sttl::Transform trans;
std::cerr<<" reading "<<i<<std::endl;
bool ret = readJson(trans, root[i]);
std::cerr<<" done reading "<<i<<std::endl;
if(!ret){
std::cerr<<"Error reading transform # "<<i<<std::endl;
return false;
......@@ -211,7 +238,12 @@ bool sttl::loadList(std::list<sttl::Transform> & transfs, const std::string &fil
std::list<sttl::Frame>::iterator sttl::findFrameForData(std::list<sttl::Frame> &frames, const std::string & dataName){
for(std::list<sttl::Frame>::iterator itr = frames.begin(); itr!= frames.end(); ++itr){
if(itr->name.compare(dataName) == 0 ){
std::string cmpName = dataName;
// adjust the size of the data name such that it is max as long as the frame name here
if(cmpName.size()>itr->name.size()){
cmpName = cmpName.substr(0, itr->name.size());
}
if(itr->name.compare(cmpName) == 0 ){
return itr;
}
}
......
......@@ -72,6 +72,7 @@ public:
};
static const std::string METHOD_MANUAL = "Manual";
static const std::string METHOD_POINT_PAIRS = "Point Pairs";
static const std::string METHOD_ICP = "ICP";
static const std::string METHOD_G2O = "g2o";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment