Fix Vector3 Property, enum work
This commit is contained in:
@@ -266,6 +266,10 @@
|
|||||||
RelativePath=".\src\source\CameraController.cpp"
|
RelativePath=".\src\source\CameraController.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\PropertiesV2\Color3Property.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\ErrorFunctions.cpp"
|
RelativePath=".\src\source\ErrorFunctions.cpp"
|
||||||
>
|
>
|
||||||
@@ -310,6 +314,10 @@
|
|||||||
RelativePath=".\src\source\TextureHandler.cpp"
|
RelativePath=".\src\source\TextureHandler.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\PropertiesV2\Vector3Property.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\WindowFunctions.cpp"
|
RelativePath=".\src\source\WindowFunctions.cpp"
|
||||||
>
|
>
|
||||||
@@ -715,6 +723,10 @@
|
|||||||
RelativePath=".\src\include\ax.h"
|
RelativePath=".\src\include\ax.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\Enum\B3DEnum.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\BrowserCallHandler.h"
|
RelativePath=".\src\include\BrowserCallHandler.h"
|
||||||
>
|
>
|
||||||
@@ -723,6 +735,10 @@
|
|||||||
RelativePath=".\src\include\CameraController.h"
|
RelativePath=".\src\include\CameraController.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\PropertiesV2\Color3Property.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\Enum.h"
|
RelativePath=".\src\include\Enum.h"
|
||||||
>
|
>
|
||||||
@@ -779,6 +795,10 @@
|
|||||||
RelativePath=".\src\include\ToolEnum.h"
|
RelativePath=".\src\include\ToolEnum.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\PropertiesV2\Vector3Property.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\versioning.h"
|
RelativePath=".\src\include\versioning.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <G3DAll.h>
|
#include <G3DAll.h>
|
||||||
#include "propertyGrid.h"
|
#include "propertyGrid.h"
|
||||||
#include "PropertiesV2/StringProperty.h"
|
#include "PropertiesV2/StringProperty.h"
|
||||||
|
#include "PropertiesV2/BoolProperty.h"
|
||||||
#include "map"
|
#include "map"
|
||||||
|
|
||||||
class Instance
|
class Instance
|
||||||
|
|||||||
@@ -13,10 +13,13 @@ public:
|
|||||||
virtual void postRender(RenderDevice* rd);
|
virtual void postRender(RenderDevice* rd);
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
virtual std::vector<Property*> collectProperties();
|
||||||
bool nameShown;
|
bool nameShown;
|
||||||
bool controllerFlagShown;
|
bool controllerFlagShown;
|
||||||
Enum::Controller::Value controller;
|
Enum::Controller::Value controller;
|
||||||
virtual void makeJoints();
|
virtual void makeJoints();
|
||||||
|
virtual void setNameShown(bool nameShown);
|
||||||
|
virtual void setControllerFlagShown(bool controllerFlagShown);
|
||||||
protected:
|
protected:
|
||||||
CoordinateFrame cFrame;
|
CoordinateFrame cFrame;
|
||||||
static G3D::Color3 getControllerColor(int controller)
|
static G3D::Color3 getControllerColor(int controller)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "PVInstance.h"
|
#include "PVInstance.h"
|
||||||
#include "Enum.h"
|
#include "Enum.h"
|
||||||
|
#include "PropertiesV2/Color3Property.h"
|
||||||
|
#include "PropertiesV2/Vector3Property.h"
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@@ -59,6 +61,7 @@ public:
|
|||||||
//Setters
|
//Setters
|
||||||
void setParent(Instance* parent);
|
void setParent(Instance* parent);
|
||||||
void setPosition(Vector3);
|
void setPosition(Vector3);
|
||||||
|
void setColor(Color3 color);
|
||||||
void setVelocity(Vector3);
|
void setVelocity(Vector3);
|
||||||
void setRotVelocity(Vector3);
|
void setRotVelocity(Vector3);
|
||||||
void setCFrame(CoordinateFrame);
|
void setCFrame(CoordinateFrame);
|
||||||
@@ -83,6 +86,7 @@ public:
|
|||||||
//Properties
|
//Properties
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
virtual std::vector<Property *> collectProperties();
|
||||||
private:
|
private:
|
||||||
bool anchored;
|
bool anchored;
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace Enum
|
namespace Enum
|
||||||
{
|
{
|
||||||
@@ -7,6 +9,30 @@ namespace Enum
|
|||||||
enum Value {
|
enum Value {
|
||||||
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5
|
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5
|
||||||
};
|
};
|
||||||
|
static std::pair<std::string, Value> map_data[] = {
|
||||||
|
std::make_pair("Smooth", Smooth),
|
||||||
|
std::make_pair("Bumps", Bumps),
|
||||||
|
std::make_pair("Hinge", Hinge),
|
||||||
|
std::make_pair("Motor", Motor),
|
||||||
|
std::make_pair("StepperMotor", StepperMotor),
|
||||||
|
std::make_pair("Spawn", Spawn)
|
||||||
|
};
|
||||||
|
static std::map<std::string, Value> nameMap(map_data,
|
||||||
|
map_data + sizeof map_data / sizeof map_data[0]);
|
||||||
|
|
||||||
|
static Value getByName(std::string name) {
|
||||||
|
if(nameMap.find(name) != nameMap.end()){
|
||||||
|
return nameMap[name];
|
||||||
|
}
|
||||||
|
return Smooth;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string getName(Value value) {
|
||||||
|
for (std::map<std::string, Value>::iterator it = nameMap.begin(); it != nameMap.end(); ++it)
|
||||||
|
if (it->second == value)
|
||||||
|
return it->first;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
namespace Shape
|
namespace Shape
|
||||||
{
|
{
|
||||||
|
|||||||
24
src/include/Enum/B3DEnum.h
Normal file
24
src/include/Enum/B3DEnum.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Enum
|
||||||
|
{
|
||||||
|
class B3DEnum {
|
||||||
|
public:
|
||||||
|
B3DEnum(int id, std::string name)
|
||||||
|
{
|
||||||
|
this->id = id;
|
||||||
|
this->name = name;
|
||||||
|
}
|
||||||
|
const int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
const std::string getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
virtual B3DEnum getByName(std::string name);
|
||||||
|
virtual B3DEnum getById(int id);
|
||||||
|
private:
|
||||||
|
int id;
|
||||||
|
std::string name;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/include/PropertiesV2/Color3Property.h
Normal file
24
src/include/PropertiesV2/Color3Property.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Property.h"
|
||||||
|
|
||||||
|
class Color3Property : public Property
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (Instance::*instanceSetter)(Color3);
|
||||||
|
~Color3Property(void){};
|
||||||
|
Color3Property(LPSTR name, LPSTR desc, LPSTR catalog, Color3 value, Instance * owner, instanceSetter setterFunc)
|
||||||
|
:Property(name, desc, catalog, &_value, owner)
|
||||||
|
{
|
||||||
|
this->_value = value;
|
||||||
|
this->setterFunc = setterFunc;
|
||||||
|
}
|
||||||
|
const void setValue(Color3 val){
|
||||||
|
(_owner->*setterFunc)(val);
|
||||||
|
_value = val;
|
||||||
|
}
|
||||||
|
PROPGRIDITEM getPropGridItem();
|
||||||
|
void setProperty(LPPROPGRIDITEM &pItem);
|
||||||
|
private:
|
||||||
|
Color3 _value;
|
||||||
|
instanceSetter setterFunc;
|
||||||
|
};
|
||||||
@@ -24,6 +24,9 @@ public:
|
|||||||
const void* getValue() {
|
const void* getValue() {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
const LPSTR getName() {
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
virtual PROPGRIDITEM getPropGridItem();
|
virtual PROPGRIDITEM getPropGridItem();
|
||||||
virtual void setProperty(LPPROPGRIDITEM &pItem);
|
virtual void setProperty(LPPROPGRIDITEM &pItem);
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
26
src/include/PropertiesV2/Vector3Property.h
Normal file
26
src/include/PropertiesV2/Vector3Property.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Property.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
class Vector3Property : public Property
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef void (Instance::*instanceSetter)(Vector3);
|
||||||
|
~Vector3Property(void){};
|
||||||
|
Vector3Property(LPSTR name, LPSTR desc, LPSTR catalog, Vector3 value, Instance * owner, instanceSetter setterFunc)
|
||||||
|
:Property(name, desc, catalog, &_value, owner)
|
||||||
|
{
|
||||||
|
this->_value = value;
|
||||||
|
this->setterFunc = setterFunc;
|
||||||
|
}
|
||||||
|
const void setValue(Vector3 val){
|
||||||
|
(_owner->*setterFunc)(val);
|
||||||
|
_value = val;
|
||||||
|
}
|
||||||
|
PROPGRIDITEM getPropGridItem();
|
||||||
|
void setProperty(LPPROPGRIDITEM &pItem);
|
||||||
|
private:
|
||||||
|
Vector3 _value;
|
||||||
|
std::string stringRep;
|
||||||
|
instanceSetter setterFunc;
|
||||||
|
};
|
||||||
@@ -15,4 +15,5 @@ private:
|
|||||||
HWND _explorerComboBox;
|
HWND _explorerComboBox;
|
||||||
void _resize();
|
void _resize();
|
||||||
void clearExplorer();
|
void clearExplorer();
|
||||||
|
void deleteProperties();
|
||||||
};
|
};
|
||||||
@@ -63,6 +63,33 @@ static Enum::Controller::Value strEnum(TCHAR * tval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<Property *> PVInstance::collectProperties()
|
||||||
|
{
|
||||||
|
std::vector<Property *> properties = Instance::collectProperties();
|
||||||
|
properties.push_back(new BoolProperty(
|
||||||
|
"NameShown",
|
||||||
|
"This chooses whether the item name is shown",
|
||||||
|
"Item",
|
||||||
|
nameShown,
|
||||||
|
this,
|
||||||
|
(BoolProperty::instanceSetter)&PVInstance::setNameShown));
|
||||||
|
properties.push_back(new BoolProperty(
|
||||||
|
"ControllerFlagShown",
|
||||||
|
"This chooses whether the item's ControllerFlag is shown",
|
||||||
|
"Item",
|
||||||
|
controllerFlagShown,
|
||||||
|
this,
|
||||||
|
(BoolProperty::instanceSetter)&PVInstance::setControllerFlagShown));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PVInstance::setNameShown(bool nameShown){
|
||||||
|
this->nameShown = nameShown;
|
||||||
|
}
|
||||||
|
void PVInstance::setControllerFlagShown(bool controllerFlagShown){
|
||||||
|
this->controllerFlagShown = controllerFlagShown;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -674,6 +674,49 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
|||||||
else PVInstance::PropUpdate(item);
|
else PVInstance::PropUpdate(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartInstance::setColor(Color3 color)
|
||||||
|
{
|
||||||
|
this->color = color;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Property *> PartInstance::collectProperties()
|
||||||
|
{
|
||||||
|
std::vector<Property *> properties = PVInstance::collectProperties();
|
||||||
|
properties.push_back(new Color3Property(
|
||||||
|
"Color3",
|
||||||
|
"The color of the selected part",
|
||||||
|
"Properties",
|
||||||
|
color,
|
||||||
|
this,
|
||||||
|
(Color3Property::instanceSetter)&PartInstance::setColor));
|
||||||
|
|
||||||
|
properties.push_back(new BoolProperty(
|
||||||
|
"Anchored",
|
||||||
|
"Whether the block can move or not",
|
||||||
|
"Item",
|
||||||
|
anchored,
|
||||||
|
this,
|
||||||
|
(BoolProperty::instanceSetter)&PartInstance::setAnchored));
|
||||||
|
|
||||||
|
properties.push_back(new Vector3Property(
|
||||||
|
"Offset",
|
||||||
|
"The position of the object in the workspace",
|
||||||
|
"Item",
|
||||||
|
position,
|
||||||
|
this,
|
||||||
|
(Vector3Property::instanceSetter)&PartInstance::setPosition));
|
||||||
|
|
||||||
|
properties.push_back(new Vector3Property(
|
||||||
|
"Size",
|
||||||
|
"The size of the object in the workspace",
|
||||||
|
"Item",
|
||||||
|
size,
|
||||||
|
this,
|
||||||
|
(Vector3Property::instanceSetter)&PartInstance::setSize));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
// This needs to be changed, buffer size of 12 is way too small
|
// This needs to be changed, buffer size of 12 is way too small
|
||||||
// Crash occurs if you put a huge number in
|
// Crash occurs if you put a huge number in
|
||||||
char changeTimerTxt[12];
|
char changeTimerTxt[12];
|
||||||
|
|||||||
21
src/source/PropertiesV2/Color3Property.cpp
Normal file
21
src/source/PropertiesV2/Color3Property.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "PropertiesV2/Color3Property.h"
|
||||||
|
|
||||||
|
PROPGRIDITEM Color3Property::getPropGridItem(){
|
||||||
|
PROPGRIDITEM pItem;
|
||||||
|
PropGrid_ItemInit(pItem);
|
||||||
|
pItem.lpszCatalog=_catalog;
|
||||||
|
pItem.lpszPropName=_name;
|
||||||
|
pItem.lpszPropDesc=_desc;
|
||||||
|
pItem.lpCurValue=RGB((_value.r*255),(_value.g*255),(_value.b*255));
|
||||||
|
pItem.iItemType=PIT_COLOR;
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Color3Property::setProperty(LPPROPGRIDITEM &pItem){
|
||||||
|
|
||||||
|
setValue(Color3(
|
||||||
|
GetRValue(pItem->lpCurValue)/255.0F,
|
||||||
|
GetGValue(pItem->lpCurValue)/255.0F,
|
||||||
|
GetBValue(pItem->lpCurValue)/255.0F
|
||||||
|
));
|
||||||
|
}
|
||||||
33
src/source/PropertiesV2/Vector3Property.cpp
Normal file
33
src/source/PropertiesV2/Vector3Property.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "PropertiesV2/Vector3Property.h"
|
||||||
|
|
||||||
|
PROPGRIDITEM Vector3Property::getPropGridItem(){
|
||||||
|
std::stringstream s;
|
||||||
|
s << _value.x << ", " << _value.y << ", " << _value.z;
|
||||||
|
stringRep = s.str();
|
||||||
|
PROPGRIDITEM pItem;
|
||||||
|
PropGrid_ItemInit(pItem);
|
||||||
|
pItem.lpszCatalog=_catalog;
|
||||||
|
pItem.lpszPropName=_name;
|
||||||
|
pItem.lpszPropDesc=_desc;
|
||||||
|
pItem.lpCurValue=(LPARAM)stringRep.c_str();
|
||||||
|
pItem.iItemType=PIT_EDIT;
|
||||||
|
return pItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vector3Property::setProperty(LPPROPGRIDITEM &pItem){
|
||||||
|
|
||||||
|
std::string str = (LPTSTR)pItem->lpCurValue;
|
||||||
|
std::vector<float> vect;
|
||||||
|
std::stringstream ss(str);
|
||||||
|
float i;
|
||||||
|
while (ss >> i)
|
||||||
|
{
|
||||||
|
vect.push_back(i);
|
||||||
|
if (ss.peek() == ',')
|
||||||
|
ss.ignore();
|
||||||
|
}
|
||||||
|
if(vect.size() == 3)
|
||||||
|
{
|
||||||
|
setValue(Vector3(vect.at(0),vect.at(1),vect.at(2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -186,8 +186,15 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
LPNMHDR pnm = (LPNMHDR)lParam;
|
LPNMHDR pnm = (LPNMHDR)lParam;
|
||||||
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
||||||
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
||||||
selectedInstance->PropUpdate(item);
|
for(size_t i = 0; i < prop.size(); i++)
|
||||||
//propWind->UpdateSelected(selectedInstance);
|
{
|
||||||
|
if(strcmp(item->lpszPropName, prop[i]->getName()) == 0)
|
||||||
|
{
|
||||||
|
prop[i]->setProperty(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//selectedInstance->PropUpdate(item);
|
||||||
|
propWind->UpdateSelected(g_dataModel->getSelectionService()->getSelection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -342,6 +349,7 @@ void PropertyWindow::_resize()
|
|||||||
|
|
||||||
void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
||||||
{
|
{
|
||||||
|
deleteProperties();
|
||||||
if(instances.size() <= 0)
|
if(instances.size() <= 0)
|
||||||
{
|
{
|
||||||
ClearProperties();
|
ClearProperties();
|
||||||
@@ -371,6 +379,16 @@ void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
|||||||
|
|
||||||
void PropertyWindow::ClearProperties()
|
void PropertyWindow::ClearProperties()
|
||||||
{
|
{
|
||||||
|
deleteProperties();
|
||||||
clearExplorer();
|
clearExplorer();
|
||||||
PropGrid_ResetContent(_propGrid);
|
PropGrid_ResetContent(_propGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyWindow::deleteProperties()
|
||||||
|
{
|
||||||
|
while(prop.size() > 0) {
|
||||||
|
Property * toDelete = prop.back();
|
||||||
|
prop.pop_back();
|
||||||
|
delete toDelete;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user