Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsteinkogler committed Apr 23, 2024
2 parents 7df9a03 + 41a5b15 commit db7bbf1
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 52 deletions.
6 changes: 4 additions & 2 deletions frontend/src/config/i18n/de/drawings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
"place_image_hint": "Klicke an die Stelle, an der das Bild platziert werden soll.",
"edit_bezier_polygon_hint": "Klicke mit der linken Maustaste, um einen Punkt zu setzen.",
"delete_bezier_polygon_point_hint": "Klicke auf einen Punkt, um ihn zu löschen.",
"bezier_polygon_add_points_beetween_hint": "Klicke auf die Karte, um einen Punkt auf der naheliegensten Linie hinzuzufügen.",
"bezier_polygon_add_points_between_hint": "Klicke auf die Karte, um einen Punkt auf der naheliegensten Linie hinzuzufügen.",
"draw_rectangle_tooltip": "Rechteck zeichnen.",
"draw_ellipse_tooltip": "Ellipse zeichnen.",
"draw_free_line_tooltip": "Freie Linie zeichnen.",
"place_text_tooltip": "Text platzieren.",
"draw_bezier_polygon_tooltip": "Freies Polygon zeichnen.",
"edit_bezier_polygon_tooltip": "Freies Polygon bearbeiten.",
"delete_bezier_polygon_point_tooltip": "Punkte löschen.",
"bezier_polygon_add_points_beetween_tooltip": "Punkte zwischen zwei Punkten hinzufügen.",
"bezier_polygon_add_points_between_tooltip": "Punkte zwischen zwei Punkten hinzufügen.",


"delete": "Element löschen",
"delete_multiple_drawings": "Elemente löschen",
"add_date": "Hinzugefügt am",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/config/i18n/en/drawings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"place_image_hint": "Click to place image.",
"edit_bezier_polygon_hint": "Use left-click to add points.",
"delete_bezier_polygon_point_hint": "Click on a point to delete it.",
"bezier_polygon_add_points_beetween_hint": "Click on the map to add points between two points.",
"bezier_polygon_add_points_between_hint": "Click on the map to add points between two points.",
"draw_rectangle_tooltip": "Draw rectangle.",
"draw_ellipse_tooltip": "Draw ellipse.",
"draw_free_line_tooltip": "Draw free line.",
"place_text_tooltip": "Place text.",
"draw_bezier_polygon_tooltip": "Draw bezier polygon.",
"edit_bezier_polygon_tooltip": "Edit bezier polygon.",
"delete_bezier_polygon_point_tooltip": "Delete points.",
"bezier_polygon_add_points_beetween_tooltip": "Add points between two points.",
"bezier_polygon_add_points_between_tooltip": "Add points between two points.",
"delete": "Delete Drawing",
"delete_multiple_drawings": "Delete Drawings",
"add_date": "Added on",
Expand Down
48 changes: 35 additions & 13 deletions frontend/src/features/map_planning/layers/drawing/DrawingLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { Ellipse, Layer, Line, Rect, Text } from 'react-konva';
import * as uuid from 'uuid';
import {
DrawingDto,
DrawingShapeType,
DrawingDto,
LayerType,
FillPatternType,
RectangleProperties,
Expand All @@ -26,6 +26,7 @@ import { getFillPattern } from '@/utils/fillPatterns';
import { NextcloudKonvaImage } from '../../components/image/NextcloudKonvaImage';
import useMapStore from '../../store/MapStore';
import { useTransformerStore } from '../../store/transformer/TransformerStore';
import { PolygonPoint } from '../../types/PolygonTypes';
import { useIsDrawingLayerActive } from '../../utils/layer-utils';
import { CreateDrawingAction, UpdateDrawingAction } from './actions';
import { useDeleteSelectedDrawings } from './hooks/useDeleteSelectedDrawings';
Expand Down Expand Up @@ -693,14 +694,19 @@ function DrawingLayer(props: DrawingLayerProps) {
e.target.moveToTop();
};

const handleUnselectDrawing: KonvaEventListener<Konva.Stage, MouseEvent> = useCallback((e) => {
// only unselect if we are clicking on the background
if (e.target instanceof Konva.Shape) {
return;
}
const handleUnselectDrawing: KonvaEventListener<Konva.Stage, MouseEvent> = useCallback(
(e) => {
// only unselect if we are clicking on the background
if (e.target instanceof Konva.Shape) {
return;
}

useMapStore.getState().selectDrawings([]);
}, []);
if (editMode) return;

useMapStore.getState().selectDrawings([]);
},
[editMode],
);

const handleSelectDrawing: KonvaEventListener<Konva.Stage, MouseEvent> = useCallback(() => {
const selectedDrawings = (foundDrawings: DrawingDto[], konvaNode: Konva.Node) => {
Expand Down Expand Up @@ -836,12 +842,12 @@ function DrawingLayer(props: DrawingLayerProps) {
props.listening,
]);

const updateNewBezierLinePoints = (points: number[][]) => {
const updateNewBezierLinePoints = (points: PolygonPoint[]) => {
if (!newBezierLine) return;

setNewBezierLine({
...newBezierLine,
points: points,
points: points.map((p) => [p.x, p.y]),
});
};

Expand All @@ -858,8 +864,18 @@ function DrawingLayer(props: DrawingLayerProps) {
id={bezierLine.id}
object={bezierLine}
editMode={editDrawingId === bezierLine.id ? editMode : undefined}
onPointsChanged={(p) => handleBezierPointsChanged(bezierLine.id, p)}
initialPoints={properties.points}
onPointsChanged={(p) =>
handleBezierPointsChanged(
bezierLine.id,
p.map((p) => [p.x, p.y]),
)
}
initialPoints={properties.points.map((p) => {
return {
x: p[0],
y: p[1],
};
})}
strokeWidth={properties.strokeWidth}
onLineClick={handleShapeClicked}
color={properties.color}
Expand All @@ -868,6 +884,7 @@ function DrawingLayer(props: DrawingLayerProps) {
y={bezierLine.y}
scaleX={bezierLine.scaleX}
scaleY={bezierLine.scaleY}
rotation={bezierLine.rotation}
onDragStart={moveToTop}
></BezierPolygon>
);
Expand All @@ -879,7 +896,12 @@ function DrawingLayer(props: DrawingLayerProps) {
key={`new-bezier-line`}
onFinishLine={handleFinishBezierLine}
onPointsChanged={updateNewBezierLinePoints}
initialPoints={newBezierLine.points}
initialPoints={newBezierLine.points.map((p) => {
return {
x: p[0],
y: p[1],
};
})}
editMode={selectedShape == DrawingShapeType.BezierPolygon ? 'draw' : undefined}
strokeWidth={selectedStrokeWidth}
color={selectedColor}
Expand Down
Loading

0 comments on commit db7bbf1

Please sign in to comment.