Skip to content

Commit e9dbb8f

Browse files
committed
Fix selection in Qt viewer example
1 parent 40bf694 commit e9dbb8f

File tree

5 files changed

+74
-10
lines changed

5 files changed

+74
-10
lines changed

IfcPlusPlus/src/ifcpp/geometry/Carve/Sweeper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
2020
#include <array>
2121
#include <ifcpp/model/BasicTypes.h>
2222
#include <ifcpp/model/StatusCallback.h>
23-
#include "earcut.hpp/include/mapbox/earcut.hpp"
23+
#include <earcut.hpp/include/mapbox/earcut.hpp>
2424

2525
#include "IncludeCarveHeaders.h"
2626
#include "GeometryInputData.h"

examples/SimpleViewerExampleQt/SimpleViewerExampleQt.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
<OutDir>bin\</OutDir>
8585
<IntDir>bin\$(Configuration)\</IntDir>
8686
<LinkIncremental>false</LinkIncremental>
87+
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
88+
<CopyLocalProjectReference>true</CopyLocalProjectReference>
89+
<CopyLocalDebugSymbols>true</CopyLocalDebugSymbols>
90+
<CopyCppRuntimeToOutputDir>true</CopyCppRuntimeToOutputDir>
8791
</PropertyGroup>
8892
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8993
<ClCompile>

examples/SimpleViewerExampleQt/src/IfcPlusPlusSystem.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ void IfcPlusPlusSystem::setObjectSelected( shared_ptr<BuildingEntity> ifc_object
239239
selected_entity->m_material_previous = material_previous;
240240
}
241241

242-
stateset->setAttribute( m_material_selected, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
242+
//stateset->setAttribute( m_material_selected, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
243+
244+
osg::ref_ptr<osg::StateSet> statesetSelected = new osg::StateSet();
245+
statesetSelected->setAttribute(m_material_selected, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
246+
grp->setStateSet(statesetSelected);
243247
selected_entity->m_material_selected = m_material_selected;
244248
}
245249

examples/SimpleViewerExampleQt/src/gui/IfcTreeWidget.cpp

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
1818
#include <ifcpp/model/BasicTypes.h>
1919
#include <ifcpp/model/BuildingObject.h>
2020
#include <ifcpp/model/BuildingModel.h>
21-
#include <ifcpp/IFC4/include/IfcObjectDefinition.h>
22-
#include <ifcpp/IFC4/include/IfcSpatialStructureElement.h>
23-
#include <ifcpp/IFC4/include/IfcRelContainedInSpatialStructure.h>
24-
#include <ifcpp/IFC4/include/IfcRelAggregates.h>
2521
#include <ifcpp/IFC4/include/IfcAxis2Placement.h>
2622
#include <ifcpp/IFC4/include/IfcAxis2Placement3D.h>
27-
#include <ifcpp/IFC4/include/IfcGeometricRepresentationContext.h>
2823
#include <ifcpp/IFC4/include/IfcDirection.h>
29-
#include <ifcpp/IFC4/include/IfcProject.h>
24+
#include <ifcpp/IFC4/include/IfcGeometricRepresentationContext.h>
3025
#include <ifcpp/IFC4/include/IfcLabel.h>
26+
#include <ifcpp/IFC4/include/IfcObjectDefinition.h>
27+
#include <ifcpp/IFC4/include/IfcProject.h>
28+
#include <ifcpp/IFC4/include/IfcRelAggregates.h>
29+
#include <ifcpp/IFC4/include/IfcRelContainedInSpatialStructure.h>
30+
#include <ifcpp/IFC4/include/IfcSpatialStructureElement.h>
31+
#include <ifcpp/IFC4/include/IfcTypeProduct.h>
3132

3233
#include "IncludeGeometryHeaders.h"
3334
#include "IfcPlusPlusSystem.h"
@@ -196,6 +197,55 @@ void IfcTreeWidget::slotModelLoadingStart()
196197
slotModelCleared();
197198
}
198199

