src/toolsets/viewtoolset.cpp

changeset 978
4603d8fd063e
parent 971
c00f9665a9f8
child 981
5d5d84ab2c48
equal deleted inserted replaced
977:dc3ceb65cda7 978:4603d8fd063e
31 ViewToolset::ViewToolset (MainWindow *parent) : 31 ViewToolset::ViewToolset (MainWindow *parent) :
32 Toolset (parent) {} 32 Toolset (parent) {}
33 33
34 void ViewToolset::selectAll() 34 void ViewToolset::selectAll()
35 { 35 {
36 for (LDObject* obj : CurrentDocument()->objects()) 36 for (LDObject* obj : currentDocument()->objects())
37 obj->select(); 37 obj->select();
38 } 38 }
39 39
40 void ViewToolset::selectByColor() 40 void ViewToolset::selectByColor()
41 { 41 {
42 if (Selection().isEmpty()) 42 if (selectedObjects().isEmpty())
43 return; 43 return;
44 44
45 QList<LDColor> colors; 45 QList<LDColor> colors;
46 46
47 for (LDObject* obj : Selection()) 47 for (LDObject* obj : selectedObjects())
48 { 48 {
49 if (obj->isColored()) 49 if (obj->isColored())
50 colors << obj->color(); 50 colors << obj->color();
51 } 51 }
52 52
53 removeDuplicates (colors); 53 removeDuplicates (colors);
54 CurrentDocument()->clearSelection(); 54 currentDocument()->clearSelection();
55 55
56 for (LDObject* obj : CurrentDocument()->objects()) 56 for (LDObject* obj : currentDocument()->objects())
57 { 57 {
58 if (colors.contains (obj->color())) 58 if (colors.contains (obj->color()))
59 obj->select(); 59 obj->select();
60 } 60 }
61 } 61 }
62 62
63 void ViewToolset::selectByType() 63 void ViewToolset::selectByType()
64 { 64 {
65 if (Selection().isEmpty()) 65 if (selectedObjects().isEmpty())
66 return; 66 return;
67 67
68 QList<LDObjectType> types; 68 QList<LDObjectType> types;
69 QStringList subfilenames; 69 QStringList subfilenames;
70 70
71 for (LDObject* obj : Selection()) 71 for (LDObject* obj : selectedObjects())
72 { 72 {
73 types << obj->type(); 73 types << obj->type();
74 74
75 if (types.last() == OBJ_Subfile) 75 if (types.last() == OBJ_Subfile)
76 subfilenames << static_cast<LDSubfile*> (obj)->fileInfo()->name(); 76 subfilenames << static_cast<LDSubfile*> (obj)->fileInfo()->name();
77 } 77 }
78 78
79 removeDuplicates (types); 79 removeDuplicates (types);
80 removeDuplicates (subfilenames); 80 removeDuplicates (subfilenames);
81 CurrentDocument()->clearSelection(); 81 currentDocument()->clearSelection();
82 82
83 for (LDObject* obj : CurrentDocument()->objects()) 83 for (LDObject* obj : currentDocument()->objects())
84 { 84 {
85 LDObjectType type = obj->type(); 85 LDObjectType type = obj->type();
86 86
87 if (not types.contains (type)) 87 if (not types.contains (type))
88 continue; 88 continue;
107 107
108 int w, h; 108 int w, h;
109 uchar* imgdata = m_window->R()->getScreencap (w, h); 109 uchar* imgdata = m_window->R()->getScreencap (w, h);
110 QImage img = GetImageFromScreencap (imgdata, w, h); 110 QImage img = GetImageFromScreencap (imgdata, w, h);
111 111
112 QString root = Basename (CurrentDocument()->name()); 112 QString root = Basename (currentDocument()->name());
113 113
114 if (root.right (4) == ".dat") 114 if (root.right (4) == ".dat")
115 root.chop (4); 115 root.chop (4);
116 116
117 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; 117 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : "";
131 m_window->R()->update(); 131 m_window->R()->update();
132 } 132 }
133 133
134 void ViewToolset::visibilityToggle() 134 void ViewToolset::visibilityToggle()
135 { 135 {
136 for (LDObject* obj : Selection()) 136 for (LDObject* obj : selectedObjects())
137 obj->setHidden (not obj->isHidden()); 137 obj->setHidden (not obj->isHidden());
138 } 138 }
139 139
140 void ViewToolset::visibilityHide() 140 void ViewToolset::visibilityHide()
141 { 141 {
142 for (LDObject* obj : Selection()) 142 for (LDObject* obj : selectedObjects())
143 obj->setHidden (true); 143 obj->setHidden (true);
144 } 144 }
145 145
146 void ViewToolset::visibilityReveal() 146 void ViewToolset::visibilityReveal()
147 { 147 {
148 for (LDObject* obj : Selection()) 148 for (LDObject* obj : selectedObjects())
149 obj->setHidden (false); 149 obj->setHidden (false);
150 } 150 }
151 151
152 void ViewToolset::wireframe() 152 void ViewToolset::wireframe()
153 { 153 {
255 { 255 {
256 bool ok; 256 bool ok;
257 int defval = 0; 257 int defval = 0;
258 LDObject* obj; 258 LDObject* obj;
259 259
260 if (Selection().size() == 1) 260 if (selectedObjects().size() == 1)
261 defval = Selection()[0]->lineNumber(); 261 defval = selectedObjects()[0]->lineNumber();
262 262
263 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, 263 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval,
264 1, CurrentDocument()->getObjectCount(), 1, &ok); 264 1, currentDocument()->getObjectCount(), 1, &ok);
265 265
266 if (not ok or (obj = CurrentDocument()->getObject (idx - 1)) == null) 266 if (not ok or (obj = currentDocument()->getObject (idx - 1)) == null)
267 return; 267 return;
268 268
269 CurrentDocument()->clearSelection(); 269 currentDocument()->clearSelection();
270 obj->select(); 270 obj->select();
271 m_window->updateSelection(); 271 m_window->updateSelection();
272 } 272 }
273 273
274 void ViewToolset::randomColors() 274 void ViewToolset::randomColors()

mercurial