Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'kchen' of https://github.com/mdfeist/BlinkAnalysis into…

… Mike
  • Loading branch information...
commit 2d7d9c3290b4bb0cff117dc1c75c0084309c7307 2 parents 5e9c22b + c9afb71
@mdfeist authored
View
743 BlinkAnalysis/AddObjectForm.h
@@ -14,8 +14,6 @@ namespace BlinkAnalysis {
using namespace System::Data;
using namespace System::Drawing;
- enum class objectType {PLANE, BOX};
-
/// <summary>
/// Summary for AddObjectForm
/// </summary>
@@ -93,6 +91,30 @@ namespace BlinkAnalysis {
private: System::Windows::Forms::TextBox^ planeInPt2TextBox;
private: System::Windows::Forms::TextBox^ planeInCornerTextBox;
private: System::Windows::Forms::TextBox^ planeInPt1TextBox;
+ private: System::Windows::Forms::TabPage^ boxPage;
+ private: System::Windows::Forms::Button^ boxSetButton;
+ private: System::Windows::Forms::TextBox^ boxInCenTextBox;
+ private: System::Windows::Forms::RadioButton^ boxCoordRadio;
+
+
+ private: System::Windows::Forms::RadioButton^ boxRigidRadio;
+ private: System::Windows::Forms::RadioButton^ boxMarkersRadio;
+
+ private: System::Windows::Forms::Label^ boxInfoLabel;
+ private: System::Windows::Forms::Label^ boxOptionalLabel;
+ private: System::Windows::Forms::TextBox^ boxNameTextBox;
+ private: System::Windows::Forms::Label^ boxNameLabel;
+ private: System::Windows::Forms::Label^ boxCentreLabel;
+ private: System::Windows::Forms::Button^ boxGetButton;
+ private: System::Windows::Forms::Label^ boxCenDataLabel;
+
+ private: System::Windows::Forms::TextBox^ boxCenTextBox;
+ private: System::Windows::Forms::TextBox^ boxHTextBox;
+ private: System::Windows::Forms::TextBox^ boxWTextBox;
+ private: System::Windows::Forms::TextBox^ boxLTextBox;
+ private: System::Windows::Forms::Label^ boxHeightLabel;
+ private: System::Windows::Forms::Label^ boxWidthLabel;
+ private: System::Windows::Forms::Label^ boxLengthLabel;
private:
/// <summary>
@@ -135,14 +157,36 @@ namespace BlinkAnalysis {
this->planeCornerTextBox = (gcnew System::Windows::Forms::TextBox());
this->planePt2TextBox = (gcnew System::Windows::Forms::TextBox());
this->planePt1TextBox = (gcnew System::Windows::Forms::TextBox());
+ this->boxPage = (gcnew System::Windows::Forms::TabPage());
+ this->boxHTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->boxWTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->boxLTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->boxHeightLabel = (gcnew System::Windows::Forms::Label());
+ this->boxWidthLabel = (gcnew System::Windows::Forms::Label());
+ this->boxLengthLabel = (gcnew System::Windows::Forms::Label());
+ this->boxSetButton = (gcnew System::Windows::Forms::Button());
+ this->boxInCenTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->boxCoordRadio = (gcnew System::Windows::Forms::RadioButton());
+ this->boxRigidRadio = (gcnew System::Windows::Forms::RadioButton());
+ this->boxMarkersRadio = (gcnew System::Windows::Forms::RadioButton());
+ this->boxInfoLabel = (gcnew System::Windows::Forms::Label());
+ this->boxOptionalLabel = (gcnew System::Windows::Forms::Label());
+ this->boxNameTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->boxNameLabel = (gcnew System::Windows::Forms::Label());
+ this->boxCentreLabel = (gcnew System::Windows::Forms::Label());
+ this->boxGetButton = (gcnew System::Windows::Forms::Button());
+ this->boxCenDataLabel = (gcnew System::Windows::Forms::Label());
+ this->boxCenTextBox = (gcnew System::Windows::Forms::TextBox());
this->tabControl1->SuspendLayout();
this->planePage->SuspendLayout();
+ this->boxPage->SuspendLayout();
this->SuspendLayout();
//
// tabControl1
//
this->tabControl1->Controls->Add(this->infoPage);
this->tabControl1->Controls->Add(this->planePage);
+ this->tabControl1->Controls->Add(this->boxPage);
this->tabControl1->Location = System::Drawing::Point(0, -1);
this->tabControl1->Name = L"tabControl1";
this->tabControl1->SelectedIndex = 0;
@@ -394,7 +438,7 @@ namespace BlinkAnalysis {
this->planeSetButton->Name = L"planeSetButton";
this->planeSetButton->Size = System::Drawing::Size(103, 23);
this->planeSetButton->TabIndex = 17;
- this->planeSetButton->Text = L"Set Points";
+ this->planeSetButton->Text = L"Make Plane";
this->planeSetButton->UseVisualStyleBackColor = true;
this->planeSetButton->Click += gcnew System::EventHandler(this, &AddObjectForm::planeSetButton_Click);
//
@@ -452,6 +496,225 @@ namespace BlinkAnalysis {
this->planePt1TextBox->Size = System::Drawing::Size(82, 20);
this->planePt1TextBox->TabIndex = 11;
//
+ // boxPage
+ //
+ this->boxPage->Controls->Add(this->boxHTextBox);
+ this->boxPage->Controls->Add(this->boxWTextBox);
+ this->boxPage->Controls->Add(this->boxLTextBox);
+ this->boxPage->Controls->Add(this->boxHeightLabel);
+ this->boxPage->Controls->Add(this->boxWidthLabel);
+ this->boxPage->Controls->Add(this->boxLengthLabel);
+ this->boxPage->Controls->Add(this->boxSetButton);
+ this->boxPage->Controls->Add(this->boxInCenTextBox);
+ this->boxPage->Controls->Add(this->boxCoordRadio);
+ this->boxPage->Controls->Add(this->boxRigidRadio);
+ this->boxPage->Controls->Add(this->boxMarkersRadio);
+ this->boxPage->Controls->Add(this->boxInfoLabel);
+ this->boxPage->Controls->Add(this->boxOptionalLabel);
+ this->boxPage->Controls->Add(this->boxNameTextBox);
+ this->boxPage->Controls->Add(this->boxNameLabel);
+ this->boxPage->Controls->Add(this->boxCentreLabel);
+ this->boxPage->Controls->Add(this->boxGetButton);
+ this->boxPage->Controls->Add(this->boxCenDataLabel);
+ this->boxPage->Controls->Add(this->boxCenTextBox);
+ this->boxPage->Location = System::Drawing::Point(4, 22);
+ this->boxPage->Name = L"boxPage";
+ this->boxPage->Padding = System::Windows::Forms::Padding(3);
+ this->boxPage->Size = System::Drawing::Size(410, 287);
+ this->boxPage->TabIndex = 2;
+ this->boxPage->Text = L"Box";
+ this->boxPage->UseVisualStyleBackColor = true;
+ //
+ // boxHTextBox
+ //
+ this->boxHTextBox->Location = System::Drawing::Point(212, 222);
+ this->boxHTextBox->Name = L"boxHTextBox";
+ this->boxHTextBox->Size = System::Drawing::Size(83, 20);
+ this->boxHTextBox->TabIndex = 54;
+ this->boxHTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &AddObjectForm::boxTextBox_Validating);
+ //
+ // boxWTextBox
+ //
+ this->boxWTextBox->Location = System::Drawing::Point(123, 222);
+ this->boxWTextBox->Name = L"boxWTextBox";
+ this->boxWTextBox->Size = System::Drawing::Size(83, 20);
+ this->boxWTextBox->TabIndex = 53;
+ this->boxWTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &AddObjectForm::boxTextBox_Validating);
+ //
+ // boxLTextBox
+ //
+ this->boxLTextBox->Location = System::Drawing::Point(34, 222);
+ this->boxLTextBox->Name = L"boxLTextBox";
+ this->boxLTextBox->Size = System::Drawing::Size(83, 20);
+ this->boxLTextBox->TabIndex = 52;
+ this->boxLTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &AddObjectForm::boxTextBox_Validating);
+ //
+ // boxHeightLabel
+ //
+ this->boxHeightLabel->AutoSize = true;
+ this->boxHeightLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxHeightLabel->Location = System::Drawing::Point(209, 204);
+ this->boxHeightLabel->Name = L"boxHeightLabel";
+ this->boxHeightLabel->Size = System::Drawing::Size(71, 15);
+ this->boxHeightLabel->TabIndex = 51;
+ this->boxHeightLabel->Text = L"Height (Z)";
+ //
+ // boxWidthLabel
+ //
+ this->boxWidthLabel->AutoSize = true;
+ this->boxWidthLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxWidthLabel->Location = System::Drawing::Point(120, 204);
+ this->boxWidthLabel->Name = L"boxWidthLabel";
+ this->boxWidthLabel->Size = System::Drawing::Size(65, 15);
+ this->boxWidthLabel->TabIndex = 50;
+ this->boxWidthLabel->Text = L"Width (Y)";
+ //
+ // boxLengthLabel
+ //
+ this->boxLengthLabel->AutoSize = true;
+ this->boxLengthLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxLengthLabel->Location = System::Drawing::Point(31, 204);
+ this->boxLengthLabel->Name = L"boxLengthLabel";
+ this->boxLengthLabel->Size = System::Drawing::Size(74, 15);
+ this->boxLengthLabel->TabIndex = 49;
+ this->boxLengthLabel->Text = L"Length (X)";
+ //
+ // boxSetButton
+ //
+ this->boxSetButton->Enabled = false;
+ this->boxSetButton->Location = System::Drawing::Point(292, 253);
+ this->boxSetButton->Name = L"boxSetButton";
+ this->boxSetButton->Size = System::Drawing::Size(103, 23);
+ this->boxSetButton->TabIndex = 48;
+ this->boxSetButton->Text = L"Make Box";
+ this->boxSetButton->UseVisualStyleBackColor = true;
+ this->boxSetButton->Click += gcnew System::EventHandler(this, &AddObjectForm::boxSetButton_Click);
+ //
+ // boxInCenTextBox
+ //
+ this->boxInCenTextBox->Location = System::Drawing::Point(108, 171);
+ this->boxInCenTextBox->Name = L"boxInCenTextBox";
+ this->boxInCenTextBox->Size = System::Drawing::Size(220, 20);
+ this->boxInCenTextBox->TabIndex = 47;
+ this->boxInCenTextBox->Visible = false;
+ this->boxInCenTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &AddObjectForm::boxTextBox_Validating);
+ //
+ // boxCoordRadio
+ //
+ this->boxCoordRadio->AutoSize = true;
+ this->boxCoordRadio->Location = System::Drawing::Point(257, 93);
+ this->boxCoordRadio->Name = L"boxCoordRadio";
+ this->boxCoordRadio->Size = System::Drawing::Size(81, 17);
+ this->boxCoordRadio->TabIndex = 46;
+ this->boxCoordRadio->TabStop = true;
+ this->boxCoordRadio->Text = L"Coordinates";
+ this->boxCoordRadio->UseVisualStyleBackColor = true;
+ this->boxCoordRadio->CheckedChanged += gcnew System::EventHandler(this, &AddObjectForm::boxCoordRadio_CheckedChanged);
+ //
+ // boxRigidRadio
+ //
+ this->boxRigidRadio->AutoSize = true;
+ this->boxRigidRadio->Location = System::Drawing::Point(148, 93);
+ this->boxRigidRadio->Name = L"boxRigidRadio";
+ this->boxRigidRadio->Size = System::Drawing::Size(100, 17);
+ this->boxRigidRadio->TabIndex = 43;
+ this->boxRigidRadio->Text = L"Rigid Body Tool";
+ this->boxRigidRadio->UseVisualStyleBackColor = true;
+ //
+ // boxMarkersRadio
+ //
+ this->boxMarkersRadio->AutoSize = true;
+ this->boxMarkersRadio->Checked = true;
+ this->boxMarkersRadio->Location = System::Drawing::Point(67, 93);
+ this->boxMarkersRadio->Name = L"boxMarkersRadio";
+ this->boxMarkersRadio->Size = System::Drawing::Size(63, 17);
+ this->boxMarkersRadio->TabIndex = 42;
+ this->boxMarkersRadio->TabStop = true;
+ this->boxMarkersRadio->Text = L"Markers";
+ this->boxMarkersRadio->UseVisualStyleBackColor = true;
+ this->boxMarkersRadio->CheckedChanged += gcnew System::EventHandler(this, &AddObjectForm::boxMarkerRadio_CheckedChanged);
+ //
+ // boxInfoLabel
+ //
+ this->boxInfoLabel->AutoSize = true;
+ this->boxInfoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxInfoLabel->Location = System::Drawing::Point(18, 21);
+ this->boxInfoLabel->Name = L"boxInfoLabel";
+ this->boxInfoLabel->Size = System::Drawing::Size(127, 15);
+ this->boxInfoLabel->TabIndex = 41;
+ this->boxInfoLabel->Text = L"Add a box to the world";
+ //
+ // boxOptionalLabel
+ //
+ this->boxOptionalLabel->AutoSize = true;
+ this->boxOptionalLabel->ForeColor = System::Drawing::SystemColors::ControlDarkDark;
+ this->boxOptionalLabel->Location = System::Drawing::Point(254, 60);
+ this->boxOptionalLabel->Name = L"boxOptionalLabel";
+ this->boxOptionalLabel->Size = System::Drawing::Size(44, 13);
+ this->boxOptionalLabel->TabIndex = 40;
+ this->boxOptionalLabel->Text = L"optional";
+ //
+ // boxNameTextBox
+ //
+ this->boxNameTextBox->Location = System::Drawing::Point(69, 57);
+ this->boxNameTextBox->Name = L"boxNameTextBox";
+ this->boxNameTextBox->Size = System::Drawing::Size(179, 20);
+ this->boxNameTextBox->TabIndex = 39;
+ //
+ // boxNameLabel
+ //
+ this->boxNameLabel->AutoSize = true;
+ this->boxNameLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxNameLabel->Location = System::Drawing::Point(18, 58);
+ this->boxNameLabel->Name = L"boxNameLabel";
+ this->boxNameLabel->Size = System::Drawing::Size(45, 15);
+ this->boxNameLabel->TabIndex = 38;
+ this->boxNameLabel->Text = L"Name";
+ //
+ // boxCentreLabel
+ //
+ this->boxCentreLabel->AutoSize = true;
+ this->boxCentreLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxCentreLabel->Location = System::Drawing::Point(17, 172);
+ this->boxCentreLabel->Name = L"boxCentreLabel";
+ this->boxCentreLabel->Size = System::Drawing::Size(85, 15);
+ this->boxCentreLabel->TabIndex = 37;
+ this->boxCentreLabel->Text = L"Base Centre";
+ //
+ // boxGetButton
+ //
+ this->boxGetButton->Location = System::Drawing::Point(21, 128);
+ this->boxGetButton->Name = L"boxGetButton";
+ this->boxGetButton->Size = System::Drawing::Size(75, 23);
+ this->boxGetButton->TabIndex = 36;
+ this->boxGetButton->Text = L"Get Data";
+ this->boxGetButton->UseVisualStyleBackColor = true;
+ this->boxGetButton->Click += gcnew System::EventHandler(this, &AddObjectForm::boxGetButton_Click);
+ //
+ // boxCenDataLabel
+ //
+ this->boxCenDataLabel->AutoSize = true;
+ this->boxCenDataLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->boxCenDataLabel->Location = System::Drawing::Point(101, 131);
+ this->boxCenDataLabel->Name = L"boxCenDataLabel";
+ this->boxCenDataLabel->Size = System::Drawing::Size(84, 15);
+ this->boxCenDataLabel->TabIndex = 35;
+ this->boxCenDataLabel->Text = L"No data found";
+ //
+ // boxCenTextBox
+ //
+ this->boxCenTextBox->Location = System::Drawing::Point(108, 171);
+ this->boxCenTextBox->Name = L"boxCenTextBox";
+ this->boxCenTextBox->Size = System::Drawing::Size(79, 20);
+ this->boxCenTextBox->TabIndex = 34;
+ //
// AddObjectForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
@@ -465,20 +728,151 @@ namespace BlinkAnalysis {
this->tabControl1->ResumeLayout(false);
this->planePage->ResumeLayout(false);
this->planePage->PerformLayout();
+ this->boxPage->ResumeLayout(false);
+ this->boxPage->PerformLayout();
this->ResumeLayout(false);
}
#pragma endregion
+///////////////////////////
// local variables
-private: osg::Vec3* pos1;
-private: osg::Vec3* posC;
-private: osg::Vec3* pos2;
-private: osg::Vec3* pos;
+///////////////////////////
+private: osg::Vec3* planePos1;
+private: osg::Vec3* planePosC;
+private: osg::Vec3* planePos2;
+private: osg::Vec3* planePos;
+private: osg::Vec3* boxPosCen;
+
+///////////////////////////
+// util functions
+///////////////////////////
+ // set text to display when there is no position data
+private: System::Void setDefaultText(Label^ text) {
+ text->Text = this->defaultDataText;
+ }
+ // set text to display when there is position data
+private: System::Void setPoint(osg::Vec3* pos, Label^ text) {
+ String^ str = Convert::ToString(pos->x());
+ str += ", ";
+ str += Convert::ToString(pos->y());
+ str += ", ";
+ str += Convert::ToString(pos->z());
+ text->Text = str;
+ }
+ // converts a managed String^ to unmanaged std::string*
+private: std::string* managedToStdString(String^ str) {
+ return new std::string( (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str)).ToPointer());
+ }
+ // checks if input string is a valid coordinate (x, y, z)
+private: bool isCoordinate(String^ str) {
+ String^ regs = "^\\s*-?\\d+(.\\d+)?\\s*," +
+ "\\s*-?\\d+(.\\d+)?\\s*," +
+ "\\s*-?\\d+(.\\d+)?\\s*$";
+ System::Text::RegularExpressions::Regex^ regex = gcnew System::Text::RegularExpressions::Regex(regs);
+ return regex->IsMatch(str);
+ }
+ // checks if input string is a valid float
+private: bool isFloat(String^ str) {
+ String^ regs = "^\\s*-?\\d+(.\\d+)?\\s*$";
+ System::Text::RegularExpressions::Regex^ regex = gcnew System::Text::RegularExpressions::Regex(regs);
+ return regex->IsMatch(str);
+ }
+ // extracts coordinates from input text box
+private: bool extractCoordinates(TextBox^ tb, osg::Vec3* pt) {
+ if (!pt || !tb)
+ return false;
+
+ float x, y, z;
+ array<String^>^ split = tb->Text->Split(gcnew array<wchar_t> {','});
+ if (!Single::TryParse(split[0], x))
+ return false;
+ if (!Single::TryParse(split[1], y))
+ return false;
+ if (!Single::TryParse(split[2], z))
+ return false;
+
+ pt->set(x, y, z);
+ return true;
+ }
+ // set visible/not visible for buttons associated with rigid body view
+private: System::Void rigidSetButtons(bool enable, bool visible, ObjectType type) {
+ switch (type)
+ {
+ // plane
+ case PLANE :
+ this->planePt1SetButton->Visible = visible;
+ this->planePt1SetButton->Enabled = enable;
+
+ this->planeCornerSetButton->Visible = visible;
+ this->planeCornerSetButton->Enabled = enable;
+
+ this->planePt2SetButton->Visible = visible;
+ this->planePt2SetButton->Enabled = enable;
+ break;
+
+
+ }
+ }
+ // set visible/not visible for text boxes associated with markers view
+private: System::Void markerTextBoxes(bool visible, ObjectType type) {
+ switch (type)
+ {
+ // plane
+ case PLANE :
+ this->planePt1TextBox->Visible = visible;
+ this->planeCornerTextBox->Visible = visible;
+ this->planePt2TextBox->Visible = visible;
+ break;
+ case BOX :
+ this->boxCenTextBox->Visible = visible;
+ break;
+
+ }
+ }
+ // set visible/not visible for text boxes associated with coordinates view
+private: System::Void coordinateTextBoxes(bool visible, ObjectType type) {
+ switch (type)
+ {
+ // plane
+ case PLANE :
+ this->planeInPt1TextBox->Visible = visible;
+ this->planeInCornerTextBox->Visible = visible;
+ this->planeInPt2TextBox->Visible = visible;
+ break;
+ case BOX :
+ this->boxInCenTextBox->Visible = visible;
+
+ }
+ }
+
+///////////////////////////
+// form functions
+///////////////////////////
+private: System::Void AddObjectForm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) {
+ if (planePos1) delete planePos1;
+ if (planePosC) delete planePosC;
+ if (planePos2) delete planePos2;
+ if (planePos) delete planePos;
+ if (boxPosCen) delete boxPosCen;
+ }
+ // set enable/disable, visible/not visible for buttons associated with rigid body tool view
+private: System::Void AddObjectForm_Load(System::Object^ sender, System::EventArgs^ e) {
+ this->defaultDataText = L"No data found";
+ planePos1 = new osg::Vec3();
+ planePosC = new osg::Vec3();
+ planePos2 = new osg::Vec3();
+ planePos = new osg::Vec3();
+ boxPosCen = new osg::Vec3();
+ }
+///////////////////////////
+// plane functions
+///////////////////////////
// get data from client
// markers: based on ID in each text field
// rigid body: based on chosen rigid body tool
+ // coordinate: based on input (validated)
private: System::Void planeDataGetButton_Click(System::Object^ sender, System::EventArgs^ e) {
ClientHandler* client = AppData::getInstance()->getClient();
// use markers
@@ -500,11 +894,8 @@ private: System::Void planeDataGetButton_Click(System::Object^ sender, System::
else
{
osg::Vec3 pt = marker->getPosition();
- if (!pos1)
- pos1 = new osg::Vec3(pt.x(), pt.y(), pt.z());
- else
- pos1->set(pt.x(), pt.y(), pt.z());
- setPoint(pos1, this->planeDataPt1Label);
+ planePos1->set(pt.x(), pt.y(), pt.z());
+ setPoint(planePos1, this->planeDataPt1Label);
}
// corner
@@ -518,11 +909,8 @@ private: System::Void planeDataGetButton_Click(System::Object^ sender, System::
else
{
osg::Vec3 pt = marker->getPosition();
- if (!posC)
- posC = new osg::Vec3(pt.x(), pt.y(), pt.z());
- else
- posC->set(pt.x(), pt.y(), pt.z());
- setPoint(posC, this->planeDataCornerLabel);
+ planePosC->set(pt.x(), pt.y(), pt.z());
+ setPoint(planePosC, this->planeDataCornerLabel);
}
// point 2
@@ -536,11 +924,8 @@ private: System::Void planeDataGetButton_Click(System::Object^ sender, System::
else
{
osg::Vec3 pt = marker->getPosition();
- if (!pos2)
- pos2 = new osg::Vec3(pt.x(), pt.y(), pt.z());
- else
- pos2->set(pt.x(), pt.y(), pt.z());
- setPoint(pos2, this->planeDataPt2Label);
+ planePos2->set(pt.x(), pt.y(), pt.z());
+ setPoint(planePos2, this->planeDataPt2Label);
}
client->unlock();
}
@@ -550,88 +935,25 @@ private: System::Void planeDataGetButton_Click(System::Object^ sender, System::
RigidBody* body = client->getRigidBody(client->getRigidBodyTool());
if (body)
{
- if (!pos)
- pos = new osg::Vec3();
-
- pos->set(body->getPosition().x(),
+ planePos->set(body->getPosition().x(),
body->getPosition().y(),
body->getPosition().z());
- setPoint(pos, this->planeRigidDataLabel);
- rigidSetButtons(true, true, objectType::PLANE);
+ setPoint(planePos, this->planeRigidDataLabel);
+ rigidSetButtons(true, true, PLANE);
return;
}
}
}
- // set text to display when there is no position data
-private: System::Void setDefaultText(Label^ text) {
- text->Text = this->defaultDataText;
- }
- // set text to display when there is position data
-private: System::Void setPoint(osg::Vec3* pos, Label^ text) {
- String^ str = Convert::ToString(pos->x());
- str += ", ";
- str += Convert::ToString(pos->y());
- str += ", ";
- str += Convert::ToString(pos->z());
- text->Text = str;
- }
- // extracts coordinates from input text box
-private: bool extractCoordinates()
- {
- float x, y, z;
- array<String^>^ split;
-
- // pos1
- split = this->planeInPt1TextBox->Text->Split(gcnew array<wchar_t> {','});
- if (!Single::TryParse(split[0], x))
- return false;
- if (!Single::TryParse(split[1], y))
- return false;
- if (!Single::TryParse(split[2], z))
- return false;
- if (!pos1)
- pos1 = new osg::Vec3(x, y, z);
- else
- pos1->set(x, y, z);
-
- // posC
- split = this->planeInCornerTextBox->Text->Split(gcnew array<wchar_t> {','});
- if (!Single::TryParse(split[0], x))
- return false;
- if (!Single::TryParse(split[1], y))
- return false;
- if (!Single::TryParse(split[2], z))
- return false;
- if (!posC)
- posC = new osg::Vec3(x, y, z);
- else
- posC->set(x, y, z);
-
- // pos2
- split = this->planeInPt2TextBox->Text->Split(gcnew array<wchar_t> {','});
- if (!Single::TryParse(split[0], x))
- return false;
- if (!Single::TryParse(split[1], y))
- return false;
- if (!Single::TryParse(split[2], z))
- return false;
- if (!pos2)
- pos2 = new osg::Vec3(x, y, z);
- else
- pos2->set(x, y, z);
-
- return true;
- }
// add plane to world based on data from posC, pos1, pos2
private: System::Void planeSetButton_Click(System::Object^ sender, System::EventArgs^ e) {
- if (this->planeCoordRadio->Checked && !extractCoordinates())
+ if (this->planeCoordRadio->Checked && !planeExtractCoordinates())
return;
CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
if (world)
{
- std::string* str = new std::string( (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(this->planeNameTextBox->Text)).ToPointer());
- CaptureObject* object = world->addPlane(*posC, *pos1, *pos2, *str);
+ std::string* str = managedToStdString(this->planeNameTextBox->Text);
+ CaptureObject* object = world->addPlane(*planePosC, *planePos1, *planePos2, *str);
if (object)
{
String^ id = Convert::ToString(object->getID());
@@ -640,64 +962,10 @@ private: System::Void planeSetButton_Click(System::Object^ sender, System::Even
}
this->Close();
}
-private: System::Void AddObjectForm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) {
- if (pos1) delete pos1;
- if (posC) delete posC;
- if (pos2) delete pos2;
- if (pos) delete pos;
- }
- // set enable/disable, visible/not visible for buttons associated with rigid body tool view
-private: System::Void rigidSetButtons(bool enable, bool visible, objectType type) {
- switch (type)
- {
- // plane
- case objectType::PLANE :
- this->planePt1SetButton->Visible = visible;
- this->planePt1SetButton->Enabled = enable;
-
- this->planeCornerSetButton->Visible = visible;
- this->planeCornerSetButton->Enabled = enable;
-
- this->planePt2SetButton->Visible = visible;
- this->planePt2SetButton->Enabled = enable;
- break;
-
-
- }
- }
- // set visible/not visible for text boxes associated with markers view
-private: System::Void markerTextBoxes(bool visible, objectType type) {
- switch (type)
- {
- // plane
- case objectType::PLANE :
- this->planePt1TextBox->Visible = visible;
- this->planeCornerTextBox->Visible = visible;
- this->planePt2TextBox->Visible = visible;
- break;
-
-
- }
- }
- // set visible/not visible for text boxes associated with coordinates view
-private: System::Void coordinateTextBoxes(bool visible, objectType type) {
- switch (type)
- {
- // plane
- case objectType::PLANE :
- this->planeInPt1TextBox->Visible = visible;
- this->planeInCornerTextBox->Visible = visible;
- this->planeInPt2TextBox->Visible = visible;
- break;
-
-
- }
- }
- // change visibility of form objects based on which radio button is checked
private: System::Void planeRigidRadio_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
if (this->planeRigidRadio->Checked)
{
- rigidSetButtons(false, true, objectType::PLANE);
+ rigidSetButtons(false, true, PLANE);
setDefaultText(this->planeRigidDataLabel);
setDefaultText(this->planeDataPt1Label);
@@ -709,7 +977,7 @@ private: System::Void planeRigidRadio_CheckedChanged(System::Object^ sender, Sy
}
else
{
- rigidSetButtons(false, false, objectType::PLANE);
+ rigidSetButtons(false, false, PLANE);
this->planeRigidDataLabel->Visible = false;
}
@@ -717,7 +985,7 @@ private: System::Void planeRigidRadio_CheckedChanged(System::Object^ sender, Sy
private: System::Void planeMarkersRadio_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
if (this->planeMarkersRadio->Checked)
{
- markerTextBoxes(true, objectType::PLANE);
+ markerTextBoxes(true, PLANE);
setDefaultText(this->planeDataPt1Label);
setDefaultText(this->planeDataCornerLabel);
@@ -727,20 +995,13 @@ private: System::Void planeMarkersRadio_CheckedChanged(System::Object^ sender,
}
else
{
- markerTextBoxes(false, objectType::PLANE);
+ markerTextBoxes(false, PLANE);
}
}
-private: bool isCoordinate(String^ str) {
- String^ regs = "^\\s*-?\\d+(.\\d+)?\\s*," +
- "\\s*-?\\d+(.\\d+)?\\s*," +
- "\\s*-?\\d+(.\\d+)?\\s*$";
- System::Text::RegularExpressions::Regex^ regex = gcnew System::Text::RegularExpressions::Regex(regs);
- return regex->IsMatch(str);
- }
private: System::Void planeCoordRadio_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
if (this->planeCoordRadio->Checked)
{
- coordinateTextBoxes(true, objectType::PLANE);
+ coordinateTextBoxes(true, PLANE);
this->planeDataPt1Label->Text = "";
this->planeDataCornerLabel->Text = "";
@@ -751,26 +1012,31 @@ private: System::Void planeCoordRadio_CheckedChanged(System::Object^ sender, Sy
}
else
{
- coordinateTextBoxes(false, objectType::PLANE);
+ coordinateTextBoxes(false, PLANE);
this->planeDataGetButton->Visible = true;
}
}
-private: System::Void AddObjectForm_Load(System::Object^ sender, System::EventArgs^ e) {
- this->defaultDataText = L"No data found";
- pos1 = NULL;
- posC = NULL;
- pos2 = NULL;
- pos = NULL;
+ // populate vectors based on coordinate input
+private: bool planeExtractCoordinates()
+ {
+ if (!extractCoordinates(this->planeInPt1TextBox, planePos1))
+ return false;
+
+ if (!extractCoordinates(this->planeInCornerTextBox, planePosC))
+ return false;
+
+ if (!extractCoordinates(this->planeInPt2TextBox, planePos2))
+ return false;
+
+ return true;
}
+ // change visibility of form objects based on which radio button is checked
// gets data from rigid body tool and sets it to one of the three points
private: System::Void planeSetDataButton_Click(System::Object^ sender, System::EventArgs^ e) {
if (sender == this->planePt1SetButton)
{
- if (!pos1)
- pos1 = new osg::Vec3();
-
- pos1->set(pos->x(), pos->y(), pos->z());
- setPoint(pos, this->planeDataPt1Label);
+ planePos1->set(planePos->x(), planePos->y(), planePos->z());
+ setPoint(planePos, this->planeDataPt1Label);
if ( String::Compare(this->planeDataCornerLabel->Text, this->defaultDataText) &&
String::Compare(this->planeDataPt2Label->Text, this->defaultDataText) )
@@ -780,11 +1046,8 @@ private: System::Void planeSetDataButton_Click(System::Object^ sender, System::
}
else if (sender == this->planeCornerSetButton)
{
- if (!posC)
- posC = new osg::Vec3();
-
- posC->set(pos->x(), pos->y(), pos->z());
- setPoint(pos, this->planeDataCornerLabel);
+ planePosC->set(planePos->x(), planePos->y(), planePos->z());
+ setPoint(planePos, this->planeDataCornerLabel);
if ( String::Compare(this->planeDataPt1Label->Text, this->defaultDataText) &&
String::Compare(this->planeDataPt2Label->Text, this->defaultDataText) )
@@ -794,11 +1057,8 @@ private: System::Void planeSetDataButton_Click(System::Object^ sender, System::
}
else if (sender == this->planePt2SetButton)
{
- if (!pos2)
- pos2 = new osg::Vec3();
-
- pos2->set(pos->x(), pos->y(), pos->z());
- setPoint(pos, this->planeDataPt2Label);
+ planePos2->set(planePos->x(), planePos->y(), planePos->z());
+ setPoint(planePos, this->planeDataPt2Label);
if ( String::Compare(this->planeDataPt1Label->Text, this->defaultDataText) &&
String::Compare(this->planeDataCornerLabel->Text, this->defaultDataText) )
@@ -841,6 +1101,131 @@ private: System::Void planeTextBox_Validating(System::Object^ sender, System::C
}
}
+
+///////////////////////////
+// box functions
+///////////////////////////
+
+private: System::Void boxGetButton_Click(System::Object^ sender, System::EventArgs^ e) {
+ ClientHandler* client = AppData::getInstance()->getClient();
+ // use markers
+ if (this->boxMarkersRadio->Checked && client->lock())
+ {
+ Marker* marker;
+ bool result;
+ int id;
+ this->boxSetButton->Enabled = true;
+
+ result = Int32::TryParse(this->boxCenTextBox->Text, id);
+ marker = client->getLabeledMarker(id);
+ if (!result || !marker)
+ {
+ setDefaultText(this->boxCenDataLabel);
+ this->boxSetButton->Enabled = false;
+ }
+ else
+ {
+ osg::Vec3 pt = marker->getPosition();
+ boxPosCen->set(pt.x(), pt.y(), pt.z());
+ setPoint(boxPosCen, this->boxCenDataLabel);
+
+ if (isFloat(this->boxLTextBox->Text) &&
+ isFloat(this->boxWTextBox->Text) &&
+ isFloat(this->boxHTextBox->Text))
+ this->boxSetButton->Enabled = true;
+ }
+
+ client->unlock();
+ }
+ // use rigid tool
+ else if (this->boxRigidRadio->Checked && client)
+ {
+ RigidBody* body = client->getRigidBody(client->getRigidBodyTool());
+ if (body)
+ {
+ boxPosCen->set(body->getPosition().x(),
+ body->getPosition().y(),
+ body->getPosition().z());
+ setPoint(boxPosCen, this->boxCenDataLabel);
+
+ if (isFloat(this->boxLTextBox->Text) &&
+ isFloat(this->boxWTextBox->Text) &&
+ isFloat(this->boxHTextBox->Text))
+ this->boxSetButton->Enabled = true;
+
+ return;
+ }
+ }
+ }
+private: System::Void boxSetButton_Click(System::Object^ sender, System::EventArgs^ e) {
+ if (this->boxCoordRadio->Checked && !extractCoordinates(this->boxInCenTextBox, boxPosCen))
+ return;
+
+ CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
+ if (world)
+ {
+ std::string* str = managedToStdString(this->boxNameTextBox->Text);
+ float l, w, h;
+
+ l = Single::Parse(this->boxLTextBox->Text);
+ w = Single::Parse(this->boxWTextBox->Text);
+ h = Single::Parse(this->boxHTextBox->Text);
+
+ CaptureObject* object = world->addBox(*boxPosCen, osg::Vec3(l, w, h), *str);
+ if (object)
+ {
+ String^ id = Convert::ToString(object->getID());
+ String^ name = gcnew String(object->getName().c_str());
+ }
+ }
+ this->Close();
+ }
+private: System::Void boxMarkerRadio_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
+ if (this->boxMarkersRadio->Checked)
+ {
+ markerTextBoxes(true, BOX);
+ setDefaultText(this->boxCenDataLabel);
+
+ this->planeSetButton->Enabled = false;
+ }
+ else
+ {
+ markerTextBoxes(false, BOX);
+ }
+ }
+private: System::Void boxCoordRadio_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
+ if (this->boxCoordRadio->Checked)
+ {
+ coordinateTextBoxes(true, BOX);
+
+ this->boxCenDataLabel->Text = "";
+
+ this->boxSetButton->Enabled = false;
+ this->boxGetButton->Visible = false;
+ }
+ else
+ {
+ coordinateTextBoxes(false, BOX);
+ this->boxGetButton->Visible = true;
+ }
+ }
+private: System::Void boxTextBox_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) {
+ if ( this->boxCoordRadio->Checked &&
+ isCoordinate(this->boxInCenTextBox->Text) &&
+ isFloat(this->boxLTextBox->Text) &&
+ isFloat(this->boxWTextBox->Text) &&
+ isFloat(this->boxHTextBox->Text) )
+ this->boxSetButton->Enabled = true;
+ else if ( !this->boxCoordRadio->Checked &&
+ String::Compare(this->boxCenDataLabel->Text, this->defaultDataText) &&
+ isFloat(this->boxLTextBox->Text) &&
+ isFloat(this->boxWTextBox->Text) &&
+ isFloat(this->boxHTextBox->Text) )
+ this->boxSetButton->Enabled = true;
+ else
+ this->boxSetButton->Enabled = false;
+ }
+
};
}
View
2  BlinkAnalysis/AppViewer.cpp
@@ -377,9 +377,11 @@ void AppViewer::initAppViewer(HWND hwnd)
}
bool AppViewer::addNodeToViewer(osg::Node* node) {
+ if (!sceneNode) return false;
return sceneNode->addChild(node);
}
bool AppViewer::removeNodeFromViewer(osg::Node* node) {
+ if (!sceneNode) return false;
return sceneNode->removeChild(node);
}
View
155 BlinkAnalysis/CaptureObject.cpp
@@ -2,6 +2,7 @@
#include "StdAfx.h"
#include <osg/Geometry>
+#include <osg/ShapeDrawable>
#include <osgUtil/SmoothingVisitor>
#include <osg/Texture2D>
@@ -10,24 +11,26 @@
#include "CaptureObject.h"
-int CaptureObject::getNumVertices()
-{
- return vertices->size();
-}
+///////////////////////////
+// CaptureObject
+///////////////////////////
-void CaptureObject::setVertices(osg::Vec3Array* vertices) {
- this->vertices = vertices;
+osg::Node* CaptureObject::setRender(bool ren)
+{
+ // state unchanged, no need to return node
+ if (render == ren)
+ return NULL;
+
+ render = ren;
+ return node;
}
-void CaptureObject::addFace(osg::DrawElementsUInt* face) {
- faces.push_back(face);
-}
-void CaptureObject::removeFaces() {
- faces.clear();
-}
+///////////////////////////
+// CaptureObjectCustom
+///////////////////////////
-osg::Geode* CaptureObject::getAsGeode()
+osg::Geode* CaptureObjectCustom::getAsGeode()
{
if (!node)
node = new osg::Geode();
@@ -59,14 +62,128 @@ osg::Geode* CaptureObject::getAsGeode()
return geo;
}
-osg::Node* CaptureObject::setRender(bool ren)
+
+
+///////////////////////////
+// CaptureObjectPlane
+///////////////////////////
+
+CaptureObjectPlane::CaptureObjectPlane(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 pt2)
+ : CaptureObject()
{
- // state unchanged, no need to return node
- if (render == ren)
- return NULL;
+ setType(PLANE);
+ setVertices(corner, pt1, pt2);
+}
+
+void CaptureObjectPlane::setVertices(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 pt2)
+{
+ // set up plane vertices
+ if (!vertices)
+ vertices = new osg::Vec3Array();
+ else
+ vertices->clear();
+
+ osg::Vec3 opposite = pt1 + pt2 - corner;
+ vertices->push_back(corner);
+ vertices->push_back(pt1);
+ vertices->push_back(opposite);
+ vertices->push_back(pt2);
+
+ // set up face
+ if (!face)
+ face = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_FAN);
+ else
+ face->clear();
+
+ face->push_back(0);
+ face->push_back(1);
+ face->push_back(2);
+ face->push_back(2);
+ face->push_back(3);
+}
+
+osg::Geode* CaptureObjectPlane::getAsGeode()
+{
+ if (!node)
+ node = new osg::Geode();
+
+ osg::Geode* geo = node->asGeode();
+ geo->removeDrawables(0, 1);
+ osg::Geometry *geom = new osg::Geometry();
+ geom->setVertexArray(vertices.get());
+
+ geom->addPrimitiveSet(face);
- render = ren;
- return node;
+ osgUtil::SmoothingVisitor::smooth(*geom);
+ geo->addDrawable(geom);
+
+ return geo;
+}
+
+
+///////////////////////////
+// CaptureObjectBox
+///////////////////////////
+
+CaptureObjectBox::CaptureObjectBox(osg::Vec3 centre, osg::Vec3 halfLen, osg::Quat rot)
+{
+ box = new osg::Box();
+ box->set(centre, halfLen);
+ box->setRotation(rot);
+}
+
+osg::Geode* CaptureObjectBox::getAsGeode()
+{
+ if (!node)
+ node = new osg::Geode();
+
+ osg::Geode* geo = node->asGeode();
+ geo->removeDrawables(0, 1);
+ if (box)
+ geo->addDrawable(new osg::ShapeDrawable(box));
+
+ return geo;
}
+void CaptureObjectBox::setCentre(osg::Vec3 centre)
+{
+ if (!box)
+ box = new osg::Box();
+ box->setCenter(centre);
+}
+
+osg::Vec3 CaptureObjectBox::getCentre()
+{
+ if (box)
+ return box->getCenter();
+ return osg::Vec3(0, 0, 0);
+}
+
+void CaptureObjectBox::setHalfLengths(osg::Vec3 halfLen)
+{
+ if (!box)
+ box = new osg::Box();
+ box->setHalfLengths(halfLen);
+}
+
+osg::Vec3 CaptureObjectBox::getHalfLengths()
+{
+ if (box)
+ return box->getHalfLengths();
+ return osg::Vec3(0, 0, 0);
+}
+
+void CaptureObjectBox::setRotation(osg::Quat rot)
+{
+ if (!box)
+ box = new osg::Box();
+ box->setRotation(rot);
+}
+
+osg::Quat CaptureObjectBox::getRotation()
+{
+ if (box)
+ return box->getRotation();
+ return osg::Quat(0, 0, 0, 1); // zero rotation
+}
View
126 BlinkAnalysis/CaptureObject.h
@@ -5,27 +5,36 @@
#include <string>
#include <osg/PrimitiveSet>
#include <osg/Node>
+#include <osg/Shape>
#include "CaptureObjectUtil.h"
+enum ObjectType {
+ CUSTOM,
+ BOX,
+ CYLINDER,
+ PLANE
+};
+
+
typedef std::vector<osg::ref_ptr<osg::DrawElementsUInt>>::iterator faces_iterator;
+///////////////////////////
+
// TODO: eventually support texture?
-// TODO: check for NULL
class CaptureObject
{
-private:
+protected:
// for tracking object with a rigid body
int rigidBody; // -1 if static object
// identifier for this object (generated)
int id;
std::string name;
- osg::ref_ptr<osg::Vec3Array> vertices;
- std::vector<osg::ref_ptr<osg::DrawElementsUInt>> faces;
osg::ref_ptr<osg::Node> node;
bool render;
+ ObjectType type;
public:
@@ -34,33 +43,122 @@ class CaptureObject
id = -1;
rigidBody = -1;
render = true;
+ type = CUSTOM;
}
~CaptureObject() {
- faces.clear();
node = NULL;
}
void setID(int id) { this->id = id; }
int getID() { return id; }
-
- int getNumVertices();
- void setVertices(osg::Vec3Array* vertices);
-
- int getNumFaces() { return faces.size(); }
- void addFace(osg::DrawElementsUInt* face);
- void removeFaces();
+ void setType(ObjectType t) { type = t; }
+ ObjectType getType() { return type; }
+
void setRigidBody(int rid) { rigidBody = rid; }
int getRigidBody() { return rigidBody; }
void setName(std::string name) { this->name = name; }
std::string getName() { return name; }
- // returns a Geode representing this object
- osg::Geode* getAsGeode();
bool renderObject() { return render; }
osg::Node* setRender(bool ren); // returns geode so world can remove it from node
+
+ // virtual functions
+ // returns a Geode representing this object
+ virtual osg::Geode* getAsGeode() = 0;
+ virtual int getNumVertices() = 0;
+ virtual int getNumFaces() = 0;
+
+};
+
+
+///////////////////////////
+
+class CaptureObjectCustom : public CaptureObject
+{
+private:
+ osg::ref_ptr<osg::Vec3Array> vertices;
+ std::vector<osg::ref_ptr<osg::DrawElementsUInt>> faces;
+
+public:
+
+ int getNumVertices() { return vertices->size(); }
+ void setVertices(osg::Vec3Array* vertices) {
+ this->vertices = vertices;
+ }
+
+ int getNumFaces() { return faces.size(); }
+ void addFace(osg::DrawElementsUInt* face) {
+ faces.push_back(face);
+ }
+ void removeFaces() {
+ faces.clear();
+ }
+
+ osg::Geode* getAsGeode();
+};
+
+
+///////////////////////////
+
+class CaptureObjectPlane : public CaptureObject
+{
+private:
+ osg::ref_ptr<osg::Vec3Array> vertices;
+ osg::ref_ptr<osg::DrawElementsUInt> face;
+
+public:
+ CaptureObjectPlane()
+ : CaptureObject()
+ {
+ type = PLANE;
+ vertices = NULL;
+ face = NULL;
+ }
+
+ CaptureObjectPlane(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 pt2);
+
+ int getNumVertices() { return 4; }
+ void setVertices(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 pt2);
+
+ int getNumFaces() { return 1; }
+
+ osg::Geode* getAsGeode();
+
+};
+
+
+///////////////////////////
+
+class CaptureObjectBox : public CaptureObject
+{
+private:
+ osg::ref_ptr<osg::Box> box;
+
+public:
+ CaptureObjectBox()
+ : CaptureObject()
+ {
+ type = BOX;
+ box = NULL;
+ }
+
+ CaptureObjectBox(osg::Vec3 centre, osg::Vec3 halfLen, osg::Quat rot);
+
+ int getNumVertices() { return 8; }
+ int getNumFaces() { return 6; }
+ osg::Geode* getAsGeode();
+
+ void setCentre(osg::Vec3 centre);
+ osg::Vec3 getCentre();
+
+ void setHalfLengths(osg::Vec3 halfLen);
+ osg::Vec3 getHalfLengths();
+
+ void setRotation(osg::Quat rot);
+ osg::Quat getRotation();
};
#endif
View
2  BlinkAnalysis/CaptureObjectUtil.cpp
@@ -8,7 +8,7 @@ bool CaptureObjectUtil::orthogonalCheckFuzzy(osg::Vec3 v1, osg::Vec3 v2, double
}
// based on MATLAB function MakeCoordSystem by J. Lanovaz
-osg::Matrix* CaptureObjectUtil::makeGlobalToLocalMatrix(
+osg::Matrix* CaptureObjectUtil::makeLocalToGlobalMatrix(
osg::Vec3 origin, osg::Vec3 x, osg::Vec3 y)
{
// form axis vectors
View
2  BlinkAnalysis/CaptureObjectUtil.h
@@ -12,7 +12,7 @@ class CaptureObjectUtil
public:
static bool orthogonalCheckFuzzy(osg::Vec3 v1, osg::Vec3 v2, double epsilon);
- static osg::Matrix* makeGlobalToLocalMatrix(osg::Vec3 origin, osg::Vec3 x, osg::Vec3 y);
+ static osg::Matrix* makeLocalToGlobalMatrix(osg::Vec3 origin, osg::Vec3 x, osg::Vec3 y);
};
View
97 BlinkAnalysis/CaptureWorld.cpp
@@ -23,11 +23,12 @@ void CaptureWorld::initCaptureWorld()
sstr << id;
name = sstr.str();
- _globalToLocal = new osg::Matrix();
- _globalToLocal->makeIdentity();
+ _localToGlobal = new osg::Matrix();
+ _localToGlobal->makeIdentity();
node = NULL;
- render = true;
+ render = false;
+ renderMat = false;
}
CaptureWorld::CaptureWorld()
@@ -43,14 +44,14 @@ CaptureWorld::CaptureWorld(std::string name)
this->name = name;
}
-CaptureWorld::CaptureWorld(std::string name, osg::Matrix* globToLoc)
+CaptureWorld::CaptureWorld(std::string name, osg::Matrix* locToGlob)
{
initCaptureWorld();
if (!name.empty())
this->name = name;
- _globalToLocal = globToLoc;
+ _localToGlobal = locToGlob;
}
void CaptureWorld::setName(std::string name)
@@ -70,12 +71,24 @@ void CaptureWorld::setName(std::string name)
const osg::Matrix CaptureWorld::getLocalToGlobalMatrix()
{
- return osg::Matrix::inverse(*_globalToLocal);
+ return *_localToGlobal;
}
const osg::Matrix CaptureWorld::getGlobalToLocalMatrix()
{
- return *_globalToLocal;
+ return osg::Matrix::inverse(*_localToGlobal);
+}
+
+void CaptureWorld::setRenderMatrix(bool ren)
+{
+ if (renderMat == ren)
+ return;
+
+ renderMat = ren;
+ if (render && renderMat && node)
+ node->setMatrix(getGlobalToLocalMatrix());
+ else if (!renderMat && node)
+ node->setMatrix(osg::Matrix::identity());
}
void CaptureWorld::setRender(bool ren)
@@ -125,10 +138,10 @@ bool CaptureWorld::toggleRenderObject(int oid)
return ren;
}
-void CaptureWorld::setCoordinateFrame(osg::Matrix* globToLoc, bool deleteObjects, bool updateObjects)
+void CaptureWorld::setCoordinateFrame(osg::Matrix* locToGlob, bool deleteObjects, bool updateObjects)
{
- delete _globalToLocal;
- _globalToLocal = globToLoc;
+ delete _localToGlobal;
+ _localToGlobal = locToGlob;
if (deleteObjects)
{
@@ -140,8 +153,8 @@ void CaptureWorld::setCoordinateFrame(osg::Matrix* globToLoc, bool deleteObjects
//TODO
}
- if (node)
- node->setMatrix(getLocalToGlobalMatrix());
+ if (render && renderMat && node)
+ node->setMatrix(getGlobalToLocalMatrix());
}
int CaptureWorld::addObject(CaptureObject* obj)
@@ -216,44 +229,50 @@ CaptureObject* CaptureWorld::getObject(int oid)
// TODO: assumed static for now
CaptureObject* CaptureWorld::addPlane(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 pt2, std::string name)
{
- CaptureObject* obj = new CaptureObject();
+ CaptureObjectPlane* plane = new CaptureObjectPlane(corner, pt1, pt2);
// if name is empty string, one will be generated in addObject
- obj->setName(name);
-
- // set up plane vertices
- osg::Vec3 opposite = pt1 + pt2 - corner;
- osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array();
- vertices->push_back(corner);
- vertices->push_back(pt1);
- vertices->push_back(opposite);
- vertices->push_back(pt2);
- obj->setVertices(vertices);
-
- // set up face
- osg::ref_ptr<osg::DrawElementsUInt> face = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLE_FAN);
- face->push_back(0);
- face->push_back(1);
- face->push_back(2);
- face->push_back(2);
- face->push_back(3);
- obj->addFace(face);
-
- if (addObject(obj) < 0)
+ plane->setName(name);
+
+ if (addObject(plane) < 0)
+ {
+ delete plane;
+ plane = NULL;
+ }
+
+ return plane;
+}
+
+CaptureObject* CaptureWorld::addBox(osg::Vec3 baseCentre, osg::Vec3 dimensions, std::string name)
+{
+ // divide dimensions to get half lengths
+ osg::Vec3 hl = dimensions * 0.5;
+ // transform base from global to local coordinates
+ osg::Vec3 centre = baseCentre * getGlobalToLocalMatrix();
+ // add z to get centre of box
+ centre += osg::Vec3(0, 0, hl.z());
+ // transform back to global coordinates
+ centre = centre * getLocalToGlobalMatrix();
+
+ CaptureObjectBox* box = new CaptureObjectBox(centre, hl, getLocalToGlobalMatrix().getRotate());
+ // if name is empty string, one will be generated in addObject
+ box->setName(name);
+
+ if (addObject(box) < 0)
{
- delete obj;
- obj = NULL;
+ delete box;
+ box = NULL;
}
- return obj;
+ return box;
}
-osg::MatrixTransform* CaptureWorld::getAsGroup(bool renderMatrix)
+osg::MatrixTransform* CaptureWorld::getAsGroup()
{
if (!node)
node = new osg::MatrixTransform();
- if (renderMatrix)
+ if (renderMat)
node->setMatrix(getGlobalToLocalMatrix());
else
node->setMatrix(osg::Matrix::identity());
View
15 BlinkAnalysis/CaptureWorld.h
@@ -20,9 +20,10 @@ class CaptureWorld
std::string name;
int id;
- osg::Matrix* _globalToLocal;
+ osg::Matrix* _localToGlobal;
osg::ref_ptr<osg::MatrixTransform> node;
bool render;
+ bool renderMat;
// increments for each new object added
int _lastObjectID;
@@ -33,11 +34,11 @@ class CaptureWorld
public:
CaptureWorld();
CaptureWorld(std::string name);
- CaptureWorld(std::string name, osg::Matrix* globToLoc);
+ CaptureWorld(std::string name, osg::Matrix* locToGlob);
~CaptureWorld()
{
- delete _globalToLocal;
+ delete _localToGlobal;
clearObjects();
}
@@ -48,15 +49,19 @@ class CaptureWorld
void setName(std::string name);
int getID() { return id; }
bool renderWorld() { return render; }
+ void setRenderMatrix(bool ren);
+ bool renderMatrix() { return renderMat; }
+
void setRender(bool ren);
bool toggleRender();
void setRenderObject(int oid, bool ren);
bool toggleRenderObject(int oid);
- void setCoordinateFrame(osg::Matrix* globToLoc, bool deleteObjects=false, bool updateObjects=false);
+ void setCoordinateFrame(osg::Matrix* locToGlob, bool deleteObjects=false, bool updateObjects=false);
CaptureObject* addPlane(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 pt2, std::string name);
+ CaptureObject* addBox(osg::Vec3 baseCentre, osg::Vec3 dimensions, std::string name);
CaptureObject* getObject(int oid);
@@ -68,7 +73,7 @@ class CaptureWorld
int getNumberObjects();
- osg::MatrixTransform* getAsGroup(bool renderMatrix=false);
+ osg::MatrixTransform* getAsGroup();
bool hasNode(osg::MatrixTransform* node) { return this->node == node; }
View
39 BlinkAnalysis/DefineCoordinateFrameForm.cpp
@@ -5,25 +5,28 @@
using namespace BlinkAnalysis;
System::Void DefineCoordinateFrameForm::coordinateSetButton_Click(System::Object^ sender, System::EventArgs^ e) {
- CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
- if (world)
- {
- world->setCoordinateFrame(CaptureObjectUtil::makeGlobalToLocalMatrix(*posO, *posX, *posY));
- MainFormController::getInstance()->worldUpdateGridView(world->getID());
- }
-
- this->Close();
+ if (sender == this->inputSetButton && !extractCoordinates())
+ return;
+
+ CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
+ if (world)
+ {
+ world->setCoordinateFrame(CaptureObjectUtil::makeLocalToGlobalMatrix(*posO, *posX, *posY));
+ MainFormController::getInstance()->worldUpdateGridView(world->getID());
}
+
+ this->Close();
+ }
System::Void DefineCoordinateFrameForm::coordinateResetButton_Click(System::Object^ sender, System::EventArgs^ e) {
- CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
- if (world)
- {
- osg::Matrix* m = new osg::Matrix();
- m->makeIdentity();
- world->setCoordinateFrame(m);
- MainFormController::getInstance()->worldUpdateGridView(world->getID());
- }
+ CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
+ if (world)
+ {
+ osg::Matrix* m = new osg::Matrix();
+ m->makeIdentity();
+ world->setCoordinateFrame(m);
+ MainFormController::getInstance()->worldUpdateGridView(world->getID());
+ }
- this->Close();
- }
+ this->Close();
+ }
View
238 BlinkAnalysis/DefineCoordinateFrameForm.h
@@ -85,6 +85,27 @@ namespace BlinkAnalysis {
private: System::String^ defaultDataText;
private: int displayWorld;
private: System::Windows::Forms::Label^ rigidInfoLabel;
+ private: System::Windows::Forms::Label^ inputInfoLabel;
+ private: System::Windows::Forms::Label^ inputYLabel;
+
+
+ private: System::Windows::Forms::Label^ inputXLabel;
+ private: System::Windows::Forms::Label^ inputOLabel;
+ private: System::Windows::Forms::Button^ inputSetButton;
+ private: System::Windows::Forms::TextBox^ inputXTextBox;
+ private: System::Windows::Forms::TextBox^ inputYTextBox;
+
+
+
+
+
+
+
+
+
+
+ private: System::Windows::Forms::TextBox^ inputOTextBox;
+
private:
@@ -100,7 +121,16 @@ namespace BlinkAnalysis {
/// </summary>
void InitializeComponent(void)
{
+ System::Windows::Forms::TabPage^ inputPage;
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(DefineCoordinateFrameForm::typeid));
+ this->inputInfoLabel = (gcnew System::Windows::Forms::Label());
+ this->inputYLabel = (gcnew System::Windows::Forms::Label());
+ this->inputXLabel = (gcnew System::Windows::Forms::Label());
+ this->inputOLabel = (gcnew System::Windows::Forms::Label());
+ this->inputSetButton = (gcnew System::Windows::Forms::Button());
+ this->inputXTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->inputYTextBox = (gcnew System::Windows::Forms::TextBox());
+ this->inputOTextBox = (gcnew System::Windows::Forms::TextBox());
this->CoordinateFramePages = (gcnew System::Windows::Forms::TabControl());
this->infoPage = (gcnew System::Windows::Forms::TabPage());
this->infoTitleLabel = (gcnew System::Windows::Forms::Label());
@@ -120,6 +150,7 @@ namespace BlinkAnalysis {
this->coordinateYTextBox = (gcnew System::Windows::Forms::TextBox());
this->coordinateOTextBox = (gcnew System::Windows::Forms::TextBox());
this->rigidPage = (gcnew System::Windows::Forms::TabPage());
+ this->rigidInfoLabel = (gcnew System::Windows::Forms::Label());
this->rigidYButton = (gcnew System::Windows::Forms::Button());
this->rigidXButton = (gcnew System::Windows::Forms::Button());
this->rigidOButton = (gcnew System::Windows::Forms::Button());
@@ -130,18 +161,117 @@ namespace BlinkAnalysis {
this->rigidGetDataButton = (gcnew System::Windows::Forms::Button());
this->rigidToolPositionLabel = (gcnew System::Windows::Forms::Label());
this->rigidBodyLabel = (gcnew System::Windows::Forms::Label());
- this->rigidInfoLabel = (gcnew System::Windows::Forms::Label());
+ inputPage = (gcnew System::Windows::Forms::TabPage());
+ inputPage->SuspendLayout();
this->CoordinateFramePages->SuspendLayout();
this->infoPage->SuspendLayout();
this->markerPage->SuspendLayout();
this->rigidPage->SuspendLayout();
this->SuspendLayout();
//
+ // inputPage
+ //
+ inputPage->Controls->Add(this->inputInfoLabel);
+ inputPage->Controls->Add(this->inputYLabel);
+ inputPage->Controls->Add(this->inputXLabel);
+ inputPage->Controls->Add(this->inputOLabel);
+ inputPage->Controls->Add(this->inputSetButton);
+ inputPage->Controls->Add(this->inputXTextBox);
+ inputPage->Controls->Add(this->inputYTextBox);
+ inputPage->Controls->Add(this->inputOTextBox);
+ inputPage->Location = System::Drawing::Point(4, 22);
+ inputPage->Name = L"inputPage";
+ inputPage->Padding = System::Windows::Forms::Padding(3);
+ inputPage->Size = System::Drawing::Size(416, 285);
+ inputPage->TabIndex = 2;
+ inputPage->Text = L"Input";
+ inputPage->UseVisualStyleBackColor = true;
+ //
+ // inputInfoLabel
+ //
+ this->inputInfoLabel->AutoSize = true;
+ this->inputInfoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->inputInfoLabel->Location = System::Drawing::Point(17, 15);
+ this->inputInfoLabel->Name = L"inputInfoLabel";
+ this->inputInfoLabel->Size = System::Drawing::Size(313, 30);
+ this->inputInfoLabel->TabIndex = 23;
+ this->inputInfoLabel->Text = L"Enter the positions of where you wish to specify the axes.\r\n\r\n";
+ //
+ // inputYLabel
+ //
+ this->inputYLabel->AutoSize = true;
+ this->inputYLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->inputYLabel->Location = System::Drawing::Point(17, 186);
+ this->inputYLabel->Name = L"inputYLabel";
+ this->inputYLabel->Size = System::Drawing::Size(46, 15);
+ this->inputYLabel->TabIndex = 22;
+ this->inputYLabel->Text = L"Y-Axis";
+ //
+ // inputXLabel
+ //
+ this->inputXLabel->AutoSize = true;
+ this->inputXLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->inputXLabel->Location = System::Drawing::Point(17, 145);
+ this->inputXLabel->Name = L"inputXLabel";
+ this->inputXLabel->Size = System::Drawing::Size(47, 15);
+ this->inputXLabel->TabIndex = 21;
+ this->inputXLabel->Text = L"X-Axis";
+ //
+ // inputOLabel
+ //
+ this->inputOLabel->AutoSize = true;
+ this->inputOLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->inputOLabel->Location = System::Drawing::Point(17, 99);
+ this->inputOLabel->Name = L"inputOLabel";
+ this->inputOLabel->Size = System::Drawing::Size(46, 15);
+ this->inputOLabel->TabIndex = 20;
+ this->inputOLabel->Text = L"Origin";
+ //
+ // inputSetButton
+ //
+ this->inputSetButton->Enabled = false;
+ this->inputSetButton->Location = System::Drawing::Point(291, 241);
+ this->inputSetButton->Name = L"inputSetButton";
+ this->inputSetButton->Size = System::Drawing::Size(103, 23);
+ this->inputSetButton->TabIndex = 18;
+ this->inputSetButton->Text = L"Set Coordinates";
+ this->inputSetButton->UseVisualStyleBackColor = true;
+ this->inputSetButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::coordinateSetButton_Click);
+ //
+ // inputXTextBox
+ //
+ this->inputXTextBox->Location = System::Drawing::Point(69, 144);
+ this->inputXTextBox->Name = L"inputXTextBox";
+ this->inputXTextBox->Size = System::Drawing::Size(230, 20);
+ this->inputXTextBox->TabIndex = 14;
+ this->inputXTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &DefineCoordinateFrameForm::inputTextBox_Validating);
+ //
+ // inputYTextBox
+ //
+ this->inputYTextBox->Location = System::Drawing::Point(69, 185);
+ this->inputYTextBox->Name = L"inputYTextBox";
+ this->inputYTextBox->Size = System::Drawing::Size(230, 20);
+ this->inputYTextBox->TabIndex = 13;
+ this->inputYTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &DefineCoordinateFrameForm::inputTextBox_Validating);
+ //
+ // inputOTextBox
+ //
+ this->inputOTextBox->Location = System::Drawing::Point(69, 99);
+ this->inputOTextBox->Name = L"inputOTextBox";
+ this->inputOTextBox->Size = System::Drawing::Size(230, 20);
+ this->inputOTextBox->TabIndex = 12;
+ this->inputOTextBox->Validating += gcnew System::ComponentModel::CancelEventHandler(this, &DefineCoordinateFrameForm::inputTextBox_Validating);
+ //
// CoordinateFramePages
//
this->CoordinateFramePages->Controls->Add(this->infoPage);
this->CoordinateFramePages->Controls->Add(this->markerPage);
this->CoordinateFramePages->Controls->Add(this->rigidPage);
+ this->CoordinateFramePages->Controls->Add(inputPage);
this->CoordinateFramePages->Location = System::Drawing::Point(0, 0);
this->CoordinateFramePages->Name = L"CoordinateFramePages";
this->CoordinateFramePages->SelectedIndex = 0;
@@ -356,6 +486,18 @@ namespace BlinkAnalysis {
this->rigidPage->TabIndex = 1;
this->rigidPage->Text = L"Rigid Body";
//
+ // rigidInfoLabel
+ //
+ this->rigidInfoLabel->AutoSize = true;
+ this->rigidInfoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
+ static_cast<System::Byte>(0)));
+ this->rigidInfoLabel->Location = System::Drawing::Point(21, 15);
+ this->rigidInfoLabel->Name = L"rigidInfoLabel";
+ this->rigidInfoLabel->Size = System::Drawing::Size(380, 30);
+ this->rigidInfoLabel->TabIndex = 14;
+ this->rigidInfoLabel->Text = L"Click \"Get Data\" to retrieve the current Rigid Body Tool position, \r\nthen choose "
+ L"one of the buttons to set that position as part of the axes.";
+ //
// rigidYButton
//
this->rigidYButton->BackColor = System::Drawing::SystemColors::ControlLightLight;
@@ -468,18 +610,6 @@ namespace BlinkAnalysis {
this->rigidBodyLabel->TabIndex = 0;
this->rigidBodyLabel->Text = L"Rigid Body Tool Position:";
//
- // rigidInfoLabel
- //
- this->rigidInfoLabel->AutoSize = true;
- this->rigidInfoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->rigidInfoLabel->Location = System::Drawing::Point(21, 15);
- this->rigidInfoLabel->Name = L"rigidInfoLabel";
- this->rigidInfoLabel->Size = System::Drawing::Size(380, 30);
- this->rigidInfoLabel->TabIndex = 14;
- this->rigidInfoLabel->Text = L"Click \"Get Data\" to retrieve the current Rigid Body Tool position, \r\nthen choose "
- L"one of the buttons to set that position as part of the axes.";
- //
// DefineCoordinateFrameForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
@@ -490,6 +620,8 @@ namespace BlinkAnalysis {
this->Text = L"Define Coordinate Frame";
this->Closed += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::DefineCoordinateFrameForm_Closed);
this->Load += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::DefineCoordinateFrameForm_Load);
+ inputPage->ResumeLayout(false);
+ inputPage->PerformLayout();
this->CoordinateFramePages->ResumeLayout(false);
this->infoPage->ResumeLayout(false);
this->infoPage->PerformLayout();
@@ -508,8 +640,39 @@ namespace BlinkAnalysis {
private: osg::Vec3* posY;
private: osg::Vec3* pos;
+
+ // checks if input string is a valid coordinate (x, y, z)
+private: bool isCoordinate(String^ str) {
+ String^ regs = "^\\s*-?\\d+(.\\d+)?\\s*," +
+ "\\s*-?\\d+(.\\d+)?\\s*," +
+ "\\s*-?\\d+(.\\d+)?\\s*$";
+ System::Text::RegularExpressions::Regex^ regex = gcnew System::Text::RegularExpressions::Regex(regs);
+ return regex->IsMatch(str);
+ }
+ // extracts coordinates from input text box
+private: bool extractCoordinates(TextBox^ tb, osg::Vec3* pt) {
+ if (!pt || !tb)
+ return false;
+
+ float x, y, z;
+ array<String^>^ split = tb->Text->Split(gcnew array<wchar_t> {','});
+ if (!Single::TryParse(split[0], x))
+ return false;
+ if (!Single::TryParse(split[1], y))
+ return false;
+ if (!Single::TryParse(split[2], z))
+ return false;
+
+ pt->set(x, y, z);
+ return true;
+ }
+
private: System::Void DefineCoordinateFrameForm_Load(System::Object^ sender, System::EventArgs^ e) {
this->defaultDataText = L"No data found";
+ posO = new osg::Vec3();
+ posX = new osg::Vec3();
+ posY = new osg::Vec3();
+ pos = new osg::Vec3();
}
private: System::Void DefineCoordinateFrameForm_Closed( Object^ /*sender*/, System::EventArgs ^ e )
{
@@ -539,10 +702,7 @@ namespace BlinkAnalysis {
else
{
osg::Vec3 pt = marker->getPosition();
- if (!posO)
- posO = new osg::Vec3(pt.x(), pt.y(), pt.z());
- else
- posO->set(pt.x(), pt.y(), pt.z());
+ posO->set(pt.x(), pt.y(), pt.z());
coordinate_setPoint(posO, coordinateOLabel);
}
@@ -558,10 +718,7 @@ namespace BlinkAnalysis {
else
{
osg::Vec3 pt = marker->getPosition();
- if (!posX)
- posX = new osg::Vec3(pt.x(), pt.y(), pt.z());
- else
- posX->set(pt.x(), pt.y(), pt.z());
+ posX->set(pt.x(), pt.y(), pt.z());
coordinate_setPoint(posX, coordinateXLabel);
}
@@ -577,10 +734,7 @@ namespace BlinkAnalysis {
else
{
osg::Vec3 pt = marker->getPosition();
- if (!posY)
- posY = new osg::Vec3(pt.x(), pt.y(), pt.z());
- else
- posY->set(pt.x(), pt.y(), pt.z());
+ posY->set(pt.x(), pt.y(), pt.z());
coordinate_setPoint(posY, coordinateYLabel);
}
@@ -616,9 +770,6 @@ namespace BlinkAnalysis {
RigidBody* body = client->getRigidBody(client->getRigidBodyTool());
if (body)
{
- if (!pos)
- pos = new osg::Vec3();
-
pos->set(body->getPosition().x(),
body->getPosition().y(),
body->getPosition().z());
@@ -634,9 +785,6 @@ namespace BlinkAnalysis {
private: System::Void rigidSetDataButton_Click(System::Object^ sender, System::EventArgs^ e) {
if (sender == this->rigidOButton)
{
- if (!posO)
- posO = new osg::Vec3();
-
posO->set(pos->x(), pos->y(), pos->z());
coordinate_setPoint(pos, rigidOLabel);
@@ -648,9 +796,6 @@ namespace BlinkAnalysis {
}
else if (sender == this->rigidXButton)
{
- if (!posX)
- posX = new osg::Vec3();
-
posX->set(pos->x(), pos->y(), pos->z());
coordinate_setPoint(pos, rigidXLabel);
@@ -662,9 +807,6 @@ namespace BlinkAnalysis {
}
else if (sender == this->rigidYButton)
{
- if (!posY)
- posY = new osg::Vec3();
-
posY->set(pos->x(), pos->y(), pos->z());
coordinate_setPoint(pos, rigidYLabel);
@@ -675,5 +817,27 @@ namespace BlinkAnalysis {
coordinateSetButton2->Enabled = false;
}
}
+private: System::Void inputTextBox_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) {
+ if (isCoordinate(this->inputOTextBox->Text) &&
+ isCoordinate(this->inputXTextBox->Text) &&
+ isCoordinate(this->inputYTextBox->Text) )
+ this->inputSetButton->Enabled = true;
+ else
+ this->inputSetButton->Enabled = false;
+ }
+ // populate vectors based on coordinate input
+private: bool extractCoordinates()
+ {
+ if (!extractCoordinates(this->inputOTextBox, posO))
+ return false;
+
+ if (!extractCoordinates(this->inputXTextBox, posX))
+ return false;
+
+ if (!extractCoordinates(this->inputYTextBox, posY))
+ return false;
+
+ return true;
+ }
};
}
View
3  BlinkAnalysis/DefineCoordinateFrameForm.resx
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <metadata name="inputPage.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>False</value>
+ </metadata>
<data name="infoLabel.Text" xml:space="preserve">
<value>Use this tool to define the ground plane for the objects being captured.
View
224 BlinkAnalysis/MainForm.h
@@ -2665,6 +2665,29 @@ private: System::Void setAsRigidBodyToolToolStripMenuItem_Click(System::Object^
// Capture World and Objects
/////////////////////
+/////////////////////
+// Util Functions
+
+// extracts ID from text format "Name (##)"
+private: int worldExtractID(String^ str) {
+ array<String^>^ split = str->Split(gcnew array<wchar_t> {'(', ')'});
+
+ int result;
+ // id contained in second to last element
+ if (Int32::TryParse(split[split->Length - 2], result))
+ return result;
+ else
+ return -1;
+ }
+ // converts a managed String^ to unmanaged std::string*
+private: std::string* managedToStdString(String^ str) {
+ return new std::string(
+ (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str)).ToPointer());
+ }
+
+/////////////////////
+// World Functions
+
// update list of worlds in both World and Object tab
public: System::Void worldUpdateList() {
static bool isUpdatingWorlds = false;
@@ -2770,20 +2793,88 @@ private: System::Void worldComboBox_SelectedIndexChanged(System::Object^ sender
worldGridView_displayWorld();
}
}
- // update list of objects if drop down list value changes
-private: System::Void objectWComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
- if (!this->objectWComboBox->SelectedItem)
+ // add a new world (name only)
+private: System::Void worldAddButton_Click(System::Object^ sender, System::EventArgs^ e) {
+ AddWorldForm^ addWorldForm = gcnew AddWorldForm();
+ addWorldForm->Show();
+ }
+
+private: System::Void worldGridView_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
+ if (e->ColumnIndex != 1) // must be value column
return;
-
- String^ text = this->objectWComboBox->SelectedItem->ToString();
- int id = worldExtractID(text);
- if (id >= 0)
+
+ if (e->RowIndex == (int)worldProperty::MATRIX && // setting coordinate frame
+ displayWorld != 0) // but not if default world
{
- this->objectAddButton->Enabled = true;
- displayObjectWorld = id;
- objectUpdateList();
+ DefineCoordinateFrameFormController ^control = DefineCoordinateFrameFormController::getInstance();
+ control->createForm();
+ control->setDisplayWorld(displayWorld);
+ control->Show();
+ }
+ else if (e->RowIndex == (int)worldProperty::RENDER)
+ {
+ CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
+ if (world)
+ {
+ String^ ren = world->toggleRender() ? "true" : "false";
+ this->worldGridView->Rows[e->RowIndex]->Cells[1]->Value = ren;
+ }
}
}
+ // user edits property value for world
+private: System::Void worldGridView_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
+ if (e->RowIndex == (int) worldProperty::NAME)
+ {
+ CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
+ if (world)
+ {
+ std::string* str = managedToStdString(
+ (String^)this->worldGridView->Rows[e->RowIndex]->Cells[e->ColumnIndex]->Value);
+ world->setName(*str);
+ int idx = this->worldComboBox->SelectedIndex;
+ worldUpdateList();
+ this->worldComboBox->SelectedIndex = idx;
+ }
+ }
+ }
+private: System::Void resetWorldGridView() {
+ if (this->worldGridView->InvokeRequired)
+ {
+ SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::resetWorldGridView);
+ BeginInvoke(d, nullptr);
+ }
+ else
+ {
+ this->worldGridView->Rows->Clear();
+ displayWorld = -1;
+ displayObjectWorld = -1;
+ this->objectAddButton->Enabled = false;
+ this->worldRemoveButton->Enabled = false;
+ }
+ }
+private: System::Void worldRemoveButton_Click(System::Object^ sender, System::EventArgs^ e) {
+ String^ message = "Are you sure you want to remove " + this->worldComboBox->SelectedItem->ToString() + "?";
+ String^ str = (String^) this->worldGridView->Rows[(int)worldProperty::OBJECTS]->Cells[1]->Value;
+ int numObjects = Int32::Parse(str);
+ if (numObjects > 0)
+ {
+ message += "\nThis will also remove " + numObjects.ToString() + " associated object";
+ if (numObjects > 1)
+ message += "s";
+ }
+
+ System::Windows::Forms::DialogResult result = MessageBox::Show(
+ message, "Remove World", MessageBoxButtons::OKCancel, MessageBoxIcon::Question);
+ if(result == ::DialogResult::OK){
+ WorldManager::getInstance()->removeWorld(displayWorld);
+ displayWorld = -1;
+ worldUpdateList();
+ }
+ }
+
+/////////////////////
+// Object Functions
+
// populate list of objects based on displayObjectWorld
public: System::Void objectUpdateList() {
if (this->objectComboBox->InvokeRequired)
@@ -2812,6 +2903,20 @@ public: System::Void objectUpdateList() {
}
}
}
+ // update list of objects if drop down list value changes
+private: System::Void objectWComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
+ if (!this->objectWComboBox->SelectedItem)
+ return;
+
+ String^ text = this->objectWComboBox->SelectedItem->ToString();
+ int id = worldExtractID(text);
+ if (id >= 0)
+ {
+ this->objectAddButton->Enabled = true;
+ displayObjectWorld = id;
+ objectUpdateList();
+ }
+ }
// update object display if drop down list value changes
private: System::Void objectComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if (!this->objectComboBox->SelectedItem)
@@ -2883,64 +2988,6 @@ private: System::Void objectGridView_displayObject() {
this->objectGridView->Rows[(int)objectProperty::NAME]->ReadOnly = false;
}
}
- // extracts ID from text format "Name (##)"
-private: int worldExtractID(String^ str) {
- array<String^>^ split = str->Split(gcnew array<wchar_t> {'(', ')'});
-
- int result;
- // id contained in second to last element
- if (Int32::TryParse(split[split->Length - 2], result))
- return result;
- else
- return -1;
- }
- // add a new world (name only)
-private: System::Void worldAddButton_Click(System::Object^ sender, System::EventArgs^ e) {
- AddWorldForm^ addWorldForm = gcnew AddWorldForm();
- addWorldForm->Show();
- }
-
-private: System::Void worldGridView_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
- if (e->ColumnIndex != 1) // must be value column
- return;
-
- if (e->RowIndex == (int)worldProperty::MATRIX && // setting coordinate frame
- displayWorld != 0) // but not if default world
- {
- DefineCoordinateFrameFormController ^control = DefineCoordinateFrameFormController::getInstance();
- control->createForm();
- control->setDisplayWorld(displayWorld);
- control->Show();
- }
- else if (e->RowIndex == (int)worldProperty::RENDER)
- {
- CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
- if (world)
- {
- String^ ren = world->toggleRender() ? "true" : "false";
- this->worldGridView->Rows[e->RowIndex]->Cells[1]->Value = ren;
- }
- }
- }
- // user edits property value for world
-private: System::Void worldGridView_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
- if (e->RowIndex == (int) worldProperty::NAME)
- {
- CaptureWorld* world = WorldManager::getInstance()->getWorld(displayWorld);
- if (world)
- {
- std::string* str = new std::string(
- (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(
- (String^)this->worldGridView->Rows[e->RowIndex]->Cells[e->ColumnIndex]->Value)
- ).ToPointer()
- );
- world->setName(*str);
- int idx = this->worldComboBox->SelectedIndex;
- worldUpdateList();
- this->worldComboBox->SelectedIndex = idx;
- }
- }
- }
// user edits property value for object
private: System::Void objectGridView_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
if (e->RowIndex == (int) objectProperty::NAME)
@@ -2951,11 +2998,8 @@ private: System::Void objectGridView_CellValueChanged(System::Object^ sender, S
CaptureObject* object = world->getObject(displayObject);
if (object)
{
- std::string* str = new std::string(
- (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(
- (String^)this->objectGridView->Rows[e->RowIndex]->Cells[e->ColumnIndex]->Value)
- ).ToPointer()
- );
+ std::string* str = managedToStdString(
+ (String^)this->objectGridView->Rows[e->RowIndex]->Cells[e->ColumnIndex]->Value);
object->setName(*str);
int idx = this->objectComboBox->SelectedIndex;
objectUpdateList();
@@ -2983,21 +3027,6 @@ private: System::Void resetObjectGridView() {
this->removeObjectButton->Enabled = false;
}
}
-private: System::Void resetWorldGridView() {
- if (this->worldGridView->InvokeRequired)
- {
- SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::resetWorldGridView);
- BeginInvoke(d, nullptr);
- }
- else
- {
- this->worldGridView->Rows->Clear();
- displayWorld = -1;
- displayObjectWorld = -1;
- this->objectAddButton->Enabled = false;
- this->worldRemoveButton->Enabled = false;
- }
- }
private: System::Void objectGridView_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
if (e->ColumnIndex != 1) // nust be Value column
return;
@@ -3024,25 +3053,6 @@ private: System::Void objectGridView_CellDoubleClick(System::Object^ sender, Sy
}
}
}
-private: System::Void worldRemoveButton_Click(System::Object^ sender, System::EventArgs^ e) {
- String^ message = "Are you sure you want to remove " + this->worldComboBox->SelectedItem->ToString() + "?";
- String^ str = (String^) this->worldGridView->Rows[(int)worldProperty::OBJECTS]->Cells[1]->Value;
- int numObjects = Int32::Parse(str);
- if (numObjects > 0)
- {
- message += "\nThis will also remove " + numObjects.ToString() + " associated object";
- if (numObjects > 1)
- message += "s";
- }
-
- System::Windows::Forms::DialogResult result = MessageBox::Show(
- message, "Remove World", MessageBoxButtons::OKCancel, MessageBoxIcon::Question);
- if(result == ::DialogResult::OK){
- WorldManager::getInstance()->removeWorld(displayWorld);
- displayWorld = -1;
- worldUpdateList();
- }
- }
private: System::Void removeObjectButton_Click(System::Object^ sender, System::EventArgs^ e) {
String^ message = "Are you sure you want to remove " + this->objectComboBox->SelectedItem->ToString() + "?";
View
1  BlinkAnalysis/WorldManager.cpp
@@ -25,6 +25,7 @@ bool WorldManager::addWorld(CaptureWorld *world)
if (ret.second) // added successfully
{
+ world->setRender(true);
MainFormController::getInstance()->worldUpdateList();
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.