Skip to content

Commit 2724744

Browse files
author
mopy
committed
small fixes, more reverse select, new cs select tool
1 parent c22911b commit 2724744

File tree

13 files changed

+247
-32
lines changed

13 files changed

+247
-32
lines changed

co_lib/co_base/co_cmn.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ def block_signals(obj: QObject):
188188
finally:
189189
obj.blockSignals(False)
190190

191+
@contextmanager
192+
def block_var(obj: bool):
193+
obj = True
194+
try:
195+
yield
196+
finally:
197+
obj = False
198+
191199

192200
def complement_color(rgb: str) -> str:
193201
s1 = rgb.replace('#', '0x')

co_lib/co_base/co_completer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import FreeCAD as App
88
import Sketcher
99
from PySide2.QtCore import Qt, QRect, QModelIndex, Slot, Signal
10-
from PySide2.QtGui import QKeyEvent, QStandardItemModel, QStandardItem, QFocusEvent, QMouseEvent
10+
from PySide2.QtGui import QKeyEvent, QStandardItemModel, QStandardItem, QFocusEvent, QMouseEvent, QFont
1111
from PySide2.QtWidgets import QLineEdit, QCompleter, QWidget, QVBoxLayout, QApplication, QAbstractItemView, QTableWidget
1212

1313
from co_lib.co_base.co_cmn import DIM_CS, ConType
14-
from co_lib.co_base.co_config import CfgTransient
14+
from co_lib.co_base.co_config import CfgTransient, CfgFonts
1515
from co_lib.co_base.co_flag import Cs
1616
from co_lib.co_base.co_logger import xp_worker, xp, flow, _cp
1717

@@ -486,6 +486,9 @@ class TableLineEdit(LineEdit):
486486

487487
def __init__(self, item, comp_root: Node, driving: bool, parent):
488488
super().__init__(item, comp_root, parent)
489+
cfg_f = CfgFonts()
490+
f: QFont = cfg_f.font_get(cfg_f.FONT_TABLE)
491+
self.setFont(f)
489492
self.item = item
490493
if Cs.V in item.sub_type:
491494
if item.expression:

co_lib/co_base/co_config.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def __init__(self):
203203
def get(self, key):
204204
if key in CfgTransient.__NAMES:
205205
if key in self.data.keys():
206-
val = self.convert_out(key, self.data[key])
206+
val = self._convert_out(key, self.data[key])
207207
return val
208208
else:
209209
return self.default(key)
@@ -213,7 +213,7 @@ def get(self, key):
213213
@flow
214214
def set(self, key, val):
215215
if key in CfgTransient.__NAMES:
216-
val = self.convert_in(val)
216+
val = self._convert_in(val)
217217
self.data = {**self.data, **{key: val}}
218218
self.save()
219219
# self.data[key] = val
@@ -233,14 +233,14 @@ def save(self):
233233
self.save_delegate(self.data)
234234

235235
@flow
236-
def convert_in(self, val: Any) -> Any:
236+
def _convert_in(self, val: Any) -> Any:
237237
if isinstance(val, QByteArray):
238238
qb64 = val.toBase64()
239239
return bytes(qb64).decode('UTF-8')
240240
return val
241241

242242
@flow
243-
def convert_out(self, key, val):
243+
def _convert_out(self, key, val):
244244
if key == CfgTransient.GEOMETRY:
245245
enc = val.encode('UTF-8')
246246
return QByteArray.fromBase64(enc)
@@ -258,6 +258,8 @@ def default(self, val):
258258
return 0.1
259259
elif val == CfgTransient.SHOW_ONLY_VALID:
260260
return True
261+
elif val == CfgTransient.CO_EXT_MATCH:
262+
return False
261263
elif val == CfgTransient.GEOMETRY:
262264
return None
263265
elif val == CfgTransient.TRIGGER_CHARS:
@@ -272,7 +274,8 @@ def default(self, val):
272274
PA_TOLERANCE: str = 'pa_tolerance'
273275
SHOW_ONLY_VALID: str = 'only_valid'
274276
TRIGGER_CHARS: str = 'trigger_chars'
275-
__NAMES: Set[str] = {CO_TOLERANCE, EQ_TOLERANCE, HV_TOLERANCE, PA_TOLERANCE, SHOW_ONLY_VALID, GEOMETRY, TRIGGER_CHARS}
277+
CO_EXT_MATCH: str = 'co_ext_match'
278+
__NAMES: Set[str] = {CO_TOLERANCE, EQ_TOLERANCE, HV_TOLERANCE, PA_TOLERANCE, SHOW_ONLY_VALID, GEOMETRY, TRIGGER_CHARS, CO_EXT_MATCH}
276279

