src/glRenderer.cpp

changeset 1099
14276e435640
parent 1098
0b837bed121d
child 1100
9b2797729c82
equal deleted inserted replaced
1098:0b837bed121d 1099:14276e435640
175 void GLRenderer::setDrawOnly (bool value) 175 void GLRenderer::setDrawOnly (bool value)
176 { 176 {
177 m_isDrawOnly = value; 177 m_isDrawOnly = value;
178 } 178 }
179 179
180 Model* GLRenderer::model() const
181 {
182 return m_model;
183 }
184
185 GLCompiler* GLRenderer::compiler() const 180 GLCompiler* GLRenderer::compiler() const
186 { 181 {
187 return m_compiler; 182 return m_compiler;
188 } 183 }
189 184
1237 // ============================================================================= 1232 // =============================================================================
1238 // 1233 //
1239 void GLRenderer::zoomToFit() 1234 void GLRenderer::zoomToFit()
1240 { 1235 {
1241 zoom() = 30.0f; 1236 zoom() = 30.0f;
1242
1243 if (model() == nullptr or m_width == -1 or m_height == -1)
1244 return;
1245
1246 bool lastfilled = false; 1237 bool lastfilled = false;
1247 bool firstrun = true; 1238 bool firstrun = true;
1248 enum { black = 0xFF000000 }; 1239 enum { black = 0xFF000000 };
1249 bool inward = true; 1240 bool inward = true;
1250 int runaway = 50; 1241 int runaway = 50;
1341 1332
1342 // ============================================================================= 1333 // =============================================================================
1343 // 1334 //
1344 LDOverlay* GLRenderer::findOverlayObject (Camera cam) 1335 LDOverlay* GLRenderer::findOverlayObject (Camera cam)
1345 { 1336 {
1346 for (LDObject* obj : model()->objects()) 1337 for (LDObject* obj : m_model->objects())
1347 { 1338 {
1348 LDOverlay* overlay = dynamic_cast<LDOverlay*> (obj); 1339 LDOverlay* overlay = dynamic_cast<LDOverlay*> (obj);
1349 1340
1350 if (overlay and overlay->camera() == cam) 1341 if (overlay and overlay->camera() == cam)
1351 return overlay; 1342 return overlay;
1401 { 1392 {
1402 // If this is the last overlay image, we need to remove the empty space after it as well. 1393 // If this is the last overlay image, we need to remove the empty space after it as well.
1403 LDObject* nextobj = overlayObject->next(); 1394 LDObject* nextobj = overlayObject->next();
1404 1395
1405 if (nextobj and nextobj->type() == OBJ_Empty) 1396 if (nextobj and nextobj->type() == OBJ_Empty)
1406 model()->remove(nextobj); 1397 m_model->remove(nextobj);
1407 1398
1408 // If the overlay object was there and the overlay itself is 1399 // If the overlay object was there and the overlay itself is
1409 // not, remove the object. 1400 // not, remove the object.
1410 model()->remove(overlayObject); 1401 m_model->remove(overlayObject);
1411 overlayObject = nullptr; 1402 overlayObject = nullptr;
1412 } 1403 }
1413 else if (meta.image and overlayObject == nullptr) 1404 else if (meta.image and overlayObject == nullptr)
1414 { 1405 {
1415 // Inverse case: image is there but the overlay object is 1406 // Inverse case: image is there but the overlay object is
1423 // there was no schemantic elements at all) 1414 // there was no schemantic elements at all)
1424 int i; 1415 int i;
1425 int lastOverlayPosition = -1; 1416 int lastOverlayPosition = -1;
1426 bool found = false; 1417 bool found = false;
1427 1418
1428 for (i = 0; i < model()->size(); ++i) 1419 for (i = 0; i < m_model->size(); ++i)
1429 { 1420 {
1430 LDObject* object = model()->getObject (i); 1421 LDObject* object = m_model->getObject (i);
1431 1422
1432 if (object->isScemantic()) 1423 if (object->isScemantic())
1433 { 1424 {
1434 found = true; 1425 found = true;
1435 break; 1426 break;
1439 lastOverlayPosition = i; 1430 lastOverlayPosition = i;
1440 } 1431 }
1441 1432
1442 if (lastOverlayPosition != -1) 1433 if (lastOverlayPosition != -1)
1443 { 1434 {
1444 overlayObject = model()->emplaceAt<LDOverlay>(lastOverlayPosition + 1); 1435 overlayObject = m_model->emplaceAt<LDOverlay>(lastOverlayPosition + 1);
1445 } 1436 }
1446 else 1437 else
1447 { 1438 {
1448 overlayObject = model()->emplaceAt<LDOverlay>(i); 1439 overlayObject = m_model->emplaceAt<LDOverlay>(i);
1449 1440
1450 if (found) 1441 if (found)
1451 model()->emplaceAt<LDEmpty>(i + 1); 1442 m_model->emplaceAt<LDEmpty>(i + 1);
1452 } 1443 }
1453 } 1444 }
1454 1445
1455 if (meta.image and overlayObject) 1446 if (meta.image and overlayObject)
1456 { 1447 {

mercurial