Skip to content

Commit

Permalink
Add point merge base logic TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
twangodev committed Jul 27, 2024
1 parent 5b0378e commit 395739e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/models/tools/tf_tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:logging/logging.dart';
import 'package:toolfoam/models/tools/tf_path_data.dart';
import 'package:toolfoam/models/tools/tf_tool_data.dart';
import 'package:toolfoam/models/tools/tf_tool_metadata.dart';
import 'package:path/path.dart' as p;

Expand Down
File renamed without changes.
25 changes: 17 additions & 8 deletions lib/widgets/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:vector_math/vector_math_64.dart';

import '../../models/editing_tool.dart';
import '../../models/line.dart';
import '../../models/tools/tf_path_data.dart';
import '../../models/tools/tf_tool_data.dart';

class Editor extends StatefulWidget {
final TfTool tool;
Expand All @@ -26,10 +26,9 @@ class Editor extends StatefulWidget {
class _EditorState extends State<Editor> {
static final logger = Logger('TFEditorState');

final TransformationController transformationController =
TransformationController();
final transformationController = TransformationController();

late final EditorData notifier = EditorData(toolData: widget.tool.data);
late final notifier = EditorData(toolData: widget.tool.data);

Size viewerSize = Size.zero;
bool allowPrimaryMouseButtonPan = false;
Expand Down Expand Up @@ -59,8 +58,19 @@ class _EditorState extends State<Editor> {

if (notifier.dragPointUuid != null) {
String dragPoint = notifier.dragPointUuid!;
notifier.toolData.points[dragPoint] = notifier
.effectivePointerCoordinates(scenePointer, ignoreUuid: dragPoint);

Offset effectivePointer =
notifier.effectivePointerCoordinates(scenePointer, ignoreUuid: dragPoint);

String? existingPoint = notifier.toolData.points.inverse[effectivePointer];
if (existingPoint != null && existingPoint != dragPoint) {
// TODO temporary point deletion (snaps to existing point)
return;
} else if (existingPoint == null) {
// TODO point reinsertion
}

notifier.toolData.points[dragPoint] = effectivePointer;
}
}

Expand All @@ -72,8 +82,7 @@ class _EditorState extends State<Editor> {
Offset effectivePointer =
notifier.effectivePointerCoordinates(scenePointer);

logger
.finer('Pointer down at: $scenePointer, effective: $effectivePointer');
logger.finer('Pointer down at: $effectivePointer');

if (activeEditingTool == EditingTool.select) {
String? pointUuid = notifier.toolData.points.inverse[effectivePointer];
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/editor/editor_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:toolfoam/widgets/editor/editor_painter_data.dart';
import 'package:vector_math/vector_math_64.dart' show Quad;

import '../../models/line.dart';
import '../../models/tools/tf_path_data.dart';
import '../../models/tools/tf_tool_data.dart';

class EditorPainter extends CustomPainter {
final Quad viewport;
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/editor/editor_painter_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:math';

import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:toolfoam/models/tools/tf_path_data.dart';
import 'package:toolfoam/models/tools/tf_tool_data.dart';
import 'package:toolfoam/widgets/editor/editor_config.dart';
import 'package:toolfoam/widgets/editor/editor_util.dart';

Expand Down

0 comments on commit 395739e

Please sign in to comment.