moleditpy 1.1.2__tar.gz → 1.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moleditpy
3
- Version: 1.1.2
3
+ Version: 1.1.4
4
4
  Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
5
5
  Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/HiroYokoyama/python_molecular_editor
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "moleditpy"
7
7
 
8
- version = "1.1.2"
8
+ version = "1.1.4"
9
9
 
10
10
  authors = [
11
11
  { name="HiroYokoyama", email="titech.yoko.hiro@gmail.com" },
@@ -11,7 +11,7 @@ DOI 10.5281/zenodo.17268532
11
11
  """
12
12
 
13
13
  #Version
14
- VERSION = "1.1.2"
14
+ VERSION = "1.1.4"
15
15
 
16
16
  import sys
17
17
  import numpy as np
@@ -450,11 +450,14 @@ class BondItem(QGraphicsItem):
450
450
  painter.drawPolygon(poly)
451
451
 
452
452
  elif self.stereo == 2: # Dash (破線)
453
+ pen = painter.pen()
454
+ pen.setWidthF(2.5) # デフォルトの太さ(2)から少し太くする
455
+ painter.setPen(pen)
453
456
  num_dashes = 8
454
457
  for i in range(num_dashes + 1):
455
458
  t = i / num_dashes
456
459
  start_pt = p1 * (1 - t) + p2 * t
457
- width = 5.0 * (1 - t)
460
+ width = 12.0 * (1 - t)
458
461
  offset = QPointF(normal.dx(), normal.dy()) * width / 2.0
459
462
  painter.drawLine(start_pt - offset, start_pt + offset)
460
463
 
@@ -476,39 +479,14 @@ class BondItem(QGraphicsItem):
476
479
  # --- 2. ホバー時のエフェクトを上から重ねて描画 ---
477
480
  if (not self.isSelected()) and getattr(self, 'hovered', False):
478
481
  try:
479
- hover_pen = QPen(QColor(144, 238, 144, 180), 8) # 少し太くして見やすく
482
+ # ホバー時のハイライトを太めの半透明な線で描画
483
+ hover_pen = QPen(QColor(144, 238, 144, 180), 8) # LightGreen, 半透明
480
484
  hover_pen.setCapStyle(Qt.PenCapStyle.RoundCap)
481
485
  painter.setPen(hover_pen)
482
- painter.drawLine(line) # 中心線をなぞる
486
+ painter.drawLine(line)
483
487
  except Exception:
484
488
  pass
485
489
 
486
- if self.order == 1:
487
- painter.drawLine(line)
488
- else:
489
- v = line.unitVector().normalVector()
490
- offset = QPointF(v.dx(), v.dy()) * BOND_OFFSET
491
- if self.order == 2:
492
- painter.drawLine(line.translated(offset))
493
- painter.drawLine(line.translated(-offset))
494
- elif self.order == 3:
495
- painter.drawLine(line)
496
- painter.drawLine(line.translated(offset))
497
- painter.drawLine(line.translated(-offset))
498
-
499
- # ホバー時は中央の線に太めの薄い緑を重ねて「枠っぽく」見せる
500
- if (not self.isSelected()) and getattr(self, 'hovered', False):
501
- try:
502
- line = self.get_line_in_local_coords()
503
- if line.length() > 0:
504
- hover_pen = QPen(QColor(144, 238, 144, 180), 6) # 太めで透過
505
- hover_pen.setCapStyle(Qt.PenCapStyle.RoundCap)
506
- hover_pen.setJoinStyle(Qt.PenJoinStyle.RoundJoin)
507
- painter.setPen(hover_pen)
508
- # 中心をなぞる一本線で十分視認できる(複数本線の結合も中心線で可)
509
- painter.drawLine(line)
510
- except Exception:
511
- pass
512
490
 
513
491
 
514
492
  def update_position(self):
@@ -1022,10 +1000,11 @@ class MoleculeScene(QGraphicsScene):
1022
1000
  self.template_context = {}
1023
1001
 
1024
1002
  if isinstance(item, AtomItem):
1025
- # 原子にスナップ
1026
1003
  p0 = item.pos()
1027
- direction = QLineF(p0, pos).unitVector()
1028
- p1 = p0 + direction.p2() * l if direction.length() > 0 else p0 + QPointF(l, 0)
1004
+ continuous_angle = math.atan2(pos.y() - p0.y(), pos.x() - p0.x())
1005
+ snap_angle_rad = math.radians(15)
1006
+ snapped_angle = round(continuous_angle / snap_angle_rad) * snap_angle_rad
1007
+ p1 = p0 + QPointF(l * math.cos(snapped_angle), l * math.sin(snapped_angle))
1029
1008
  points = self._calculate_polygon_from_edge(p0, p1, n)
1030
1009
  self.template_context['items'] = [item]
1031
1010
 
@@ -1083,7 +1062,7 @@ class MoleculeScene(QGraphicsScene):
1083
1062
  # Note: v_edgeは正規化済みだが、方向は同じなので判定には問題ない
1084
1063
  v_cursor = cursor_pos - p0
1085
1064
  cross_product_z = (p1 - p0).x() * v_cursor.y() - (p1 - p0).y() * v_cursor.x()
1086
- if cross_product_z > 0:
1065
+ if cross_product_z < 0:
1087
1066
  rotation_angle = -rotation_angle
1088
1067
 
1089
1068
  cos_a, sin_a = math.cos(rotation_angle), math.sin(rotation_angle)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moleditpy
3
- Version: 1.1.2
3
+ Version: 1.1.4
4
4
  Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
5
5
  Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/HiroYokoyama/python_molecular_editor
File without changes
File without changes