Made parts deselectable

This commit is contained in:
andreja6
2018-10-23 15:15:08 -07:00
parent 8909ded488
commit 421498e1fe
3 changed files with 20 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
_propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID); _propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID);
PROPGRIDITEM pItem; /*PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem); PropGrid_ItemInit(pItem);
pItem.lpszCatalog="Test"; pItem.lpszCatalog="Test";
@@ -109,8 +109,8 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
PropGrid_Enable(_propGrid,true); PropGrid_Enable(_propGrid,true);
ShowWindow(_propGrid,SW_SHOW); ShowWindow(_propGrid,SW_SHOW);
PropGrid_AddItem(_propGrid,&pItem); // PropGrid_AddItem(_propGrid,&pItem);
PropGrid_AddItem(_propGrid,&pItem2); // PropGrid_AddItem(_propGrid,&pItem2);
PropGrid_SetItemHeight(_propGrid,20); PropGrid_SetItemHeight(_propGrid,20);
PropGrid_ShowToolTips(_propGrid,TRUE); PropGrid_ShowToolTips(_propGrid,TRUE);
PropGrid_ShowPropertyDescriptions(_propGrid,TRUE); PropGrid_ShowPropertyDescriptions(_propGrid,TRUE);
@@ -155,3 +155,8 @@ void PropertyWindow::SetProperties(Instance * instance)
SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this); SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
_redraw(); _redraw();
} }
void PropertyWindow::ClearProperties()
{
PropGrid_ResetContent(_propGrid);
}

View File

@@ -5,6 +5,7 @@ public:
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance); PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);
bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance); bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance);
void SetProperties(Instance *); void SetProperties(Instance *);
void ClearProperties();
void onResize(); void onResize();
HWND _hwndProp; HWND _hwndProp;

View File

@@ -1262,13 +1262,16 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
float nearest=std::numeric_limits<float>::infinity(); float nearest=std::numeric_limits<float>::infinity();
Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation; Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation;
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren(); std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
for(size_t i = 0; i < instances.size(); i++) bool objFound = false;
for(size_t i = 0; i < instances.size(); i++)
{ {
if(PhysicalInstance* test = dynamic_cast<PhysicalInstance*>(instances.at(i))) if(PhysicalInstance* test = dynamic_cast<PhysicalInstance*>(instances.at(i)))
{ {
float time = testRay.intersectionTime(test->getBox()); float time = testRay.intersectionTime(test->getBox());
if (time != inf()) if (time != inf())
{ {
objFound = true;
if (nearest>time) if (nearest>time)
{ {
nearest=time; nearest=time;
@@ -1297,6 +1300,12 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
} }
} }
} }
if(!objFound)
{
while(selectedInstances.size() > 0)
selectedInstances.erase(selectedInstances.begin());
_propWindow->ClearProperties();
}
} }
} }
void Demo::onMouseLeftUp(int x,int y) void Demo::onMouseLeftUp(int x,int y)