@@ -9,13 +9,13 @@ namespace
99
1010MEWidget::MEWidget () :
1111 _scene(Scene::getInstance()),
12- _emRenderer (),
12+ _meRenderer (),
1313 _layerDrawing(this ),
1414 _width(1 ),
1515 _height(1 ),
1616 _isCortical(false )
1717{
18- connect (&_emRenderer , &EMRenderer::requestNewAspectRatio , this , &MEWidget::onNewAspectRatioRequested);
18+ connect (&_meRenderer , &MERenderer::RequestNewAspectRatio , this , &MEWidget::onNewAspectRatioRequested);
1919
2020 // setMinimumSize(10, 10);
2121 setSizePolicy (QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding);
@@ -32,36 +32,30 @@ void MEWidget::setCells(const std::vector<Cell>& cells)
3232 return ;
3333
3434 makeCurrent ();
35- _emRenderer .BuildRenderObjects (cells);
35+ _meRenderer .BuildRenderObjects (cells);
3636}
3737
3838void MEWidget::setSelectedCells (const std::vector<uint32_t >& indices)
3939{
40- // if (!isWidgetInitialized()) // Shouldn't be necessary
41- // return;
42-
43- // _cells = cells;
44-
4540 _scene.selectedCells .clear ();
4641 for (uint32_t cellIndex : indices)
4742 {
4843 _scene.selectedCells .push_back (_scene.allCells [cellIndex]);
4944 }
5045
51- // makeCurrent(); // Shouldn't be necessary
52- _emRenderer.SetSelectedCellIds (indices);
46+ _meRenderer.SetSelectedCellIds (indices);
5347}
5448
5549void MEWidget::SetCortical (bool isCortical)
5650{
5751 _isCortical = isCortical;
5852
59- _emRenderer .SetCortical (isCortical);
53+ _meRenderer .SetCortical (isCortical);
6054}
6155
6256void MEWidget::onWidgetInitialized ()
6357{
64- _emRenderer. init ();
58+ _meRenderer. Init ();
6559
6660 // Start 40 fps render timer
6761 QTimer* updateTimer = new QTimer ();
@@ -72,7 +66,7 @@ void MEWidget::onWidgetInitialized()
7266void MEWidget::onWidgetResized (int w, int h)
7367{
7468 _width = w; _height = h;
75- _emRenderer. resize (w, h, devicePixelRatioF ());
69+ _meRenderer. Resize (w, h, devicePixelRatioF ());
7670}
7771
7872void MEWidget::onWidgetRendered ()
@@ -93,30 +87,14 @@ void MEWidget::onWidgetRendered()
9387
9488 _layerDrawing.setDepthRange (scene.getCortexStructure ().getMinDepth (), scene.getCortexStructure ().getMaxDepth ());
9589 _layerDrawing.drawAxes (painter, _isCortical);
90+ // _layerDrawing.drawSeparations(painter, _isCortical);
9691
9792 painter.beginNativePainting ();
98- _emRenderer. update (t );
93+ _meRenderer. Update (t, painter );
9994 painter.endNativePainting ();
10095
101- std::vector<float > horizontalCellLocations = _emRenderer.GetHorizontalCellLocations ();
102- for (int i = 0 ; i < horizontalCellLocations.size (); i++)
103- {
104- int xCoord = horizontalCellLocations[i] / devicePixelRatioF ();
105- int yCoord = 16 ;
106-
107- QFontMetrics fm (painter.font ());
108- int textWidth = fm.horizontalAdvance (_scene.selectedCells [i].cluster );
109- int textHeight = fm.height ();
110-
111- // Calculate top-left corner to draw the text so that it is centered
112- int x = xCoord - textWidth / 2 ;
113- int y = yCoord + fm.ascent () - textHeight / 2 ;
114-
115- const QRect boundingRect = QRect (xCoord - 50 , yCoord - 12 , 100 , 28 );
116- painter.drawText (boundingRect, Qt::AlignCenter | Qt::AlignTop | Qt::TextWordWrap, _scene.selectedCells [i].cluster );
117-
118- // painter.drawText(x, y, _scene.selectedCells[i].cluster);
119- }
96+ _meRenderer.RenderLabels (painter);
97+ _meRenderer.RenderSeparations (painter);
12098
12199 painter.end ();
122100}
@@ -132,7 +110,7 @@ void MEWidget::mousePressEvent(QMouseEvent* event)
132110 QPoint localPos = event->pos (); // position inside the widget
133111 QPoint globalPos = mapToGlobal (localPos);
134112
135- std::vector<float > cellLocations = _emRenderer .GetHorizontalCellLocations ();
113+ std::vector<float > cellLocations = _meRenderer .GetHorizontalCellLocations ();
136114 Cell* cell = nullptr ;
137115 float closestDist = std::numeric_limits<float >::max ();
138116 for (int i = 0 ; i < cellLocations.size (); i++)
0 commit comments