Skip to content

Commit

Permalink
Merge pull request pixano#52 from pixano/fix/scale-bbox-edges
Browse files Browse the repository at this point in the history
fix: Fixed scaling issue in addBBox function
  • Loading branch information
cpvannier authored Jan 22, 2024
2 parents 50cb1d7 + f414416 commit a499fca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 9 additions & 2 deletions ui/components/canvas2d/src/api/boundingBoxesApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BBox, Mask, SelectionTool } from "@pixano/core";
import LockIcon from "@pixano/core/src/assets/icons/lockIcon.svg";
import Konva from "konva";
import simplify from "simplify-js";
import type { Mask, BBox, SelectionTool } from "@pixano/core";
import LockIcon from "@pixano/core/src/assets/icons/lockIcon.svg";

import { BBOX_STROKEWIDTH, MASK_STROKEWIDTH } from "../lib/constants";
import type { PolygonGroupDetails, PolygonGroupPoint } from "../lib/types/canvas2dTypes";
Expand Down Expand Up @@ -174,6 +174,13 @@ export function addBBox(
bboxGroup.add(bboxKonva);

bboxRect.on("transform", function () {
const rect: Konva.Rect = bboxKonva.findOne(`#rect${bbox.id}`);
rect.setAttrs({
width: rect.width() * rect.scaleX(),
height: rect.height() * rect.scaleY(),
scaleX: 1,
scaleY: 1,
});
stickLabelsToRectangle(tooltip, lockTooltip, bboxRect);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
*
* http://www.cecill.info
*/
import { Eye, EyeOff, ChevronRight } from "lucide-svelte";
import { ChevronRight, Eye, EyeOff } from "lucide-svelte";
import { cn, IconButton } from "@pixano/core/src";
import { itemObjects } from "../../lib/stores/imageWorkspaceStores";
import { toggleObjectDisplayControl } from "../../lib/api/objectsApi";
import { GROUND_TRUTH, MODEL_RUN } from "../../lib/constants";
import { itemObjects } from "../../lib/stores/imageWorkspaceStores";
export let sectionTitle: string;
export let modelName: string;
Expand All @@ -29,6 +29,7 @@
let open: boolean = true;
itemObjects.subscribe((items) => {
if (!items.length) return;
const allObjectsOfCurrentModel = items.filter((item) => {
if (modelName === MODEL_RUN) {
return item.source_id !== GROUND_TRUTH;
Expand Down
2 changes: 1 addition & 1 deletion ui/components/imageWorkspace/src/components/Toolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
</div>
<div
class={cn("flex items-center flex-col gap-4 mt-4", {
"bg-slate-100 rounded-sm": showSmartTools,
"bg-slate-200 rounded-sm": showSmartTools,
})}
>
<button
Expand Down

0 comments on commit a499fca

Please sign in to comment.