46 |
46 |
self.category = ''
|
47 |
47 |
self.type = ''
|
48 |
48 |
self.angle = 0
|
|
49 |
self._scale = 1
|
49 |
50 |
self.origin = None
|
50 |
51 |
self.loc = None
|
51 |
52 |
self.size = None
|
... | ... | |
202 |
203 |
|
203 |
204 |
rect = self.sceneBoundingRect()
|
204 |
205 |
|
205 |
|
cols = ['UID', 'Drawings_UID', 'Symbols_UID', 'X', 'Y', 'Rotation']
|
206 |
|
values = ['?','?','?', '?', '?', '?']
|
207 |
|
param = [str(self.uid), str(appDocData.activeDrawing.UID), str(self.dbUid), rect.left(), rect.top(), str(self.angle)]
|
|
206 |
cols = ['UID', 'Drawings_UID', 'Symbols_UID', 'X', 'Y', 'Rotation', 'Scale']
|
|
207 |
values = ['?','?','?', '?', '?', '?', '?']
|
|
208 |
param = [str(self.uid), str(appDocData.activeDrawing.UID), str(self.dbUid), rect.left(), rect.top(), str(self.angle), self.transform().m11()]
|
208 |
209 |
sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values))
|
209 |
210 |
res.append((sql, tuple(param)))
|
210 |
211 |
|
... | ... | |
224 |
225 |
@history 2018.05.09 Jeongwoo Clear self.connectors
|
225 |
226 |
2018.05.30 Jeongwoo Add parameters (parentSymbol, childSymbol)
|
226 |
227 |
'''
|
227 |
|
def buildItem(self, name, _type, angle, loc, origin, connPts, dbUid=None, pointsUids=None):
|
|
228 |
def buildItem(self, name, _type, angle, scale, loc, origin, connPts, dbUid=None, pointsUids=None):
|
228 |
229 |
try:
|
229 |
230 |
docData = AppDocData.instance()
|
230 |
231 |
self.name = name
|
231 |
232 |
self.type = _type
|
232 |
233 |
self.angle = angle
|
|
234 |
self._scale = scale
|
233 |
235 |
self.loc = loc
|
234 |
236 |
self.origin = origin
|
235 |
237 |
if dbUid is None:
|
... | ... | |
874 |
876 |
|
875 |
877 |
@staticmethod
|
876 |
878 |
def fromDatabase(componentInfos):
|
|
879 |
""" create a componenet from database """
|
877 |
880 |
item = None
|
878 |
881 |
|
879 |
882 |
try:
|
... | ... | |
886 |
889 |
x = componentInfos[0][7] # X@Components
|
887 |
890 |
y = componentInfos[0][8] # Y@Components
|
888 |
891 |
angle = componentInfos[0][9] # Rotation@Components
|
|
892 |
scale = componentInfos[0][10] # Scale@Components
|
889 |
893 |
|
890 |
894 |
pt = []
|
891 |
895 |
pt.append(float(x))
|
... | ... | |
906 |
910 |
if os.path.isfile(svgFilePath):
|
907 |
911 |
item = SymbolSvgItem.createItem(_type, svgFilePath, uid)
|
908 |
912 |
item.setVisible(False)
|
909 |
|
item.buildItem(name, _type, float(angle), pt, origin, connPts, dbUid, pointsUids)
|
|
913 |
item.buildItem(name, _type, float(angle), float(scale), pt, origin, connPts, dbUid, pointsUids)
|
910 |
914 |
|
911 |
915 |
for area in appDocData.getAreaList():
|
912 |
916 |
if area.contains(pt):
|
... | ... | |
1120 |
1124 |
transform.translate(self.loc[0] + self.symbolOrigin[0], self.loc[1] + self.symbolOrigin[1])
|
1121 |
1125 |
transform.rotateRadians(-self.angle)
|
1122 |
1126 |
transform.translate(-self.symbolOrigin[0], -self.symbolOrigin[1])
|
|
1127 |
transform.scale(self._scale, self._scale)
|
1123 |
1128 |
|
1124 |
1129 |
self.setTransform(transform)
|
1125 |
1130 |
scene.addItem(self)
|
... | ... | |
1322 |
1327 |
rect = self.sceneBoundingRect()
|
1323 |
1328 |
loc = QPointF(rect.x(), rect.y())
|
1324 |
1329 |
self.resetTransform()
|
|
1330 |
#self.setScale(1)
|
1325 |
1331 |
rect = self.sceneBoundingRect()
|
1326 |
1332 |
scale = [(change.width() - loc.x())/rect.width(), (change.height() - loc.y())/rect.height()]
|
1327 |
1333 |
#scale the item
|
1328 |
1334 |
if scale[0] > 0 and scale[1] > 0:
|
1329 |
1335 |
self.setPos(loc)
|
|
1336 |
#self.setScale(scale[0] if scale[0] < scale[1] else scale[1])
|
1330 |
1337 |
trans = QTransform()
|
1331 |
1338 |
trans.scale(scale[0] if scale[0] < scale[1] else scale[1],scale[0] if scale[0] < scale[1] else scale[1])
|
1332 |
|
self.setTransform(trans);
|
|
1339 |
self.setTransform(trans)
|
1333 |
1340 |
self.prepareGeometryChange()
|
1334 |
1341 |
self.update()
|
1335 |
1342 |
|