개정판 0cdec51f
add text overlapping error
Change-Id: I8ab385ce7a3c63396d6c4f1b8329d2631ce7f4a4
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
189 | 189 |
def hoverMoveEvent(self, event): |
190 | 190 |
pass |
191 | 191 |
|
192 |
''' |
|
193 |
@brief remove item when user press delete key |
|
194 |
@author humkyung |
|
195 |
@date 2018.04.23 |
|
196 |
@history 2018.05.25 Jeongwoo Seperate delete item method |
|
197 |
humkyung 2018.08.18 rotate text when user press 'R' |
|
198 |
''' |
|
192 |
def validate(self): |
|
193 |
""" validation check """ |
|
194 |
|
|
195 |
errors = [] |
|
196 |
|
|
197 |
try: |
|
198 |
app_doc_data = AppDocData.instance() |
|
199 |
dataPath = app_doc_data.getErrorItemSvgPath() |
|
200 |
|
|
201 |
# check overlapping |
|
202 |
texts = [item for item in self.scene().items() if item is not self and issubclass(type(item), QEngineeringTextItem)] |
|
203 |
for text in texts: |
|
204 |
textRect = text.sceneBoundingRect() |
|
205 |
rect1 = QRectF(textRect.left() - 3, textRect.top() - 3, textRect.width() + 6, textRect.height() + 6) |
|
206 |
rect2 = QRectF(textRect.left() + 3, textRect.top() + 3, textRect.width() - 6, textRect.height() - 6) |
|
207 |
if rect1.contains(self.sceneBoundingRect()) or rect2.contains(self.sceneBoundingRect().center()): |
|
208 |
error = SymbolSvgItem.createItem('Error', None, dataPath) |
|
209 |
error.parent = self |
|
210 |
error.msg = self.tr('Text overlapping error') |
|
211 |
error.setToolTip(error.msg) |
|
212 |
error.area = self.area |
|
213 |
error.name = 'Error' |
|
214 |
errors.append(error) |
|
215 |
|
|
216 |
error.setPosition([self.sceneBoundingRect().center().x(), self.sceneBoundingRect().center().y()]) |
|
217 |
|
|
218 |
except Exception as ex: |
|
219 |
from App import App |
|
220 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
221 |
sys.exc_info()[-1].tb_lineno) |
|
222 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
223 |
|
|
224 |
return errors |
|
199 | 225 |
|
200 | 226 |
def contextMenuEvent(self, event): |
201 | 227 |
items = self.scene().selectedItems() |
... | ... | |
309 | 335 |
self.setTransform(trans) |
310 | 336 |
elif event.key() == Qt.Key_M: |
311 | 337 |
from App import App |
312 |
|
|
338 |
|
|
313 | 339 |
App.mainWnd().keyPressEvent(event) |
314 | 340 |
|
315 | 341 |
# QGraphicsTextItem.keyPressEvent(self, event) |
내보내기 Unified diff