23 #include <boost/filesystem.hpp> 29 #include <boost/regex.hpp> 31 #include <HalconCpp.h> 36 std::vector<boost::filesystem::path> files;
40 for (
unsigned int i = 0; i < files.size(); i++) {
46 std::string object_model_name = std::string(
choice_object_model->GetStringSelection().mb_str());
47 std::string object_model_path = input_path.string() + object_model_name;
48 HalconCpp::HObjectModel3D model;
49 model.ReadObjectModel3d(object_model_path.c_str(),
"mm", HalconCpp::HTuple(), HalconCpp::HTuple());
50 wxString diameter_string;
51 diameter_string << model.MaxDiameterObjectModel3d();
52 std::replace(diameter_string.begin(), diameter_string.end(),
',',
'.');
58 for (
unsigned int i = 0; i < files.size(); i++) {
59 choice_mesh->AppendString(wxString(files[i].
string().c_str(), wxConvUTF8));
67 Main_Dialog::Main_Dialog(wxWindow *parent, std::string name, std::string object_model, std::string mesh, std::string rotation_type, std::string orientation_x, std::string orientation_y, std::string orientation_z, std::string diameter, std::string score_3D)
70 edit_name->SetValue(wxString(name.c_str(), wxConvUTF8));
74 edit_diameter->SetValue(wxString(diameter.c_str(), wxConvUTF8));
75 edit_score_3D->SetValue(wxString(score_3D.c_str(), wxConvUTF8));
77 std::vector<boost::filesystem::path> files;
82 for (
unsigned int i = 0; i < files.size(); i++) {
84 if (files[i].
string() == object_model) {
94 for (
unsigned int i = 0; i < files.size(); i++) {
95 choice_mesh->AppendString(wxString(files[i].
string().c_str(), wxConvUTF8));
96 if (files[i].
string() == mesh) {
110 wxMessageDialog *dial =
new wxMessageDialog(
this,
111 wxT(
"Are you sure to quit?"), wxT(
"Quit"),
112 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
113 if (dial->ShowModal() == wxID_YES) {
120 std::string object_model_name = std::string(
choice_object_model->GetStringSelection().mb_str());
121 std::string object_model_path = input_path.string() + object_model_name;
122 HalconCpp::HObjectModel3D model;
123 model.ReadObjectModel3d(object_model_path.c_str(),
"mm", HalconCpp::HTuple(), HalconCpp::HTuple());
124 wxString diameter_string;
125 diameter_string << model.MaxDiameterObjectModel3d();;
131 wxMessageDialog *dial =
new wxMessageDialog(
this,
132 wxT(
"Are you sure to quit?"), wxT(
"Quit"),
133 wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
134 if (dial->ShowModal() == wxID_YES) {
144 std::string name =
trim(std::string(
edit_name->GetValue().mb_str()));
161 std::string object_model = std::string(
choice_object_model->GetStringSelection().mb_str());
162 std::string mesh = std::string(
choice_mesh->GetStringSelection().mb_str());
164 DescModelsDialog *descModelsDialog =
new DescModelsDialog( (wxWindow*)
NULL, name, object_model, mesh, rotation_type, orientation_x, orientation_y, orientation_z, diameter, score_3D);
166 descModelsDialog ->Show();
171 wxMessageDialog *dial =
new wxMessageDialog(
this,
172 wxT(
"There was no valid mesh found in the input folder. Please provide a mesh-file (*.dae)"), wxT(
"Warning"), wxOK | wxICON_WARNING);
176 wxMessageDialog *dial =
new wxMessageDialog(
this,
177 wxT(
"There was no valid object-model found in the input folder. Please provide an object model (*.obj)"), wxT(
"Warning"), wxOK | wxICON_WARNING);
181 wxMessageDialog *dial =
new wxMessageDialog(
this,
182 wxT(
"The provided score is not a valid double!"), wxT(
"Warning"), wxOK | wxICON_WARNING);
186 wxMessageDialog *dial =
new wxMessageDialog(
this,
187 wxT(
"The provided diameter is not a valid double!"), wxT(
"Warning"), wxOK | wxICON_WARNING);
191 wxMessageDialog *dial =
new wxMessageDialog(
this,
192 wxT(
"The provided z-value of the orientation is not a valid double!"), wxT(
"Warning"), wxOK | wxICON_WARNING);
196 wxMessageDialog *dial =
new wxMessageDialog(
this,
197 wxT(
"The provided y-value of the orientation is not a valid double!"), wxT(
"Warning"), wxOK | wxICON_WARNING);
201 wxMessageDialog *dial =
new wxMessageDialog(
this,
202 wxT(
"The provided x-value of the orientation is not a valid double!"), wxT(
"Warning"), wxOK | wxICON_WARNING);
206 wxMessageDialog *dial =
new wxMessageDialog(
this,
207 wxT(
"The provided name is not correct, please enter a name containing only letters!"), wxT(
"Warning"), wxOK | wxICON_WARNING);
216 std::string name =
trim(std::string(
edit_name->GetValue().mb_str()));
225 if (!(
check_string_redex(orientation_x, boost::regex(
"^[-+]?[0-9]+(\\.[0-9]+)?$")))) {
233 if (!(
check_string_redex(orientation_y, boost::regex(
"^[-+]?[0-9]+(\\.[0-9]+)?$")))) {
241 if (!(
check_string_redex(orientation_z, boost::regex(
"^[-+]?[0-9]+(\\.[0-9]+)?$")))) {
250 double dia = boost::lexical_cast<
double>(
trim(std::string(
edit_diameter->GetValue().mb_str())));
263 double score = boost::lexical_cast<
double>(
trim(std::string(
edit_score_3D->GetValue().mb_str())));
264 if ((score <= 0) || (score >= 1)) {
void onDialogClose(wxCloseEvent &event)
void onCancelPressed(wxCommandEvent &event)
Main_Dialog(wxWindow *parent)
The constructor of this class.
void onKillFocusOrientationY(wxFocusEvent &event)
wxTextCtrl * edit_orientation_x
void onTextEnterOrientationY(wxCommandEvent &event)
std::string trim(std::string input)
Removes spaces from the beginning and end of the given string.
void onTextEnterOrientationX(wxCommandEvent &event)
const std::string ROTATIONTYPE_CYLINDER
wxTextCtrl * edit_orientation_y
wxTextCtrl * edit_diameter
void onKillFocusOrientationZ(wxFocusEvent &event)
void onKillFocusDiameter(wxFocusEvent &event)
const std::string ROTATIONTYPE_SPHERE
wxChoice * choice_rotation_type
void onNextPressed(wxCommandEvent &event)
const std::string ROTATIONTYPE_NO_ROTATION
bool check_string_redex(std::string to_check, boost::regex regex)
Checks a string with the given regex.
ROSLIB_DECL std::string getPath(const std::string &package_name)
wxTextCtrl * edit_orientation_z
void get_all_files_with_ext(const boost::filesystem::path &root, const std::string &ext, std::vector< boost::filesystem::path > &ret)
Gets all files in a directory with a specific extension.
void onKillFocusOrientationX(wxFocusEvent &event)
void onObjectModelSelected(wxCommandEvent &event)
const std::string INPUT_FOLDER
void onTextEnterName(wxCommandEvent &event)
void onKillFocusScore3D(wxFocusEvent &event)
void onTextEnterDiameter(wxCommandEvent &event)
wxChoice * choice_object_model
void onKillFocusName(wxFocusEvent &event)
void onTextEnterScore3D(wxCommandEvent &event)
wxTextCtrl * edit_score_3D
void onTextEnterOrientationZ(wxCommandEvent &event)