src/gldraw.cpp

changeset 522
afa691788bdb
parent 520
37d5da2f188e
child 526
b29b6fc45ba9
equal deleted inserted replaced
521:b85554206155 522:afa691788bdb
1161 // Use particularly thick lines while picking ease up selecting lines. 1161 // Use particularly thick lines while picking ease up selecting lines.
1162 glLineWidth (max<double> (gl_linethickness, 6.5f)); 1162 glLineWidth (max<double> (gl_linethickness, 6.5f));
1163 1163
1164 // Clear the selection if we do not wish to add to it. 1164 // Clear the selection if we do not wish to add to it.
1165 if (!m_addpick) 1165 if (!m_addpick)
1166 { QList<LDObject*> oldsel = g_win->sel(); 1166 { QList<LDObject*> oldsel = selection();
1167 g_win->sel().clear(); 1167 LDFile::current()->clearSelection();
1168 1168
1169 for (LDObject* obj : oldsel) 1169 for (LDObject* obj : oldsel)
1170 { obj->setSelected (false);
1171 compileObject (obj); 1170 compileObject (obj);
1172 }
1173 } 1171 }
1174 1172
1175 m_picking = true; 1173 m_picking = true;
1176 1174
1177 // Paint the picking scene 1175 // Paint the picking scene
1239 LDObject* obj = LDObject::fromID (idx); 1237 LDObject* obj = LDObject::fromID (idx);
1240 1238
1241 // If this is an additive single pick and the object is currently selected, 1239 // If this is an additive single pick and the object is currently selected,
1242 // we remove it from selection instead. 1240 // we remove it from selection instead.
1243 if (!m_rangepick && m_addpick) 1241 if (!m_rangepick && m_addpick)
1244 { int pos = g_win->sel().indexOf (obj); 1242 { if (obj->selected())
1245 1243 { obj->unselect();
1246 if (pos != -1)
1247 { g_win->sel().removeAt (i);
1248 obj->setSelected (false);
1249 removedObj = obj; 1244 removedObj = obj;
1250 break; 1245 break;
1251 } 1246 }
1252 } 1247 }
1253 1248
1254 g_win->sel() << obj; 1249 obj->select();
1255 } 1250 }
1256 1251
1257 delete[] pixeldata; 1252 delete[] pixeldata;
1258
1259 // Remove duplicated entries
1260 removeDuplicates (g_win->sel());
1261 1253
1262 // Update everything now. 1254 // Update everything now.
1263 g_win->updateSelection(); 1255 g_win->updateSelection();
1264 1256
1265 // Recompile the objects now to update their color 1257 // Recompile the objects now to update their color
1266 for (LDObject* obj : g_win->sel()) 1258 for (LDObject* obj : selection())
1267 compileObject (obj); 1259 compileObject (obj);
1268 1260
1269 if (removedObj) 1261 if (removedObj)
1270 compileObject (removedObj); 1262 compileObject (removedObj);
1271 1263
1309 1301
1310 // Use the crosshair cursor when drawing. 1302 // Use the crosshair cursor when drawing.
1311 setCursor (Qt::CrossCursor); 1303 setCursor (Qt::CrossCursor);
1312 1304
1313 // Clear the selection when beginning to draw. 1305 // Clear the selection when beginning to draw.
1314 // FIXME: make the selection clearing stuff in ::pick a method and use it 1306 QList<LDObject*> priorsel = selection();
1315 // here! This code doesn't update the GL lists. 1307 LDFile::current()->clearSelection();
1316 g_win->sel().clear(); 1308
1309 for (LDObject* obj : priorsel)
1310 compileObject (obj);
1311
1317 g_win->updateSelection(); 1312 g_win->updateSelection();
1318 m_drawedVerts.clear(); 1313 m_drawedVerts.clear();
1319 } break; 1314 } break;
1320 } 1315 }
1321 1316
1863 { if (! (ev->buttons() & Qt::LeftButton) || editMode() != Select) 1858 { if (! (ev->buttons() & Qt::LeftButton) || editMode() != Select)
1864 return; 1859 return;
1865 1860
1866 pick (ev->x(), ev->y()); 1861 pick (ev->x(), ev->y());
1867 1862
1868 if (g_win->sel().size() == 0) 1863 if (selection().isEmpty())
1869 return; 1864 return;
1870 1865
1871 g_win->beginAction (null); 1866 g_win->beginAction (null);
1872 LDObject* obj = g_win->sel() [0]; 1867 LDObject* obj = selection().first();
1873 AddObjectDialog::staticDialog (obj->getType(), obj); 1868 AddObjectDialog::staticDialog (obj->getType(), obj);
1874 g_win->endAction(); 1869 g_win->endAction();
1875 ev->accept(); 1870 ev->accept();
1876 } 1871 }
1877 1872
1878 // ============================================================================= 1873 // =============================================================================
1879 // ----------------------------------------------------------------------------- 1874 // -----------------------------------------------------------------------------
1880 LDOverlay* GLRenderer::findOverlayObject (GLRenderer::Camera cam) 1875 LDOverlay* GLRenderer::findOverlayObject (GLRenderer::Camera cam)
1881 { LDOverlay* ovlobj = null; 1876 { LDOverlay* ovlobj = null;
1882 1877
1883 for (LDObject * obj : file()->objects()) 1878 for (LDObject * obj : file()->objects())
1884 { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->camera() == cam) 1879 { if (obj->getType() == LDObject::Overlay && static_cast<LDOverlay*> (obj)->camera() == cam)
1885 { ovlobj = static_cast<LDOverlay*> (obj); 1880 { ovlobj = static_cast<LDOverlay*> (obj);
1886 break; 1881 break;
1887 } 1882 }
1888 } 1883 }

mercurial