@@ -19,7 +19,7 @@ namespace
1919 float maxHeight = std::numeric_limits<float >::min ();
2020 for (int i = 0 ; i < cellRenderObjects.size (); i++)
2121 {
22- CellMorphology::Extent extent = cellRenderObjects[i]->morphologyObject .ComputeExtents () ;
22+ CellMorphology::Extent extent = cellRenderObjects[i]->morphologyObject .totalExtent ;
2323 mv::Vector3f dimensions = extent.emax - extent.emin ;
2424
2525 if (dimensions.y > maxHeight)
@@ -56,11 +56,8 @@ void EMRenderer::resize(int w, int h)
5656 float aspectRatio = (float )w / h;
5757 qDebug () << " Resize called" ;
5858 _projMatrix.setToIdentity ();
59- // _projMatrix.ortho(0, aspectRatio, 0, 1, -1, 1);
60-
6159 _projMatrix.ortho (0 , aspectRatio, 0 , 1 , 1 , -1 );
6260
63- vx = 0 ; vy = 0 ; vw = w; vh = h;
6461 _fullViewport.Set (0 , 0 , w, h);
6562
6663 int quarter = h / 4 ;
@@ -105,7 +102,7 @@ void EMRenderer::update(float t)
105102 _morphologyViewport.Begin ();
106103 _projMatrix.setToIdentity ();
107104 _projMatrix.ortho (0 , _morphologyViewport.GetAspectRatio (), 0 , 1 , -1 , 1 );
108- qDebug () << " Aspect ratio: " << _morphologyViewport. GetAspectRatio ();
105+
109106 _lineShader.uniformMatrix4f (" projMatrix" , _projMatrix.constData ());
110107
111108 float xOffset = 0 ;
@@ -114,12 +111,17 @@ void EMRenderer::update(float t)
114111 // if (cortical)
115112 // yToUnit = MapYRangeToUnit(-_scene.getCortexStructure().getMaxDepth(), -_scene.getCortexStructure().getMinDepth());
116113
114+ std::vector<CellMorphology::Type> ignoredTypes;
115+ if (!_showAxons)
116+ ignoredTypes.push_back (CellMorphology::Type::Axon);
117+
117118 // qDebug() << "Rendering " << cellRenderObjects.size() << " objects.";
118119 for (int i = 0 ; i < cellRenderObjects.size (); i++)
119120 {
120121 CellRenderObject* cro = cellRenderObjects[i];
121122
122- CellMorphology::Extent extent = cro->morphologyObject .ComputeExtents ();
123+ cro->morphologyObject .ComputeExtents (ignoredTypes);
124+ const CellMorphology::Extent& extent = cro->morphologyObject .totalExtent ;
123125
124126 mv::Vector3f dimensions = extent.emax - extent.emin ;
125127
@@ -150,6 +152,8 @@ void EMRenderer::update(float t)
150152 for (auto it = cro->morphologyObject .processes .begin (); it != cro->morphologyObject .processes .end (); ++it)
151153 {
152154 CellMorphology::Type type = it.key ();
155+ if (type == CellMorphology::Type::Axon && !_showAxons)
156+ continue ;
153157 MorphologyProcessRenderObject mpro = it.value ();
154158 _lineShader.uniform1i (" type" , (int )type);
155159 glBindVertexArray (mpro.vao );
@@ -179,7 +183,7 @@ void EMRenderer::update(float t)
179183 {
180184 CellRenderObject* cro = cellRenderObjects[i];
181185
182- CellMorphology::Extent extent = cro->morphologyObject .ComputeExtents () ;
186+ const CellMorphology::Extent& extent = cro->morphologyObject .totalExtent ;
183187 mv::Vector3f dimensions = extent.emax - extent.emin ;
184188 float maxWidth = sqrtf (powf (dimensions.x , 2 ) + powf (dimensions.z , 2 )) * 1 .5f ;
185189
@@ -246,6 +250,8 @@ void EMRenderer::showAxons(bool enabled)
246250 _showAxons = enabled;
247251
248252 // RebuildMorphologies();
253+
254+ RequestNewWidgetWidth ();
249255}
250256
251257void EMRenderer::setCurrentStimset (const QString& stimSet)
@@ -262,20 +268,9 @@ void EMRenderer::SetCortical(bool isCortical)
262268
263269void EMRenderer::SetSelectedCellIds (const std::vector<Cell>& cells)
264270{
265- std::vector<QString> cellIds;
266-
267271 // Build list of selected cell render object references
268272 std::vector<CellRenderObject*> cellRenderObjects;
269- for (const Cell& cell : cells)
270- {
271- cellIds.push_back (cell.cellId );
272- auto it = _renderState._cellRenderObjects .find (cell.cellId );
273-
274- if (it != _renderState._cellRenderObjects .end ())
275- cellRenderObjects.push_back (&(*it));
276- else
277- qDebug () << " [EMRenderer] This should never happen, but cellId wasn't found in _cellRenderObjects" ;
278- }
273+ BuildListOfCellRenderObjects (cells, cellRenderObjects);
279274
280275 _renderState._selectedCells = cells;
281276
@@ -313,13 +308,45 @@ void EMRenderer::SetSelectedCellIds(const std::vector<Cell>& cells)
313308 }
314309 }
315310
311+ RequestNewWidgetWidth ();
312+ }
313+
314+ void EMRenderer::BuildRenderObjects (const std::vector<Cell>& cells)
315+ {
316+ _renderObjectBuilder.BuildCellRenderObjects (cells);
317+ }
318+
319+ void EMRenderer::BuildListOfCellRenderObjects (const std::vector<Cell>& cells, std::vector<CellRenderObject*>& cellRenderObjects)
320+ {
321+ // Build list of selected cell render object references
322+ for (const Cell& cell : cells)
323+ {
324+ auto it = _renderState._cellRenderObjects .find (cell.cellId );
325+
326+ if (it != _renderState._cellRenderObjects .end ())
327+ cellRenderObjects.push_back (&(*it));
328+ else
329+ qDebug () << " [EMRenderer] This should never happen, but cellId wasn't found in _cellRenderObjects" ;
330+ }
331+ }
332+
333+ void EMRenderer::RequestNewWidgetWidth ()
334+ {
335+ std::vector<CellRenderObject*> cellRenderObjects;
336+ BuildListOfCellRenderObjects (_renderState._selectedCells , cellRenderObjects);
337+
338+ std::vector<CellMorphology::Type> ignoredTypes;
339+ if (!_showAxons)
340+ ignoredTypes.push_back (CellMorphology::Type::Axon);
341+
316342 // Compute new widget width
317343 float newWidgetWidthToRequest = 0 ;
318344 for (int i = 0 ; i < cellRenderObjects.size (); i++)
319345 {
320- CellMorphology::Extent extent = cellRenderObjects[i]->morphologyObject .ComputeExtents ();
346+ cellRenderObjects[i]->morphologyObject .ComputeExtents (ignoredTypes);
347+ CellMorphology::Extent extent = cellRenderObjects[i]->morphologyObject .totalExtent ;
321348 mv::Vector3f dimensions = extent.emax - extent.emin ;
322-
349+
323350 newWidgetWidthToRequest += sqrtf (powf (dimensions.x , 2 ) + powf (dimensions.z , 2 )) * 1 .2f ;
324351 }
325352
@@ -330,8 +357,3 @@ void EMRenderer::SetSelectedCellIds(const std::vector<Cell>& cells)
330357
331358 emit requestNewAspectRatio (aspectRatioRequest);
332359}
333-
334- void EMRenderer::BuildRenderObjects (const std::vector<Cell>& cells)
335- {
336- _renderObjectBuilder.BuildCellRenderObjects (cells);
337- }
0 commit comments