200+
bool hasParentInBuildingStructure(shared_ptr<BuildingObject> obj)
201+
{
202+
shared_ptr<IfcObjectDefinition> obj_def = dynamic_pointer_cast<IfcObjectDefinition>(obj);
203+
if (!obj_def)
204+
{
205+
return true;
206+
}
207+
208+
shared_ptr<IfcTypeProduct> typeProduct = dynamic_pointer_cast<IfcTypeProduct>(obj);
209+
if (typeProduct)
210+
{
211+
return true;
212+
}
213+
214+
if (obj_def->m_Decomposes_inverse.size() > 0)
215+
{
216+
return true;
217+
}
218+
219+
shared_ptr<IfcSpatialStructureElement> spatial_ele = dynamic_pointer_cast<IfcSpatialStructureElement>(obj_def);
220+
if (spatial_ele)
221+
{
222+
std::vector<weak_ptr<IfcRelContainedInSpatialStructure> >& vec_contained = spatial_ele->m_ContainsElements_inverse;
223+
if (vec_contained.size() > 0)
224+
{
225+
226+
for (auto it_rel_contained = vec_contained.begin(); it_rel_contained!=vec_contained.end(); ++it_rel_contained)
227+
{
228+
shared_ptr<IfcRelContainedInSpatialStructure> rel_contained(*it_rel_contained);
229+
230+
//std::vector<shared_ptr<IfcProduct> > m_RelatedElements;
231+
//shared_ptr<IfcSpatialElement> m_RelatingStructure;
232+
233+
std::vector<shared_ptr<IfcProduct> >& vec_related_elements = rel_contained->m_RelatedElements;
234+
235+
if (rel_contained->m_RelatingStructure == spatial_ele)
236+
{
237+
if (vec_related_elements.size() > 0)
238+
{
239+
return true;
240+
}
241+
}
242+
}
243+
}
244+
}
245+
246+
return false;
247+
}
248+
199249
QTreeWidgetItem* resolveTreeItems( shared_ptr<BuildingObject> obj, std::unordered_set<int>& set_visited )
200250
{
201251
QTreeWidgetItem* item = nullptr;
@@ -229,8 +279,7 @@ QTreeWidgetItem* resolveTreeItems( shared_ptr<BuildingObject> obj, std::unordere
229279
if( obj_def->m_IsDecomposedBy_inverse.size() > 0 )
230280
{
231281
std::vector<weak_ptr<IfcRelAggregates> >& vec_IsDecomposedBy = obj_def->m_IsDecomposedBy_inverse;
232-
std::vector<weak_ptr<IfcRelAggregates> >::iterator it;
233-
for( it=vec_IsDecomposedBy.begin(); it!=vec_IsDecomposedBy.end(); ++it )
282+
for( auto it=vec_IsDecomposedBy.begin(); it!=vec_IsDecomposedBy.end(); ++it )
234283
{
235284
shared_ptr<IfcRelAggregates> rel_agg( *it );
236285
std::vector<shared_ptr<IfcObjectDefinition> >& vec = rel_agg->m_RelatedObjects;
@@ -307,6 +356,12 @@ void IfcTreeWidget::slotModelLoadingDone()
307356
for( auto it = map_outside.begin(); it != map_outside.end(); ++it )
308357
{
309358
shared_ptr<BuildingObject>& ifc_object = it->second;
359+
360+
if (hasParentInBuildingStructure(ifc_object))
361+
{
362+
continue;
363+
}
364+
310365
QTreeWidgetItem* object_item = resolveTreeItems( ifc_object, set_visited );
311366
if( object_item != NULL )
312367
{

examples/SimpleViewerExampleQt/src/viewer/OrbitCameraManipulator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ bool OrbitCameraManipulator::intersectSceneSelect( const osgGA::GUIEventAdapter&
527527
m_system->clearSelection();
528528
}
529529
m_system->setObjectSelected(entitiy_selected, true, group);
530+
break;
530531
}
531532
}
532533
return true;

0 commit comments

Comments
 (0)