diff --git a/BlinkAnalysis/AddObjectForm.h b/BlinkAnalysis/AddObjectForm.h index 553fac8..34bdbd5 100644 --- a/BlinkAnalysis/AddObjectForm.h +++ b/BlinkAnalysis/AddObjectForm.h @@ -24,11 +24,16 @@ namespace BlinkAnalysis { AddObjectForm(void) { InitializeComponent(); - // - //TODO: Add the constructor code here - // + displayWorld = -1; } + void setDisplayWorld(int id) { + displayWorld = id; + this->Text = L"Add Object (World ID " + displayWorld.ToString() + ")"; + } + int getDisplayWorld() { return displayWorld; } + + protected: /// /// Clean up any resources being used. @@ -82,8 +87,7 @@ namespace BlinkAnalysis { private: System::Windows::Forms::RadioButton^ planeMarkersRadio; private: System::Windows::Forms::Label^ planeRigidDataLabel; - - public: event EventHandler^ UpdateObject; + private: int displayWorld; private: /// @@ -100,7 +104,6 @@ namespace BlinkAnalysis { { this->tabControl1 = (gcnew System::Windows::Forms::TabControl()); this->infoPage = (gcnew System::Windows::Forms::TabPage()); - this->planeInfoLabel = (gcnew System::Windows::Forms::Label()); this->planePage = (gcnew System::Windows::Forms::TabPage()); this->planeRigidDataLabel = (gcnew System::Windows::Forms::Label()); this->planePt2SetButton = (gcnew System::Windows::Forms::Button()); @@ -108,6 +111,7 @@ namespace BlinkAnalysis { this->planePt1SetButton = (gcnew System::Windows::Forms::Button()); this->planeRigidRadio = (gcnew System::Windows::Forms::RadioButton()); this->planeMarkersRadio = (gcnew System::Windows::Forms::RadioButton()); + this->planeInfoLabel = (gcnew System::Windows::Forms::Label()); this->planeOptionalLabel = (gcnew System::Windows::Forms::Label()); this->planeNameTextBox = (gcnew System::Windows::Forms::TextBox()); this->planeNameLabel = (gcnew System::Windows::Forms::Label()); @@ -146,17 +150,6 @@ namespace BlinkAnalysis { this->infoPage->Text = L"Info"; this->infoPage->UseVisualStyleBackColor = true; // - // planeInfoLabel - // - this->planeInfoLabel->AutoSize = true; - this->planeInfoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, - static_cast(0))); - this->planeInfoLabel->Location = System::Drawing::Point(18, 21); - this->planeInfoLabel->Name = L"planeInfoLabel"; - this->planeInfoLabel->Size = System::Drawing::Size(167, 15); - this->planeInfoLabel->TabIndex = 25; - this->planeInfoLabel->Text = L"Add a finite plane to the world"; - // // planePage // this->planePage->Controls->Add(this->planeRigidDataLabel); @@ -260,6 +253,17 @@ namespace BlinkAnalysis { this->planeMarkersRadio->UseVisualStyleBackColor = true; this->planeMarkersRadio->CheckedChanged += gcnew System::EventHandler(this, &AddObjectForm::planeMarkersRadio_CheckedChanged); // + // planeInfoLabel + // + this->planeInfoLabel->AutoSize = true; + this->planeInfoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->planeInfoLabel->Location = System::Drawing::Point(18, 21); + this->planeInfoLabel->Name = L"planeInfoLabel"; + this->planeInfoLabel->Size = System::Drawing::Size(167, 15); + this->planeInfoLabel->TabIndex = 25; + this->planeInfoLabel->Text = L"Add a finite plane to the world"; + // // planeOptionalLabel // this->planeOptionalLabel->AutoSize = true; @@ -403,7 +407,7 @@ namespace BlinkAnalysis { this->ClientSize = System::Drawing::Size(418, 311); this->Controls->Add(this->tabControl1); this->Name = L"AddObjectForm"; - this->Text = L"AddObjectForm"; + this->Text = L"Add Object "; this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &AddObjectForm::AddObjectForm_FormClosed); this->Load += gcnew System::EventHandler(this, &AddObjectForm::AddObjectForm_Load); this->tabControl1->ResumeLayout(false); @@ -521,7 +525,7 @@ private: System::Void setPoint(osg::Vec3* pos, Label^ text) { } // add plane to world based on data from posC, pos1, pos2 private: System::Void planeSetButton_Click(System::Object^ sender, System::EventArgs^ e) { - CaptureWorld* world = AppData::getInstance()->getWorld(); + CaptureWorld* world = AppData::getInstance()->getWorld(displayWorld); if (world) { std::string* str = new std::string( (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(this->planeNameTextBox->Text)).ToPointer()); @@ -530,8 +534,6 @@ private: System::Void planeSetButton_Click(System::Object^ sender, System::Even { String^ id = Convert::ToString(object->getID()); String^ name = gcnew String(object->getName().c_str()); - UpdateObject(this, gcnew EventArgs()); - AppViewer::redrawObjects(); } } this->Close(); diff --git a/BlinkAnalysis/AddObjectFormController.h b/BlinkAnalysis/AddObjectFormController.h new file mode 100644 index 0000000..17f4ecf --- /dev/null +++ b/BlinkAnalysis/AddObjectFormController.h @@ -0,0 +1,29 @@ +#pragma once +#include "stdafx.h" +#include + +#include "AddObjectForm.h" +#include "FormController.h" + +using namespace System; + +public ref class AddObjectFormController sealed : + public FormController +{ +public: + + void setDisplayWorld(int id) + { + if (form && !form->IsDisposed) + form->setDisplayWorld(id); + } + + int getDisplayWorld() + { + if (form && !form->IsDisposed) + return form->getDisplayWorld(); + return -1; + } + +}; + diff --git a/BlinkAnalysis/AddWorldForm.h b/BlinkAnalysis/AddWorldForm.h new file mode 100644 index 0000000..f04fcdd --- /dev/null +++ b/BlinkAnalysis/AddWorldForm.h @@ -0,0 +1,125 @@ +#pragma once + +#include "AppData.h" + +namespace BlinkAnalysis { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for AddWorldForm + /// + public ref class AddWorldForm : public System::Windows::Forms::Form + { + public: + AddWorldForm(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~AddWorldForm() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::Label^ nameLabel; + private: System::Windows::Forms::TextBox^ nameTextBox; + private: System::Windows::Forms::Button^ nameButton; + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->nameLabel = (gcnew System::Windows::Forms::Label()); + this->nameTextBox = (gcnew System::Windows::Forms::TextBox()); + this->nameButton = (gcnew System::Windows::Forms::Button()); + this->SuspendLayout(); + // + // nameLabel + // + this->nameLabel->AutoSize = true; + this->nameLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->nameLabel->Location = System::Drawing::Point(12, 13); + this->nameLabel->Name = L"nameLabel"; + this->nameLabel->Size = System::Drawing::Size(41, 15); + this->nameLabel->TabIndex = 0; + this->nameLabel->Text = L"Name"; + // + // nameTextBox + // + this->nameTextBox->Location = System::Drawing::Point(59, 12); + this->nameTextBox->Name = L"nameTextBox"; + this->nameTextBox->Size = System::Drawing::Size(213, 20); + this->nameTextBox->TabIndex = 1; + this->nameTextBox->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &AddWorldForm::nameTextBox_KeyPress); + // + // nameButton + // + this->nameButton->Location = System::Drawing::Point(197, 38); + this->nameButton->Name = L"nameButton"; + this->nameButton->Size = System::Drawing::Size(75, 23); + this->nameButton->TabIndex = 2; + this->nameButton->Text = L"Add World"; + this->nameButton->UseVisualStyleBackColor = true; + this->nameButton->Click += gcnew System::EventHandler(this, &AddWorldForm::nameButton_Click); + // + // AddWorldForm + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(284, 73); + this->Controls->Add(this->nameButton); + this->Controls->Add(this->nameTextBox); + this->Controls->Add(this->nameLabel); + this->Name = L"AddWorldForm"; + this->Text = L"Add a New World"; + this->ResumeLayout(false); + this->PerformLayout(); + + } +#pragma endregion + private: System::Void nameButton_Click(System::Object^ sender, System::EventArgs^ e) { + std::string *name = new std::string( + (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(this->nameTextBox->Text)).ToPointer() + ); + CaptureWorld* world = new CaptureWorld(*name); + AppData::getInstance()->addWorld(world); + Close(); + } + private: System::Void nameTextBox_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) { + if (e->KeyChar == '\r') + { + std::string *name = new std::string( + (const char*) (Runtime::InteropServices::Marshal::StringToHGlobalAnsi(this->nameTextBox->Text)).ToPointer() + ); + CaptureWorld* world = new CaptureWorld(*name); + AppData::getInstance()->addWorld(world); + Close(); + } + } + }; +} diff --git a/BlinkAnalysis/AddWorldForm.resx b/BlinkAnalysis/AddWorldForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BlinkAnalysis/AddWorldForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BlinkAnalysis/AppData.cpp b/BlinkAnalysis/AppData.cpp index dda8eee..3f81240 100644 --- a/BlinkAnalysis/AppData.cpp +++ b/BlinkAnalysis/AppData.cpp @@ -181,9 +181,12 @@ bool AppData::addWorld(CaptureWorld *world) std::pair ret; ret = worlds.insert(std::pair(id, world)); - MainFormController::getInstance()->worldUpdateData(); - - return (ret.second == false) ? true : false; + if (ret.second) // added successfully + { + MainFormController::getInstance()->worldUpdateList(); + return true; + } + return false; } CaptureWorld* AppData::getWorld(int id) diff --git a/BlinkAnalysis/AppViewer.cpp b/BlinkAnalysis/AppViewer.cpp index f45cd6f..225a7e5 100644 --- a/BlinkAnalysis/AppViewer.cpp +++ b/BlinkAnalysis/AppViewer.cpp @@ -30,13 +30,11 @@ osg::Group* rootNode; bool running = false; bool visible = false; -bool redrawObj = false; float VIEWER_SCALE = 1; void AppViewer::stopAppViewer() { running = false; } void AppViewer::setVisible(bool bVisible) { visible = bVisible; } -void AppViewer::redrawObjects() { redrawObj = true; } void render(void *) { // Started Rendering @@ -156,21 +154,7 @@ void render(void *) { nodeState->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); // End Create Points } - } - - // TODO change this look at the Google Doc - if (redrawObj) - { - std::map worlds = AppData::getInstance()->getWorlds(); - for (worlds_iterator itr = worlds.begin(); itr != worlds.end(); itr++) - { - itr->second->updateObjectsNode(); - // TODO handle new worlds being added? - } - - redrawObj = false; - } - + } // Add Node containing all the points to the scene rootNode->addChild( node ); @@ -279,4 +263,12 @@ void AppViewer::initAppViewer(HWND hwnd) // Begin rendering on new thread _beginthread( render, 0, NULL ); +} + +bool AppViewer::addNodeToViewer(osg::Node* node) { + return rootNode->addChild(node); +} + +bool AppViewer::removeNodeFromViewer(osg::Node* node) { + return rootNode->removeChild(node); } \ No newline at end of file diff --git a/BlinkAnalysis/AppViewer.h b/BlinkAnalysis/AppViewer.h index 5f2e1ad..e49a403 100644 --- a/BlinkAnalysis/AppViewer.h +++ b/BlinkAnalysis/AppViewer.h @@ -8,6 +8,7 @@ #pragma once #include "stdafx.h" #include +#include namespace AppViewer { // Creates a new OSG view in the given windows view @@ -16,6 +17,7 @@ namespace AppViewer { void stopAppViewer(); // Pause rendering when not visible void setVisible(bool bVisible); - // Updates list of objects - void redrawObjects(); + // Add/remove nodes from scene + bool addNodeToViewer(osg::Node* node); + bool removeNodeFromViewer(osg::Node* node); }; \ No newline at end of file diff --git a/BlinkAnalysis/BlinkAnalysis.vcxproj b/BlinkAnalysis/BlinkAnalysis.vcxproj index 6d50033..6bf3418 100644 --- a/BlinkAnalysis/BlinkAnalysis.vcxproj +++ b/BlinkAnalysis/BlinkAnalysis.vcxproj @@ -130,6 +130,7 @@ + @@ -142,6 +143,7 @@ + Create @@ -154,11 +156,19 @@ CppForm + + + CppForm + + + CppForm + + CppForm @@ -182,6 +192,10 @@ + + CppForm + + @@ -195,6 +209,12 @@ AddObjectForm.h + + AddWorldForm.h + + + DefineCoordinateFrameForm.h + DikablisHelp.h @@ -205,6 +225,9 @@ MainForm.h Designer + + SetObjectRigidBodyForm.h + diff --git a/BlinkAnalysis/BlinkAnalysis.vcxproj.filters b/BlinkAnalysis/BlinkAnalysis.vcxproj.filters index d8f09e4..fc62dce 100644 --- a/BlinkAnalysis/BlinkAnalysis.vcxproj.filters +++ b/BlinkAnalysis/BlinkAnalysis.vcxproj.filters @@ -82,6 +82,12 @@ Source Files + + Source Files + + + Source Files + @@ -166,6 +172,24 @@ Header Files + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + Header Files @@ -187,5 +211,11 @@ Resource Files + + Resource Files + + + Resource Files + \ No newline at end of file diff --git a/BlinkAnalysis/CaptureObject.h b/BlinkAnalysis/CaptureObject.h index 8e0ae2b..7f3b368 100644 --- a/BlinkAnalysis/CaptureObject.h +++ b/BlinkAnalysis/CaptureObject.h @@ -34,24 +34,21 @@ class CaptureObject ~CaptureObject() { faces.clear(); } void setID(int id) { this->id = id; } - int getID() { return id; } void setVertices(osg::Vec3Array* vertices) { this->vertices = vertices; } + int getNumVertices() { return vertices->size(); } void addFace(osg::DrawElementsUInt* face) { faces.push_back(face); } - int getNumFaces() { return faces.size(); } - void removeFaces() { faces.clear(); } - void setRigidBody(int rid) { id = rid; } - - int getRigidBody() { return id; } + 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(); }; diff --git a/BlinkAnalysis/CaptureWorld.cpp b/BlinkAnalysis/CaptureWorld.cpp index b14a268..d49735b 100644 --- a/BlinkAnalysis/CaptureWorld.cpp +++ b/BlinkAnalysis/CaptureWorld.cpp @@ -6,6 +6,7 @@ #include #include +#include "MainFormController.h" #include "CaptureWorld.h" @@ -23,6 +24,8 @@ CaptureWorld::CaptureWorld() _globalToLocal = new osg::Matrix(); _globalToLocal->makeIdentity(); + + node = NULL; } CaptureWorld::CaptureWorld(std::string name) @@ -44,6 +47,8 @@ CaptureWorld::CaptureWorld(std::string name) _globalToLocal = new osg::Matrix(); _globalToLocal->makeIdentity(); + + node = NULL; } CaptureWorld::CaptureWorld(std::string name, osg::Matrix* globToLoc) @@ -64,8 +69,24 @@ CaptureWorld::CaptureWorld(std::string name, osg::Matrix* globToLoc) } _globalToLocal = globToLoc; + + node = NULL; } +void CaptureWorld::setName(std::string name) +{ + if (!name.empty()) + { + this->name = name; + } + else + { + std::stringstream sstr; + sstr << "World"; + sstr << id; + this->name = sstr.str(); + } +} void CaptureWorld::setCoordinateFrame(osg::Matrix* globToLoc, bool deleteObjects, bool updateObjects) { @@ -101,7 +122,12 @@ int CaptureWorld::addObject(CaptureObject* obj) std::pair ret; ret = _objects.insert(std::pair(_lastObjectID, obj)); - return (ret.second == false) ? -1 : _lastObjectID++; + if (ret.second) + { + MainFormController::getInstance()->objectUpdateList(); + return _lastObjectID++; + } + return -1; } @@ -149,13 +175,6 @@ CaptureObject* CaptureWorld::addPlane(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 // if name is empty string, one will be generated in addObject obj->setName(name); - if (objectsRelative) - { - corner = corner * *_globalToLocal; - pt1 = pt1 * *_globalToLocal; - pt2 = pt2 * *_globalToLocal; - } - // set up plane vertices osg::Vec3 opposite = pt1 + pt2 - corner; osg::Vec3Array* vertices = new osg::Vec3Array(); @@ -184,13 +203,13 @@ CaptureObject* CaptureWorld::addPlane(osg::Vec3 corner, osg::Vec3 pt1, osg::Vec3 } -osg::MatrixTransform* CaptureWorld::getAsGroup() +osg::MatrixTransform* CaptureWorld::getAsGroup(bool renderMatrix) { if (!node) node = new osg::MatrixTransform(); - if (objectsRelative) - node->setMatrix(getLocalToGlobalMatrix()); + if (renderMatrix) + node->setMatrix(getGlobalToLocalMatrix()); else node->setMatrix(osg::Matrix::identity()); diff --git a/BlinkAnalysis/CaptureWorld.h b/BlinkAnalysis/CaptureWorld.h index 3c87621..9e0f273 100644 --- a/BlinkAnalysis/CaptureWorld.h +++ b/BlinkAnalysis/CaptureWorld.h @@ -22,10 +22,7 @@ class CaptureWorld int id; osg::Matrix* _globalToLocal; - // true: object positions are relative to transformation - // false: object positions are global position data - bool objectsRelative; - + // increments for each new object added int _lastObjectID; // map of IDs to objects in this world @@ -55,7 +52,7 @@ class CaptureWorld } std::string getName() { return name; } - void setName(std::string name) { this->name = name; } + void setName(std::string name); int getID() { return id; } void setCoordinateFrame(osg::Matrix* globToLoc, bool deleteObjects=false, bool updateObjects=false); @@ -72,7 +69,10 @@ class CaptureWorld int getNumberObjects(); - osg::MatrixTransform* getAsGroup(); + osg::MatrixTransform* getAsGroup(bool renderMatrix=false); + + bool hasNode(osg::MatrixTransform* node) { return this->node == node; } + void updateObjectsNode(); }; diff --git a/BlinkAnalysis/DefineCoordinateFrameForm.cpp b/BlinkAnalysis/DefineCoordinateFrameForm.cpp new file mode 100644 index 0000000..eb30a4e --- /dev/null +++ b/BlinkAnalysis/DefineCoordinateFrameForm.cpp @@ -0,0 +1,29 @@ +#include "StdAfx.h" +#include "DefineCoordinateFrameForm.h" +#include "MainFormController.h" + +using namespace BlinkAnalysis; + +System::Void DefineCoordinateFrameForm::coordinateSetButton_Click(System::Object^ sender, System::EventArgs^ e) { + CaptureWorld* world = AppData::getInstance()->getWorld(displayWorld); + if (world) + { + world->setCoordinateFrame(CaptureObjectUtil::makeGlobalToLocalMatrix(*posO, *posX, *posY)); + MainFormController::getInstance()->worldUpdateGridView(); + } + + this->Close(); + } + +System::Void DefineCoordinateFrameForm::coordinateResetButton_Click(System::Object^ sender, System::EventArgs^ e) { + CaptureWorld* world = AppData::getInstance()->getWorld(displayWorld); + if (world) + { + osg::Matrix* m = new osg::Matrix(); + m->makeIdentity(); + world->setCoordinateFrame(m); + MainFormController::getInstance()->worldUpdateGridView(); + } + + this->Close(); + } \ No newline at end of file diff --git a/BlinkAnalysis/DefineCoordinateFrameForm.h b/BlinkAnalysis/DefineCoordinateFrameForm.h new file mode 100644 index 0000000..56730e5 --- /dev/null +++ b/BlinkAnalysis/DefineCoordinateFrameForm.h @@ -0,0 +1,679 @@ +#pragma once + +#include "AppData.h" +#include "CaptureObjectUtil.h" + +namespace BlinkAnalysis { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for DefineCoordinateFrameForm + /// + public ref class DefineCoordinateFrameForm : public System::Windows::Forms::Form + { + public: + DefineCoordinateFrameForm(void) + { + InitializeComponent(); + displayWorld = -1; + } + + void setDisplayWorld(int id) { displayWorld = id; } + int getDisplayWorld() { return displayWorld; } + + protected: + /// + /// Clean up any resources being used. + /// + ~DefineCoordinateFrameForm() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::TabControl^ CoordinateFramePages; + protected: + + protected: + private: System::Windows::Forms::TabPage^ infoPage; + private: System::Windows::Forms::TabPage^ markerPage; + private: System::Windows::Forms::TabPage^ rigidPage; + private: System::Windows::Forms::TextBox^ coordinateOTextBox; + private: System::Windows::Forms::TextBox^ coordinateXTextBox; + private: System::Windows::Forms::TextBox^ coordinateYTextBox; + private: System::Windows::Forms::Label^ coordinateOLabel; + private: System::Windows::Forms::Button^ coordinateSetButton; + private: System::Windows::Forms::Label^ coordinateYLabel; + + + private: System::Windows::Forms::Label^ coordinateXLabel; + + private: System::Windows::Forms::Button^ coordinateGetButton; + private: System::Windows::Forms::Button^ coordinateResetButton; + private: System::Windows::Forms::Label^ originLabel; + private: System::Windows::Forms::Label^ yLabel; + + private: System::Windows::Forms::Label^ xLabel; + private: System::Windows::Forms::Label^ infoLabel; + private: System::Windows::Forms::Label^ markerLabel; + + + + + + + private: System::Windows::Forms::Label^ infoTitleLabel; + private: System::Windows::Forms::Label^ rigidBodyLabel; + private: System::Windows::Forms::Label^ rigidToolPositionLabel; + private: System::Windows::Forms::Button^ rigidGetDataButton; + private: System::Windows::Forms::Button^ coordinateSetButton2; + private: System::Windows::Forms::Button^ rigidYButton; + private: System::Windows::Forms::Button^ rigidXButton; + private: System::Windows::Forms::Button^ rigidOButton; + private: System::Windows::Forms::Label^ rigidYLabel; + private: System::Windows::Forms::Label^ rigidXLabel; + private: System::Windows::Forms::Label^ rigidOLabel; + + // added variables + private: System::String^ defaultDataText; + private: int displayWorld; + private: System::Windows::Forms::Label^ rigidInfoLabel; + + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(DefineCoordinateFrameForm::typeid)); + this->CoordinateFramePages = (gcnew System::Windows::Forms::TabControl()); + this->infoPage = (gcnew System::Windows::Forms::TabPage()); + this->infoTitleLabel = (gcnew System::Windows::Forms::Label()); + this->infoLabel = (gcnew System::Windows::Forms::Label()); + this->coordinateResetButton = (gcnew System::Windows::Forms::Button()); + this->markerPage = (gcnew System::Windows::Forms::TabPage()); + this->markerLabel = (gcnew System::Windows::Forms::Label()); + this->yLabel = (gcnew System::Windows::Forms::Label()); + this->xLabel = (gcnew System::Windows::Forms::Label()); + this->originLabel = (gcnew System::Windows::Forms::Label()); + this->coordinateGetButton = (gcnew System::Windows::Forms::Button()); + this->coordinateSetButton = (gcnew System::Windows::Forms::Button()); + this->coordinateYLabel = (gcnew System::Windows::Forms::Label()); + this->coordinateXLabel = (gcnew System::Windows::Forms::Label()); + this->coordinateOLabel = (gcnew System::Windows::Forms::Label()); + this->coordinateXTextBox = (gcnew System::Windows::Forms::TextBox()); + this->coordinateYTextBox = (gcnew System::Windows::Forms::TextBox()); + this->coordinateOTextBox = (gcnew System::Windows::Forms::TextBox()); + this->rigidPage = (gcnew System::Windows::Forms::TabPage()); + this->rigidYButton = (gcnew System::Windows::Forms::Button()); + this->rigidXButton = (gcnew System::Windows::Forms::Button()); + this->rigidOButton = (gcnew System::Windows::Forms::Button()); + this->rigidYLabel = (gcnew System::Windows::Forms::Label()); + this->rigidXLabel = (gcnew System::Windows::Forms::Label()); + this->rigidOLabel = (gcnew System::Windows::Forms::Label()); + this->coordinateSetButton2 = (gcnew System::Windows::Forms::Button()); + 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()); + this->CoordinateFramePages->SuspendLayout(); + this->infoPage->SuspendLayout(); + this->markerPage->SuspendLayout(); + this->rigidPage->SuspendLayout(); + this->SuspendLayout(); + // + // CoordinateFramePages + // + this->CoordinateFramePages->Controls->Add(this->infoPage); + this->CoordinateFramePages->Controls->Add(this->markerPage); + this->CoordinateFramePages->Controls->Add(this->rigidPage); + this->CoordinateFramePages->Location = System::Drawing::Point(0, 0); + this->CoordinateFramePages->Name = L"CoordinateFramePages"; + this->CoordinateFramePages->SelectedIndex = 0; + this->CoordinateFramePages->Size = System::Drawing::Size(424, 311); + this->CoordinateFramePages->TabIndex = 0; + // + // infoPage + // + this->infoPage->BackColor = System::Drawing::Color::White; + this->infoPage->Controls->Add(this->infoTitleLabel); + this->infoPage->Controls->Add(this->infoLabel); + this->infoPage->Controls->Add(this->coordinateResetButton); + this->infoPage->Location = System::Drawing::Point(4, 22); + this->infoPage->Name = L"infoPage"; + this->infoPage->Padding = System::Windows::Forms::Padding(3); + this->infoPage->Size = System::Drawing::Size(416, 285); + this->infoPage->TabIndex = 0; + this->infoPage->Text = L"Info"; + // + // infoTitleLabel + // + this->infoTitleLabel->AutoSize = true; + this->infoTitleLabel->Font = (gcnew System::Drawing::Font(L"Segoe UI", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->infoTitleLabel->Location = System::Drawing::Point(8, 12); + this->infoTitleLabel->Name = L"infoTitleLabel"; + this->infoTitleLabel->Size = System::Drawing::Size(258, 30); + this->infoTitleLabel->TabIndex = 2; + this->infoTitleLabel->Text = L"Define Coordinate Frame"; + // + // infoLabel + // + this->infoLabel->AutoSize = true; + this->infoLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->infoLabel->Location = System::Drawing::Point(8, 61); + this->infoLabel->Name = L"infoLabel"; + this->infoLabel->Size = System::Drawing::Size(387, 165); + this->infoLabel->TabIndex = 1; + this->infoLabel->Text = resources->GetString(L"infoLabel.Text"); + // + // coordinateResetButton + // + this->coordinateResetButton->Location = System::Drawing::Point(270, 239); + this->coordinateResetButton->Name = L"coordinateResetButton"; + this->coordinateResetButton->Size = System::Drawing::Size(125, 23); + this->coordinateResetButton->TabIndex = 0; + this->coordinateResetButton->Text = L"Reset Coordinates"; + this->coordinateResetButton->UseVisualStyleBackColor = true; + this->coordinateResetButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::coordinateResetButton_Click); + // + // markerPage + // + this->markerPage->BackColor = System::Drawing::SystemColors::ControlLight; + this->markerPage->Controls->Add(this->markerLabel); + this->markerPage->Controls->Add(this->yLabel); + this->markerPage->Controls->Add(this->xLabel); + this->markerPage->Controls->Add(this->originLabel); + this->markerPage->Controls->Add(this->coordinateGetButton); + this->markerPage->Controls->Add(this->coordinateSetButton); + this->markerPage->Controls->Add(this->coordinateYLabel); + this->markerPage->Controls->Add(this->coordinateXLabel); + this->markerPage->Controls->Add(this->coordinateOLabel); + this->markerPage->Controls->Add(this->coordinateXTextBox); + this->markerPage->Controls->Add(this->coordinateYTextBox); + this->markerPage->Controls->Add(this->coordinateOTextBox); + this->markerPage->Location = System::Drawing::Point(4, 22); + this->markerPage->Name = L"markerPage"; + this->markerPage->Padding = System::Windows::Forms::Padding(3); + this->markerPage->Size = System::Drawing::Size(416, 285); + this->markerPage->TabIndex = 1; + this->markerPage->Text = L"Markers"; + // + // markerLabel + // + this->markerLabel->AutoSize = true; + this->markerLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->markerLabel->Location = System::Drawing::Point(17, 15); + this->markerLabel->Name = L"markerLabel"; + this->markerLabel->Size = System::Drawing::Size(370, 45); + this->markerLabel->TabIndex = 11; + this->markerLabel->Text = L"Enter the IDs of the markers you wish to use for specifying the axes.\r\n\r\nClick \"G" + L"et Data\" to retrieve the marker positions."; + // + // yLabel + // + this->yLabel->AutoSize = true; + this->yLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->yLabel->Location = System::Drawing::Point(17, 186); + this->yLabel->Name = L"yLabel"; + this->yLabel->Size = System::Drawing::Size(46, 15); + this->yLabel->TabIndex = 10; + this->yLabel->Text = L"Y-Axis"; + // + // xLabel + // + this->xLabel->AutoSize = true; + this->xLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->xLabel->Location = System::Drawing::Point(17, 145); + this->xLabel->Name = L"xLabel"; + this->xLabel->Size = System::Drawing::Size(47, 15); + this->xLabel->TabIndex = 9; + this->xLabel->Text = L"X-Axis"; + // + // originLabel + // + this->originLabel->AutoSize = true; + this->originLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->originLabel->Location = System::Drawing::Point(17, 99); + this->originLabel->Name = L"originLabel"; + this->originLabel->Size = System::Drawing::Size(46, 15); + this->originLabel->TabIndex = 8; + this->originLabel->Text = L"Origin"; + // + // coordinateGetButton + // + this->coordinateGetButton->Location = System::Drawing::Point(20, 241); + this->coordinateGetButton->Name = L"coordinateGetButton"; + this->coordinateGetButton->Size = System::Drawing::Size(75, 23); + this->coordinateGetButton->TabIndex = 7; + this->coordinateGetButton->Text = L"Get Data"; + this->coordinateGetButton->UseVisualStyleBackColor = true; + this->coordinateGetButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::coordinateGetButton_Click); + // + // coordinateSetButton + // + this->coordinateSetButton->Enabled = false; + this->coordinateSetButton->Location = System::Drawing::Point(291, 241); + this->coordinateSetButton->Name = L"coordinateSetButton"; + this->coordinateSetButton->Size = System::Drawing::Size(103, 23); + this->coordinateSetButton->TabIndex = 6; + this->coordinateSetButton->Text = L"Set Coordinates"; + this->coordinateSetButton->UseVisualStyleBackColor = true; + this->coordinateSetButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::coordinateSetButton_Click); + // + // coordinateYLabel + // + this->coordinateYLabel->AutoSize = true; + this->coordinateYLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->coordinateYLabel->Location = System::Drawing::Point(164, 186); + this->coordinateYLabel->Name = L"coordinateYLabel"; + this->coordinateYLabel->Size = System::Drawing::Size(84, 15); + this->coordinateYLabel->TabIndex = 5; + this->coordinateYLabel->Text = L"No data found"; + // + // coordinateXLabel + // + this->coordinateXLabel->AutoSize = true; + this->coordinateXLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->coordinateXLabel->Location = System::Drawing::Point(164, 145); + this->coordinateXLabel->Name = L"coordinateXLabel"; + this->coordinateXLabel->Size = System::Drawing::Size(84, 15); + this->coordinateXLabel->TabIndex = 4; + this->coordinateXLabel->Text = L"No data found"; + // + // coordinateOLabel + // + this->coordinateOLabel->AutoSize = true; + this->coordinateOLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->coordinateOLabel->Location = System::Drawing::Point(164, 99); + this->coordinateOLabel->Name = L"coordinateOLabel"; + this->coordinateOLabel->Size = System::Drawing::Size(84, 15); + this->coordinateOLabel->TabIndex = 3; + this->coordinateOLabel->Text = L"No data found"; + // + // coordinateXTextBox + // + this->coordinateXTextBox->Location = System::Drawing::Point(69, 144); + this->coordinateXTextBox->Name = L"coordinateXTextBox"; + this->coordinateXTextBox->Size = System::Drawing::Size(82, 20); + this->coordinateXTextBox->TabIndex = 2; + // + // coordinateYTextBox + // + this->coordinateYTextBox->Location = System::Drawing::Point(69, 185); + this->coordinateYTextBox->Name = L"coordinateYTextBox"; + this->coordinateYTextBox->Size = System::Drawing::Size(82, 20); + this->coordinateYTextBox->TabIndex = 1; + // + // coordinateOTextBox + // + this->coordinateOTextBox->Location = System::Drawing::Point(69, 99); + this->coordinateOTextBox->Name = L"coordinateOTextBox"; + this->coordinateOTextBox->Size = System::Drawing::Size(82, 20); + this->coordinateOTextBox->TabIndex = 0; + // + // rigidPage + // + this->rigidPage->BackColor = System::Drawing::SystemColors::ControlLight; + this->rigidPage->Controls->Add(this->rigidInfoLabel); + this->rigidPage->Controls->Add(this->rigidYButton); + this->rigidPage->Controls->Add(this->rigidXButton); + this->rigidPage->Controls->Add(this->rigidOButton); + this->rigidPage->Controls->Add(this->rigidYLabel); + this->rigidPage->Controls->Add(this->rigidXLabel); + this->rigidPage->Controls->Add(this->rigidOLabel); + this->rigidPage->Controls->Add(this->coordinateSetButton2); + this->rigidPage->Controls->Add(this->rigidGetDataButton); + this->rigidPage->Controls->Add(this->rigidToolPositionLabel); + this->rigidPage->Controls->Add(this->rigidBodyLabel); + this->rigidPage->Location = System::Drawing::Point(4, 22); + this->rigidPage->Name = L"rigidPage"; + this->rigidPage->Padding = System::Windows::Forms::Padding(3); + this->rigidPage->Size = System::Drawing::Size(416, 285); + this->rigidPage->TabIndex = 1; + this->rigidPage->Text = L"Rigid Body"; + // + // rigidYButton + // + this->rigidYButton->BackColor = System::Drawing::SystemColors::ControlLightLight; + this->rigidYButton->Enabled = false; + this->rigidYButton->Location = System::Drawing::Point(85, 194); + this->rigidYButton->Name = L"rigidYButton"; + this->rigidYButton->Size = System::Drawing::Size(75, 23); + this->rigidYButton->TabIndex = 13; + this->rigidYButton->Text = L"Y-Axis"; + this->rigidYButton->UseVisualStyleBackColor = true; + this->rigidYButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::rigidSetDataButton_Click); + // + // rigidXButton + // + this->rigidXButton->BackColor = System::Drawing::SystemColors::ControlLightLight; + this->rigidXButton->Enabled = false; + this->rigidXButton->Location = System::Drawing::Point(85, 163); + this->rigidXButton->Name = L"rigidXButton"; + this->rigidXButton->Size = System::Drawing::Size(75, 23); + this->rigidXButton->TabIndex = 12; + this->rigidXButton->Text = L"X-Axis"; + this->rigidXButton->UseVisualStyleBackColor = true; + this->rigidXButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::rigidSetDataButton_Click); + // + // rigidOButton + // + this->rigidOButton->BackColor = System::Drawing::SystemColors::ControlLightLight; + this->rigidOButton->Enabled = false; + this->rigidOButton->Location = System::Drawing::Point(85, 132); + this->rigidOButton->Name = L"rigidOButton"; + this->rigidOButton->Size = System::Drawing::Size(75, 23); + this->rigidOButton->TabIndex = 11; + this->rigidOButton->Text = L"Origin"; + this->rigidOButton->UseVisualStyleBackColor = true; + this->rigidOButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::rigidSetDataButton_Click); + // + // rigidYLabel + // + this->rigidYLabel->AutoSize = true; + this->rigidYLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->rigidYLabel->Location = System::Drawing::Point(166, 197); + this->rigidYLabel->Name = L"rigidYLabel"; + this->rigidYLabel->Size = System::Drawing::Size(84, 15); + this->rigidYLabel->TabIndex = 10; + this->rigidYLabel->Text = L"No data found"; + // + // rigidXLabel + // + this->rigidXLabel->AutoSize = true; + this->rigidXLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->rigidXLabel->Location = System::Drawing::Point(166, 166); + this->rigidXLabel->Name = L"rigidXLabel"; + this->rigidXLabel->Size = System::Drawing::Size(84, 15); + this->rigidXLabel->TabIndex = 9; + this->rigidXLabel->Text = L"No data found"; + // + // rigidOLabel + // + this->rigidOLabel->AutoSize = true; + this->rigidOLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->rigidOLabel->Location = System::Drawing::Point(166, 135); + this->rigidOLabel->Name = L"rigidOLabel"; + this->rigidOLabel->Size = System::Drawing::Size(84, 15); + this->rigidOLabel->TabIndex = 8; + this->rigidOLabel->Text = L"No data found"; + // + // coordinateSetButton2 + // + this->coordinateSetButton2->Enabled = false; + this->coordinateSetButton2->Location = System::Drawing::Point(291, 241); + this->coordinateSetButton2->Name = L"coordinateSetButton2"; + this->coordinateSetButton2->Size = System::Drawing::Size(103, 23); + this->coordinateSetButton2->TabIndex = 7; + this->coordinateSetButton2->Text = L"Set Coordinates"; + this->coordinateSetButton2->UseVisualStyleBackColor = true; + this->coordinateSetButton2->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::coordinateSetButton_Click); + // + // rigidGetDataButton + // + this->rigidGetDataButton->Location = System::Drawing::Point(36, 101); + this->rigidGetDataButton->Name = L"rigidGetDataButton"; + this->rigidGetDataButton->Size = System::Drawing::Size(75, 23); + this->rigidGetDataButton->TabIndex = 2; + this->rigidGetDataButton->Text = L"Get Data"; + this->rigidGetDataButton->UseVisualStyleBackColor = true; + this->rigidGetDataButton->Click += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::rigidGetDataButton_Click); + // + // rigidToolPositionLabel + // + this->rigidToolPositionLabel->AutoSize = true; + this->rigidToolPositionLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, + System::Drawing::GraphicsUnit::Point, static_cast(0))); + this->rigidToolPositionLabel->Location = System::Drawing::Point(117, 104); + this->rigidToolPositionLabel->Name = L"rigidToolPositionLabel"; + this->rigidToolPositionLabel->Size = System::Drawing::Size(92, 16); + this->rigidToolPositionLabel->TabIndex = 1; + this->rigidToolPositionLabel->Text = L"No data found"; + // + // rigidBodyLabel + // + this->rigidBodyLabel->AutoSize = true; + this->rigidBodyLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->rigidBodyLabel->Location = System::Drawing::Point(21, 79); + this->rigidBodyLabel->Name = L"rigidBodyLabel"; + this->rigidBodyLabel->Size = System::Drawing::Size(160, 16); + 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(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); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(426, 310); + this->Controls->Add(this->CoordinateFramePages); + this->Name = L"DefineCoordinateFrameForm"; + this->Text = L"Define Coordinate Frame"; + this->Closed += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::DefineCoordinateFrameForm_Closed); + this->Load += gcnew System::EventHandler(this, &DefineCoordinateFrameForm::DefineCoordinateFrameForm_Load); + this->CoordinateFramePages->ResumeLayout(false); + this->infoPage->ResumeLayout(false); + this->infoPage->PerformLayout(); + this->markerPage->ResumeLayout(false); + this->markerPage->PerformLayout(); + this->rigidPage->ResumeLayout(false); + this->rigidPage->PerformLayout(); + this->ResumeLayout(false); + + } +#pragma endregion + + // local variables + private: osg::Vec3* posO; + private: osg::Vec3* posX; + private: osg::Vec3* posY; + private: osg::Vec3* pos; + + private: System::Void DefineCoordinateFrameForm_Load(System::Object^ sender, System::EventArgs^ e) { + this->defaultDataText = L"No data found"; + } + private: System::Void DefineCoordinateFrameForm_Closed( Object^ /*sender*/, System::EventArgs ^ e ) + { + if (posO) delete posO; + if (posX) delete posX; + if (posY) delete posY; + if (pos) delete pos; + } + + private: System::Void coordinateGetButton_Click(System::Object^ sender, System::EventArgs^ e) { + ClientHandler* client = AppData::getInstance()->getClient(); + if (client->lock()) + { + Marker* marker; + bool result; + int id; + this->coordinateSetButton->Enabled = true; + + // origin + result = Int32::TryParse(coordinateOTextBox->Text, id); + marker = client->getLabeledMarker(id); + if (!result || !marker) + { + coordinate_setDefaultText(coordinateOLabel); + this->coordinateSetButton->Enabled = false; + } + 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()); + + coordinate_setPoint(posO, coordinateOLabel); + } + + // x + result = Int32::TryParse(coordinateXTextBox->Text, id); + marker = client->getLabeledMarker(id); + if (!result || !marker) + { + coordinate_setDefaultText(coordinateXLabel); + this->coordinateSetButton->Enabled = false; + } + 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()); + + coordinate_setPoint(posX, coordinateXLabel); + } + + // y + result = Int32::TryParse(coordinateYTextBox->Text, id); + marker = client->getLabeledMarker(id); + if (!result || !marker) + { + coordinate_setDefaultText(coordinateYLabel); + this->coordinateSetButton->Enabled = false; + } + 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()); + + coordinate_setPoint(posY, coordinateYLabel); + } + + client->unlock(); + } + } + private: System::Void coordinate_setDefaultText(Label^ text) { + text->Text = defaultDataText; + } + private: System::Void coordinate_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; + } + + private: System::Void coordinateSetButton_Click(System::Object^ sender, System::EventArgs^ e); + + private: System::Void coordinateResetButton_Click(System::Object^ sender, System::EventArgs^ e); + + private: System::Void rigidSetButtons(bool enable) { + this->rigidOButton->Enabled = enable; + this->rigidXButton->Enabled = enable; + this->rigidYButton->Enabled = enable; + } + private: System::Void rigidGetDataButton_Click(System::Object^ sender, System::EventArgs^ e) { + ClientHandler* client = AppData::getInstance()->getClient(); + if (client) + { + 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()); + coordinate_setPoint(pos, rigidToolPositionLabel); + rigidSetButtons(true); + return; + } + } + coordinate_setDefaultText(rigidToolPositionLabel); + rigidSetButtons(false); + } + + 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); + + if ( String::Compare(rigidXLabel->Text, defaultDataText) && + String::Compare(rigidYLabel->Text, defaultDataText) ) + coordinateSetButton2->Enabled = true; + else + coordinateSetButton2->Enabled = false; + } + else if (sender == this->rigidXButton) + { + if (!posX) + posX = new osg::Vec3(); + + posX->set(pos->x(), pos->y(), pos->z()); + coordinate_setPoint(pos, rigidXLabel); + + if ( String::Compare(rigidOLabel->Text, defaultDataText) && + String::Compare(rigidYLabel->Text, defaultDataText) ) + coordinateSetButton2->Enabled = true; + else + coordinateSetButton2->Enabled = false; + } + else if (sender == this->rigidYButton) + { + if (!posY) + posY = new osg::Vec3(); + + posY->set(pos->x(), pos->y(), pos->z()); + coordinate_setPoint(pos, rigidYLabel); + + if ( String::Compare(rigidOLabel->Text, defaultDataText) && + String::Compare(rigidXLabel->Text, defaultDataText) ) + coordinateSetButton2->Enabled = true; + else + coordinateSetButton2->Enabled = false; + } + } +}; +} diff --git a/BlinkAnalysis/DefineCoordinateFrameForm.resx b/BlinkAnalysis/DefineCoordinateFrameForm.resx index 43cbcac..45fe718 100644 --- a/BlinkAnalysis/DefineCoordinateFrameForm.resx +++ b/BlinkAnalysis/DefineCoordinateFrameForm.resx @@ -125,6 +125,7 @@ Markers Rigid Body Define the axes using the Rigid Body Tool. + Please ensure a rigid body has been set before using this form. Click "Reset Coordinates" below to revert to the original coordinates. diff --git a/BlinkAnalysis/DefineCoordinateFrameFormController.h b/BlinkAnalysis/DefineCoordinateFrameFormController.h new file mode 100644 index 0000000..11b4334 --- /dev/null +++ b/BlinkAnalysis/DefineCoordinateFrameFormController.h @@ -0,0 +1,29 @@ +#pragma once +#include "stdafx.h" +#include + +#include "DefineCoordinateFrameForm.h" +#include "FormController.h" + +using namespace System; + +public ref class DefineCoordinateFrameFormController sealed : + public FormController +{ +public: + + void setDisplayWorld(int id) + { + if (form && !form->IsDisposed) + form->setDisplayWorld(id); + } + + int getDisplayWorld() + { + if (form && !form->IsDisposed) + return form->getDisplayWorld(); + return -1; + } + +}; + diff --git a/BlinkAnalysis/MainForm.h b/BlinkAnalysis/MainForm.h index fedd8bd..81ab558 100644 --- a/BlinkAnalysis/MainForm.h +++ b/BlinkAnalysis/MainForm.h @@ -18,8 +18,11 @@ #include "Dikablis.h" #include "DikablisHelp.h" -//#include "AddObjectForm.h" +#include "AddObjectFormController.h" +#include "AddWorldForm.h" // TODO need to add controller? +#include "DefineCoordinateFrameFormController.h" #include "EyeCalibrationWizardFormController.h" +#include "SetObjectRigidBodyFormController.h" #include "AppData.h" #include "AppViewer.h" @@ -37,6 +40,25 @@ namespace BlinkAnalysis { using namespace System::Reflection; using namespace msclr::interop; + // enums used to help define ordering of values + // in the grid view of world or object properties + // Make sure to follow this order when adding rows to GridView + enum class worldProperty + { + ID = 0, + NAME = 1, + OBJECTS = 2, + MATRIX = 3 + }; + enum class objectProperty + { + ID = 0, + NAME = 1, + RIGID = 2, + FACES = 3, + VERTICES = 4 + }; + /// /// Summary for MainForm /// @@ -213,11 +235,34 @@ private: System::Windows::Forms::ToolStripMenuItem^ addObjectToolStripMenuItem; private: System::Windows::Forms::ContextMenuStrip^ rigidBodyToolContextMenu; private: System::Windows::Forms::ToolStripMenuItem^ setAsRigidBodyToolToolStripMenuItem; -private: System::Windows::Forms::TabControl^ tabControl1; +private: System::Windows::Forms::TabControl^ visualPropertiesTabControl; + private: System::Windows::Forms::TabPage^ rigidBodyTabPage; private: System::Windows::Forms::TabPage^ worldTabPage; private: System::Windows::Forms::TabPage^ objectTabPage; private: System::Windows::Forms::ComboBox^ worldComboBox; +private: System::Windows::Forms::Button^ worldAddButton; + +private: System::Windows::Forms::DataGridView^ worldGridView; +private: System::Windows::Forms::DataGridViewTextBoxColumn^ worldPropertyColumn; +private: System::Windows::Forms::DataGridViewTextBoxColumn^ worldValueColumn; +private: System::Windows::Forms::Label^ worldListLabel; +private: System::Windows::Forms::Label^ objectLabel; + +private: System::Windows::Forms::Label^ objectWLabel; +private: System::Windows::Forms::ComboBox^ objectWComboBox; +private: System::Windows::Forms::Button^ objectAddButton; +private: System::Windows::Forms::ComboBox^ objectComboBox; +private: System::Windows::Forms::DataGridView^ objectGridView; +private: System::Windows::Forms::DataGridViewTextBoxColumn^ objectPropertyColumn; +private: System::Windows::Forms::DataGridViewTextBoxColumn^ objectValueColumn; + + + + + + + @@ -315,12 +360,25 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; this->visualSplitContainer = (gcnew System::Windows::Forms::SplitContainer()); this->visualOutputLogTextBox = (gcnew System::Windows::Forms::TextBox()); this->visualOutputLogLabel = (gcnew System::Windows::Forms::Label()); - this->tabControl1 = (gcnew System::Windows::Forms::TabControl()); + this->visualPropertiesTabControl = (gcnew System::Windows::Forms::TabControl()); this->rigidBodyTabPage = (gcnew System::Windows::Forms::TabPage()); this->visualRigidBodyListView = (gcnew System::Windows::Forms::ListView()); this->worldTabPage = (gcnew System::Windows::Forms::TabPage()); + this->worldListLabel = (gcnew System::Windows::Forms::Label()); + this->worldGridView = (gcnew System::Windows::Forms::DataGridView()); + this->worldPropertyColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->worldValueColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->worldAddButton = (gcnew System::Windows::Forms::Button()); this->worldComboBox = (gcnew System::Windows::Forms::ComboBox()); this->objectTabPage = (gcnew System::Windows::Forms::TabPage()); + this->objectLabel = (gcnew System::Windows::Forms::Label()); + this->objectWLabel = (gcnew System::Windows::Forms::Label()); + this->objectWComboBox = (gcnew System::Windows::Forms::ComboBox()); + this->objectAddButton = (gcnew System::Windows::Forms::Button()); + this->objectComboBox = (gcnew System::Windows::Forms::ComboBox()); + this->objectGridView = (gcnew System::Windows::Forms::DataGridView()); + this->objectPropertyColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->objectValueColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); this->menuStrip = (gcnew System::Windows::Forms::MenuStrip()); this->projectToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->newToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); @@ -360,9 +418,12 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; (cli::safe_cast(this->visualSplitContainer))->BeginInit(); this->visualSplitContainer->Panel2->SuspendLayout(); this->visualSplitContainer->SuspendLayout(); - this->tabControl1->SuspendLayout(); + this->visualPropertiesTabControl->SuspendLayout(); this->rigidBodyTabPage->SuspendLayout(); this->worldTabPage->SuspendLayout(); + (cli::safe_cast(this->worldGridView))->BeginInit(); + this->objectTabPage->SuspendLayout(); + (cli::safe_cast(this->objectGridView))->BeginInit(); this->menuStrip->SuspendLayout(); this->rigidBodyToolContextMenu->SuspendLayout(); this->SuspendLayout(); @@ -426,7 +487,7 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; this->optiTrackMainSplitContainer->Panel2->Controls->Add(this->optiTrackServerTitleLabel); this->optiTrackMainSplitContainer->Panel2->Controls->Add(this->optiTrackPropertiesLabel); this->optiTrackMainSplitContainer->Panel2->Cursor = System::Windows::Forms::Cursors::Arrow; - this->optiTrackMainSplitContainer->Panel2MinSize = 250; + this->optiTrackMainSplitContainer->Panel2MinSize = 273; this->optiTrackMainSplitContainer->Size = System::Drawing::Size(770, 503); this->optiTrackMainSplitContainer->SplitterDistance = 493; this->optiTrackMainSplitContainer->TabIndex = 1; @@ -802,7 +863,7 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; this->dikablisMainSplitContainer->Panel2->Controls->Add(this->dikablisIPLabel); this->dikablisMainSplitContainer->Panel2->Controls->Add(this->dikablisRecorderSetting); this->dikablisMainSplitContainer->Panel2->Controls->Add(this->dikablisPropertiesLabel); - this->dikablisMainSplitContainer->Panel2MinSize = 250; + this->dikablisMainSplitContainer->Panel2MinSize = 273; this->dikablisMainSplitContainer->Size = System::Drawing::Size(770, 503); this->dikablisMainSplitContainer->SplitterDistance = 493; this->dikablisMainSplitContainer->TabIndex = 0; @@ -1275,8 +1336,8 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; // visualMainSplitContainer.Panel2 // this->visualMainSplitContainer->Panel2->BackColor = System::Drawing::Color::WhiteSmoke; - this->visualMainSplitContainer->Panel2->Controls->Add(this->tabControl1); - this->visualMainSplitContainer->Panel2MinSize = 250; + this->visualMainSplitContainer->Panel2->Controls->Add(this->visualPropertiesTabControl); + this->visualMainSplitContainer->Panel2MinSize = 273; this->visualMainSplitContainer->Size = System::Drawing::Size(770, 503); this->visualMainSplitContainer->SplitterDistance = 493; this->visualMainSplitContainer->TabIndex = 0; @@ -1330,16 +1391,17 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; this->visualOutputLogLabel->TabIndex = 0; this->visualOutputLogLabel->Text = L"Output Log"; // - // tabControl1 + // visualPropertiesTabControl // - this->tabControl1->Controls->Add(this->rigidBodyTabPage); - this->tabControl1->Controls->Add(this->worldTabPage); - this->tabControl1->Controls->Add(this->objectTabPage); - this->tabControl1->Location = System::Drawing::Point(3, 3); - this->tabControl1->Name = L"tabControl1"; - this->tabControl1->SelectedIndex = 0; - this->tabControl1->Size = System::Drawing::Size(270, 500); - this->tabControl1->TabIndex = 6; + this->visualPropertiesTabControl->Controls->Add(this->rigidBodyTabPage); + this->visualPropertiesTabControl->Controls->Add(this->worldTabPage); + this->visualPropertiesTabControl->Controls->Add(this->objectTabPage); + this->visualPropertiesTabControl->Dock = System::Windows::Forms::DockStyle::Fill; + this->visualPropertiesTabControl->Location = System::Drawing::Point(0, 0); + this->visualPropertiesTabControl->Name = L"visualPropertiesTabControl"; + this->visualPropertiesTabControl->SelectedIndex = 0; + this->visualPropertiesTabControl->Size = System::Drawing::Size(273, 503); + this->visualPropertiesTabControl->TabIndex = 6; // // rigidBodyTabPage // @@ -1347,7 +1409,7 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; this->rigidBodyTabPage->Location = System::Drawing::Point(4, 22); this->rigidBodyTabPage->Name = L"rigidBodyTabPage"; this->rigidBodyTabPage->Padding = System::Windows::Forms::Padding(3); - this->rigidBodyTabPage->Size = System::Drawing::Size(262, 474); + this->rigidBodyTabPage->Size = System::Drawing::Size(265, 477); this->rigidBodyTabPage->TabIndex = 0; this->rigidBodyTabPage->Text = L"Rigid Body"; this->rigidBodyTabPage->UseVisualStyleBackColor = true; @@ -1355,14 +1417,13 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; // visualRigidBodyListView // this->visualRigidBodyListView->Alignment = System::Windows::Forms::ListViewAlignment::Left; - this->visualRigidBodyListView->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) - | System::Windows::Forms::AnchorStyles::Right)); + this->visualRigidBodyListView->Dock = System::Windows::Forms::DockStyle::Fill; this->visualRigidBodyListView->FullRowSelect = true; this->visualRigidBodyListView->LabelWrap = false; - this->visualRigidBodyListView->Location = System::Drawing::Point(6, 6); + this->visualRigidBodyListView->Location = System::Drawing::Point(3, 3); this->visualRigidBodyListView->MultiSelect = false; this->visualRigidBodyListView->Name = L"visualRigidBodyListView"; - this->visualRigidBodyListView->Size = System::Drawing::Size(250, 435); + this->visualRigidBodyListView->Size = System::Drawing::Size(259, 471); this->visualRigidBodyListView->TabIndex = 1; this->visualRigidBodyListView->TileSize = System::Drawing::Size(100, 20); this->visualRigidBodyListView->UseCompatibleStateImageBehavior = false; @@ -1371,35 +1432,179 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; // // worldTabPage // + this->worldTabPage->Controls->Add(this->worldListLabel); + this->worldTabPage->Controls->Add(this->worldGridView); + this->worldTabPage->Controls->Add(this->worldAddButton); this->worldTabPage->Controls->Add(this->worldComboBox); this->worldTabPage->Location = System::Drawing::Point(4, 22); this->worldTabPage->Name = L"worldTabPage"; this->worldTabPage->Padding = System::Windows::Forms::Padding(3); - this->worldTabPage->Size = System::Drawing::Size(262, 474); + this->worldTabPage->Size = System::Drawing::Size(265, 477); this->worldTabPage->TabIndex = 1; this->worldTabPage->Text = L"World"; this->worldTabPage->UseVisualStyleBackColor = true; // + // worldListLabel + // + this->worldListLabel->AutoSize = true; + this->worldListLabel->Location = System::Drawing::Point(3, 3); + this->worldListLabel->Name = L"worldListLabel"; + this->worldListLabel->Size = System::Drawing::Size(39, 13); + this->worldListLabel->TabIndex = 4; + this->worldListLabel->Text = L"World"; + // + // worldGridView + // + this->worldGridView->AllowUserToAddRows = false; + this->worldGridView->AllowUserToDeleteRows = false; + this->worldGridView->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); + this->worldGridView->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill; + this->worldGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; + this->worldGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(2) {this->worldPropertyColumn, + this->worldValueColumn}); + this->worldGridView->Location = System::Drawing::Point(6, 46); + this->worldGridView->Name = L"worldGridView"; + this->worldGridView->Size = System::Drawing::Size(250, 422); + this->worldGridView->TabIndex = 3; + this->worldGridView->CellDoubleClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MainForm::worldGridView_CellDoubleClick); + this->worldGridView->CellValueChanged += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MainForm::worldGridView_CellValueChanged); + // + // worldPropertyColumn + // + this->worldPropertyColumn->HeaderText = L"Property"; + this->worldPropertyColumn->Name = L"worldPropertyColumn"; + this->worldPropertyColumn->ReadOnly = true; + // + // worldValueColumn + // + this->worldValueColumn->HeaderText = L"Value"; + this->worldValueColumn->Name = L"worldValueColumn"; + // + // worldAddButton + // + this->worldAddButton->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right)); + this->worldAddButton->Location = System::Drawing::Point(200, 17); + this->worldAddButton->Name = L"worldAddButton"; + this->worldAddButton->Size = System::Drawing::Size(56, 23); + this->worldAddButton->TabIndex = 2; + this->worldAddButton->Text = L"Add"; + this->worldAddButton->UseVisualStyleBackColor = true; + this->worldAddButton->Click += gcnew System::EventHandler(this, &MainForm::worldAddButton_Click); + // // worldComboBox // + this->worldComboBox->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); this->worldComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList; this->worldComboBox->ForeColor = System::Drawing::SystemColors::InfoText; this->worldComboBox->FormattingEnabled = true; - this->worldComboBox->Location = System::Drawing::Point(6, 6); + this->worldComboBox->Location = System::Drawing::Point(6, 19); this->worldComboBox->Name = L"worldComboBox"; - this->worldComboBox->Size = System::Drawing::Size(198, 21); + this->worldComboBox->Size = System::Drawing::Size(188, 21); this->worldComboBox->TabIndex = 0; + this->worldComboBox->SelectedIndexChanged += gcnew System::EventHandler(this, &MainForm::worldComboBox_SelectedIndexChanged); // // objectTabPage // + this->objectTabPage->Controls->Add(this->objectLabel); + this->objectTabPage->Controls->Add(this->objectWLabel); + this->objectTabPage->Controls->Add(this->objectWComboBox); + this->objectTabPage->Controls->Add(this->objectAddButton); + this->objectTabPage->Controls->Add(this->objectComboBox); + this->objectTabPage->Controls->Add(this->objectGridView); this->objectTabPage->Location = System::Drawing::Point(4, 22); this->objectTabPage->Name = L"objectTabPage"; this->objectTabPage->Padding = System::Windows::Forms::Padding(3); - this->objectTabPage->Size = System::Drawing::Size(262, 474); + this->objectTabPage->Size = System::Drawing::Size(265, 477); this->objectTabPage->TabIndex = 2; this->objectTabPage->Text = L"Object"; this->objectTabPage->UseVisualStyleBackColor = true; // + // objectLabel + // + this->objectLabel->AutoSize = true; + this->objectLabel->Location = System::Drawing::Point(3, 43); + this->objectLabel->Name = L"objectLabel"; + this->objectLabel->Size = System::Drawing::Size(41, 13); + this->objectLabel->TabIndex = 12; + this->objectLabel->Text = L"Object"; + // + // objectWLabel + // + this->objectWLabel->AutoSize = true; + this->objectWLabel->Location = System::Drawing::Point(3, 3); + this->objectWLabel->Name = L"objectWLabel"; + this->objectWLabel->Size = System::Drawing::Size(39, 13); + this->objectWLabel->TabIndex = 11; + this->objectWLabel->Text = L"World"; + // + // objectWComboBox + // + this->objectWComboBox->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); + this->objectWComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList; + this->objectWComboBox->ForeColor = System::Drawing::SystemColors::InfoText; + this->objectWComboBox->FormattingEnabled = true; + this->objectWComboBox->Location = System::Drawing::Point(6, 19); + this->objectWComboBox->Name = L"objectWComboBox"; + this->objectWComboBox->Size = System::Drawing::Size(188, 21); + this->objectWComboBox->TabIndex = 9; + this->objectWComboBox->SelectedIndexChanged += gcnew System::EventHandler(this, &MainForm::objectWComboBox_SelectedIndexChanged); + // + // objectAddButton + // + this->objectAddButton->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right)); + this->objectAddButton->Enabled = false; + this->objectAddButton->Location = System::Drawing::Point(200, 57); + this->objectAddButton->Name = L"objectAddButton"; + this->objectAddButton->Size = System::Drawing::Size(56, 23); + this->objectAddButton->TabIndex = 8; + this->objectAddButton->Text = L"Add"; + this->objectAddButton->UseVisualStyleBackColor = true; + this->objectAddButton->Click += gcnew System::EventHandler(this, &MainForm::objectAddButton_Click); + // + // objectComboBox + // + this->objectComboBox->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); + this->objectComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList; + this->objectComboBox->ForeColor = System::Drawing::SystemColors::InfoText; + this->objectComboBox->FormattingEnabled = true; + this->objectComboBox->Location = System::Drawing::Point(6, 59); + this->objectComboBox->Name = L"objectComboBox"; + this->objectComboBox->Size = System::Drawing::Size(188, 21); + this->objectComboBox->TabIndex = 7; + this->objectComboBox->SelectedIndexChanged += gcnew System::EventHandler(this, &MainForm::objectComboBox_SelectedIndexChanged); + // + // objectGridView + // + this->objectGridView->AllowUserToAddRows = false; + this->objectGridView->AllowUserToDeleteRows = false; + this->objectGridView->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); + this->objectGridView->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill; + this->objectGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; + this->objectGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(2) {this->objectPropertyColumn, + this->objectValueColumn}); + this->objectGridView->Location = System::Drawing::Point(6, 86); + this->objectGridView->Name = L"objectGridView"; + this->objectGridView->Size = System::Drawing::Size(250, 382); + this->objectGridView->TabIndex = 6; + this->objectGridView->CellDoubleClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MainForm::objectGridView_CellDoubleClick); + this->objectGridView->CellValueChanged += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MainForm::objectGridView_CellValueChanged); + // + // objectPropertyColumn + // + this->objectPropertyColumn->HeaderText = L"Property"; + this->objectPropertyColumn->Name = L"objectPropertyColumn"; + this->objectPropertyColumn->ReadOnly = true; + // + // objectValueColumn + // + this->objectValueColumn->HeaderText = L"Value"; + this->objectValueColumn->Name = L"objectValueColumn"; + // // menuStrip // this->menuStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->projectToolStripMenuItem, @@ -1541,9 +1746,14 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; this->visualSplitContainer->Panel2->PerformLayout(); (cli::safe_cast(this->visualSplitContainer))->EndInit(); this->visualSplitContainer->ResumeLayout(false); - this->tabControl1->ResumeLayout(false); + this->visualPropertiesTabControl->ResumeLayout(false); this->rigidBodyTabPage->ResumeLayout(false); this->worldTabPage->ResumeLayout(false); + this->worldTabPage->PerformLayout(); + (cli::safe_cast(this->worldGridView))->EndInit(); + this->objectTabPage->ResumeLayout(false); + this->objectTabPage->PerformLayout(); + (cli::safe_cast(this->objectGridView))->EndInit(); this->menuStrip->ResumeLayout(false); this->menuStrip->PerformLayout(); this->rigidBodyToolContextMenu->ResumeLayout(false); @@ -1561,7 +1771,10 @@ private: System::Windows::Forms::ComboBox^ worldComboBox; private: std::vector* optiTrackLabeledMarkerVector; private: SplitContainer^ currentMainSplitContainer; private: SplitContainer^ currentSplitContainer; - private: int setRigidBodyTool; + private: int setRigidBodyTool; // ID of rigid body to use as pointing tool + private: int displayWorld; // ID of world displayed in World tab + private: int displayObjectWorld; // ID of world of object displayed in Object tab + private: int displayObject; // ID of object displayed in Object tab // User Defined Functions private: void getOptiTrackInfo() { @@ -2276,30 +2489,6 @@ private: System::Void saveAsToolStripMenuItem_Click(System::Object^ sender, Sys this->saveAsProject(); } private: System::Void addObjectToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { -/* AddObjectForm^ objectForm = gcnew AddObjectForm(); - objectForm->UpdateObject += gcnew System::EventHandler(this, &MainForm::AddObjectForm_UpdateObject); - objectForm->Show();*/ - } -private: System::Void AddObjectForm_UpdateObject(System::Object^ sender, System::EventArgs^ e) { - /*CaptureWorld* world = AppData::getInstance()->getWorld(); - if (world) - { - std::map objectMap = world->getObjects(); - - this->visualObjectsListView->Items->Clear(); - - for (objects_iterator it = objectMap.begin(); it != objectMap.end(); it++) - { - // Add Capture Object to list - String^ objectID = Convert::ToString(it->second->getID()); - String^ objectName = gcnew String(it->second->getName().c_str()); - ListViewItem^ listViewItem = gcnew ListViewItem(objectID); - listViewItem->SubItems->Add(objectName); - this->visualObjectsListView->Items->Add(listViewItem); - } - }*/ - } -private: System::Void objectsListView_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { } /*private: System::Void markersListView_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { int toggled = -1; @@ -2339,7 +2528,9 @@ private: System::Void setAsRigidBodyToolToolStripMenuItem_Click(System::Object^ ////////////////////// // Capture World and Objects ///////////////////// -public: System::Void worldUpdateData() { + + // update list of worlds in both World and Object tab +public: System::Void worldUpdateList() { static bool isUpdatingWorlds = false; if (isUpdatingWorlds) @@ -2347,41 +2538,314 @@ public: System::Void worldUpdateData() { isUpdatingWorlds = true; - // Start update - // Check if the main tab control needs invoke. - // If not then check to see if the visual tab - // is selected. - if (this->mainTabControl->InvokeRequired) + if (this->worldComboBox->InvokeRequired) { - SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::worldUpdateData); + SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::worldUpdateList); BeginInvoke(d, nullptr); } else { - if (this->worldComboBox->InvokeRequired) + this->worldComboBox->Items->Clear(); + this->objectWComboBox->Items->Clear(); + this->objectComboBox->Items->Clear(); + resetWorldGridView(); + resetObjectGridView(); + + std::map worlds = AppData::getInstance()->getWorlds(); + int idx = 0; + for (worlds_iterator itr = worlds.begin(); itr != worlds.end(); itr++) { - SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::worldUpdateData); - BeginInvoke(d, nullptr); - } - else - { - this->worldComboBox->Items->Clear(); - std::map worlds = AppData::getInstance()->getWorlds(); - for (worlds_iterator itr = worlds.begin(); itr != worlds.end(); itr++) - { - String^ worldName = gcnew String(itr->second->getName().c_str()); - worldName += " ("; - worldName += itr->first.ToString(); - worldName += ")"; - this->worldComboBox->Items->Add(worldName); - } + String^ worldName = gcnew String(itr->second->getName().c_str()); + worldName += " ("; + worldName += itr->first.ToString(); + worldName += ")"; + this->worldComboBox->Items->Add(worldName); + this->objectWComboBox->Items->Add(worldName); } } - // End of update isUpdatingWorlds = false; } +public: System::Void worldUpdateGridView() { + worldGridView_displayWorld(); + } + // populates the world GridView based on selected value from world ComboBox +private: System::Void worldGridView_displayWorld() { + if (this->worldGridView->InvokeRequired) + { + SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::worldGridView_displayWorld); + BeginInvoke(d, nullptr); + } + else + { + this->worldGridView->Rows->Clear(); + CaptureWorld* world = AppData::getInstance()->getWorld(displayWorld); + if (!world) return; + + array^ row; + + // populate values + // NOTE: this has to match the order in the enum worldProperty + row = gcnew array { "ID", world->getID().ToString() }; + this->worldGridView->Rows->Add(row); + + row = gcnew array { "Name", gcnew String(world->getName().c_str()) }; + this->worldGridView->Rows->Add(row); + row = gcnew array { "Objects", world->getNumberObjects().ToString() }; + this->worldGridView->Rows->Add(row); + + String^ iden = (world->getGlobalToLocalMatrix().isIdentity()) ? "false" : "true"; + row = gcnew array { "Transformation", iden }; + this->worldGridView->Rows->Add(row); + + // set certain rows to read only + this->worldGridView->Rows[(int)worldProperty::ID]->ReadOnly = true; + this->worldGridView->Rows[(int)worldProperty::OBJECTS]->ReadOnly = true; + this->worldGridView->Rows[(int)worldProperty::MATRIX]->ReadOnly = true; + + // if default world + if (world->getID() == 0) + { + this->worldGridView->Rows[(int)worldProperty::NAME]->ReadOnly = true; + } + } + } + // update world display if drop down list value changes +private: System::Void worldComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { + if (!this->worldComboBox->SelectedItem) + { + resetWorldGridView(); + return; + } + + String^ text = this->worldComboBox->SelectedItem->ToString(); + int id = worldExtractID(text); + if (id >= 0) + { + displayWorld = id; + 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) + return; + + this->objectAddButton->Enabled = true; + + String^ text = this->objectWComboBox->SelectedItem->ToString(); + int id = worldExtractID(text); + if (id >= 0) + { + displayObjectWorld = id; + objectComboBox_updateList(); + } + } + // populate list of objects based on displayObjectWorld +public: System::Void objectComboBox_updateList() { + if (this->objectComboBox->InvokeRequired) + { + SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::objectComboBox_updateList); + BeginInvoke(d, nullptr); + } + else + { + this->objectComboBox->Items->Clear(); + resetObjectGridView(); + + CaptureWorld* world = AppData::getInstance()->getWorld(displayObjectWorld); + int idx = 0; + if (world) + { + std::map objects = world->getObjects(); + for (objects_iterator itr = objects.begin(); itr != objects.end(); itr++) + { + String^ objectName = gcnew String(itr->second->getName().c_str()); + objectName += " ("; + objectName += itr->first.ToString(); + objectName += ")"; + this->objectComboBox->Items->Add(objectName); + } + } + } + } + // update object display if drop down list value changes +private: System::Void objectComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { + if (!this->objectComboBox->SelectedItem) + { + resetObjectGridView(); + return; + } + + String^ text = this->objectComboBox->SelectedItem->ToString(); + int id = worldExtractID(text); + if (id >= 0) + { + displayObject = id; + objectGridView_displayObject(); + } + } +public: System::Void objectUpdateGridView() { + objectGridView_displayObject(); + } + // populates the object GridView based on selected value from world and object ComboBoxes +private: System::Void objectGridView_displayObject() { + if (this->objectGridView->InvokeRequired) + { + SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::objectGridView_displayObject); + BeginInvoke(d, nullptr); + } + else + { + this->objectGridView->Rows->Clear(); + CaptureWorld* world = AppData::getInstance()->getWorld(displayObjectWorld); + if (!world) return; + CaptureObject* object = world->getObject(displayObject); + if (!object) return; + + array^ row; + + // populate values + // NOTE: this has to match the order in the enum objectProperty + row = gcnew array { "ID", object->getID().ToString() }; + this->objectGridView->Rows->Add(row); + + row = gcnew array { "Name", gcnew String(object->getName().c_str()) }; + this->objectGridView->Rows->Add(row); + + String^ iden = (object->getRigidBody() < 0) ? "none" : object->getRigidBody().ToString(); + row = gcnew array { "Rigid Body ID", iden }; + this->objectGridView->Rows->Add(row); + + row = gcnew array { "Faces", object->getNumFaces().ToString() }; + this->objectGridView->Rows->Add(row); + + row = gcnew array { "Vertices", object->getNumVertices().ToString() }; + this->objectGridView->Rows->Add(row); + + // set certain rows to read only + this->objectGridView->Rows[(int)objectProperty::ID]->ReadOnly = true; + this->objectGridView->Rows[(int)objectProperty::FACES]->ReadOnly = true; + this->objectGridView->Rows[(int)objectProperty::VERTICES]->ReadOnly = true; + } + } + // extracts ID from text format "Name (##)" +private: int worldExtractID(String^ str) { + array^ split = str->Split(gcnew array {'(', ')'}); + + 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(); + } + // TODO: allow wider use case? + // this is only for editing coordinate frame of a world +private: System::Void worldGridView_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) { + if (e->RowIndex != (int)worldProperty::MATRIX || + e->ColumnIndex != 1 || // Value + displayWorld == 0) // default world, cannot change coordinates + return; + + DefineCoordinateFrameFormController ^control = DefineCoordinateFrameFormController::getInstance(); + control->createForm(); + control->setDisplayWorld(displayWorld); + control->Show(); + } + // 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 = AppData::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) + { + CaptureWorld* world = AppData::getInstance()->getWorld(displayObjectWorld); + if (world) + { + 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() + ); + object->setName(*str); + int idx = this->objectComboBox->SelectedIndex; + objectComboBox_updateList(); + this->objectComboBox->SelectedIndex = idx; + } + } + } + } +private: System::Void objectAddButton_Click(System::Object^ sender, System::EventArgs^ e) { + AddObjectFormController ^control = AddObjectFormController::getInstance(); + control->createForm(); + control->setDisplayWorld(displayObjectWorld); + control->Show(); + } +private: System::Void resetObjectGridView() { + if (this->objectGridView->InvokeRequired) + { + SetDelegate^ d = gcnew SetDelegate(this, &BlinkAnalysis::MainForm::resetObjectGridView); + BeginInvoke(d, nullptr); + } + else + { + this->objectGridView->Rows->Clear(); + displayObject = -1; + } + } +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; + } + } +private: System::Void objectGridView_CellDoubleClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) { + if (e->RowIndex != (int)objectProperty::RIGID || + e->ColumnIndex != 1) // Value + return; + + SetObjectRigidBodyFormController ^control = SetObjectRigidBodyFormController::getInstance(); + control->createForm(); + control->setRigidBodyVector(this->optiTrackRigidBodyVector); + control->setWorldAndObject(displayObjectWorld, displayObject); + int rb = String::Compare((String^)this->objectGridView->Rows[e->RowIndex]->Cells[e->ColumnIndex]->Value, "none"); + control->setHasRigidBody(rb != 0); + control->Show(); + } }; } diff --git a/BlinkAnalysis/MainForm.resX b/BlinkAnalysis/MainForm.resX index 1706531..95ebbd5 100644 --- a/BlinkAnalysis/MainForm.resX +++ b/BlinkAnalysis/MainForm.resX @@ -117,6 +117,45 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True diff --git a/BlinkAnalysis/MainFormController.h b/BlinkAnalysis/MainFormController.h index a4226e6..6d01cad 100644 --- a/BlinkAnalysis/MainFormController.h +++ b/BlinkAnalysis/MainFormController.h @@ -36,6 +36,9 @@ public ref class MainFormController sealed : // Initiate the OptiTrack view void optiTrackInitDataView() { this->form->optiTrackInitDataView(); } // Update world list - void worldUpdateData() { this->form->worldUpdateData(); } + void worldUpdateList() { this->form->worldUpdateList(); } + void worldUpdateGridView() { this->form->worldUpdateGridView(); } + void objectUpdateList() { this->form->objectComboBox_updateList(); } + void objectUpdateGridView() { this->form->objectUpdateGridView(); } }; diff --git a/BlinkAnalysis/SetObjectRigidBodyForm.cpp b/BlinkAnalysis/SetObjectRigidBodyForm.cpp new file mode 100644 index 0000000..4872d1a --- /dev/null +++ b/BlinkAnalysis/SetObjectRigidBodyForm.cpp @@ -0,0 +1,35 @@ +#include "StdAfx.h" +#include "SetObjectRigidBodyForm.h" +#include "MainFormController.h" + +using namespace BlinkAnalysis; + +System::Void SetObjectRigidBodyForm::attachButton_Click(System::Object^ sender, System::EventArgs^ e) { + if (rigidID >= 0) + { + CaptureWorld* world = AppData::getInstance()->getWorld(worldID); + if (world) + { + CaptureObject* object = world->getObject(objectID); + if (object) + { + object->setRigidBody(rigidID); + MainFormController::getInstance()->objectUpdateGridView(); + } + } + } + this->Close(); + } +System::Void SetObjectRigidBodyForm::detachButton_Click(System::Object^ sender, System::EventArgs^ e) { + CaptureWorld* world = AppData::getInstance()->getWorld(worldID); + if (world) + { + CaptureObject* object = world->getObject(objectID); + if (object) + { + object->setRigidBody(-1); + MainFormController::getInstance()->objectUpdateGridView(); + } + } + this->Close(); + } diff --git a/BlinkAnalysis/SetObjectRigidBodyForm.h b/BlinkAnalysis/SetObjectRigidBodyForm.h new file mode 100644 index 0000000..1828f00 --- /dev/null +++ b/BlinkAnalysis/SetObjectRigidBodyForm.h @@ -0,0 +1,238 @@ +#pragma once + +#include +#include "AppData.h" + +namespace BlinkAnalysis { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for SetObjectRigidBodyForm + /// + public ref class SetObjectRigidBodyForm : public System::Windows::Forms::Form + { + public: + SetObjectRigidBodyForm(void) + { + InitializeComponent(); + + rigidBodyVector = NULL; + rigidID = -1; + hasRB = false; + } + + void setRigidBodyVector(std::vector* vector) + { + rigidBodyVector = vector; + } + + void setWorldAndObject(int world, int object) + { + this->worldID = world; + this->objectID = object; + } + + void setHasRigidBody(bool rb) + { + hasRB = rb; + } + + + + protected: + /// + /// Clean up any resources being used. + /// + ~SetObjectRigidBodyForm() + { + if (components) + { + delete components; + } + } + + private: System::String^ defaultDataText; + private: std::vector* rigidBodyVector; + private: int rigidID; + private: int worldID; + private: int objectID; + private: bool hasRB; + + private: System::Windows::Forms::ListView^ rigidBodyListView; + + private: System::Windows::Forms::Label^ positionLabel; + private: System::Windows::Forms::Label^ rigidDataLabel; + private: System::Windows::Forms::Button^ attachButton; + private: System::Windows::Forms::Button^ detachButton; + + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->rigidBodyListView = (gcnew System::Windows::Forms::ListView()); + this->positionLabel = (gcnew System::Windows::Forms::Label()); + this->rigidDataLabel = (gcnew System::Windows::Forms::Label()); + this->attachButton = (gcnew System::Windows::Forms::Button()); + this->detachButton = (gcnew System::Windows::Forms::Button()); + this->SuspendLayout(); + // + // rigidBodyListView + // + this->rigidBodyListView->Alignment = System::Windows::Forms::ListViewAlignment::Left; + this->rigidBodyListView->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); + this->rigidBodyListView->FullRowSelect = true; + this->rigidBodyListView->LabelWrap = false; + this->rigidBodyListView->Location = System::Drawing::Point(12, 12); + this->rigidBodyListView->MultiSelect = false; + this->rigidBodyListView->Name = L"rigidBodyListView"; + this->rigidBodyListView->Size = System::Drawing::Size(261, 268); + this->rigidBodyListView->TabIndex = 2; + this->rigidBodyListView->TileSize = System::Drawing::Size(100, 20); + this->rigidBodyListView->UseCompatibleStateImageBehavior = false; + this->rigidBodyListView->View = System::Windows::Forms::View::SmallIcon; + this->rigidBodyListView->SelectedIndexChanged += gcnew System::EventHandler(this, &SetObjectRigidBodyForm::rigidBodyListView_SelectedIndexChanged); + // + // positionLabel + // + this->positionLabel->AutoSize = true; + this->positionLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->positionLabel->Location = System::Drawing::Point(12, 283); + this->positionLabel->Name = L"positionLabel"; + this->positionLabel->Size = System::Drawing::Size(51, 15); + this->positionLabel->TabIndex = 3; + this->positionLabel->Text = L"Position"; + // + // rigidDataLabel + // + this->rigidDataLabel->AutoSize = true; + this->rigidDataLabel->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->rigidDataLabel->Location = System::Drawing::Point(42, 310); + this->rigidDataLabel->Name = L"rigidDataLabel"; + this->rigidDataLabel->Size = System::Drawing::Size(84, 15); + this->rigidDataLabel->TabIndex = 4; + this->rigidDataLabel->Text = L"No data found"; + // + // attachButton + // + this->attachButton->Enabled = false; + this->attachButton->Location = System::Drawing::Point(186, 344); + this->attachButton->Name = L"attachButton"; + this->attachButton->Size = System::Drawing::Size(87, 23); + this->attachButton->TabIndex = 5; + this->attachButton->Text = L"Attach Object"; + this->attachButton->UseVisualStyleBackColor = true; + this->attachButton->Click += gcnew System::EventHandler(this, &SetObjectRigidBodyForm::attachButton_Click); + // + // detachButton + // + this->detachButton->Location = System::Drawing::Point(12, 344); + this->detachButton->Name = L"detachButton"; + this->detachButton->Size = System::Drawing::Size(88, 23); + this->detachButton->TabIndex = 6; + this->detachButton->Text = L"Detach Object"; + this->detachButton->UseVisualStyleBackColor = true; + this->detachButton->Visible = false; + this->detachButton->Click += gcnew System::EventHandler(this, &SetObjectRigidBodyForm::detachButton_Click); + // + // SetObjectRigidBodyForm + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(285, 379); + this->Controls->Add(this->detachButton); + this->Controls->Add(this->attachButton); + this->Controls->Add(this->rigidDataLabel); + this->Controls->Add(this->positionLabel); + this->Controls->Add(this->rigidBodyListView); + this->Name = L"SetObjectRigidBodyForm"; + this->Text = L"Attach Object to Rigid Body"; + this->Load += gcnew System::EventHandler(this, &SetObjectRigidBodyForm::SetObjectRigidBodyForm_Load); + this->ResumeLayout(false); + this->PerformLayout(); + + } +#pragma endregion +private: System::Void coordinate_setDefaultText(Label^ text) { + text->Text = defaultDataText; + } +private: System::Void coordinate_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; + } + +private: System::Void loadRigidBodyList() { + if (!rigidBodyVector) return; + + this->rigidBodyListView->Items->Clear(); + + for (std::vector::iterator itr = rigidBodyVector->begin(); + itr != rigidBodyVector->end(); itr++) + { + RigidBody* body = *itr; + String^ rigidBodyID = Convert::ToString(body->getID()); + String^ rigidBodyName = gcnew String(body->getName()); + ListViewItem^ listViewItem = gcnew ListViewItem(rigidBodyID); + listViewItem->SubItems->Add(rigidBodyName); + this->rigidBodyListView->Items->Add(listViewItem); + } + } +private: System::Void SetObjectRigidBodyForm_Load(System::Object^ sender, System::EventArgs^ e) { + this->defaultDataText = L"No data found"; + + this->rigidBodyListView->View = View::Details; + this->rigidBodyListView->Columns->Add("Id", 50, HorizontalAlignment::Left ); + this->rigidBodyListView->Columns->Add("Name", 150, HorizontalAlignment::Left ); + + loadRigidBodyList(); + + if (hasRB) + this->detachButton->Visible = true; + } +private: System::Void rigidBodyListView_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { + if (this->rigidBodyListView->SelectedItems->Count <= 0) + return; + + ListViewItem^ item = this->rigidBodyListView->SelectedItems->default[0]; + if (item && Int32::TryParse(item->Text, rigidID)) + { + this->attachButton->Enabled = true; + ClientHandler* client = AppData::getInstance()->getClient(); + if (client) + { + RigidBody* body = client->getRigidBody(rigidID); + if (body) + { + coordinate_setPoint(&(body->getPosition()), this->rigidDataLabel); + return; + } + } + } + coordinate_setDefaultText(this->rigidDataLabel); + } +private: System::Void attachButton_Click(System::Object^ sender, System::EventArgs^ e); +private: System::Void detachButton_Click(System::Object^ sender, System::EventArgs^ e); +}; +} diff --git a/BlinkAnalysis/SetObjectRigidBodyForm.resx b/BlinkAnalysis/SetObjectRigidBodyForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BlinkAnalysis/SetObjectRigidBodyForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BlinkAnalysis/SetObjectRigidBodyFormController.h b/BlinkAnalysis/SetObjectRigidBodyFormController.h new file mode 100644 index 0000000..58590fb --- /dev/null +++ b/BlinkAnalysis/SetObjectRigidBodyFormController.h @@ -0,0 +1,33 @@ +#pragma once +#include "stdafx.h" +#include + +#include "SetObjectRigidBodyForm.h" +#include "FormController.h" + +using namespace System; + +public ref class SetObjectRigidBodyFormController sealed : + public FormController +{ +public: + + void setRigidBodyVector(std::vector* vector) + { + if (form && !form->IsDisposed) + form->setRigidBodyVector(vector); + } + + void setWorldAndObject(int world, int object) + { + if (form && !form->IsDisposed) + form->setWorldAndObject(world, object); + } + + void setHasRigidBody(bool rb) + { + if (form && !form->IsDisposed) + form->setHasRigidBody(rb); + } +}; +