277280

278281
@cfg_decorator

co_lib/co_base/co_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def ind_dec(ident, dec):
347347

348348

349349
# '': use without kwargs
350-
_xp_topic('', 'obs_sel')
350+
_xp_topic('', 'equal')
351351
# _xp_topic('', 'flow', 'constraint')
352352
# _xp_topic('')
353353

co_lib/co_tabs/co_co_gui.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .co_co import CoPoints, CoPoint, GeoId, GeoIdDist
2727
from .. import co_impl, co_gui
2828
from ..co_base.co_cmn import GeoPt, fmt_vec, pt_typ_str, wait_cursor, TableLabel, ColorTableItem, ObjType, block_signals
29+
from ..co_base.co_config import CfgTransient
2930
from ..co_base.co_logger import flow, xp, _co, _ev, xps, Profile
3031
from ..co_base.co_lookup import Lookup
3132
from ..co_base.co_observer import observer_block, observer_event_provider_get
@@ -40,6 +41,7 @@ def __init__(self, base):
4041
self.impl: co_impl.CoEd = self.base.base
4142
self.co: CoPoints = self.impl.co_points
4243
self.tab_co = QWidget(None)
44+
self.cfg = CfgTransient()
4345
xp('co.created.connect', **_ev)
4446
self.co.created.connect(self.on_co_create)
4547
xp('co.creation_done.connect', **_ev)
@@ -146,6 +148,7 @@ def task_up(self, co):
146148

147149
@flow(short=True)
148150
def on_result_up(self, result, id_lst: List[GeoId]):
151+
self.co_btn_create.setDisabled(True)
149152
self.co_tbl_wid.setUpdatesEnabled(False)
150153
self.co_tbl_wid.setRowCount(0)
151154
__sorting_enabled = self.co_tbl_wid.isSortingEnabled()
@@ -186,18 +189,19 @@ def on_result_up(self, result, id_lst: List[GeoId]):
186189
self.co_tbl_wid.setUpdatesEnabled(True)
187190

188191
def check(self, pt: CoPoint, id_lst: List[GeoId]):
189-
xp('pt id', repr(pt.geo_id), 'id lst', repr(id_lst))
190-
# xp('dst lst', pt.pt_distance_lst)
191192
if id_lst is None:
192193
return True
194+
xp('pt id', repr(pt.geo_id), 'id lst', repr(id_lst))
195+
xp('dst lst', [x.geo_id for x in pt.pt_distance_lst])
196+
lst = [x.geo_id in id_lst for x in pt.pt_distance_lst]
193197
if pt.geo_id in id_lst:
194198
return True
199+
if self.cfg.get(CfgTransient.CO_EXT_MATCH) and any(lst):
200+
return True
195201
return False
196202

197203
def split(self, pt: CoPoint):
198-
res_n = list()
199-
res_c = list()
200-
res_e = list()
204+
res_n, res_c, res_e = list(), list(), list()
201205
for x in pt.pt_distance_lst:
202206
x: GeoIdDist
203207
t = Lookup.translate_geo_idx(x.geo_id.idx)
@@ -257,7 +261,6 @@ def select(self, obj, pnt):
257261
if not from_gui:
258262
xp('ignore if not from gui', **_co)
259263
return
260-
# sk: Sketcher.Sketch = sel_ex.Object
261264
self.update_table(id_lst=res)
262265

263266
@flow

co_lib/co_tabs/co_cs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def __init__(self, base):
8080
self.evo = observer_event_provider_get()
8181
self.evo.in_edit.connect(self.on_in_edit)
8282
self.__constraints: List[Constraint] = list()
83+
self.tol = str(pathlib.Path(CfgBase.BASE_DIR, self.ico['krankenwagen']))
8384

8485
@property
8586
def constraints(self):
@@ -146,6 +147,7 @@ def on_in_edit(self, obj):
146147
'Icon48': 'co_lib/Icon/Sketcher_ToggleConstraint.svg',
147148
'Icon49': 'co_lib/Icon/Sketcher_Toggle_Constraint_Driven.svg',
148149
'Icon50': 'co_lib/Icon/Sketcher_Toggle_Constraint_Driving.svg',
150+
'krankenwagen': 'co_lib/Icon/krankenwagen.svg',
149151
}
150152

151153
@flow

0 commit comments

Comments
 (0)