Skip to content

Commit 7c66f66

Browse files
committed
Merge branch 'feature/ployline'
2 parents 9048fef + aee00a8 commit 7c66f66

33 files changed

Lines changed: 2074 additions & 1227 deletions

src/App.types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ export enum LOCAL_STORAGE_KEY {
5252
DRAWING = 'OPEN_WEB_CAD__DRAWING',
5353
DROPDOWN = 'OPEN_WEB_CAD__DROPDOWN',
5454
}
55+
56+
export interface StartAndEndpointEntity {
57+
getStartPoint(): Point;
58+
getEndPoint(): Point;
59+
}

src/components/Icon/Icon.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import SendUpIcon from 'teenyicons/outline/send-up.svg?react';
3939
import SquareIcon from 'teenyicons/outline/square.svg?react';
4040
import SvgIcon from 'teenyicons/outline/svg.svg?react';
4141
import UnlockIcon from 'teenyicons/outline/unlock.svg?react';
42+
import HomeAltIcon from 'teenyicons/outline/home-alt.svg?react';
43+
4244
import VectorDocumentIcon from 'teenyicons/outline/vector-document.svg?react';
4345
import SolidDownSmallIcon from 'teenyicons/solid/down-small.svg?react';
4446
import SolidDownIcon from 'teenyicons/solid/down.svg?react';
@@ -100,6 +102,7 @@ enum IconName {
100102
Lock = 'Lock',
101103
Unlock = 'Unlock',
102104
GridLayout = 'GridLayout',
105+
HomeAlt = 'HomeAlt',
103106

104107
// Solid icons
105108
SolidDown = 'SolidDown',
@@ -159,6 +162,7 @@ const icons: Record<IconName, FC> = {
159162
[IconName.Lock]: LockIcon,
160163
[IconName.Unlock]: UnlockIcon,
161164
[IconName.GridLayout]: GridLayoutIcon,
165+
[IconName.HomeAlt]: HomeAltIcon,
162166

163167
// Solid icons
164168
[IconName.SolidDown]: SolidDownIcon,

src/components/Toolbar.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {type FC, type MouseEvent, useCallback, useEffect, useState} from 'react';
2+
import {toast} from 'react-toastify';
23
import {Actor} from 'xstate';
34
import {COLOR_LIST} from '../App.consts';
45
import {HtmlEvent, type Layer} from '../App.types';
@@ -7,10 +8,10 @@ import {exportEntitiesToLocalStorage} from '../helpers/import-export-handlers/ex
78
import {exportEntitiesToPdfFile} from '../helpers/import-export-handlers/export-entities-to-pdf.ts';
89
import {exportEntitiesToPngFile} from '../helpers/import-export-handlers/export-entities-to-png';
910
import {exportEntitiesToSvgFile} from '../helpers/import-export-handlers/export-entities-to-svg';
11+
import {importEntitiesFromDxfFile} from '../helpers/import-export-handlers/import-entities-from-dxf';
1012
import {importEntitiesFromJsonFile} from '../helpers/import-export-handlers/import-entities-from-json';
1113
import {importEntitiesFromSvgFile} from '../helpers/import-export-handlers/import-entities-from-svg.ts';
1214
import {importImageFromFile} from '../helpers/import-export-handlers/import-image-from-file';
13-
import {importEntitiesFromDxfFile} from '../helpers/import-export-handlers/import-entities-from-dxf';
1415
import {times} from '../helpers/times';
1516
import {
1617
getActiveLayerId,
@@ -36,7 +37,7 @@ import {TOOL_STATE_MACHINES} from '../tools/tool.consts';
3637
import {ActorEvent} from '../tools/tool.types';
3738
import {Button} from './Button.tsx';
3839
import {DropdownButton} from './DropdownButton.tsx';
39-
import {IconName} from './Icon/Icon.tsx';
40+
import {Icon, IconName} from './Icon/Icon.tsx';
4041
import {LayerManager} from './LayerManager.tsx';
4142

4243
export const Toolbar: FC = () => {
@@ -219,6 +220,18 @@ export const Toolbar: FC = () => {
219220
active={activeToolLocal === Tool.ARRAY}
220221
label="Array copy"
221222
/>
223+
<Button
224+
className="w-full"
225+
title="Create polyline lines and arcs"
226+
dataId="pedit-button"
227+
iconComponent={<Icon name={IconName.HomeAlt} className="rotate-270" />}
228+
onClick={(evt) => {
229+
evt.stopPropagation();
230+
handleToolClick(Tool.PEDIT);
231+
}}
232+
active={activeToolLocal === Tool.PEDIT}
233+
label="Polyline edit"
234+
/>
222235

223236
<Button
224237
className="mt-2 w-full"
@@ -458,8 +471,20 @@ export const Toolbar: FC = () => {
458471
}}
459472
active={zoom === screenZoomLocal}
460473
/>
461-
// TODO add option to fit screen
462474
))}
475+
<Button
476+
key="zoom-level--fit"
477+
title="Zoom fit screen"
478+
dataId="zoom-level-fit-button"
479+
label="Fit screen"
480+
style={{ width: 'calc(60% - 2px)', padding: '8px' }}
481+
onClick={(evt) => {
482+
evt.stopPropagation();
483+
getScreenCanvasDrawController().zoomToFitScreen();
484+
setScreenZoomLocal(getScreenCanvasDrawController().getScreenScale());
485+
}}
486+
active={false}
487+
/>
463488
</DropdownButton>
464489

465490
<Button
@@ -470,6 +495,7 @@ export const Toolbar: FC = () => {
470495
onClick={async (evt) => {
471496
evt.stopPropagation();
472497
await exportEntitiesToLocalStorage();
498+
toast.success('Saved');
473499
}}
474500
label="Save drawing"
475501
/>

0 commit comments

Comments
 (0)