chlor-commits Mailing List for Chlor
Status: Pre-Alpha
Brought to you by:
lenny222
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(32) |
May
(12) |
Jun
(58) |
Jul
(14) |
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
|
Feb
|
Mar
(52) |
Apr
(10) |
May
(28) |
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(3) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
|
From: Chlor c. to s. <chl...@li...> - 2009-12-06 22:20:13
|
Revision: 568
http://chlor.svn.sourceforge.net/chlor/?rev=568&view=rev
Author: lenny222
Date: 2009-12-06 22:19:56 +0000 (Sun, 06 Dec 2009)
Log Message:
-----------
Removed Paths:
-------------
trunk/haskell/Chlor.hs
Deleted: trunk/haskell/Chlor.hs
===================================================================
--- trunk/haskell/Chlor.hs 2009-12-06 22:15:39 UTC (rev 567)
+++ trunk/haskell/Chlor.hs 2009-12-06 22:19:56 UTC (rev 568)
@@ -1,185 +0,0 @@
-{-# OPTIONS -fglasgow-exts #-}
-
-
-module Graphics.Chlor (
- ) where
-
-import Prelude hiding (length)
-
-
--- | The document.
-data Document = Document{
- documentFrames :: [Frame] -- ^ document frames/layers
- } deriving(Eq, Show)
-
-
--- | The document frame/layer.
-data Frame = Frame {
- } deriving(Eq, Show)
-
-
--- | Graphical objects.
-data Object = forall a. ShapeLike a => Object {
- effects :: [Effect] -- ^
- , fill :: Maybe Paint -- ^
- , shape :: a -- ^
- , stroke :: Maybe Stroke -- ^
- } -- deriving(Eq, Show)
-
-
--- | The filter effect.
-data Effect = Effect {
--- shadow
- } deriving(Eq, Show)
-
-
--- | The stroke.
-data Stroke = Stroke {
- strokePaint :: Paint -- ^
- , lineWidth :: Double -- ^
- , dashPattern :: Maybe DashPattern -- ^
- , lineCap :: LineCap -- ^
- , lineJoin :: LineJoin -- ^
- , miterLimit :: Double -- ^
--- , startSymbol :: Maybe LineEnding -- ^
--- , endSymbol :: Maybe LineEnding -- ^
- } deriving(Eq, Show)
-
-
--- | The line cap style.
-data LineCap =
- LineCapButt -- ^
- | LineCapRound -- ^
- | LineCapSquare -- ^
- deriving(Eq, Show)
-
-
--- | The line join style.
-data LineJoin =
- LineJoinMiter -- ^
- | LineJoinRound -- ^
- | LineJoinBevel -- ^
- deriving(Eq, Show)
-
-
--- | The dash pattern.
-data DashPattern = DashPattern {
- } deriving(Eq, Show)
-
-
--- | The paint.
-data Paint =
- SolidColor -- ^
- | Pattern -- ^
- | Gradient -- ^
- deriving(Eq, Show)
-
-
--- | A class for shape-like data structures.
-class ShapeLike a where
- convertToShape :: a -> Shape -- ^
-
-
--- | Shapes
-data Shape =
- ShapeCircle Vector2d Double -- ^ c, r
- | ShapeEllipse Vector2d Double Double -- ^ c, rx, ry
- | ShapeGroup [Shape] -- ^
- | ShapePath Path -- ^
- | ShapeRectangle Vector2d Double Double -- ^ tl, w, h
- | ShapeRegularPolygon Int Vector2d Double Double -- ^ edges, c, r, angle
- | ShapeText -- ^
- deriving(Eq, Show)
-
-instance ShapeLike Shape where
- convertToShape x = x
-
-
--- | Converts a shape to path segments.
-convertToPath :: Shape -> Path -- ^
-convertToPath _ = error "implement"
-
-
--- | Segment orientation.
-data Orientation =
- ClockWise
- | CounterClockWise
- deriving (Eq, Show)
-
-
--- | Path.
-data Path = Path [[Segment]] deriving (Eq, Show)
-
-
--- | Path segments.
-data Segment =
- Close Vector2d Vector2d -- ^ x0, x1
- | CubicBezier Vector2d Vector2d Vector2d Vector2d -- ^ x0, x1, x2, x3
--- | SegmentEllipticalArc -- ^ x, rx, ry, c ???
--- See http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
- | HorizontalLine Vector2d Double -- ^ x, w
- | Line Vector2d Vector2d -- ^ x0, x1
- | QuadraticBezier Vector2d Vector2d Vector2d -- ^ x0, x1, x2
- | VerticalLine Vector2d Double -- ^ x, h
- deriving (Eq, Show)
-
-
--- | Calculates the segment arc length.
-arcLength :: Segment -> Double
---
-arcLength (Close x0 x1) = length $ x1 .- x0
-arcLength (CubicBezier x0 x1 x2 x3) = error "implement"
---arcLength (SegmentEllipticalArc x0 x1 x2 x3) = error "implement"
-arcLength (HorizontalLine x w) = w
-arcLength (Line x0 x1) = length $ x1 .- x0
-arcLength (QuadraticBezier x0 x1 x2) = error "implement"
-arcLength (VerticalLine x h) = h
-
-
--- | Converts special line segments to "Line".
-linesToSegmentLine :: Segment -> Segment
---
-linesToSegmentLine (HorizontalLine x w) = Line x ( x .+ (Vector2d w 0) )
-linesToSegmentLine (VerticalLine x h) = Line x ( x .+ (Vector2d 0 h) )
-linesToSegmentLine s = s
-
-
-infixl 7 .*
-infixl 7 ./
-infixl 6 .+
-infixl 6 .-
-
--- | A class for vector-like data.
-class VectorLike a where
- (.+) :: a -> a -> a
- (.-) :: a -> a -> a
- (.*) :: Double -> a -> a
- (./) :: a -> Double -> a
- invert :: a -> a
- length :: a -> Double
- normalize :: a -> a
- normalize v = v ./ (length v)
-
-
--- | 2-dimensional coordinates for graphical paths.
-data Vector2d = Vector2d Double Double deriving (Eq, Show)
-
-instance VectorLike Vector2d where
- (.+) (Vector2d x1 y1) (Vector2d x2 y2) = Vector2d (x1+x2) (y1+y2)
- (.-) (Vector2d x1 y1) (Vector2d x2 y2) = Vector2d (x1-x2) (y1-y2)
- (.*) s (Vector2d x y) = Vector2d (s*x) (s*y)
- (./) (Vector2d x y) s = Vector2d (x/s) (y/s)
- invert (Vector2d x y) = Vector2d (-x) (-y)
- length (Vector2d x y) = sqrt(x*x + y*y)
-
-
--- | 3-dimensional coordinates for graphical paths.
-data Vector3d = Vector3d Double Double Double deriving (Eq, Show)
-
-instance VectorLike Vector3d where
- (.+) (Vector3d x1 y1 z1) (Vector3d x2 y2 z2) = Vector3d (x1+x2) (y1+y2) (z1+z2)
- (.-) (Vector3d x1 y1 z1) (Vector3d x2 y2 z2) = Vector3d (x1-x2) (y1-y2) (z1-z2)
- (.*) s (Vector3d x y z) = Vector3d (s*x) (s*y) (s*z)
- (./) (Vector3d x y z) s = Vector3d (x/s) (y/s) (z/s)
- invert (Vector3d x y z) = Vector3d (-x) (-y) (-z)
- length (Vector3d x y z) = sqrt(x*x + y*y + z*z)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2009-12-06 22:15:49
|
Revision: 567
http://chlor.svn.sourceforge.net/chlor/?rev=567&view=rev
Author: lenny222
Date: 2009-12-06 22:15:39 +0000 (Sun, 06 Dec 2009)
Log Message:
-----------
split up
Added Paths:
-----------
trunk/haskell/Chlor/
trunk/haskell/Chlor/Chlor.hs
trunk/haskell/Chlor/Document.hs
trunk/haskell/Chlor/Path.hs
trunk/haskell/Chlor/Shape.hs
trunk/haskell/Chlor/Vector.hs
Copied: trunk/haskell/Chlor/Chlor.hs (from rev 566, trunk/haskell/Chlor.hs)
===================================================================
--- trunk/haskell/Chlor/Chlor.hs (rev 0)
+++ trunk/haskell/Chlor/Chlor.hs 2009-12-06 22:15:39 UTC (rev 567)
@@ -0,0 +1,61 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module Chlor (
+ ) where
+
+
+-- | Graphical objects.
+data Object = forall a. ShapeLike a => Object {
+ effects :: [Effect] -- ^
+ , fill :: Maybe Paint -- ^
+ , shape :: a -- ^
+ , stroke :: Maybe Stroke -- ^
+ } -- deriving(Eq, Show)
+
+
+-- | The filter effect.
+data Effect = Effect {
+-- shadow
+ } deriving(Eq, Show)
+
+
+-- | The stroke.
+data Stroke = Stroke {
+ strokePaint :: Paint -- ^
+ , lineWidth :: Double -- ^
+ , dashPattern :: Maybe DashPattern -- ^
+ , lineCap :: LineCap -- ^
+ , lineJoin :: LineJoin -- ^
+ , miterLimit :: Double -- ^
+-- , startSymbol :: Maybe LineEnding -- ^
+-- , endSymbol :: Maybe LineEnding -- ^
+ } deriving(Eq, Show)
+
+
+-- | The line cap style.
+data LineCap =
+ LineCapButt -- ^
+ | LineCapRound -- ^
+ | LineCapSquare -- ^
+ deriving(Eq, Show)
+
+
+-- | The line join style.
+data LineJoin =
+ LineJoinMiter -- ^
+ | LineJoinRound -- ^
+ | LineJoinBevel -- ^
+ deriving(Eq, Show)
+
+
+-- | The dash pattern.
+data DashPattern = DashPattern {
+ } deriving(Eq, Show)
+
+
+-- | The paint.
+data Paint =
+ SolidColor -- ^
+ | Pattern -- ^
+ | Gradient -- ^
+ deriving(Eq, Show)
\ No newline at end of file
Added: trunk/haskell/Chlor/Document.hs
===================================================================
--- trunk/haskell/Chlor/Document.hs (rev 0)
+++ trunk/haskell/Chlor/Document.hs 2009-12-06 22:15:39 UTC (rev 567)
@@ -0,0 +1,13 @@
+module Chlor.Document (
+ ) where
+
+
+-- | The document.
+data Document = Document{
+ documentFrames :: [Frame] -- ^ document frames/layers
+ } deriving(Eq, Show)
+
+
+-- | The document frame/layer.
+data Frame = Frame {
+ } deriving(Eq, Show)
\ No newline at end of file
Added: trunk/haskell/Chlor/Path.hs
===================================================================
--- trunk/haskell/Chlor/Path.hs (rev 0)
+++ trunk/haskell/Chlor/Path.hs 2009-12-06 22:15:39 UTC (rev 567)
@@ -0,0 +1,59 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module Chlor.Path (
+ Path
+ ) where
+
+import Prelude hiding (length)
+import Chlor.Vector (
+ (.+)
+ , (.-)
+ , (.*)
+ , (./)
+ , length
+ , Vector2d(..)
+ )
+
+
+-- | Segment orientation.
+data Orientation =
+ ClockWise
+ | CounterClockWise
+ deriving (Eq, Show)
+
+
+-- | Path.
+data Path = Path [[Segment]] deriving (Eq, Show)
+
+
+-- | Path segments.
+data Segment =
+ Close Vector2d Vector2d -- ^ x0, x1
+ | CubicBezier Vector2d Vector2d Vector2d Vector2d -- ^ x0, x1, x2, x3
+-- | SegmentEllipticalArc -- ^ x, rx, ry, c ???
+-- See http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
+ | HorizontalLine Vector2d Double -- ^ x, w
+ | Line Vector2d Vector2d -- ^ x0, x1
+ | QuadraticBezier Vector2d Vector2d Vector2d -- ^ x0, x1, x2
+ | VerticalLine Vector2d Double -- ^ x, h
+ deriving (Eq, Show)
+
+
+-- | Calculates the segment arc length.
+arcLength :: Segment -> Double
+--
+arcLength (Close x0 x1) = length $ x1 .- x0
+arcLength (CubicBezier x0 x1 x2 x3) = error "implement"
+--arcLength (SegmentEllipticalArc x0 x1 x2 x3) = error "implement"
+arcLength (HorizontalLine x w) = w
+arcLength (Line x0 x1) = length $ x1 .- x0
+arcLength (QuadraticBezier x0 x1 x2) = error "implement"
+arcLength (VerticalLine x h) = h
+
+
+-- | Converts special line segments to "Line".
+linesToSegmentLine :: Segment -> Segment
+--
+linesToSegmentLine (HorizontalLine x w) = Line x ( x .+ (Vector2d w 0) )
+linesToSegmentLine (VerticalLine x h) = Line x ( x .+ (Vector2d 0 h) )
+linesToSegmentLine s = s
\ No newline at end of file
Added: trunk/haskell/Chlor/Shape.hs
===================================================================
--- trunk/haskell/Chlor/Shape.hs (rev 0)
+++ trunk/haskell/Chlor/Shape.hs 2009-12-06 22:15:39 UTC (rev 567)
@@ -0,0 +1,32 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module Chlor.Shape (
+ ) where
+
+import Chlor.Path (Path)
+import Chlor.Vector (Vector2d)
+
+
+-- | A class for shape-like data structures.
+class ShapeLike a where
+ convertToShape :: a -> Shape -- ^
+
+
+-- | Shapes
+data Shape =
+ ShapeCircle Vector2d Double -- ^ c, r
+ | ShapeEllipse Vector2d Double Double -- ^ c, rx, ry
+ | ShapeGroup [Shape] -- ^
+ | ShapePath Path -- ^
+ | ShapeRectangle Vector2d Double Double -- ^ tl, w, h
+ | ShapeRegularPolygon Int Vector2d Double Double -- ^ edges, c, r, angle
+ | ShapeText -- ^
+ deriving(Eq, Show)
+
+instance ShapeLike Shape where
+ convertToShape x = x
+
+
+-- | Converts a shape to path segments.
+convertToPath :: Shape -> Path -- ^
+convertToPath _ = error "implement"
\ No newline at end of file
Added: trunk/haskell/Chlor/Vector.hs
===================================================================
--- trunk/haskell/Chlor/Vector.hs (rev 0)
+++ trunk/haskell/Chlor/Vector.hs 2009-12-06 22:15:39 UTC (rev 567)
@@ -0,0 +1,53 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module Chlor.Vector (
+ (.+)
+ , (.-)
+ , (.*)
+ , (./)
+ , length
+ , Vector2d(..)
+ ) where
+
+import Prelude hiding (length)
+
+
+infixl 7 .*
+infixl 7 ./
+infixl 6 .+
+infixl 6 .-
+
+-- | A class for vector-like data.
+class VectorLike a where
+ (.+) :: a -> a -> a
+ (.-) :: a -> a -> a
+ (.*) :: Double -> a -> a
+ (./) :: a -> Double -> a
+ invert :: a -> a
+ length :: a -> Double
+ normalize :: a -> a
+ normalize v = v ./ (length v)
+
+
+-- | 2-dimensional coordinates for graphical paths.
+data Vector2d = Vector2d Double Double deriving (Eq, Show)
+
+instance VectorLike Vector2d where
+ (.+) (Vector2d x1 y1) (Vector2d x2 y2) = Vector2d (x1+x2) (y1+y2)
+ (.-) (Vector2d x1 y1) (Vector2d x2 y2) = Vector2d (x1-x2) (y1-y2)
+ (.*) s (Vector2d x y) = Vector2d (s*x) (s*y)
+ (./) (Vector2d x y) s = Vector2d (x/s) (y/s)
+ invert (Vector2d x y) = Vector2d (-x) (-y)
+ length (Vector2d x y) = sqrt(x*x + y*y)
+
+
+-- | 3-dimensional coordinates for graphical paths.
+data Vector3d = Vector3d Double Double Double deriving (Eq, Show)
+
+instance VectorLike Vector3d where
+ (.+) (Vector3d x1 y1 z1) (Vector3d x2 y2 z2) = Vector3d (x1+x2) (y1+y2) (z1+z2)
+ (.-) (Vector3d x1 y1 z1) (Vector3d x2 y2 z2) = Vector3d (x1-x2) (y1-y2) (z1-z2)
+ (.*) s (Vector3d x y z) = Vector3d (s*x) (s*y) (s*z)
+ (./) (Vector3d x y z) s = Vector3d (x/s) (y/s) (z/s)
+ invert (Vector3d x y z) = Vector3d (-x) (-y) (-z)
+ length (Vector3d x y z) = sqrt(x*x + y*y + z*z)
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2009-12-06 21:45:20
|
Revision: 566
http://chlor.svn.sourceforge.net/chlor/?rev=566&view=rev
Author: lenny222
Date: 2009-12-06 21:45:10 +0000 (Sun, 06 Dec 2009)
Log Message:
-----------
add Haskell testbed
Added Paths:
-----------
trunk/haskell/
trunk/haskell/Chlor.hs
Added: trunk/haskell/Chlor.hs
===================================================================
--- trunk/haskell/Chlor.hs (rev 0)
+++ trunk/haskell/Chlor.hs 2009-12-06 21:45:10 UTC (rev 566)
@@ -0,0 +1,185 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+
+module Graphics.Chlor (
+ ) where
+
+import Prelude hiding (length)
+
+
+-- | The document.
+data Document = Document{
+ documentFrames :: [Frame] -- ^ document frames/layers
+ } deriving(Eq, Show)
+
+
+-- | The document frame/layer.
+data Frame = Frame {
+ } deriving(Eq, Show)
+
+
+-- | Graphical objects.
+data Object = forall a. ShapeLike a => Object {
+ effects :: [Effect] -- ^
+ , fill :: Maybe Paint -- ^
+ , shape :: a -- ^
+ , stroke :: Maybe Stroke -- ^
+ } -- deriving(Eq, Show)
+
+
+-- | The filter effect.
+data Effect = Effect {
+-- shadow
+ } deriving(Eq, Show)
+
+
+-- | The stroke.
+data Stroke = Stroke {
+ strokePaint :: Paint -- ^
+ , lineWidth :: Double -- ^
+ , dashPattern :: Maybe DashPattern -- ^
+ , lineCap :: LineCap -- ^
+ , lineJoin :: LineJoin -- ^
+ , miterLimit :: Double -- ^
+-- , startSymbol :: Maybe LineEnding -- ^
+-- , endSymbol :: Maybe LineEnding -- ^
+ } deriving(Eq, Show)
+
+
+-- | The line cap style.
+data LineCap =
+ LineCapButt -- ^
+ | LineCapRound -- ^
+ | LineCapSquare -- ^
+ deriving(Eq, Show)
+
+
+-- | The line join style.
+data LineJoin =
+ LineJoinMiter -- ^
+ | LineJoinRound -- ^
+ | LineJoinBevel -- ^
+ deriving(Eq, Show)
+
+
+-- | The dash pattern.
+data DashPattern = DashPattern {
+ } deriving(Eq, Show)
+
+
+-- | The paint.
+data Paint =
+ SolidColor -- ^
+ | Pattern -- ^
+ | Gradient -- ^
+ deriving(Eq, Show)
+
+
+-- | A class for shape-like data structures.
+class ShapeLike a where
+ convertToShape :: a -> Shape -- ^
+
+
+-- | Shapes
+data Shape =
+ ShapeCircle Vector2d Double -- ^ c, r
+ | ShapeEllipse Vector2d Double Double -- ^ c, rx, ry
+ | ShapeGroup [Shape] -- ^
+ | ShapePath Path -- ^
+ | ShapeRectangle Vector2d Double Double -- ^ tl, w, h
+ | ShapeRegularPolygon Int Vector2d Double Double -- ^ edges, c, r, angle
+ | ShapeText -- ^
+ deriving(Eq, Show)
+
+instance ShapeLike Shape where
+ convertToShape x = x
+
+
+-- | Converts a shape to path segments.
+convertToPath :: Shape -> Path -- ^
+convertToPath _ = error "implement"
+
+
+-- | Segment orientation.
+data Orientation =
+ ClockWise
+ | CounterClockWise
+ deriving (Eq, Show)
+
+
+-- | Path.
+data Path = Path [[Segment]] deriving (Eq, Show)
+
+
+-- | Path segments.
+data Segment =
+ Close Vector2d Vector2d -- ^ x0, x1
+ | CubicBezier Vector2d Vector2d Vector2d Vector2d -- ^ x0, x1, x2, x3
+-- | SegmentEllipticalArc -- ^ x, rx, ry, c ???
+-- See http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
+ | HorizontalLine Vector2d Double -- ^ x, w
+ | Line Vector2d Vector2d -- ^ x0, x1
+ | QuadraticBezier Vector2d Vector2d Vector2d -- ^ x0, x1, x2
+ | VerticalLine Vector2d Double -- ^ x, h
+ deriving (Eq, Show)
+
+
+-- | Calculates the segment arc length.
+arcLength :: Segment -> Double
+--
+arcLength (Close x0 x1) = length $ x1 .- x0
+arcLength (CubicBezier x0 x1 x2 x3) = error "implement"
+--arcLength (SegmentEllipticalArc x0 x1 x2 x3) = error "implement"
+arcLength (HorizontalLine x w) = w
+arcLength (Line x0 x1) = length $ x1 .- x0
+arcLength (QuadraticBezier x0 x1 x2) = error "implement"
+arcLength (VerticalLine x h) = h
+
+
+-- | Converts special line segments to "Line".
+linesToSegmentLine :: Segment -> Segment
+--
+linesToSegmentLine (HorizontalLine x w) = Line x ( x .+ (Vector2d w 0) )
+linesToSegmentLine (VerticalLine x h) = Line x ( x .+ (Vector2d 0 h) )
+linesToSegmentLine s = s
+
+
+infixl 7 .*
+infixl 7 ./
+infixl 6 .+
+infixl 6 .-
+
+-- | A class for vector-like data.
+class VectorLike a where
+ (.+) :: a -> a -> a
+ (.-) :: a -> a -> a
+ (.*) :: Double -> a -> a
+ (./) :: a -> Double -> a
+ invert :: a -> a
+ length :: a -> Double
+ normalize :: a -> a
+ normalize v = v ./ (length v)
+
+
+-- | 2-dimensional coordinates for graphical paths.
+data Vector2d = Vector2d Double Double deriving (Eq, Show)
+
+instance VectorLike Vector2d where
+ (.+) (Vector2d x1 y1) (Vector2d x2 y2) = Vector2d (x1+x2) (y1+y2)
+ (.-) (Vector2d x1 y1) (Vector2d x2 y2) = Vector2d (x1-x2) (y1-y2)
+ (.*) s (Vector2d x y) = Vector2d (s*x) (s*y)
+ (./) (Vector2d x y) s = Vector2d (x/s) (y/s)
+ invert (Vector2d x y) = Vector2d (-x) (-y)
+ length (Vector2d x y) = sqrt(x*x + y*y)
+
+
+-- | 3-dimensional coordinates for graphical paths.
+data Vector3d = Vector3d Double Double Double deriving (Eq, Show)
+
+instance VectorLike Vector3d where
+ (.+) (Vector3d x1 y1 z1) (Vector3d x2 y2 z2) = Vector3d (x1+x2) (y1+y2) (z1+z2)
+ (.-) (Vector3d x1 y1 z1) (Vector3d x2 y2 z2) = Vector3d (x1-x2) (y1-y2) (z1-z2)
+ (.*) s (Vector3d x y z) = Vector3d (s*x) (s*y) (s*z)
+ (./) (Vector3d x y z) s = Vector3d (x/s) (y/s) (z/s)
+ invert (Vector3d x y z) = Vector3d (-x) (-y) (-z)
+ length (Vector3d x y z) = sqrt(x*x + y*y + z*z)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-09-23 19:27:48
|
Revision: 565
http://chlor.svn.sourceforge.net/chlor/?rev=565&view=rev
Author: floi
Date: 2008-09-23 19:27:26 +0000 (Tue, 23 Sep 2008)
Log Message:
-----------
Methods reordered.
Modified Paths:
--------------
trunk/src/tools/CTool.h
trunk/src/tools/CTool.m
Modified: trunk/src/tools/CTool.h
===================================================================
--- trunk/src/tools/CTool.h 2008-09-09 05:11:12 UTC (rev 564)
+++ trunk/src/tools/CTool.h 2008-09-23 19:27:26 UTC (rev 565)
@@ -59,6 +59,11 @@
- (BOOL) controlKeyIsDown;
/**
+ * Returns YES when the Shift key is down.
+ */
+- (BOOL) shiftKeyIsDown;
+
+/**
* This method is called when the tool gets deactivated.
*/
- (void) deactivate;
@@ -104,11 +109,6 @@
- (void) setView: (ChlorMainView*) theView;
/**
- * Returns YES when the Shift key is down.
- */
-- (BOOL) shiftKeyIsDown;
-
-/**
* Updates the internal state variables.
*/
- (void) updateInternalState;
Modified: trunk/src/tools/CTool.m
===================================================================
--- trunk/src/tools/CTool.m 2008-09-09 05:11:12 UTC (rev 564)
+++ trunk/src/tools/CTool.m 2008-09-23 19:27:26 UTC (rev 565)
@@ -42,6 +42,11 @@
return ( m_modifierKeysStatus & NSControlKeyMask ) == NSControlKeyMask;
}
+- (BOOL) shiftKeyIsDown
+{
+ return ( m_modifierKeysStatus & NSShiftKeyMask ) == NSShiftKeyMask;
+}
+
- (void) deactivate
{
}
@@ -104,11 +109,6 @@
m_view = theView;
}
-- (BOOL) shiftKeyIsDown
-{
- return ( m_modifierKeysStatus & NSShiftKeyMask ) == NSShiftKeyMask;
-}
-
- (void) updateInternalState
{
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-09-09 05:11:14
|
Revision: 564
http://chlor.svn.sourceforge.net/chlor/?rev=564&view=rev
Author: floi
Date: 2008-09-09 05:11:12 +0000 (Tue, 09 Sep 2008)
Log Message:
-----------
SVG importer scans the SvgViewBox correctly.
Modified Paths:
--------------
trunk/src/io/svg/import/core/CSvgDataTypes.h
trunk/src/io/svg/import/core/CSvgScanner.h
trunk/src/io/svg/import/core/CSvgScanner.m
trunk/src/io/svg/import/elements/CSvgDocument.m
Modified: trunk/src/io/svg/import/core/CSvgDataTypes.h
===================================================================
--- trunk/src/io/svg/import/core/CSvgDataTypes.h 2008-07-09 05:12:46 UTC (rev 563)
+++ trunk/src/io/svg/import/core/CSvgDataTypes.h 2008-09-09 05:11:12 UTC (rev 564)
@@ -39,4 +39,15 @@
{
CSvgUnit unit;
double val;
-} CSvgLength;
\ No newline at end of file
+} CSvgLength;
+
+/**
+ * @brief A SVG viewBox.
+ */
+typedef struct
+{
+ double x;
+ double y;
+ double width;
+ double height;
+} CSvgViewBox;
\ No newline at end of file
Modified: trunk/src/io/svg/import/core/CSvgScanner.h
===================================================================
--- trunk/src/io/svg/import/core/CSvgScanner.h 2008-07-09 05:12:46 UTC (rev 563)
+++ trunk/src/io/svg/import/core/CSvgScanner.h 2008-09-09 05:11:12 UTC (rev 564)
@@ -38,6 +38,13 @@
into: (float*) theFloat;
/**
+ * Scans a SVG view box from the given string.
+ */
++ (BOOL)
+ scanViewBoxFromString: (NSString *) theString
+ into: (CSvgViewBox*) theViewBox;
+
+/**
* Scans a SVG length from the given string.
*/
+ (BOOL)
Modified: trunk/src/io/svg/import/core/CSvgScanner.m
===================================================================
--- trunk/src/io/svg/import/core/CSvgScanner.m 2008-07-09 05:12:46 UTC (rev 563)
+++ trunk/src/io/svg/import/core/CSvgScanner.m 2008-09-09 05:11:12 UTC (rev 564)
@@ -454,6 +454,46 @@
}
+ (BOOL)
+ scanViewBoxFromString: (NSString *) theString
+ into: (CSvgViewBox*) theViewBox
+{
+ float tmpFloat;
+
+ // Create a string scanner.
+ NSScanner* scanner = [[NSScanner scannerWithString: theString] retain];
+
+ // Prefill with sensual values.
+ theViewBox->x = 0.0;
+ theViewBox->y = 0.0;
+ theViewBox->width = 0.0;
+ theViewBox->height = 0.0;
+
+ // Scan the first float as x.
+ if( [scanner scanFloat: &tmpFloat] )
+ {
+ theViewBox->x = tmpFloat;
+ if( [scanner scanFloat: &tmpFloat] )
+ {
+ theViewBox->y = tmpFloat;
+ if( [scanner scanFloat: &tmpFloat] )
+ {
+ theViewBox->width = tmpFloat;
+ if( [scanner scanFloat: &tmpFloat] )
+ {
+ theViewBox->height = tmpFloat;
+ // Release the string scanner.
+ [scanner release];
+ return YES;
+ }
+ }
+ }
+ }
+ // Release the string scanner.
+ [scanner release];
+ return NO;
+}
+
++ (BOOL)
scanLengthFromString: (NSString*) theString
into: (CSvgLength*) theLength;
{
Modified: trunk/src/io/svg/import/elements/CSvgDocument.m
===================================================================
--- trunk/src/io/svg/import/elements/CSvgDocument.m 2008-07-09 05:12:46 UTC (rev 563)
+++ trunk/src/io/svg/import/elements/CSvgDocument.m 2008-09-09 05:11:12 UTC (rev 564)
@@ -121,7 +121,13 @@
[CSvgScanner scanLengthFromString: attribute into: &m_height];
if( ( attribute = [theAttributes objectForKey: @"viewBox"] ) )
- NSLog( @"TODO: CSvgDocument parseDocumentAttributesFrom: attribute \"viewBox\"!" );
+ {
+ CSvgViewBox aViewBox;
+ [CSvgScanner scanViewBoxFromString: attribute into: &aViewBox];
+ m_width.val = aViewBox.width;
+ m_height.val = aViewBox.height;
+ NSLog( @"TODO: Complete CSvgDocument parseDocumentAttributesFrom: attribute \"viewBox\"!" );
+ }
}
@end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-07-09 05:12:51
|
Revision: 563
http://chlor.svn.sourceforge.net/chlor/?rev=563&view=rev
Author: floi
Date: 2008-07-08 22:12:46 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
We consume mouse-Up events and thus avoid, that they're passed to the main controller (ChlorMainController).
Modified Paths:
--------------
trunk/src/gui/CColorSelectView.m
Modified: trunk/src/gui/CColorSelectView.m
===================================================================
--- trunk/src/gui/CColorSelectView.m 2008-07-08 19:33:30 UTC (rev 562)
+++ trunk/src/gui/CColorSelectView.m 2008-07-09 05:12:46 UTC (rev 563)
@@ -180,6 +180,14 @@
[[NSColorPanel sharedColorPanel] makeKeyAndOrderFront: self];
}
+- (void) mouseUp: (NSEvent*) theEvent
+{
+ // We consume that one.
+ // This avoids passing the event to ChlorMainController, which can cause funny
+ // things there.
+}
+
+
@end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-07-08 19:34:34
|
Revision: 562
http://chlor.svn.sourceforge.net/chlor/?rev=562&view=rev
Author: floi
Date: 2008-07-08 12:33:30 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
BUG resolved: shift dragging while one object is selected moves the object even when clicked/dragged is outside of it.
Modified Paths:
--------------
trunk/src/tools/CSelectionTool.m
Modified: trunk/src/tools/CSelectionTool.m
===================================================================
--- trunk/src/tools/CSelectionTool.m 2008-07-08 19:28:34 UTC (rev 561)
+++ trunk/src/tools/CSelectionTool.m 2008-07-08 19:33:30 UTC (rev 562)
@@ -105,8 +105,6 @@
// Add the found objects to the document selection.
[selection addObjectsFromArray: [findVisior objects]];
- // Release the find visitor.
- [findVisior release];
// The document selection is empty.
if( [[selection objects] count] < 1 )
@@ -117,9 +115,19 @@
// The document selection is not empty.
else
{
- // Activate the object moving state.
- m_activeState = [CSelectionToolMoveState sharedSelectionToolMoveObjectsState];
+ // Nothing found at the mouse position
+ if( [[findVisior objects] count] < 1 )
+ {
+ // Activate the object selection state.
+ m_activeState = [CSelectionToolRectangleState sharedSelectionToolSelectState];
+ } else {
+ // Activate the object moving state.
+ m_activeState = [CSelectionToolMoveState sharedSelectionToolMoveObjectsState];
+ }
}
+
+ // Release the find visitor.
+ [findVisior release];
}
// Activate and recalculate the current state.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-07-08 19:30:44
|
Revision: 561
http://chlor.svn.sourceforge.net/chlor/?rev=561&view=rev
Author: floi
Date: 2008-07-08 12:28:34 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
CRect runs with float values, all other object of chlor run with doubles. With that, the bounding box can get in some cases smaller than the actual graphic inside.
Algorithms, which rely on the property, that everything is truly inside, get in trouble. A prominent example is the algorithm to check for "insideness". It calculates the intersections of a line from the point in questions to the right border of the bounding box. As the latter may be smaller, the algorithm can't detect the insideness.
Three solutions:
a) Adapt the "insideness" algorithm - quick fix, but the problem may remain unnoticed in other areas.
b) Add methods to CRect to add coordinates in double precision.
c) Rewrite CRect completly with double precision.
Solution a) seems to be currently superior, as we wont break other implementations.
Modified Paths:
--------------
trunk/src/core/CPath.m
Modified: trunk/src/core/CPath.m
===================================================================
--- trunk/src/core/CPath.m 2008-05-15 19:53:15 UTC (rev 560)
+++ trunk/src/core/CPath.m 2008-07-08 19:28:34 UTC (rev 561)
@@ -313,8 +313,14 @@
numberOfIntersections +=
[segment numberOfIntersectionsWithLineX1: x
y1: y
- x2: [shapeBoundary right]
+ x2: nextafterf([shapeBoundary right], [shapeBoundary right] +1)
y2: y];
+ // The shapeBoundary is stored in a CRect, which uses float to store
+ // the coordinates. When converting doubles (from the "rest of the Chlor-world"
+ // some roundoff happens. In some cases, the shapeBoundary gets a little
+ // smaller than it should be, causing this code to fail.
+ // To get on the safe side, we use next bigger representable float
+ // number here.
}
// The point (x,y) lies inside the path if the number of segment intersections with the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-05-15 19:54:21
|
Revision: 560
http://chlor.svn.sourceforge.net/chlor/?rev=560&view=rev
Author: floi
Date: 2008-05-15 12:53:15 -0700 (Thu, 15 May 2008)
Log Message:
-----------
Additional intersection test - values are taken from a box which was resized within chlor, afterwards it is not selectable anymore. Reason is, this intersection test fails.
Modified Paths:
--------------
trunk/src/tests/CGeometryTest.m
Modified: trunk/src/tests/CGeometryTest.m
===================================================================
--- trunk/src/tests/CGeometryTest.m 2008-05-11 19:01:45 UTC (rev 559)
+++ trunk/src/tests/CGeometryTest.m 2008-05-15 19:53:15 UTC (rev 560)
@@ -135,5 +135,13 @@
@"Intersection not hit");
}
+- (void) testLineIntersection5
+{
+ STAssertTrue(
+ [CGeometry lineX1: 462.69544315338135 y1: 224.31506991386414 x2: 462.69544315338135 y2: 415.0
+ intersectsWithLineX1: 351.0 y1: 308.0 x2: 462.6954345703125 y2: 308.0],
+ @"Intersection not hit");
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2008-05-11 19:01:56
|
Revision: 559
http://chlor.svn.sourceforge.net/chlor/?rev=559&view=rev
Author: floi
Date: 2008-05-11 12:01:45 -0700 (Sun, 11 May 2008)
Log Message:
-----------
Resize of the selection now scales correctly.
(Using the [selection rectangle] instead of [selection shapeBoundary])
Modified Paths:
--------------
trunk/src/tools/CSelectionToolResizeState.m
Modified: trunk/src/tools/CSelectionToolResizeState.m
===================================================================
--- trunk/src/tools/CSelectionToolResizeState.m 2007-06-10 14:52:39 UTC (rev 558)
+++ trunk/src/tools/CSelectionToolResizeState.m 2008-05-11 19:01:45 UTC (rev 559)
@@ -155,40 +155,40 @@
// With that position we compute the origin
switch( handlePosition ) {
case CSelection_TopLeft:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] right],
- [[mySelection shapeBoundary] bottom]);
+ handlePoint = NSMakePoint( CGRectGetMaxX([mySelection rectangle]), /* right */
+ CGRectGetMinY([mySelection rectangle])); /* bottom */
break;
case CSelection_Top:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] centerX],
- [[mySelection shapeBoundary] bottom]);
+ handlePoint = NSMakePoint( CGRectGetMidX([mySelection rectangle]), /* centerX */
+ CGRectGetMinY([mySelection rectangle])); /* bottom */
ignoreX = YES;
break;
case CSelection_TopRight:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] left],
- [[mySelection shapeBoundary] bottom]);
+ handlePoint = NSMakePoint( CGRectGetMinX([mySelection rectangle]), /* left */
+ CGRectGetMinY([mySelection rectangle])); /* bottom */
break;
case CSelection_Left:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] right],
- [[mySelection shapeBoundary] centerY]);
+ handlePoint = NSMakePoint( CGRectGetMaxX([mySelection rectangle]), /* right */
+ CGRectGetMidY([mySelection rectangle])); /* centerY */
ignoreY = YES;
break;
case CSelection_Right:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] left],
- [[mySelection shapeBoundary] centerY]);
+ handlePoint = NSMakePoint( CGRectGetMinX([mySelection rectangle]), /* left */
+ CGRectGetMidY([mySelection rectangle])); /* centerY */
ignoreY = YES;
break;
case CSelection_BottomLeft:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] right],
- [[mySelection shapeBoundary] top]);
+ handlePoint = NSMakePoint( CGRectGetMaxX([mySelection rectangle]), /* right */
+ CGRectGetMaxY([mySelection rectangle])); /* top */
break;
case CSelection_Bottom:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] centerX],
- [[mySelection shapeBoundary] top]);
+ handlePoint = NSMakePoint( CGRectGetMidX([mySelection rectangle]), /* centerX */
+ CGRectGetMaxY([mySelection rectangle])); /* top */
ignoreX = YES;
break;
case CSelection_BottomRight:
- handlePoint = NSMakePoint([[mySelection shapeBoundary] left],
- [[mySelection shapeBoundary] top]);
+ handlePoint = NSMakePoint( CGRectGetMinX([mySelection rectangle]), /* left */
+ CGRectGetMaxY([mySelection rectangle])); /* top */
break;
default:
// UUUps, why do we end here?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-10 14:52:41
|
Revision: 558
http://svn.sourceforge.net/chlor/?rev=558&view=rev
Author: lenny222
Date: 2007-06-10 07:52:39 -0700 (Sun, 10 Jun 2007)
Log Message:
-----------
add line tool stub
Modified Paths:
--------------
trunk/src/Chlor.xcodeproj/project.pbxproj
trunk/src/English.lproj/Help/index.html
trunk/src/English.lproj/MainMenu.nib/info.nib
trunk/src/English.lproj/MainMenu.nib/objects.nib
trunk/src/notes/TODO.txt
Added Paths:
-----------
trunk/src/tools/CLineTool.h
trunk/src/tools/CLineTool.m
Modified: trunk/src/Chlor.xcodeproj/project.pbxproj
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/Help/index.html
===================================================================
--- trunk/src/English.lproj/Help/index.html 2007-06-03 20:22:35 UTC (rev 557)
+++ trunk/src/English.lproj/Help/index.html 2007-06-10 14:52:39 UTC (rev 558)
@@ -6,6 +6,6 @@
<body>
<h1>Chlor Help</h1>
<p>Chlor is an Open Source vector graphics editor. It is work in progress. We
-are always looking got volunteers helping out.</p>
+are always looking for volunteers helping out.</p>
</body>
</html>
\ No newline at end of file
Modified: trunk/src/English.lproj/MainMenu.nib/info.nib
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/MainMenu.nib/objects.nib
===================================================================
(Binary files differ)
Modified: trunk/src/notes/TODO.txt
===================================================================
--- trunk/src/notes/TODO.txt 2007-06-03 20:22:35 UTC (rev 557)
+++ trunk/src/notes/TODO.txt 2007-06-10 14:52:39 UTC (rev 558)
@@ -1,6 +1,8 @@
User experience
---------------
-- TODO: add polyline tool
+- BUG: Chlor SVGs can be loaded in Chlor but the objects appar sevearley translated in Inkscape and Squiggle
+- BUG: Command A is not shown in Chlor for Select->All, while it is present in InterfaceBuilder
+- TODO: add line tool
- TODO: add affine transformation and properties palette
- BUG: shift dragging while one object is selected moves the object even when clicked/dragged is outside of it
- TODO: add keyboard short cuts like <Backspace> which deletes the selected objects and <Esc> which cancels the current tool
Added: trunk/src/tools/CLineTool.h
===================================================================
--- trunk/src/tools/CLineTool.h (rev 0)
+++ trunk/src/tools/CLineTool.h 2007-06-10 14:52:39 UTC (rev 558)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CTool.h"
+
+@interface CLineTool : CTool
+{
+}
+
+@end
Property changes on: trunk/src/tools/CLineTool.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/tools/CLineTool.m
===================================================================
--- trunk/src/tools/CLineTool.m (rev 0)
+++ trunk/src/tools/CLineTool.m 2007-06-10 14:52:39 UTC (rev 558)
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CLineTool.h"
+
+
+@implementation CLineTool
+
+@end
Property changes on: trunk/src/tools/CLineTool.m
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 20:22:40
|
Revision: 557
http://svn.sourceforge.net/chlor/?rev=557&view=rev
Author: lenny222
Date: 2007-06-03 13:22:35 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
add a functional Select menu
Modified Paths:
--------------
trunk/src/English.lproj/MainMenu.nib/classes.nib
trunk/src/English.lproj/MainMenu.nib/info.nib
trunk/src/English.lproj/MainMenu.nib/objects.nib
trunk/src/core/ChlorDocument.h
trunk/src/core/ChlorDocument.m
trunk/src/gui/ChlorMainController.h
trunk/src/gui/ChlorMainController.m
trunk/src/notes/Read Me!.rtf
Modified: trunk/src/English.lproj/MainMenu.nib/classes.nib
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/MainMenu.nib/info.nib
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/MainMenu.nib/objects.nib
===================================================================
(Binary files differ)
Modified: trunk/src/core/ChlorDocument.h
===================================================================
--- trunk/src/core/ChlorDocument.h 2007-06-03 16:51:11 UTC (rev 556)
+++ trunk/src/core/ChlorDocument.h 2007-06-03 20:22:35 UTC (rev 557)
@@ -84,34 +84,39 @@
- (CGColorSpaceRef) colorSpace;
/**
+ * Deletes the selected objects from the document.
+ */
+- (void) deleteSelectedObjects;
+
+/**
+ * Deselects all objects.
+ */
+- (void) deselectAllObjects;
+
+/**
* Returns the document height.
*/
- (double) height;
/**
- * Returns the layers.
+ * Returns the document layers.
*/
- (CLayers*) layers;
-
/**
* Returns the document page.
*/
- (CPage*) page;
/**
- * Transforms the the selceted objects with the given map.
- * This is an operation with undo-capabilities.
+ * Selects all objects from the document.
*/
-- (void) transformSelectionFirstBy: (CAffineMap*) map1
- thenBy: (CAffineMap*) map2
- actionName: (NSString*) undoString;
+- (void) selectAllObjects;
/**
- * Deletes the selected objects from the document. This is an operation with
- * undo-capabilities.
+ * Selects all objects from the document which are not selected and deselect the selected.
*/
-- (void) deleteSelection;
+- (void) selectAllNotSelectedObjects;
/**
* Returns the selection.
@@ -129,6 +134,14 @@
- (void) setWidth: (double) theWidth;
/**
+ * Transforms the the selceted objects with the given map.
+ * This is an operation with undo-capabilities.
+ */
+- (void) transformSelectionFirstBy: (CAffineMap*) map1
+ thenBy: (CAffineMap*) map2
+ actionName: (NSString*) undoString;
+
+/**
* Returns the document width.
*/
- (double) width;
Modified: trunk/src/core/ChlorDocument.m
===================================================================
--- trunk/src/core/ChlorDocument.m 2007-06-03 16:51:11 UTC (rev 556)
+++ trunk/src/core/ChlorDocument.m 2007-06-03 20:22:35 UTC (rev 557)
@@ -45,68 +45,6 @@
#import "CSolidPaint.h"
@implementation ChlorDocument
-
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- // Create an initial color space.
- m_colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
-
- // Create the layers.
- m_layers = [[CLayers alloc] init];
-
-#if 0
-// Add a temporary welcome text.
-{
- CText* text = [[CText alloc] init];
- CSolidPaint* paint = [[CSolidPaint alloc] init];
- {
- float components[ 4 ] = { 0.0, 0.0, 0.0, 1.0 };
- CGColorRef color = CGColorCreate( m_colorSpace, components );
- [paint setColor: color];
- CGColorRelease( color );
- }
-
- CFill* fill = [[CFill alloc] init];
- [fill setPaint: [paint autorelease]];
- [text setFill: [fill autorelease]];
-
- // Set the the Chlor text origin.
- [text setOrigin: [CPoint pointWithX: 200.0 y: 200.0]];
- [text setString: @"Welcome"];
-
- [[m_layers activeLayer] addObject: [text autorelease]];
-}
-#endif
-
- // Create the page.
- m_page = [[CPage alloc] initWithDocument: self];
-
- // Create the selection.
- m_selection = [[CSelection alloc] initWithDocument: self];
-
- // Get the preferred document width and height from the preferences.
- m_height = [[ChlorPreferences sharedPreferences] documentHeight];
- m_width = [[ChlorPreferences sharedPreferences] documentWidth];
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver: self];
-
- [m_page release];
- [m_selection release];
- [m_layers release];
- CGColorSpaceRelease( m_colorSpace );
- [super dealloc];
-}
-
- (void) addObject: (CObject*) anObject
{
// Set the fill and stroke from the ChlorApplication.
@@ -233,11 +171,130 @@
return [data autorelease];
}
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+
+ [m_page release];
+ [m_selection release];
+ [m_layers release];
+ CGColorSpaceRelease( m_colorSpace );
+ [super dealloc];
+}
+
+- (void) deleteSelectedObjects
+{
+ if( [[[self selection] objects] count] < 1 )
+ return;
+
+ // Create the target array for the z-order
+ NSMutableIndexSet* zOrder = [[NSMutableIndexSet alloc] init];
+
+ {
+ // Retrieve the z-order.
+ unsigned int localIndex;
+
+ // Iterate over all elements in otherGroup
+ NSEnumerator* enumerator = [[[self selection] objects] objectEnumerator];
+ id object;
+
+ while( object = [enumerator nextObject] )
+ {
+ // Get index of iterated element within its own array
+ localIndex = [[[[self layers] activeLayer] objects] indexOfObject: object];
+
+ if( localIndex != NSNotFound )
+ {
+ //The found index is the z-order, add it to the to-be-returned array
+ [zOrder addIndex: localIndex];
+ }
+ else
+ {
+ NSLog( @"Errrm! CGroup zOrderOfGroup strangeness" );
+ }
+ }
+ }
+
+ // Register the undo action.
+ // TODO: do we really want to create a deep copy of the selction here?
+ [[[self undoManager]
+ prepareWithInvocationTarget: self]
+ addObjects: [[[self selection] objects] copyWithZone:[self zone]] withZOrder: zOrder];
+
+ // Remove the selection from the active layer
+ [[[self layers] activeLayer] removeObjects: [[self selection] objects]];
+
+ // Set the undo/redo name.
+ [[self undoManager] setActionName:
+ NSLocalizedString(
+ @"Delete Objects",
+ @"Name of undo/redo action for deleted objects" )];
+
+ // The selection should be empty now.
+ [m_selection clear];
+}
+
+- (void) deselectAllObjects
+{
+ // Clear the selection.
+ [m_selection clear];
+}
+
- (double) height
{
return m_height;
}
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ // Create an initial color space.
+ m_colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
+
+ // Create the layers.
+ m_layers = [[CLayers alloc] init];
+
+#if 0
+// Add a temporary welcome text.
+{
+ CText* text = [[CText alloc] init];
+ CSolidPaint* paint = [[CSolidPaint alloc] init];
+ {
+ float components[ 4 ] = { 0.0, 0.0, 0.0, 1.0 };
+ CGColorRef color = CGColorCreate( m_colorSpace, components );
+ [paint setColor: color];
+ CGColorRelease( color );
+ }
+
+ CFill* fill = [[CFill alloc] init];
+ [fill setPaint: [paint autorelease]];
+ [text setFill: [fill autorelease]];
+
+ // Set the the Chlor text origin.
+ [text setOrigin: [CPoint pointWithX: 200.0 y: 200.0]];
+ [text setString: @"Welcome"];
+
+ [[m_layers activeLayer] addObject: [text autorelease]];
+}
+#endif
+
+ // Create the page.
+ m_page = [[CPage alloc] initWithDocument: self];
+
+ // Create the selection.
+ m_selection = [[CSelection alloc] initWithDocument: self];
+
+ // Get the preferred document width and height from the preferences.
+ m_height = [[ChlorPreferences sharedPreferences] documentHeight];
+ m_width = [[ChlorPreferences sharedPreferences] documentWidth];
+ }
+
+ return self;
+}
+
- (CLayers*) layers
{
return m_layers;
@@ -330,56 +387,35 @@
[map2 release]; // TODO: Really needed?
}
-- (void) deleteSelection
+- (void) selectAllObjects
{
- if( [[[self selection] objects] count] < 1 )
- return;
+ // Clear the selection.
+ [m_selection clear];
- // Create the target array for the z-order
- NSMutableIndexSet* zOrder = [[NSMutableIndexSet alloc] init];
+ // Iterate over all layers.
+ NSEnumerator* enumerator = [[m_layers objects] objectEnumerator];
+ CLayer* layer;
+ while( layer = [enumerator nextObject] )
{
- // Retrieve the z-order.
- unsigned int localIndex;
-
- // Iterate over all elements in otherGroup
- NSEnumerator* enumerator = [[[self selection] objects] objectEnumerator];
- id object;
-
- while( object = [enumerator nextObject] )
- {
- // Get index of iterated element within its own array
- localIndex = [[[[self layers] activeLayer] objects] indexOfObject: object];
-
- if( localIndex != NSNotFound )
- {
- //The found index is the z-order, add it to the to-be-returned array
- [zOrder addIndex: localIndex];
- }
- else
- {
- NSLog( @"Errrm! CGroup zOrderOfGroup strangeness" );
- }
- }
+ // Add all objects in the current layer to the selection.
+ [m_selection addObjectsFromArray: [layer objects]];
}
+}
+
+- (void) selectAllNotSelectedObjects
+{
+ // Copy the list of selected objects.
+ NSArray* copy = [[m_selection objects] copy];
- // Register the undo action.
- // TODO: do we really want to create a deep copy of the selction here?
- [[[self undoManager]
- prepareWithInvocationTarget: self]
- addObjects: [[[self selection] objects] copyWithZone:[self zone]] withZOrder: zOrder];
+ // Select all objects.
+ [self selectAllObjects];
- // Remove the selection from the active layer
- [[[self layers] activeLayer] removeObjects: [[self selection] objects]];
+ // Deselect all former selected objects.
+ [m_selection removeObjects: copy];
- // Set the undo/redo name.
- [[self undoManager] setActionName:
- NSLocalizedString(
- @"Delete Objects",
- @"Name of undo/redo action for deleted objects" )];
-
- // The selection should be empty now.
- [m_selection clear];
+ // Release the copied list.
+ [copy release];
}
- (CSelection*) selection
Modified: trunk/src/gui/ChlorMainController.h
===================================================================
--- trunk/src/gui/ChlorMainController.h 2007-06-03 16:51:11 UTC (rev 556)
+++ trunk/src/gui/ChlorMainController.h 2007-06-03 20:22:35 UTC (rev 557)
@@ -32,6 +32,21 @@
}
/**
+ * Selects all objects.
+ */
+- (IBAction) actionSelectAll: (id) theSender;
+
+/**
+ * Inverts the document selection.
+ */
+- (IBAction) actionSelectInverse: (id) theSender;
+
+/**
+ * Clears the selection.
+ */
+- (IBAction) actionSelectNone: (id) theSender;
+
+/**
* Invalidates the drawing area of anObject within the main window.
*/
- (void) invalidateObject: (CObject*) anObject;
Modified: trunk/src/gui/ChlorMainController.m
===================================================================
--- trunk/src/gui/ChlorMainController.m 2007-06-03 16:51:11 UTC (rev 556)
+++ trunk/src/gui/ChlorMainController.m 2007-06-03 20:22:35 UTC (rev 557)
@@ -28,6 +28,24 @@
@implementation ChlorMainController
+- (IBAction) actionSelectAll: (id) theSender
+{
+ ChlorDocument* document = [self document];
+ [document selectAllObjects];
+}
+
+- (IBAction) actionSelectInverse: (id) theSender
+{
+ ChlorDocument* document = [self document];
+ [document selectAllNotSelectedObjects];
+}
+
+- (IBAction) actionSelectNone: (id) theSender
+{
+ ChlorDocument* document = [self document];
+ [document deselectAllObjects];
+}
+
- (id) init
{
self = [self initWithWindowNibName: @"MainWindow"];
Modified: trunk/src/notes/Read Me!.rtf
===================================================================
--- trunk/src/notes/Read Me!.rtf 2007-06-03 16:51:11 UTC (rev 556)
+++ trunk/src/notes/Read Me!.rtf 2007-06-03 20:22:35 UTC (rev 557)
@@ -48,7 +48,7 @@
\fs28 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
-\f1\b0\fs24 \cf0 \ulnone *
+\f1\b0\fs24 \cf0 \ulnone * added the "Select" menu with "Select All", "Select None", "Select Invert"
\f0\b\fs28 \ul \
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 16:51:15
|
Revision: 556
http://svn.sourceforge.net/chlor/?rev=556&view=rev
Author: lenny222
Date: 2007-06-03 09:51:11 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
add some menu items
Modified Paths:
--------------
trunk/src/Chlor.xcodeproj/project.pbxproj
trunk/src/English.lproj/EditPalette.nib/keyedobjects.nib
trunk/src/English.lproj/MainMenu.nib/info.nib
trunk/src/English.lproj/MainMenu.nib/objects.nib
trunk/src/gui/CColorSelectView.m
trunk/src/gui/CEditPaletteController.m
trunk/src/gui/CToolPaletteController.m
Modified: trunk/src/Chlor.xcodeproj/project.pbxproj
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/EditPalette.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/MainMenu.nib/info.nib
===================================================================
(Binary files differ)
Modified: trunk/src/English.lproj/MainMenu.nib/objects.nib
===================================================================
(Binary files differ)
Modified: trunk/src/gui/CColorSelectView.m
===================================================================
--- trunk/src/gui/CColorSelectView.m 2007-06-03 16:24:15 UTC (rev 555)
+++ trunk/src/gui/CColorSelectView.m 2007-06-03 16:51:11 UTC (rev 556)
@@ -180,4 +180,6 @@
[[NSColorPanel sharedColorPanel] makeKeyAndOrderFront: self];
}
+
+
@end
Modified: trunk/src/gui/CEditPaletteController.m
===================================================================
--- trunk/src/gui/CEditPaletteController.m 2007-06-03 16:24:15 UTC (rev 555)
+++ trunk/src/gui/CEditPaletteController.m 2007-06-03 16:51:11 UTC (rev 556)
@@ -53,4 +53,25 @@
[self showWindow: self];
}
+- (void) windowDidLoad
+{
+ [super windowDidLoad];
+
+ // Do not cascade the edit palette.
+ [self setShouldCascadeWindows: NO];
+
+ // Sets the name under which the window's frame is saved in the defaults database.
+ [self setWindowFrameAutosaveName: @"EditPalette"];
+
+ // Get the panel.
+ NSAssert(
+ [[self window] isKindOfClass: [NSPanel class]],
+ @"Edit window is not an NSPanel!" );
+
+ NSPanel* panel = (NSPanel*) [self window];
+
+ // The panel should not grab focus.
+ [panel setBecomesKeyOnlyIfNeeded: YES];
+}
+
@end
Modified: trunk/src/gui/CToolPaletteController.m
===================================================================
--- trunk/src/gui/CToolPaletteController.m 2007-06-03 16:24:15 UTC (rev 555)
+++ trunk/src/gui/CToolPaletteController.m 2007-06-03 16:51:11 UTC (rev 556)
@@ -180,20 +180,22 @@
// Do not cascade the tool palette.
[self setShouldCascadeWindows: NO];
+
// Sets the name under which the window's frame is saved in the defaults database.
[self setWindowFrameAutosaveName: @"ToolPalette"];
+
// Call setDocument: once.
[self setDocument: [self document]];
- // Get the tool panel.
+ // Get the panel.
NSAssert(
[[self window] isKindOfClass: [NSPanel class]],
@"Tool window is not an NSPanel!" );
- NSPanel* toolPanel = (NSPanel*) [self window];
+ NSPanel* panel = (NSPanel*) [self window];
- // The tool panel should not grab focus.
- [toolPanel setBecomesKeyOnlyIfNeeded: YES];
+ // The panel should not grab focus.
+ [panel setBecomesKeyOnlyIfNeeded: YES];
}
@end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 16:24:19
|
Revision: 555
http://svn.sourceforge.net/chlor/?rev=555&view=rev
Author: lenny222
Date: 2007-06-03 09:24:15 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
add nib
Added Paths:
-----------
trunk/src/English.lproj/EditPalette.nib/
trunk/src/English.lproj/EditPalette.nib/classes.nib
trunk/src/English.lproj/EditPalette.nib/info.nib
trunk/src/English.lproj/EditPalette.nib/keyedobjects.nib
Added: trunk/src/English.lproj/EditPalette.nib/classes.nib
===================================================================
--- trunk/src/English.lproj/EditPalette.nib/classes.nib (rev 0)
+++ trunk/src/English.lproj/EditPalette.nib/classes.nib 2007-06-03 16:24:15 UTC (rev 555)
@@ -0,0 +1,19 @@
+{
+ IBClasses = (
+ {CLASS = CColorSelectView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
+ {
+ ACTIONS = {activateToolAction = id; };
+ CLASS = CToolPaletteController;
+ LANGUAGE = ObjC;
+ OUTLETS = {"m_toolButtons" = NSMatrix; };
+ SUPERCLASS = NSWindowController;
+ },
+ {
+ ACTIONS = {"" = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+}
\ No newline at end of file
Added: trunk/src/English.lproj/EditPalette.nib/info.nib
===================================================================
--- trunk/src/English.lproj/EditPalette.nib/info.nib (rev 0)
+++ trunk/src/English.lproj/EditPalette.nib/info.nib 2007-06-03 16:24:15 UTC (rev 555)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IBDocumentLocation</key>
+ <string>23 277 356 240 0 0 1440 878 </string>
+ <key>IBFramework Version</key>
+ <string>446.1</string>
+ <key>IBOldestOS</key>
+ <integer>4</integer>
+ <key>IBOpenObjects</key>
+ <array>
+ <integer>5</integer>
+ </array>
+ <key>IBSystem Version</key>
+ <string>8P2137</string>
+</dict>
+</plist>
Added: trunk/src/English.lproj/EditPalette.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Property changes on: trunk/src/English.lproj/EditPalette.nib/keyedobjects.nib
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 16:20:46
|
Revision: 554
http://svn.sourceforge.net/chlor/?rev=554&view=rev
Author: lenny222
Date: 2007-06-03 09:20:44 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
add edit palette
Modified Paths:
--------------
trunk/src/Chlor.xcodeproj/project.pbxproj
trunk/src/gui/CToolPaletteController.m
trunk/src/gui/ChlorMainController.m
Added Paths:
-----------
trunk/src/gui/CEditPaletteController.h
trunk/src/gui/CEditPaletteController.m
Modified: trunk/src/Chlor.xcodeproj/project.pbxproj
===================================================================
(Binary files differ)
Added: trunk/src/gui/CEditPaletteController.h
===================================================================
--- trunk/src/gui/CEditPaletteController.h (rev 0)
+++ trunk/src/gui/CEditPaletteController.h 2007-06-03 16:20:44 UTC (rev 554)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+/**
+ * @brief The edit palette controller.
+ */
+@interface CEditPaletteController : NSWindowController
+{
+}
+
+/**
+ * Returns the shared edit palette controller.
+ */
++ (CEditPaletteController*) sharedEditPaletteController;
+
+/**
+ * Shows the edit palette.
+ */
+- (void) show;
+
+@end
Property changes on: trunk/src/gui/CEditPaletteController.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/gui/CEditPaletteController.m
===================================================================
--- trunk/src/gui/CEditPaletteController.m (rev 0)
+++ trunk/src/gui/CEditPaletteController.m 2007-06-03 16:20:44 UTC (rev 554)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CEditPaletteController.h"
+
+@implementation CEditPaletteController
+
+- (id) init
+{
+ self = [self initWithWindowNibName: @"EditPalette"];
+
+ if( self )
+ {
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
+}
+
++ (CEditPaletteController*) sharedEditPaletteController
+{
+ static CEditPaletteController* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CEditPaletteController alloc] init];
+
+ return s_instance;
+}
+
+- (void) show
+{
+ [self showWindow: self];
+}
+
+@end
Property changes on: trunk/src/gui/CEditPaletteController.m
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/gui/CToolPaletteController.m
===================================================================
--- trunk/src/gui/CToolPaletteController.m 2007-06-03 15:43:39 UTC (rev 553)
+++ trunk/src/gui/CToolPaletteController.m 2007-06-03 16:20:44 UTC (rev 554)
@@ -33,50 +33,6 @@
@implementation CToolPaletteController
-- (id) init
-{
- self = [self initWithWindowNibName: @"ToolPalette"];
-
- if( self )
- {
- // Activate the selection tool.
- m_activeTool = [CSelectionTool sharedSelectionTool];
- [m_activeTool activate];
-
- // Observe document activations.
- [[NSNotificationCenter defaultCenter]
- addObserver: self
- selector: @selector( documentWasActivated: )
- name: CDocumentActivateNotification
- object: nil];
-
- // Observe document deactivations.
- [[NSNotificationCenter defaultCenter]
- addObserver: self
- selector: @selector( documentWasDeactivated: )
- name: CDocumentDeactivateNotification
- object: nil];
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver: self];
- [super dealloc];
-}
-
-+ (CToolPaletteController*) sharedToolPaletteController
-{
- static CToolPaletteController* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CToolPaletteController alloc] init];
-
- return s_instance;
-}
-
- (IBAction) activateToolAction: (id) theSender
{
// Get the current next responder.
@@ -147,6 +103,12 @@
return m_activeTool;
}
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
+}
+
- (void) documentWasActivated: (NSNotification*) theNotification
{
[self setDocument: [theNotification object]];
@@ -157,6 +119,34 @@
[self setDocument: nil];
}
+- (id) init
+{
+ self = [self initWithWindowNibName: @"ToolPalette"];
+
+ if( self )
+ {
+ // Activate the selection tool.
+ m_activeTool = [CSelectionTool sharedSelectionTool];
+ [m_activeTool activate];
+
+ // Observe document activations.
+ [[NSNotificationCenter defaultCenter]
+ addObserver: self
+ selector: @selector( documentWasActivated: )
+ name: CDocumentActivateNotification
+ object: nil];
+
+ // Observe document deactivations.
+ [[NSNotificationCenter defaultCenter]
+ addObserver: self
+ selector: @selector( documentWasDeactivated: )
+ name: CDocumentDeactivateNotification
+ object: nil];
+ }
+
+ return self;
+}
+
- (void) setDocument: (NSDocument*) theDocument
{
[super setDocument: theDocument];
@@ -174,6 +164,16 @@
return [[m_toolButtons selectedCell] tag];
}
++ (CToolPaletteController*) sharedToolPaletteController
+{
+ static CToolPaletteController* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CToolPaletteController alloc] init];
+
+ return s_instance;
+}
+
- (void) windowDidLoad
{
[super windowDidLoad];
Modified: trunk/src/gui/ChlorMainController.m
===================================================================
--- trunk/src/gui/ChlorMainController.m 2007-06-03 15:43:39 UTC (rev 553)
+++ trunk/src/gui/ChlorMainController.m 2007-06-03 16:20:44 UTC (rev 554)
@@ -17,6 +17,7 @@
* $Id$
*/
+#import "CEditPaletteController.h"
#import "ChlorDocument.h"
#import "ChlorMainController.h"
#import "ChlorMainView.h"
@@ -103,6 +104,9 @@
// Show tool palette.
[[CToolPaletteController sharedToolPaletteController] show];
+
+ // Show edit palette.
+ [[CEditPaletteController sharedEditPaletteController] show];
}
- (void) windowDidBecomeMain: (NSNotification*) theNotification
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 15:44:06
|
Revision: 553
http://svn.sourceforge.net/chlor/?rev=553&view=rev
Author: lenny222
Date: 2007-06-03 08:43:39 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
simplify directory structure
Modified Paths:
--------------
trunk/src/Chlor.xcodeproj/project.pbxproj
trunk/src/Info.plist
trunk/src/notes/Developer Handbook.rtf
trunk/src/notes/Read Me!.rtf
trunk/src/notes/TODO.txt
Added Paths:
-----------
trunk/src/gui/CColorSelectView.h
trunk/src/gui/CColorSelectView.m
trunk/src/gui/CPasswordDialogController.h
trunk/src/gui/CPasswordDialogController.m
trunk/src/gui/CToolPaletteController.h
trunk/src/gui/CToolPaletteController.m
trunk/src/gui/ChlorMainController.h
trunk/src/gui/ChlorMainController.m
trunk/src/gui/ChlorMainView.h
trunk/src/gui/ChlorMainView.m
trunk/src/gui/ChlorMainWindow.h
trunk/src/gui/ChlorMainWindow.m
Removed Paths:
-------------
trunk/src/gui/controllers/
trunk/src/gui/views/
trunk/src/gui/windows/
Modified: trunk/src/Chlor.xcodeproj/project.pbxproj
===================================================================
(Binary files differ)
Modified: trunk/src/Info.plist
===================================================================
--- trunk/src/Info.plist 2007-06-03 15:39:04 UTC (rev 552)
+++ trunk/src/Info.plist 2007-06-03 15:43:39 UTC (rev 553)
@@ -170,7 +170,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>0.0.6</string>
+ <string>0.0.7</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Copied: trunk/src/gui/CColorSelectView.h (from rev 551, trunk/src/gui/views/CColorSelectView.h)
===================================================================
--- trunk/src/gui/CColorSelectView.h (rev 0)
+++ trunk/src/gui/CColorSelectView.h 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import <Cocoa/Cocoa.h>
+@class CPath;
+@class CRenderer;
+
+/**
+ * @brief The color selection view.
+ */
+@interface CColorSelectView : NSView
+{
+ /**
+ * The Chlor path which is used to draw the fill representation.
+ */
+ CPath* m_fillRepresentation;
+
+ /**
+ * The image used to draw the fill/stroke selector background.
+ */
+ CGImageRef m_image;
+
+ /**
+ * The Chlor path which is used to draw the stroke representation.
+ */
+ CPath* m_strokeRepresentation;
+}
+
+@end
Copied: trunk/src/gui/CColorSelectView.m (from rev 551, trunk/src/gui/views/CColorSelectView.m)
===================================================================
--- trunk/src/gui/CColorSelectView.m (rev 0)
+++ trunk/src/gui/CColorSelectView.m 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "ChlorApplication.h"
+#import "ChlorMainController.h"
+#import "CColorSelectView.h"
+#import "CFill.h"
+#import "CNotifications.h"
+#import "CPath.h"
+#import "CRenderer.h"
+#import "CShape.h"
+#import "CStroke.h"
+
+@implementation CColorSelectView
+
+- (id) initWithFrame: (NSRect) frameRect
+{
+ if( ( self = [super initWithFrame: frameRect] ) != nil )
+ {
+ // Get the application bundle.
+ CFBundleRef applicationBundle = CFBundleGetMainBundle();
+
+ // Convert the image file name.
+ CFStringRef imageFilename =
+ CFStringCreateWithCString(
+ NULL,
+ "fillstroke.png",
+ kCFStringEncodingASCII );
+
+ // Create the URL for the image inside the application bundle.
+ CFURLRef imageUrl = CFBundleCopyResourceURL( applicationBundle, imageFilename, NULL, NULL );
+
+ // Create the image data provider using the image URL.
+ CGDataProviderRef imageDataProvider = CGDataProviderCreateWithURL( imageUrl );
+
+ // Release the image URL.
+ CFRelease( imageUrl );
+
+ // Create the PNG image.
+ m_image =
+ CGImageCreateWithPNGDataProvider(
+ imageDataProvider,
+ NULL,
+ true,
+ kCGRenderingIntentDefault);
+
+ // Release the image data provider.
+ CGDataProviderRelease( imageDataProvider );
+
+ // Create the fill representing CPath.
+ m_fillRepresentation = [[CShape rectangleLeft: 8.5 bottom: 18.5 width: 12.0 height: 18.0] retain];
+
+ // Create the stroke representing CPath.
+ m_strokeRepresentation = [[CShape rectangleLeft: 2.5 bottom: 12.5 width: 36.0 height: 30.0] retain];
+ [m_strokeRepresentation moveToX: 5.5 y: 15.5];
+ [m_strokeRepresentation lineToX: 5.5 y: 39.5];
+ [m_strokeRepresentation lineToX: 23.5 y: 39.5];
+ [m_strokeRepresentation lineToX: 23.5 y: 15.5];
+ [m_strokeRepresentation close];
+
+ [m_fillRepresentation setFill: [[[CFill alloc] init] autorelease]];
+ [m_strokeRepresentation setFill: [[[CFill alloc] init] autorelease]];
+
+ // Observe application fill changes.
+ [[NSNotificationCenter defaultCenter]
+ addObserver: self
+ selector: @selector( setNeedsDisplay: )
+ name: CApplicationFillChangedNotification
+ object: nil];
+
+ // Observe application stroke changes.
+ [[NSNotificationCenter defaultCenter]
+ addObserver: self
+ selector: @selector( setNeedsDisplay: )
+ name: CApplicationStrokeChangedNotification
+ object: nil];
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+
+ CGImageRelease( m_image );
+ [m_fillRepresentation release];
+ [m_strokeRepresentation release];
+
+ [super dealloc];
+}
+
+- (BOOL) acceptsFirstMouse: (NSEvent*) theEvent
+{
+ // The first mouseDown will not used to get focus but will already be processed.
+ return YES;
+}
+
+- (void) drawRect: (NSRect) theRect
+{
+ // Convert NSRect to CGRect.
+ CGRect drawRect = CGRectMake( theRect.origin.x, theRect.origin.y, theRect.size.width, theRect.size.height );
+
+ // Use the application stroke and fill paints.
+ [[m_fillRepresentation fill] setPaint: [[[ChlorApplication sharedChlorApplication] fill] paint]];
+ [[m_strokeRepresentation fill] setPaint: [[[ChlorApplication sharedChlorApplication] stroke] paint]];
+
+ // Get the graphics context and begin the page.
+ CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextBeginPage( context, &drawRect );
+
+ // Set the drawing boundary and the graphics context.
+ CRenderer* renderer = [CRenderer sharedRenderer];
+ [renderer setDrawingBoundary: drawRect];
+ [renderer setContext: context];
+ // Set the color space.
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ [renderer setColorSpace: colorSpace];
+ CGColorSpaceRelease( colorSpace );
+
+ // Draw the image.
+ CGContextDrawImage( context, drawRect, m_image );
+
+ // Render the objects.
+ [renderer visit: m_strokeRepresentation];
+ [renderer visit: m_fillRepresentation];
+
+ // End the page and flush the context.
+ CGContextEndPage( context );
+ CGContextFlush( context );
+}
+
+- (void) mouseDown: (NSEvent*) theEvent
+{
+ // Find out where the mouse was clicked.
+ NSPoint aPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil];
+
+ // The stroke was selected.
+ if( [m_strokeRepresentation containsX: aPoint.x y: aPoint.y] )
+ {
+ // Set the setStrokeColor: action in the ChlorApplication.
+ [[NSColorPanel sharedColorPanel] setTarget: [ChlorApplication sharedChlorApplication]];
+ [[NSColorPanel sharedColorPanel] setAction: @selector( setStrokeColor: )];
+
+ // TODO: set the stroke color to the NSColorPanel.
+ }
+ // The fill was selected.
+ else if( [m_fillRepresentation containsX: aPoint.x y: aPoint.y] )
+ {
+ // Set the setFillColor: action in the ChlorApplication.
+ [[NSColorPanel sharedColorPanel] setTarget: [ChlorApplication sharedChlorApplication]];
+ [[NSColorPanel sharedColorPanel] setAction: @selector( setFillColor: )];
+
+ // TODO: set the fill color to the NSColorPanel.
+ }
+ // Neither was selected.
+ else
+ return;
+
+ // The color panel should show the alpha component.
+ [[NSColorPanel sharedColorPanel] setShowsAlpha: YES];
+
+ // Show the color panel.
+ [[NSColorPanel sharedColorPanel] makeKeyAndOrderFront: self];
+}
+
+@end
Copied: trunk/src/gui/CPasswordDialogController.h (from rev 551, trunk/src/gui/controllers/CPasswordDialogController.h)
===================================================================
--- trunk/src/gui/CPasswordDialogController.h (rev 0)
+++ trunk/src/gui/CPasswordDialogController.h 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2006 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@interface CPasswordDialogController : NSWindowController
+{
+ /**
+ * The password input text field.
+ */
+ IBOutlet NSSecureTextField* m_passwordTextField;
+
+ /**
+ * The password string.
+ */
+ NSString* m_passwordString;
+}
+
+/**
+ * Returns the shared password dialog controller.
+ */
++ (CPasswordDialogController*) sharedPasswordDialogController;
+
+/**
+ * Gets called when any button was pressed.
+ */
+- (IBAction) buttonAction: (id) theSender;
+
+/**
+ * Shows the password panel.
+ * @return the entered password string if available and "OK" was pressed.
+ */
+- (NSString*) show;
+
+@end
Copied: trunk/src/gui/CPasswordDialogController.m (from rev 551, trunk/src/gui/controllers/CPasswordDialogController.m)
===================================================================
--- trunk/src/gui/CPasswordDialogController.m (rev 0)
+++ trunk/src/gui/CPasswordDialogController.m 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2006 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CPasswordDialogController.h"
+
+@implementation CPasswordDialogController
+
+- (id) init
+{
+ self = [self initWithWindowNibName: @"PasswordDialog"];
+
+ if( self )
+ {
+ m_passwordString = nil;
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [m_passwordString dealloc];
+ [super dealloc];
+}
+
++ (CPasswordDialogController*) sharedPasswordDialogController
+{
+ static CPasswordDialogController* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CPasswordDialogController alloc] init];
+
+ return s_instance;
+}
+
+- (IBAction) buttonAction: (id) theSender
+{
+ // "OK" button was pressed.
+ if( [theSender tag] == NSOKButton )
+ {
+ // TODO: retain or not?
+ m_passwordString = [[m_passwordTextField stringValue] retain];
+ }
+ // "Cancel button" was pressed.
+ else
+ {
+ [m_passwordString release];
+ m_passwordString = nil;
+ }
+
+ // Stop the modal password panel.
+ [NSApp stopModal];
+}
+
+- (NSString*) show
+{
+ // Show the modal password panel.
+ [NSApp runModalForWindow: [self window]];
+
+ // Return the password string.
+ return m_passwordString;
+}
+
+@end
Copied: trunk/src/gui/CToolPaletteController.h (from rev 551, trunk/src/gui/controllers/CToolPaletteController.h)
===================================================================
--- trunk/src/gui/CToolPaletteController.h (rev 0)
+++ trunk/src/gui/CToolPaletteController.h 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@class CTool;
+
+/**
+ * @brief The tool palette controller.
+ */
+@interface CToolPaletteController : NSWindowController
+{
+ /**
+ * The active tool.
+ */
+ CTool* m_activeTool;
+
+ /**
+ * The tool buttons in the tool palette.
+ */
+ IBOutlet NSMatrix* m_toolButtons;
+}
+
+/**
+ * Returns the shared tool palette controller.
+ */
++ (CToolPaletteController*) sharedToolPaletteController;
+
+/**
+ * Gets called when a tool button in the tool palette is pressed.
+ */
+- (IBAction) activateToolAction: (id) theSender;
+
+/**
+ * Returns the active tool.
+ */
+- (CTool*) activeTool;
+
+/**
+ * Shows the tool palette.
+ */
+- (void) show;
+
+/**
+ * Returns the id of the selected tool button.
+ */
+- (int) toolTag;
+
+@end
Copied: trunk/src/gui/CToolPaletteController.m (from rev 551, trunk/src/gui/controllers/CToolPaletteController.m)
===================================================================
--- trunk/src/gui/CToolPaletteController.m (rev 0)
+++ trunk/src/gui/CToolPaletteController.m 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "ChlorMainWindow.h"
+#import "CEllipseTool.h"
+#import "CGrabHandTool.h"
+#import "CNotifications.h"
+#import "CPolygonTool.h"
+#import "CRectangleTool.h"
+#import "CRoundRectTool.h"
+#import "CSelectionTool.h"
+#import "CStarTool.h"
+#import "CTool.h"
+#import "CToolPaletteController.h"
+
+@class CRect;
+
+@implementation CToolPaletteController
+
+- (id) init
+{
+ self = [self initWithWindowNibName: @"ToolPalette"];
+
+ if( self )
+ {
+ // Activate the selection tool.
+ m_activeTool = [CSelectionTool sharedSelectionTool];
+ [m_activeTool activate];
+
+ // Observe document activations.
+ [[NSNotificationCenter defaultCenter]
+ addObserver: self
+ selector: @selector( documentWasActivated: )
+ name: CDocumentActivateNotification
+ object: nil];
+
+ // Observe document deactivations.
+ [[NSNotificationCenter defaultCenter]
+ addObserver: self
+ selector: @selector( documentWasDeactivated: )
+ name: CDocumentDeactivateNotification
+ object: nil];
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
+}
+
++ (CToolPaletteController*) sharedToolPaletteController
+{
+ static CToolPaletteController* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CToolPaletteController alloc] init];
+
+ return s_instance;
+}
+
+- (IBAction) activateToolAction: (id) theSender
+{
+ // Get the current next responder.
+ NSResponder* currentNextResponder;
+
+ if( m_activeTool )
+ currentNextResponder = [m_activeTool nextResponder];
+ else
+ currentNextResponder = [self nextResponder];
+
+ // Get the active main view.
+ ChlorMainView* activeMainView = [m_activeTool view];
+
+ // Deactivate active tool.
+ [m_activeTool deactivate];
+
+ // Select the new tool from the tool button tag.
+ switch( [self toolTag] )
+ {
+ case 1:
+ // Select the rectangle tool.
+ m_activeTool = [CRectangleTool sharedRectangleTool];
+ break;
+
+ case 2:
+ // Select the ellipse tool.
+ m_activeTool = [CEllipseTool sharedEllipseTool];
+ break;
+
+ case 3:
+ // Select the rounded rectangle tool.
+ m_activeTool = [CRoundRectTool sharedRoundRectTool];
+ break;
+
+ case 4:
+ // Select the polygon tool.
+ m_activeTool = [CPolygonTool sharedPolygonTool];
+ break;
+
+ case 5:
+ // Select the star tool.
+ m_activeTool = [CStarTool sharedStarTool];
+ break;
+
+ case 6:
+ // Select the grab hand tool.
+ m_activeTool = [CGrabHandTool sharedGrabHandTool];
+ break;
+
+ default:
+ // Select the selection tool.
+ m_activeTool = [CSelectionTool sharedSelectionTool];
+ break;
+ }
+
+ // Set the active main view.
+ [m_activeTool setView: activeMainView];
+ // Activate the new tool.
+ [m_activeTool activate];
+
+ // Make the active tool the next responder.
+ [self setNextResponder: m_activeTool];
+ [m_activeTool setNextResponder: currentNextResponder];
+}
+
+- (CTool*) activeTool
+{
+ return m_activeTool;
+}
+
+- (void) documentWasActivated: (NSNotification*) theNotification
+{
+ [self setDocument: [theNotification object]];
+}
+
+- (void) documentWasDeactivated: (NSNotification*) theNotification
+{
+ [self setDocument: nil];
+}
+
+- (void) setDocument: (NSDocument*) theDocument
+{
+ [super setDocument: theDocument];
+}
+
+- (void) show
+{
+ [self setDocument: [[NSDocumentController sharedDocumentController] currentDocument]];
+ [self showWindow: self];
+}
+
+- (int) toolTag
+{
+ // Get tag from selected button.
+ return [[m_toolButtons selectedCell] tag];
+}
+
+- (void) windowDidLoad
+{
+ [super windowDidLoad];
+
+ // Do not cascade the tool palette.
+ [self setShouldCascadeWindows: NO];
+ // Sets the name under which the window's frame is saved in the defaults database.
+ [self setWindowFrameAutosaveName: @"ToolPalette"];
+ // Call setDocument: once.
+ [self setDocument: [self document]];
+
+ // Get the tool panel.
+ NSAssert(
+ [[self window] isKindOfClass: [NSPanel class]],
+ @"Tool window is not an NSPanel!" );
+
+ NSPanel* toolPanel = (NSPanel*) [self window];
+
+ // The tool panel should not grab focus.
+ [toolPanel setBecomesKeyOnlyIfNeeded: YES];
+}
+
+@end
Copied: trunk/src/gui/ChlorMainController.h (from rev 551, trunk/src/gui/controllers/ChlorMainController.h)
===================================================================
--- trunk/src/gui/ChlorMainController.h (rev 0)
+++ trunk/src/gui/ChlorMainController.h 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@class ChlorMainView;
+@class CObject;
+
+/**
+ * @brief Chlor's main window controller.
+ */
+@interface ChlorMainController : NSWindowController
+{
+ /**
+ * The main window.
+ */
+ IBOutlet ChlorMainView* m_mainView;
+}
+
+/**
+ * Invalidates the drawing area of anObject within the main window.
+ */
+- (void) invalidateObject: (CObject*) anObject;
+
+/**
+ * Returns the main window.
+ */
+- (ChlorMainView*) mainView;
+
+@end
Copied: trunk/src/gui/ChlorMainController.m (from rev 551, trunk/src/gui/controllers/ChlorMainController.m)
===================================================================
--- trunk/src/gui/ChlorMainController.m (rev 0)
+++ trunk/src/gui/ChlorMainController.m 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "ChlorDocument.h"
+#import "ChlorMainController.h"
+#import "ChlorMainView.h"
+#import "ChlorMainWindow.h"
+#import "CNotifications.h"
+#import "CSelection.h"
+#import "CToolPaletteController.h"
+
+@implementation ChlorMainController
+
+- (id) init
+{
+ self = [self initWithWindowNibName: @"MainWindow"];
+
+ if( self )
+ {
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
+}
+
+- (void) invalidateObject: (CObject*) anObject
+{
+ [[self mainView] setNeedsDisplayInRect: [[anObject drawingBoundary] rectangle].nsRect];
+}
+
+- (void) flagsChanged: (NSEvent*) theEvent
+{
+ // Delegate events to the active tool.
+ [[[CToolPaletteController sharedToolPaletteController] activeTool] flagsChanged: theEvent];
+}
+
+- (void) keyDown: (NSEvent*) theEvent
+{
+ [self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
+}
+
+- (ChlorMainView*) mainView
+{
+ return m_mainView;
+}
+
+- (void) mouseDown: (NSEvent*) theEvent
+{
+ // Delegate events to the active tool.
+ [[[CToolPaletteController sharedToolPaletteController] activeTool] mouseDown: theEvent];
+}
+
+- (void) mouseDragged: (NSEvent*) theEvent
+{
+ // Delegate events to the active tool.
+ [[[CToolPaletteController sharedToolPaletteController] activeTool] mouseDragged: theEvent];
+}
+
+- (void) mouseMoved: (NSEvent*) theEvent
+{
+ // Delegate events to the active tool.
+ [[[CToolPaletteController sharedToolPaletteController] activeTool] mouseMoved: theEvent];
+}
+
+- (void) mouseUp: (NSEvent*) theEvent
+{
+ // Delegate events to the active tool.
+ [[[CToolPaletteController sharedToolPaletteController] activeTool] mouseUp: theEvent];
+}
+
+- (void) windowDidLoad
+{
+ [super windowDidLoad];
+
+ // Sets the name under which the window's frame is saved in the defaults database.
+ [self setWindowFrameAutosaveName: @"MainWindow"];
+
+ // Make self the main view's controller.
+ [m_mainView setMainViewController: self];
+ // Make self main view's first responder.
+ [[self window] makeFirstResponder: m_mainView];
+
+ // Show tool palette.
+ [[CToolPaletteController sharedToolPaletteController] show];
+}
+
+- (void) windowDidBecomeMain: (NSNotification*) theNotification
+{
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName: CDocumentActivateNotification
+ object: [self document]];
+}
+
+- (void) windowDidResignMain: (NSNotification*) theNotification
+{
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName: CDocumentDeactivateNotification
+ object: [self document]];
+}
+
+- (void) windowWillClose: (NSNotification*) theNotification
+{
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName: CDocumentDeactivateNotification
+ object: [self document]];
+}
+
+@end
Copied: trunk/src/gui/ChlorMainView.h (from rev 551, trunk/src/gui/views/ChlorMainView.h)
===================================================================
--- trunk/src/gui/ChlorMainView.h (rev 0)
+++ trunk/src/gui/ChlorMainView.h 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@class ChlorMainController;
+@class ChlorMainView;
+
+/**
+ * @brief Chlor's main view.
+ */
+@interface ChlorMainView : NSView
+{
+@private
+ /**
+ * The main controller.
+ */
+ IBOutlet ChlorMainController* m_mainController;
+
+ /**
+ * The autoscoll mode.
+ */
+ BOOL m_shouldAutoscroll;
+}
+
+//- (NSSize) contentSize;
+
+/**
+ * Returns the main controller.
+ */
+- (ChlorMainController*) mainController;
+
+/**
+ * Sets the autoscroll mode.
+ */
+- (void) setAutoscrollMode: (BOOL) theMode;
+
+/**
+ * Sets the main view controller.
+ */
+- (void) setMainViewController: (ChlorMainController*) theController;
+
+
+@end
Copied: trunk/src/gui/ChlorMainView.m (from rev 551, trunk/src/gui/views/ChlorMainView.m)
===================================================================
--- trunk/src/gui/ChlorMainView.m (rev 0)
+++ trunk/src/gui/ChlorMainView.m 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "ChlorDocument.h"
+#import "ChlorMainController.h"
+#import "ChlorMainView.h"
+#import "CPath.h"
+#import "CRenderer.h"
+#import "CSelectionRenderer.h"
+#import "CSelectionTool.h"
+#import "CToolPaletteController.h"
+
+@implementation ChlorMainView
+
+- (id) initWithFrame: (NSRect) frameRect
+{
+ if( ( self = [super initWithFrame: frameRect] ) != nil )
+ {
+ [self setAutoscrollMode: YES];
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
+}
+
+- (BOOL) acceptsFirstMouse: (NSEvent*) theEvent
+{
+ // The first mouseDown event will get through.
+ return YES;
+}
+
+- (void) drawRect: (NSRect) theRect
+{
+ // Convert NSRect to CGRect.
+ CGRect drawRect = CGRectMake( theRect.origin.x, theRect.origin.y, theRect.size.width, theRect.size.height );
+
+ // Get the graphics context and begin the page.
+ CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextBeginPage( context, &drawRect );
+
+ // Draw a white background.
+ CGContextBeginPath( context );
+ CGContextAddRect( context, drawRect );
+ CGContextSetRGBFillColor( context, 1.0, 1.0, 1.0, 1.0 );
+ CGContextFillPath( context );
+
+ // Set the drawing boundary, graphics context and color space.
+ CRenderer* renderer = [CRenderer sharedRenderer];
+ [renderer setDrawingBoundary: drawRect];
+ [renderer setContext: context];
+ [renderer setColorSpace: [[m_mainController document] colorSpace]];
+
+ // Render the document.
+ [renderer visitDocument: [m_mainController document]];
+
+ // Draw the selected objects.
+ CSelectionRenderer* selectionRenderer = [CSelectionRenderer sharedSelectionRenderer];
+ [selectionRenderer setDrawingBoundary: drawRect];
+ [selectionRenderer setContext: context];
+ [selectionRenderer setColorSpace: [[m_mainController document] colorSpace]];
+ [selectionRenderer visitDocument: [m_mainController document]];
+
+ // Let the active tool paint its stuff.
+ [[[CToolPaletteController sharedToolPaletteController] activeTool] drawRect: theRect];
+
+ // End the page and flush the context.
+ CGContextEndPage( context );
+ CGContextFlush( context );
+}
+
+- (BOOL) isOpaque
+{
+ // This view does not need to be composited with the background.
+ return YES;
+}
+
+- (ChlorMainController*) mainController
+{
+ return m_mainController;
+}
+
+- (void) mouseDragged: (NSEvent*) theEvent
+{
+ // Scroll the view accordingly if the mouse is dragged
+ // outside the visible area.
+ if( m_shouldAutoscroll )
+ {
+ [self autoscroll: theEvent];
+ }
+
+ [super mouseDragged: theEvent];
+}
+
+- (void) setAutoscrollMode: (BOOL) theMode
+{
+ // Sets the autoscroll mode.
+ m_shouldAutoscroll = theMode;
+}
+
+- (void) setMainViewController: (ChlorMainController*) theController
+{
+ m_mainController = theController;
+}
+
+@end
\ No newline at end of file
Copied: trunk/src/gui/ChlorMainWindow.h (from rev 551, trunk/src/gui/windows/ChlorMainWindow.h)
===================================================================
--- trunk/src/gui/ChlorMainWindow.h (rev 0)
+++ trunk/src/gui/ChlorMainWindow.h 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2006 Florian Wohlgemuth
+ * Copyright (c) 2006 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+/**
+ * @brief Chlor's main window.
+ */
+@interface ChlorMainWindow : NSWindow
+{
+}
+
+@end
Copied: trunk/src/gui/ChlorMainWindow.m (from rev 551, trunk/src/gui/windows/ChlorMainWindow.m)
===================================================================
--- trunk/src/gui/ChlorMainWindow.m (rev 0)
+++ trunk/src/gui/ChlorMainWindow.m 2007-06-03 15:43:39 UTC (rev 553)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2006 Florian Wohlgemuth
+ * Copyright (c) 2006 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "ChlorMainController.h"
+#import "ChlorMainView.h"
+#import "ChlorMainWindow.h"
+#import "CToolPaletteController.h"
+
+@implementation ChlorMainWindow
+
+- (void) becomeKeyWindow
+{
+ [super becomeKeyWindow];
+
+ // Get the main window controller.
+ NSAssert(
+ [[self delegate] isKindOfClass: [ChlorMainController class]],
+ @"Delegate is not a ChlorMainController!" );
+
+ ChlorMainController* controller = (ChlorMainController*) [self delegate];
+
+ // Set the main view to the active tool.
+ NSAssert(
+ [[controller mainView] isKindOfClass: [ChlorMainView class]],
+ @"Main view is not a ChlorMainView!" );
+
+ // Inform the active tool about the new active view.
+ [[[CToolPaletteController sharedToolPaletteController]
+ activeTool]
+ setView: (ChlorMainView *)[controller mainView]];
+}
+
+@end
Modified: trunk/src/notes/Developer Handbook.rtf
===================================================================
--- trunk/src/notes/Developer Handbook.rtf 2007-06-03 15:39:04 UTC (rev 552)
+++ trunk/src/notes/Developer Handbook.rtf 2007-06-03 15:43:39 UTC (rev 553)
@@ -1,7 +1,7 @@
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
-{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;}
+{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fnil\fcharset77 Monaco;
+}
{\colortbl;\red255\green255\blue255;}
-\vieww11820\viewh9060\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f0\b\fs28 \cf0 The Chlor Developer Handbook
@@ -23,8 +23,7 @@
\
CAcceptor and CVisitor implement the Visitor design pattern in Chlor. Classes derived from CObject just hold the object data. They do not implement how the data is represented on screen or how it is written to any file format (not even Chlor's native file format). They neither implement any data modification like moving an object or resizing etc. All such processings are implemented as a visitor. Objects are drawn with the CRenderer, they are loaded and saved from or to a file using a import or export visitor.\
\
-\pard\tx480\tx960\tx1440\tx1920\tx2400\tx2880\tx3360\tx3840\tx4320\tx4800\tx5280\tx5760\tx6240\tx6720\tx7200\tx7680\tx8160\tx8640\tx9120\tx9600\tx10080\tx10560\tx11040\tx11520\tx12000\tx12480\tx12960\tx13440\tx13920\tx14400\tx14880\tx15360\tx15840\tx16320\tx16800\tx17280\tx17760\tx18240\tx18720\tx19200\tx19680\tx20160\tx20640\tx21120\tx21600\tx22080\tx22560\tx23040\tx23520\tx24000\tx24480\tx24960\tx25440\tx25920\tx26400\tx26880\tx27360\tx27840\tx28320\tx28800\tx29280\tx29760\tx30240\tx30720\tx31200\tx31680\tx32160\tx32640\tx33120\tx33600\tx34080\tx34560\tx35040\tx35520\tx36000\tx36480\tx36960\tx37440\tx37920\tx38400\tx38880\tx39360\tx39840\tx40320\tx40800\tx41280\tx41760\tx42240\tx42720\tx43200\tx43680\tx44160\tx44640\tx45120\tx45600\tx46080\tx46560\tx47040\tx47520\tx48000\ql\qnatural\pardirnatural
-\cf0 The CHasComplexBoundaries protocol defines that an object of an implementing class has a boundary. Actually it has two boundaries. Imagine a circle with radius 1. It's shapeBoundary would have a widht and height of 2. If the circle is painted using line with 0.5 the drawingBoundary will be 1 larger than the shapeBoundary.
+The CHasComplexBoundaries protocol defines that an object of an implementing class has a boundary. Actually it has two boundaries. Imagine a circle with radius 1. It's shapeBoundary would have a widht and height of 2. If the circle is painted using line with 0.5 the drawingBoundary will be 1 larger than the shapeBoundary.
\fs24 \CocoaLigature1 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\cf0 \
@@ -60,4 +59,11 @@
\f0\b\fs26 \CocoaLigature1 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\cf0 \
-Import/Export Filters}
\ No newline at end of file
+Import/Export Filters\
+\
+\
+\pard\tx480\tx960\tx1440\tx1920\tx2400\tx2880\tx3360\tx3840\tx4320\tx4800\tx5280\tx5760\tx6240\tx6720\tx7200\tx7680\tx8160\tx8640\tx9120\tx9600\tx10080\tx10560\tx11040\tx11520\tx12000\tx12480\tx12960\tx13440\tx13920\tx14400\tx14880\tx15360\tx15840\tx16320\tx16800\tx17280\tx17760\tx18240\tx18720\tx19200\tx19680\tx20160\tx20640\tx21120\tx21600\tx22080\tx22560\tx23040\tx23520\tx24000\tx24480\tx24960\tx25440\tx25920\tx26400\tx26880\tx27360\tx27840\tx28320\tx28800\tx29280\tx29760\tx30240\tx30720\tx31200\tx31680\tx32160\tx32640\tx33120\tx33600\tx34080\tx34560\tx35040\tx35520\tx36000\tx36480\tx36960\tx37440\tx37920\tx38400\tx38880\tx39360\tx39840\tx40320\tx40800\tx41280\tx41760\tx42240\tx42720\tx43200\tx43680\tx44160\tx44640\tx45120\tx45600\tx46080\tx46560\tx47040\tx47520\tx48000\ql\qnatural\pardirnatural
+
+\f2\b0\fs20 \cf0 \CocoaLigature0 \
+\
+svn propset svn:keywords Id foo.h}
\ No newline at end of file
Modified: trunk/src/notes/Read Me!.rtf
===================================================================
--- trunk/src/notes/Read Me!.rtf 2007-06-03 15:39:04 UTC (rev 552)
+++ trunk/src/notes/Read Me!.rtf 2007-06-03 15:43:39 UTC (rev 553)
@@ -4,7 +4,7 @@
{\colortbl;\red255\green255\blue255;}
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
-\f0\b\fs32 \cf0 Chlor 0.0.6\
+\f0\b\fs32 \cf0 Chlor 0.0.7\
\fs24 An Open Source Vector Graphics Editor for Apple Mac OS X
\f1\b0 \
@@ -16,9 +16,15 @@
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
-\f0\b\fs28 \cf0 \ul \ulc0 Features
+\f0\b\fs28 \cf0 \ul \ulc0 How to install
\f1\b0\fs24 \ulnone \
\
+Drag the Chlor application to your application folder.\
+\
+
+\f0\b\fs28 \ul Features
+\f1\b0\fs24 \ulnone \
+\
* Import formats\
* PDF\
* SVG\
@@ -35,14 +41,26 @@
\
\f0\b\fs28 \ul Changes\
+\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
+\fs24 \cf0 Version 0.0.7
+\fs28 \
+\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
+
+\f1\b0\fs24 \cf0 \ulnone *
+\f0\b\fs28 \ul \
+\
+\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
+
\fs24 \cf0 Version 0.0.6
\fs28 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f1\b0\fs24 \cf0 \ulnone * Overall\
+ * Really ship a universal binary\
* Shift click adds objects to the selection now\
+ * Chlor and Chlor created SVG files do not appear empty anymore after loading them\
* SVG export\
* write the fill again\
* do not round the color alpha values to zero\
Modified: trunk/src/notes/TODO.txt
===================================================================
--- trunk/src/notes/TODO.txt 2007-06-03 15:39:04 UTC (rev 552)
+++ trunk/src/notes/TODO.txt 2007-06-03 15:43:39 UTC (rev 553)
@@ -1,5 +1,7 @@
User experience
---------------
+- TODO: add polyline tool
+- TODO: add affine transformation and properties palette
- BUG: shift dragging while one object is selected moves the object even when clicked/dragged is outside of it
- TODO: add keyboard short cuts like <Backspace> which deletes the selected objects and <Esc> which cancels the current tool
- call CSelectionToolState's "cancel:" method
@@ -9,7 +11,21 @@
- create Unit Tests breaking down to bezier/line interesections
- maybe this has something to do with NSArray clear/adding in CSelection?
- BUG: undo/redo of deleting objects doesnt repaint
-- TODO: create CUnkownFill, CUnknownStroke, CUnknownPaint
+- TODO: create CUnkown*
+ - Which solutions
+ - CUnknownPaint
+ PRO:
+ - not much refactoring
+ - do not need to check whether a stroke/fill has a paint
+ CON:
+ - a group with an unknown stroke paint would still need to provide stroke properties
+ - CUnkownFill, CUnknownStroke
+ PRO:
+ - it better communicates that we do no know the fill/stroke for groups
+ CON:
+ - a lot of refactoring
+ - do need to check whether a stroke/fill has a paint
+ - we need to disable stroke property viewers in the GUI
- CGroup's fill: and stroke: need to use these if the group contains many objects
- Create a case in the CRenderer (e.g. painting questionmarks)
- BUG: update the color in the NSColorPanel from application's fill/stroke
@@ -54,13 +70,13 @@
SVG import
----------
- TODO: definitions
+- paint URIs in "#xyz" or "url(#xyz)"
+- TODO: gradient
- TODO: if the document width/heigth are in percent just make the documents the size of the shape boundary box of all included objects
-- TODO: write unit tests for SVG import
- TODO: move all NSScanner using code to CSvgScanner
- BUG: wrong vertical and horizontal offset for ellipse during SVG import (http://www.w3.org/Graphics/SVG/Test/20030813/htmlframe/full-shapes-ellipse-01-t.html) and
circles (http://www.w3.org/Graphics/SVG/Test/20030813/htmlframe/full-shapes-circle-01-t.html)
- partial inheritance like "<g stroke-width=10><line stroke=black..."
-- paint URIs in "#xyz" or "url(#xyz)"
- TODO: graphic elements can have "title" and "desc" as well
IO
@@ -74,5 +90,6 @@
-------------
- Developer FAQ: write down, how MainView's Controller, Window, View, Document can be obtain from each other
-- Qt has now a boolean clipping algorithm
-svn propset svn:keywords Id foo.h
\ No newline at end of file
+Interesting
+-----------
+- Qt has a boolean clipping algorithm
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 15:39:07
|
Revision: 552
http://svn.sourceforge.net/chlor/?rev=552&view=rev
Author: lenny222
Date: 2007-06-03 08:39:04 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
move tools
Removed Paths:
-------------
trunk/src/gui/tools/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 15:38:27
|
Revision: 551
http://svn.sourceforge.net/chlor/?rev=551&view=rev
Author: lenny222
Date: 2007-06-03 08:38:25 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
move tools
Added Paths:
-----------
trunk/src/tools/
trunk/src/tools/CEllipseTool.h
trunk/src/tools/CEllipseTool.m
trunk/src/tools/CGrabHandTool.h
trunk/src/tools/CGrabHandTool.m
trunk/src/tools/CPolygonTool.h
trunk/src/tools/CPolygonTool.m
trunk/src/tools/CRectangleTool.h
trunk/src/tools/CRectangleTool.m
trunk/src/tools/CRoundRectTool.h
trunk/src/tools/CRoundRectTool.m
trunk/src/tools/CSelectionTool.h
trunk/src/tools/CSelectionTool.m
trunk/src/tools/CSelectionToolMoveState.h
trunk/src/tools/CSelectionToolMoveState.m
trunk/src/tools/CSelectionToolRectangleState.h
trunk/src/tools/CSelectionToolRectangleState.m
trunk/src/tools/CSelectionToolResizeState.h
trunk/src/tools/CSelectionToolResizeState.m
trunk/src/tools/CSelectionToolState.h
trunk/src/tools/CShapeTool.h
trunk/src/tools/CShapeTool.m
trunk/src/tools/CStarTool.h
trunk/src/tools/CStarTool.m
trunk/src/tools/CTool.h
trunk/src/tools/CTool.m
Removed Paths:
-------------
trunk/src/tools/CEllipseTool.h
trunk/src/tools/CEllipseTool.m
trunk/src/tools/CGrabHandTool.h
trunk/src/tools/CGrabHandTool.m
trunk/src/tools/CPolygonTool.h
trunk/src/tools/CPolygonTool.m
trunk/src/tools/CRectangleTool.h
trunk/src/tools/CRectangleTool.m
trunk/src/tools/CRoundRectTool.h
trunk/src/tools/CRoundRectTool.m
trunk/src/tools/CSelectionTool.h
trunk/src/tools/CSelectionTool.m
trunk/src/tools/CSelectionToolMoveObjectsState.h
trunk/src/tools/CSelectionToolMoveObjectsState.m
trunk/src/tools/CSelectionToolResizeState.h
trunk/src/tools/CSelectionToolResizeState.m
trunk/src/tools/CSelectionToolSelectState.h
trunk/src/tools/CSelectionToolSelectState.m
trunk/src/tools/CSelectionToolState.h
trunk/src/tools/CShapeTool.h
trunk/src/tools/CShapeTool.m
trunk/src/tools/CStarTool.h
trunk/src/tools/CStarTool.m
trunk/src/tools/CTool.h
trunk/src/tools/CTool.m
Copied: trunk/src/tools (from rev 533, trunk/src/gui/tools)
Deleted: trunk/src/tools/CEllipseTool.h
===================================================================
--- trunk/src/gui/tools/CEllipseTool.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CEllipseTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CShapeTool.h"
-
-/**
- * @brief A GUI tool to create ellipse shapes.
- */
-@interface CEllipseTool : CRectangularShapeTool
-{
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CEllipseTool*) sharedEllipseTool;
-
-@end
-
Copied: trunk/src/tools/CEllipseTool.h (from rev 538, trunk/src/gui/tools/CEllipseTool.h)
===================================================================
--- trunk/src/tools/CEllipseTool.h (rev 0)
+++ trunk/src/tools/CEllipseTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CShapeTool.h"
+
+/**
+ * @brief A GUI tool to create ellipse shapes.
+ */
+@interface CEllipseTool : CRectangularShapeTool
+{
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CEllipseTool*) sharedEllipseTool;
+
+@end
+
Deleted: trunk/src/tools/CEllipseTool.m
===================================================================
--- trunk/src/gui/tools/CEllipseTool.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CEllipseTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CEllipseTool.h"
-#import "CPath.h"
-#import "CRect.h"
-#import "CShape.h"
-
-@implementation CEllipseTool
-
-+ (CEllipseTool*) sharedEllipseTool
-{
- static CEllipseTool* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CEllipseTool alloc] init];
-
- return s_instance;
-}
-
-- (CPath*) shape
-{
- if( !m_shape )
- {
- m_shape = [[CShape ellipseWithinRectangle: m_rect] retain];
-
- // Set the stroke
- [m_shape setStroke: m_stroke];
- }
-
- return m_shape;
-}
-
-@end
Copied: trunk/src/tools/CEllipseTool.m (from rev 538, trunk/src/gui/tools/CEllipseTool.m)
===================================================================
--- trunk/src/tools/CEllipseTool.m (rev 0)
+++ trunk/src/tools/CEllipseTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CEllipseTool.h"
+#import "CPath.h"
+#import "CRect.h"
+#import "CShape.h"
+
+@implementation CEllipseTool
+
++ (CEllipseTool*) sharedEllipseTool
+{
+ static CEllipseTool* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CEllipseTool alloc] init];
+
+ return s_instance;
+}
+
+- (CPath*) shape
+{
+ if( !m_shape )
+ {
+ m_shape = [[CShape ellipseWithinRectangle: m_rect] retain];
+
+ // Set the stroke
+ [m_shape setStroke: m_stroke];
+ }
+
+ return m_shape;
+}
+
+@end
Deleted: trunk/src/tools/CGrabHandTool.h
===================================================================
--- trunk/src/gui/tools/CGrabHandTool.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CGrabHandTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CTool.h"
-
-/**
- * @brief A GUI tool for grab hand scrolling.
- */
-@interface CGrabHandTool : CTool
-{
- /**
- * The mouse down point.
- */
- NSPoint m_mouseDownPoint;
-
- /**
- * Scroll view's orignal position.
- */
- NSPoint m_originalPostion;
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CGrabHandTool*) sharedGrabHandTool;
-
-@end
Copied: trunk/src/tools/CGrabHandTool.h (from rev 538, trunk/src/gui/tools/CGrabHandTool.h)
===================================================================
--- trunk/src/tools/CGrabHandTool.h (rev 0)
+++ trunk/src/tools/CGrabHandTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CTool.h"
+
+/**
+ * @brief A GUI tool for grab hand scrolling.
+ */
+@interface CGrabHandTool : CTool
+{
+ /**
+ * The mouse down point.
+ */
+ NSPoint m_mouseDownPoint;
+
+ /**
+ * Scroll view's orignal position.
+ */
+ NSPoint m_originalPostion;
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CGrabHandTool*) sharedGrabHandTool;
+
+@end
Deleted: trunk/src/tools/CGrabHandTool.m
===================================================================
--- trunk/src/gui/tools/CGrabHandTool.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CGrabHandTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CGrabHandTool.h"
-
-@implementation CGrabHandTool
-
-+ (CGrabHandTool*) sharedGrabHandTool
-{
- static CGrabHandTool* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CGrabHandTool alloc] init];
-
- return s_instance;
-}
-
-- (void) mouseDown: (NSEvent*) theEvent
-{
- // Grab the starting point untranslated, to be independent scrolls.
- m_mouseDownPoint = [theEvent locationInWindow];
- m_originalPostion = [[m_view superview] bounds].origin;
-}
-
-- (void) mouseDragged: (NSEvent*) theEvent
-{
- // Now translate also the starting point
- NSPoint firstMousePoint = [m_view convertPoint: m_mouseDownPoint fromView: nil];
- NSPoint lastMousePoint = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
-
- float delta[ 2 ] =
- {
- firstMousePoint.x - lastMousePoint.x,
- firstMousePoint.y - lastMousePoint.y
- };
-
- NSPoint newPosition =
- NSMakePoint(
- m_originalPostion.x + delta[ 0 ],
- m_originalPostion.y + delta[ 1 ]);
-
- [[m_view superview] scrollPoint: newPosition];
-}
-
-- (void) activate
-{
- [super activate];
-
- // Autoscrolling interfers with our scrolling activities - we switch it
- // therefore off.
- [m_view setAutoscrollMode: NO];
-}
-
-- (void) deactivate
-{
- [super deactivate];
-
- // We're done, so we can switch autoscrolling back on again.
- [m_view setAutoscrollMode: YES];
-}
-
-
-@end
Copied: trunk/src/tools/CGrabHandTool.m (from rev 538, trunk/src/gui/tools/CGrabHandTool.m)
===================================================================
--- trunk/src/tools/CGrabHandTool.m (rev 0)
+++ trunk/src/tools/CGrabHandTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2006 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CGrabHandTool.h"
+
+@implementation CGrabHandTool
+
++ (CGrabHandTool*) sharedGrabHandTool
+{
+ static CGrabHandTool* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CGrabHandTool alloc] init];
+
+ return s_instance;
+}
+
+- (void) mouseDown: (NSEvent*) theEvent
+{
+ // Grab the starting point untranslated, to be independent scrolls.
+ m_mouseDownPoint = [theEvent locationInWindow];
+ m_originalPostion = [[m_view superview] bounds].origin;
+}
+
+- (void) mouseDragged: (NSEvent*) theEvent
+{
+ // Now translate also the starting point
+ NSPoint firstMousePoint = [m_view convertPoint: m_mouseDownPoint fromView: nil];
+ NSPoint lastMousePoint = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
+
+ float delta[ 2 ] =
+ {
+ firstMousePoint.x - lastMousePoint.x,
+ firstMousePoint.y - lastMousePoint.y
+ };
+
+ NSPoint newPosition =
+ NSMakePoint(
+ m_originalPostion.x + delta[ 0 ],
+ m_originalPostion.y + delta[ 1 ]);
+
+ [[m_view superview] scrollPoint: newPosition];
+}
+
+- (void) activate
+{
+ [super activate];
+
+ // Autoscrolling interfers with our scrolling activities - we switch it
+ // therefore off.
+ [m_view setAutoscrollMode: NO];
+}
+
+- (void) deactivate
+{
+ [super deactivate];
+
+ // We're done, so we can switch autoscrolling back on again.
+ [m_view setAutoscrollMode: YES];
+}
+
+
+@end
Deleted: trunk/src/tools/CPolygonTool.h
===================================================================
--- trunk/src/gui/tools/CPolygonTool.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CPolygonTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CShapeTool.h"
-
-/**
- * @brief A GUI tool to create polygon shapes.
- */
-@interface CPolygonTool : CPolarShapeTool
-{
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CPolygonTool*) sharedPolygonTool;
-
-@end
Copied: trunk/src/tools/CPolygonTool.h (from rev 538, trunk/src/gui/tools/CPolygonTool.h)
===================================================================
--- trunk/src/tools/CPolygonTool.h (rev 0)
+++ trunk/src/tools/CPolygonTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CShapeTool.h"
+
+/**
+ * @brief A GUI tool to create polygon shapes.
+ */
+@interface CPolygonTool : CPolarShapeTool
+{
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CPolygonTool*) sharedPolygonTool;
+
+@end
Deleted: trunk/src/tools/CPolygonTool.m
===================================================================
--- trunk/src/gui/tools/CPolygonTool.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CPolygonTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CPath.h"
-#import "CPolygonTool.h"
-#import "CShape.h"
-
-@implementation CPolygonTool
-
-+ (CPolygonTool*) sharedPolygonTool
-{
- static CPolygonTool* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CPolygonTool alloc] init];
-
- return s_instance;
-}
-
-- (CPath*) shape
-{
- if( !m_shape )
- {
- m_shape =
- [[CShape
- polygonX: m_x
- y: m_y
- radius: m_radius
- edges: 5
- angle: m_angle] retain];
-
- // Set the stroke
- [m_shape setStroke: m_stroke];
- }
-
- return m_shape;
-}
-
-@end
Copied: trunk/src/tools/CPolygonTool.m (from rev 538, trunk/src/gui/tools/CPolygonTool.m)
===================================================================
--- trunk/src/tools/CPolygonTool.m (rev 0)
+++ trunk/src/tools/CPolygonTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CPath.h"
+#import "CPolygonTool.h"
+#import "CShape.h"
+
+@implementation CPolygonTool
+
++ (CPolygonTool*) sharedPolygonTool
+{
+ static CPolygonTool* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CPolygonTool alloc] init];
+
+ return s_instance;
+}
+
+- (CPath*) shape
+{
+ if( !m_shape )
+ {
+ m_shape =
+ [[CShape
+ polygonX: m_x
+ y: m_y
+ radius: m_radius
+ edges: 5
+ angle: m_angle] retain];
+
+ // Set the stroke
+ [m_shape setStroke: m_stroke];
+ }
+
+ return m_shape;
+}
+
+@end
Deleted: trunk/src/tools/CRectangleTool.h
===================================================================
--- trunk/src/gui/tools/CRectangleTool.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CRectangleTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CShapeTool.h"
-
-/**
- * @brief A GUI tool to create rectangle shapes.
- */
-@interface CRectangleTool : CRectangularShapeTool
-{
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CRectangleTool*) sharedRectangleTool;
-
-@end
Copied: trunk/src/tools/CRectangleTool.h (from rev 538, trunk/src/gui/tools/CRectangleTool.h)
===================================================================
--- trunk/src/tools/CRectangleTool.h (rev 0)
+++ trunk/src/tools/CRectangleTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CShapeTool.h"
+
+/**
+ * @brief A GUI tool to create rectangle shapes.
+ */
+@interface CRectangleTool : CRectangularShapeTool
+{
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CRectangleTool*) sharedRectangleTool;
+
+@end
Deleted: trunk/src/tools/CRectangleTool.m
===================================================================
--- trunk/src/gui/tools/CRectangleTool.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CRectangleTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CPath.h"
-#import "CRect.h"
-#import "CRectangleTool.h"
-#import "CShape.h"
-
-@implementation CRectangleTool
-
-+ (CRectangleTool*) sharedRectangleTool
-{
- static CRectangleTool* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CRectangleTool alloc] init];
-
- return s_instance;
-}
-
- - (CPath*) shape
- {
- if( !m_shape )
- {
- m_shape =
- [[CShape
- rectangleLeft: [m_rect left]
- bottom: [m_rect bottom]
- width: [m_rect width]
- height: [m_rect height]] retain];
-
- // Set the stroke
- [m_shape setStroke: m_stroke];
- }
-
- return m_shape;
- }
-
-@end
Copied: trunk/src/tools/CRectangleTool.m (from rev 538, trunk/src/gui/tools/CRectangleTool.m)
===================================================================
--- trunk/src/tools/CRectangleTool.m (rev 0)
+++ trunk/src/tools/CRectangleTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CPath.h"
+#import "CRect.h"
+#import "CRectangleTool.h"
+#import "CShape.h"
+
+@implementation CRectangleTool
+
++ (CRectangleTool*) sharedRectangleTool
+{
+ static CRectangleTool* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CRectangleTool alloc] init];
+
+ return s_instance;
+}
+
+ - (CPath*) shape
+ {
+ if( !m_shape )
+ {
+ m_shape =
+ [[CShape
+ rectangleLeft: [m_rect left]
+ bottom: [m_rect bottom]
+ width: [m_rect width]
+ height: [m_rect height]] retain];
+
+ // Set the stroke
+ [m_shape setStroke: m_stroke];
+ }
+
+ return m_shape;
+ }
+
+@end
Deleted: trunk/src/tools/CRoundRectTool.h
===================================================================
--- trunk/src/gui/tools/CRoundRectTool.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CRoundRectTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CShapeTool.h"
-
-/**
- * @brief A GUI tool to create rectangle shapes with rounded corners.
- */
-@interface CRoundRectTool : CRectangularShapeTool
-{
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CRoundRectTool*) sharedRoundRectTool;
-
-@end
\ No newline at end of file
Copied: trunk/src/tools/CRoundRectTool.h (from rev 538, trunk/src/gui/tools/CRoundRectTool.h)
===================================================================
--- trunk/src/tools/CRoundRectTool.h (rev 0)
+++ trunk/src/tools/CRoundRectTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CShapeTool.h"
+
+/**
+ * @brief A GUI tool to create rectangle shapes with rounded corners.
+ */
+@interface CRoundRectTool : CRectangularShapeTool
+{
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CRoundRectTool*) sharedRoundRectTool;
+
+@end
\ No newline at end of file
Deleted: trunk/src/tools/CRoundRectTool.m
===================================================================
--- trunk/src/gui/tools/CRoundRectTool.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CRoundRectTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CPath.h"
-#import "CRect.h"
-#import "CRoundRectTool.h"
-#import "CShape.h"
-
-@implementation CRoundRectTool
-
-+ (CRoundRectTool*) sharedRoundRectTool
-{
- static CRoundRectTool* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CRoundRectTool alloc] init];
-
- return s_instance;
-}
-
- - (CPath*) shape
- {
- if( !m_shape )
- {
- m_shape =
- [[CShape
- roundRectLeft: [m_rect left]
- bottom: [m_rect bottom]
- width: [m_rect width]
- height: [m_rect height]
- radius: 10.0] retain];
-
- // Set the stroke
- [m_shape setStroke: m_stroke];
- }
-
- return m_shape;
- }
-
-@end
Copied: trunk/src/tools/CRoundRectTool.m (from rev 538, trunk/src/gui/tools/CRoundRectTool.m)
===================================================================
--- trunk/src/tools/CRoundRectTool.m (rev 0)
+++ trunk/src/tools/CRoundRectTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CPath.h"
+#import "CRect.h"
+#import "CRoundRectTool.h"
+#import "CShape.h"
+
+@implementation CRoundRectTool
+
++ (CRoundRectTool*) sharedRoundRectTool
+{
+ static CRoundRectTool* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CRoundRectTool alloc] init];
+
+ return s_instance;
+}
+
+ - (CPath*) shape
+ {
+ if( !m_shape )
+ {
+ m_shape =
+ [[CShape
+ roundRectLeft: [m_rect left]
+ bottom: [m_rect bottom]
+ width: [m_rect width]
+ height: [m_rect height]
+ radius: 10.0] retain];
+
+ // Set the stroke
+ [m_shape setStroke: m_stroke];
+ }
+
+ return m_shape;
+ }
+
+@end
Deleted: trunk/src/tools/CSelectionTool.h
===================================================================
--- trunk/src/gui/tools/CSelectionTool.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CSelectionTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-@class CSelectionToolState;
-#import "CTool.h"
-
-/**
- * A GUI tool to select, move, scale and delete graphical objects.
- */
-@interface CSelectionTool : CTool
-{
- /**
- * The position of the last mouse down.
- */
- NSPoint m_mouseDownPos;
-
- /**
- * The current mouse position.
- */
- NSPoint m_currentMousePos;
-
- /**
- * The active tool state.
- */
- CSelectionToolState* m_activeState;
-}
-
-/**
- * Returns the current mouse poisition.
- */
-- (NSPoint) currentMousePos;
-
-/**
- * Returns the mouse down position.
- */
-- (NSPoint) mouseDownPos;
-
-/**
- * Returns the singleton instance.
- */
-+ (CSelectionTool*) sharedSelectionTool;
-
-@end
Copied: trunk/src/tools/CSelectionTool.h (from rev 538, trunk/src/gui/tools/CSelectionTool.h)
===================================================================
--- trunk/src/tools/CSelectionTool.h (rev 0)
+++ trunk/src/tools/CSelectionTool.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@class CSelectionToolState;
+#import "CTool.h"
+
+/**
+ * A GUI tool to select, move, scale and delete graphical objects.
+ */
+@interface CSelectionTool : CTool
+{
+ /**
+ * The position of the last mouse down.
+ */
+ NSPoint m_mouseDownPos;
+
+ /**
+ * The current mouse position.
+ */
+ NSPoint m_currentMousePos;
+
+ /**
+ * The active tool state.
+ */
+ CSelectionToolState* m_activeState;
+}
+
+/**
+ * Returns the current mouse poisition.
+ */
+- (NSPoint) currentMousePos;
+
+/**
+ * Returns the mouse down position.
+ */
+- (NSPoint) mouseDownPos;
+
+/**
+ * Returns the singleton instance.
+ */
++ (CSelectionTool*) sharedSelectionTool;
+
+@end
Deleted: trunk/src/tools/CSelectionTool.m
===================================================================
--- trunk/src/gui/tools/CSelectionTool.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CSelectionTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2005, 2006 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CSelection.h"
-#import "CSelectionTool.h"
-#import "CSelectionToolState.h"
-#import "CSelectionToolMoveObjectsState.h"
-#import "CSelectionToolResizeState.h"
-#import "CSelectionToolSelectState.h"
-#import "CSelectVisitor.h"
-
-@implementation CSelectionTool
-
-- (void) activate
-{
- [super activate];
-
- // Use regular "arrow" mouse cursor.
- // TODO: this somehow works only for the first call.
- [m_view
- addCursorRect: [m_view visibleRect]
- cursor: [NSCursor arrowCursor]];
-}
-
-- (NSPoint) currentMousePos
-{
- return m_currentMousePos;
-}
-
-- (void) drawRect: (NSRect) rect
-{
- // Delegate the draw event to the active state.
- [m_activeState drawRect: rect];
-}
-
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- m_activeState = nil;
- }
-
- return self;
-}
-
-- (void) keyDown: (NSEvent*) theEvent
-{
-}
-
-- (void) mouseDown: (NSEvent*) theEvent
-{
- // Save the mouse down position.
- m_mouseDownPos = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
- // Save the current mouse position.
- m_currentMousePos = m_mouseDownPos;
-
- // Get the document selection.
- CSelection* selection = [[[m_view mainController] document] selection];
-
- // A selection handle was selected.
- if(
- [selection
- handleContainingX: m_mouseDownPos.x
- y: m_mouseDownPos.y] != -1 )
- {
- // Activate the resize state.
- m_activeState = [CSelectionToolResizeState sharedSelectionToolResizeState];
- }
- // There are selected objects at the mouse down position.
- else if( [selection containsX: m_mouseDownPos.x y: m_mouseDownPos.y] )
- {
- // Activate the object moving state.
- m_activeState = [CSelectionToolMoveObjectsState sharedSelectionToolMoveObjectsState];
- }
- // Select all objects at the mouse down location.
- else
- {
- // Clear the document selection.
- [selection clear];
-
- // TODO: we should add the objects according to "shiftKeyIsDown:"
-
- // Select the objects at the mouse down location.
- CSelectObjectsVisitor* selectionVisitor = [[CSelectObjectsVisitor alloc] init];
- [selectionVisitor setSelectionPointX: m_mouseDownPos.x Y: m_mouseDownPos.y];
- [selectionVisitor visitDocument: [[m_view mainController] document]];
- [selectionVisitor release];
-
- // The document selection is empty.
- if( [[selection collection] isEmpty] )
- {
- // Activate the object selection state.
- m_activeState = [CSelectionToolSelectState sharedSelectionToolSelectState];
- }
- // The document selection is not empty.
- else
- {
- // Activate the object moving state.
- m_activeState = [CSelectionToolMoveObjectsState sharedSelectionToolMoveObjectsState];
- }
- }
-
- // Activate and recalculate the current state.
- [m_activeState start];
- [m_activeState updateInternalState];
-
- // Repaint.
- // TODO: do not repaint everything.
- [m_view setNeedsDisplay: YES];
-}
-
-- (NSPoint) mouseDownPos
-{
- return m_mouseDownPos;
-}
-
-- (void) mouseDragged: (NSEvent*) theEvent
-{
- // Save the current mouse position.
- m_currentMousePos = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
-
- // Update the internal state.
- [m_activeState updateInternalState];
-
- // Repaint.
- // TODO: do not repaint everything.
- [m_view setNeedsDisplay: YES];
-}
-
-- (void) mouseUp: (NSEvent*) theEvent
-{
- // Save the current mouse position.
- m_currentMousePos = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
-
- // Update the internal state.
- [m_activeState updateInternalState];
-
- // Ask the .
- [m_activeState finish];
-
- // Unset current tool state.
- m_activeState = nil;
-
- // Repaint.
- // TODO: do not repaint everything.
- [m_view setNeedsDisplay: YES];
-}
-
-+ (CSelectionTool*) sharedSelectionTool
-{
- static CSelectionTool* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CSelectionTool alloc] init];
-
- return s_instance;
-}
-
-@end
\ No newline at end of file
Copied: trunk/src/tools/CSelectionTool.m (from rev 544, trunk/src/gui/tools/CSelectionTool.m)
===================================================================
--- trunk/src/tools/CSelectionTool.m (rev 0)
+++ trunk/src/tools/CSelectionTool.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2005 - 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CFindObjectsContainingAPointVisitor.h"
+#import "CSelection.h"
+#import "CSelectionTool.h"
+#import "CSelectionToolState.h"
+#import "CSelectionToolMoveState.h"
+#import "CSelectionToolRectangleState.h"
+#import "CSelectionToolResizeState.h"
+
+@implementation CSelectionTool
+
+- (void) activate
+{
+ [super activate];
+
+ // Use regular "arrow" mouse cursor.
+ // TODO: this somehow works only for the first call.
+ [m_view
+ addCursorRect: [m_view visibleRect]
+ cursor: [NSCursor arrowCursor]];
+}
+
+- (NSPoint) currentMousePos
+{
+ return m_currentMousePos;
+}
+
+- (void) drawRect: (NSRect) rect
+{
+ // Delegate the draw event to the active state.
+ [m_activeState drawRect: rect];
+}
+
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_activeState = nil;
+ }
+
+ return self;
+}
+
+- (void) keyDown: (NSEvent*) theEvent
+{
+}
+
+- (void) mouseDown: (NSEvent*) theEvent
+{
+ // Save the mouse down position.
+ m_mouseDownPos = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
+ // Save the current mouse position.
+ m_currentMousePos = m_mouseDownPos;
+
+ // Get the document selection.
+ CSelection* selection = [[[m_view mainController] document] selection];
+
+ // A selection handle was selected.
+ if(
+ [selection
+ handleContainingX: m_mouseDownPos.x
+ y: m_mouseDownPos.y] != -1 )
+ {
+ // Activate the resize state.
+ m_activeState = [CSelectionToolResizeState sharedSelectionToolResizeState];
+ }
+ // There are selected objects at the mouse down position.
+ else if( [selection containsX: m_mouseDownPos.x y: m_mouseDownPos.y] )
+ {
+ // Activate the object moving state.
+ m_activeState = [CSelectionToolMoveState sharedSelectionToolMoveObjectsState];
+ }
+ // Select all objects at the mouse down location.
+ else
+ {
+ // Find all objects at the mouse down locations.
+ CFindObjectsContainingAPointVisitor* findVisior = [[CFindObjectsContainingAPointVisitor alloc] init];
+ [findVisior findPointX: m_mouseDownPos.x Y: m_mouseDownPos.y];
+ [findVisior visitDocument: [[m_view mainController] document]];
+
+ // Clear the selection if the Shift key is not down.
+ if( ![self shiftKeyIsDown] )
+ [selection clear];
+
+ // Add the found objects to the document selection.
+ [selection addObjectsFromArray: [findVisior objects]];
+
+ // Release the find visitor.
+ [findVisior release];
+
+ // The document selection is empty.
+ if( [[selection objects] count] < 1 )
+ {
+ // Activate the object selection state.
+ m_activeState = [CSelectionToolRectangleState sharedSelectionToolSelectState];
+ }
+ // The document selection is not empty.
+ else
+ {
+ // Activate the object moving state.
+ m_activeState = [CSelectionToolMoveState sharedSelectionToolMoveObjectsState];
+ }
+ }
+
+ // Activate and recalculate the current state.
+ [m_activeState start];
+ [m_activeState updateInternalState];
+
+ // Repaint.
+ // TODO: do not repaint everything.
+ [m_view setNeedsDisplay: YES];
+}
+
+- (NSPoint) mouseDownPos
+{
+ return m_mouseDownPos;
+}
+
+- (void) mouseDragged: (NSEvent*) theEvent
+{
+ // Save the current mouse position.
+ m_currentMousePos = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
+
+ // Update the internal state.
+ [m_activeState updateInternalState];
+
+ // Repaint.
+ // TODO: do not repaint everything.
+ [m_view setNeedsDisplay: YES];
+}
+
+- (void) mouseUp: (NSEvent*) theEvent
+{
+ // Save the current mouse position.
+ m_currentMousePos = [m_view convertPoint: [theEvent locationInWindow] fromView: nil];
+
+ // Update the internal state.
+ [m_activeState updateInternalState];
+
+ // Ask the .
+ [m_activeState finish];
+
+ // Unset current tool state.
+ m_activeState = nil;
+
+ // Repaint.
+ // TODO: do not repaint everything.
+ [m_view setNeedsDisplay: YES];
+}
+
++ (CSelectionTool*) sharedSelectionTool
+{
+ static CSelectionTool* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CSelectionTool alloc] init];
+
+ return s_instance;
+}
+
+@end
\ No newline at end of file
Deleted: trunk/src/tools/CSelectionToolMoveObjectsState.h
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveObjectsState.h 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CSelectionToolMoveObjectsState.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2007 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import <Cocoa/Cocoa.h>
-@class CAffineTrafo;
-@class CSelection;
-#import "CSelectionToolState.h"
-
-/**
- * The selection tool state for moving objects.
- */
-@interface CSelectionToolMoveObjectsState : CSelectionToolState
-{
- /**
- * The resulting affine transformation visitor (@see m_affineMap).
- */
- CAffineTrafo* m_affineTrafo;
-
- /**
- * The manipulated objects which are drawn during object moving.
- */
- CSelection* m_copiedObjects;
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CSelectionToolMoveObjectsState*) sharedSelectionToolMoveObjectsState;
-
-@end
Deleted: trunk/src/tools/CSelectionToolMoveObjectsState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveObjectsState.m 2007-05-27 11:19:37 UTC (rev 533)
+++ trunk/src/tools/CSelectionToolMoveObjectsState.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2007 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CAffineMap.h"
-#import "CAffineTrafo.h"
-#import "CContourRenderer.h"
-#import "ChlorDocument.h"
-#import "CSelectionTool.h"
-#import "CSelectionToolMoveObjectsState.h"
-
-@implementation CSelectionToolMoveObjectsState
-
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- m_affineTrafo = [[CAffineTrafo alloc] init];
- m_copiedObjects = nil;
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- [m_copiedObjects release];
- [m_affineTrafo release];
- [super dealloc];
-}
-
-- (void) cancel
-{
- // Release the copied objects.
- [m_copiedObjects release];
- m_copiedObjects = nil;
-
- // Get the selection.
- CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
-
- // Reshow the selection.
- [selection show];
-
- // Clear the selection.
- [selection clear];
-}
-
-- (void) drawRect: (NSRect) rect
-{
- // Convert NSRect to CGRect.
- CGRect drawRect = CGRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height );
- // Get context.
- CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
-
- // Draw the copied objects.
- CContourRenderer* copiedObjectsRenderer = [CContourRenderer sharedContourRenderer];
-
- [copiedObjectsRenderer setDrawingBoundary: drawRect];
- [copiedObjectsRenderer setContext: context];
- [copiedObjectsRenderer visitSelection: m_copiedObjects];
-}
-
-- (void) finish
-{
- // Release the copied objects.
- [m_copiedObjects release];
- m_copiedObjects = nil;
-
- // Get the document.
- ChlorDocument* document = [[[[CSelectionTool sharedSelectionTool] view] mainController] document];
-
- // Make the document transform the selection.
- [document transformSelectionFirstBy: [[m_affineTrafo affineMap] copyWithZone:[self zone]]
- thenBy: [[CAffineMap allocWithZone:[self zone]] init]
- actionName: NSLocalizedString(
- @"Move Objects",
- @"Name of undo/redo action for moving objects" )];
-
- // Reshow the selection.
- [[document selection] show];
-}
-
-- (void) updateInternalState
-{
- // Release the copied objects.
- [m_copiedObjects release];
-
- // Get the selection tool.
- CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
-
- // Get the selection.
- CSelection* selection = [[[[selectionTool view] mainController] document] selection];
-
- // Copy the selected objects.
- m_copiedObjects = [selection copy];
-
- // Calculate the movement.
- double dx = [selectionTool currentMousePos].x - [selectionTool mouseDownPos].x;
- double dy = [selectionTool currentMousePos].y - [selectionTool mouseDownPos].y;
-
- // Set the affine map.
- [[m_affineTrafo affineMap] reset];
- [[m_affineTrafo affineMap] translateX: dx Y: dy];
-
- // Apply the affine transformation to the copied objects.
- [m_affineTrafo visitSelection: m_copiedObjects];
-
- // Show the copied objects.
- [m_copiedObjects show];
-}
-
-+ (CSelectionToolMoveObjectsState*) sharedSelectionToolMoveObjectsState
-{
- static CSelectionToolMoveObjectsState* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CSelectionToolMoveObjectsState alloc] init];
-
- return s_instance;
-}
-
-- (void) start
-{
- // Get the document selection.
- CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
-
- // Hide the selection.
- [selection hide];
-}
-
-@end
Copied: trunk/src/tools/CSelectionToolMoveState.h (from rev 544, trunk/src/gui/tools/CSelectionToolMoveState.h)
===================================================================
--- trunk/src/tools/CSelectionToolMoveState.h (rev 0)
+++ trunk/src/tools/CSelectionToolMoveState.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: CSelectionToolMoveState.h 531 2007-05-27 01:27:33Z lenny222 $
+ */
+
+#import <Cocoa/Cocoa.h>
+@class CAffineTrafo;
+@class CSelection;
+#import "CSelectionToolState.h"
+
+/**
+ * The selection tool state for moving objects.
+ */
+@interface CSelectionToolMoveState : CSelectionToolState
+{
+ /**
+ * The resulting affine transformation visitor (@see m_affineMap).
+ */
+ CAffineTrafo* m_affineTrafo;
+
+ /**
+ * The manipulated objects which are drawn during object moving.
+ */
+ CSelection* m_copiedObjects;
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CSelectionToolMoveState*) sharedSelectionToolMoveObjectsState;
+
+@end
Copied: trunk/src/tools/CSelectionToolMoveState.m (from rev 545, trunk/src/gui/tools/CSelectionToolMoveState.m)
===================================================================
--- trunk/src/tools/CSelectionToolMoveState.m (rev 0)
+++ trunk/src/tools/CSelectionToolMoveState.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: CSelectionToolMoveState.m 533 2007-05-27 11:19:37Z lenny222 $
+ */
+
+#import "CAffineMap.h"
+#import "CAffineTrafo.h"
+#import "CContourRenderer.h"
+#import "ChlorDocument.h"
+#import "CSelectionTool.h"
+#import "CSelectionToolMoveState.h"
+
+@implementation CSelectionToolMoveState
+
+- (void) cancel
+{
+ // Release the copied objects.
+ [m_copiedObjects release];
+ m_copiedObjects = nil;
+
+ // Get the selection.
+ CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
+
+ // Clear the selection.
+ [selection clear];
+
+ // Show the selection again.
+ [selection show];
+}
+
+- (void) dealloc
+{
+ [m_copiedObjects release];
+ [m_affineTrafo release];
+ [super dealloc];
+}
+
+- (void) drawRect: (NSRect) rect
+{
+ // Convert NSRect to CGRect.
+ CGRect drawRect = CGRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height );
+ // Get context.
+ CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
+
+ // Draw the copied objects.
+ CContourRenderer* copiedObjectsRenderer = [CContourRenderer sharedContourRenderer];
+
+ [copiedObjectsRenderer setDrawingBoundary: drawRect];
+ [copiedObjectsRenderer setContext: context];
+ [copiedObjectsRenderer visitSelection: m_copiedObjects];
+}
+
+- (void) finish
+{
+ // Release the copied objects.
+ [m_copiedObjects release];
+ m_copiedObjects = nil;
+
+ // Get the document.
+ ChlorDocument* document = [[[[CSelectionTool sharedSelectionTool] view] mainController] document];
+
+ // Make the document transform the selection.
+ [document transformSelectionFirstBy: [[m_affineTrafo affineMap] copyWithZone:[self zone]]
+ thenBy: [[CAffineMap allocWithZone:[self zone]] init]
+ actionName: NSLocalizedString(
+ @"Move Objects",
+ @"Name of undo/redo action for moving objects" )];
+
+ // Show the selection agin.
+ [[document selection] show];
+}
+
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_affineTrafo = [[CAffineTrafo alloc] init];
+ m_copiedObjects = nil;
+ }
+
+ return self;
+}
+
+- (void) updateInternalState
+{
+ // Release the copied objects.
+ [m_copiedObjects release];
+
+ // Get the selection tool.
+ CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
+
+ // Get the selection.
+ CSelection* selection = [[[[selectionTool view] mainController] document] selection];
+
+ // Copy the selected objects.
+ m_copiedObjects = [selection copy];
+
+ // Calculate the movement.
+ double dx = [selectionTool currentMousePos].x - [selectionTool mouseDownPos].x;
+ double dy = [selectionTool currentMousePos].y - [selectionTool mouseDownPos].y;
+
+ // Set the affine map.
+ [[m_affineTrafo affineMap] reset];
+ [[m_affineTrafo affineMap] translateX: dx Y: dy];
+
+ // Apply the affine transformation to the copied objects.
+ [m_affineTrafo visitSelection: m_copiedObjects];
+
+ // Show the copied objects.
+ [m_copiedObjects show];
+}
+
++ (CSelectionToolMoveState*) sharedSelectionToolMoveObjectsState
+{
+ static CSelectionToolMoveState* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CSelectionToolMoveState alloc] init];
+
+ return s_instance;
+}
+
+- (void) start
+{
+ // Get the document selection.
+ CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
+
+ // Hide the document selection.
+ [selection hide];
+}
+
+@end
Copied: trunk/src/tools/CSelectionToolRectangleState.h (from rev 544, trunk/src/gui/tools/CSelectionToolRectangleState.h)
===================================================================
--- trunk/src/tools/CSelectionToolRectangleState.h (rev 0)
+++ trunk/src/tools/CSelectionToolRectangleState.h 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@class CRect;
+#import "CSelectionToolState.h"
+
+/**
+ * The selection tool state for selecting objects with the selction rectangle.
+ */
+@interface CSelectionToolRectangleState : CSelectionToolState
+{
+ /**
+ * The selection rectangle.
+ */
+ CRect* m_selectionRectangle;
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CSelectionToolRectangleState*) sharedSelectionToolSelectState;
+
+@end
Copied: trunk/src/tools/CSelectionToolRectangleState.m (from rev 545, trunk/src/gui/tools/CSelectionToolRectangleState.m)
===================================================================
--- trunk/src/tools/CSelectionToolRectangleState.m (rev 0)
+++ trunk/src/tools/CSelectionToolRectangleState.m 2007-06-03 15:38:25 UTC (rev 551)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public Lice...
[truncated message content] |
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 14:28:07
|
Revision: 550
http://svn.sourceforge.net/chlor/?rev=550&view=rev
Author: lenny222
Date: 2007-06-03 07:28:02 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
finally change the mirroring bug
Modified Paths:
--------------
trunk/src/io/svg/export/CSvgExport.m
trunk/src/io/svg/import/core/CSvgImportVisitor.m
trunk/src/notes/TODO.txt
Modified: trunk/src/io/svg/export/CSvgExport.m
===================================================================
--- trunk/src/io/svg/export/CSvgExport.m 2007-06-03 13:28:42 UTC (rev 549)
+++ trunk/src/io/svg/export/CSvgExport.m 2007-06-03 14:28:02 UTC (rev 550)
@@ -71,7 +71,7 @@
NSXMLElement* mirrorGroup = (NSXMLElement*) [NSXMLNode elementWithName: @"g"];
[mirrorGroup addAttribute:
[NSXMLNode attributeWithName: @"transform" stringValue:
- [NSString stringWithFormat: @"scale(1, -1) translate(0, -%f)", [aDocument height]]]];
+ [NSString stringWithFormat: @"translate(0, -%f) scale(1, -1)", [aDocument height]]]];
[m_parentNode addChild: mirrorGroup];
// Make the mirror group the current parent node.
Modified: trunk/src/io/svg/import/core/CSvgImportVisitor.m
===================================================================
--- trunk/src/io/svg/import/core/CSvgImportVisitor.m 2007-06-03 13:28:42 UTC (rev 549)
+++ trunk/src/io/svg/import/core/CSvgImportVisitor.m 2007-06-03 14:28:02 UTC (rev 550)
@@ -314,8 +314,8 @@
// Mirror objects since SVG has a vertically flipped coordinate system.
CAffineTrafo* affineTrafo = [[CAffineTrafo alloc] init];
- [[affineTrafo affineMap] translateX: 0.0 Y: -[m_chlorDocument height]];
[[affineTrafo affineMap] scaleX: 1.0 Y: -1.0];
+ [[affineTrafo affineMap] translateX: 0.0 Y: [m_chlorDocument height]];
[affineTrafo visitDocument: m_chlorDocument];
[affineTrafo release];
}
Modified: trunk/src/notes/TODO.txt
===================================================================
--- trunk/src/notes/TODO.txt 2007-06-03 13:28:42 UTC (rev 549)
+++ trunk/src/notes/TODO.txt 2007-06-03 14:28:02 UTC (rev 550)
@@ -1,9 +1,5 @@
User experience
---------------
-- BUG: a file saved by Chlor appears empty if loaded by Chlor again
- - it works if one removes the "-" in CSvgImportVisitor:
- "[[affineTrafo affineMap] translateX: 0.0 Y: -[m_chlorDocument height]];"
- but then all other SVG files break
- BUG: shift dragging while one object is selected moves the object even when clicked/dragged is outside of it
- TODO: add keyboard short cuts like <Backspace> which deletes the selected objects and <Esc> which cancels the current tool
- call CSelectionToolState's "cancel:" method
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 13:28:44
|
Revision: 549
http://svn.sourceforge.net/chlor/?rev=549&view=rev
Author: lenny222
Date: 2007-06-03 06:28:42 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
it looks like we have a problem with fill/stroke in nested groups
Modified Paths:
--------------
trunk/src/tests/CSvgImportTest.m
Modified: trunk/src/tests/CSvgImportTest.m
===================================================================
--- trunk/src/tests/CSvgImportTest.m 2007-06-03 13:05:58 UTC (rev 548)
+++ trunk/src/tests/CSvgImportTest.m 2007-06-03 13:28:42 UTC (rev 549)
@@ -134,12 +134,15 @@
// Check the number of stroke color components.
STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
- // Check the stroke color components.
- const float* components = CGColorGetComponents( [paint color] );
- STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
- STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
- STAssertEqualsWithAccuracy( components[ 2 ], 1.0f, [CGeometry accuracy], @"The blue color component is wrong" );
- STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ if( CGColorGetNumberOfComponents( [paint color] ) == 4 )
+ {
+ // Check the stroke color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 1.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ }
}
@finally
@@ -237,10 +240,152 @@
STAssertTrue( [path fill] && [[path fill] paint] , @"There should be fill and fill paint" );
STAssertTrue( [path stroke] && [[path stroke] paint] , @"There should be stroke and stroke paint" );
- /*
+ // Check the fill paint.
+ CSolidPaint* paint;
+
+ if( [[[path fill] paint] isKindOfClass: [CSolidPaint class]] )
+ paint = (CSolidPaint*) [[path fill] paint];
+ else
+ paint = nil;
+
+ STAssertNotNil( path, @"The fill paint must be a solid paint" );
+
+ // Check the number of fill color components.
+ STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
+
+ if( CGColorGetNumberOfComponents( [paint color] ) == 4 )
+ {
+ // Check the fill color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 1.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ }
+
// Check the stroke paint.
+ if( [[[path stroke] paint] isKindOfClass: [CSolidPaint class]] )
+ paint = (CSolidPaint*) [[path stroke] paint];
+ else
+ paint = nil;
+
+ STAssertNotNil( path, @"The stroke paint must be a solid paint" );
+
+ // Check the number of stroke color components.
+ STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
+
+ if( CGColorGetNumberOfComponents( [paint color] ) == 4 )
+ {
+ // Check the stroke color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 1.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 0.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ }
+
+ }
+ @finally
+ {
+ [chlorDocument release];
+ }
+}
+
+// Tests transformations.
+- (void) testTransformations
+{
+ // The SVG document.
+ NSString* svgDocument =
+ @"<svg width=\"300.0\" height=\"400\">"
+ @" <g transform=\"scale(20.0, 50) rotate(90)\">"
+ @" <rect x=\"0\" y=\"0\" width=\"1\" height=\"1.0\" stroke=\"yellow\" fill=\"black\" />"
+ @" </g>"
+ @"</svg>";
+
+ // Create the Chlor document.
+ ChlorDocument* chlorDocument = [[ChlorDocument alloc] init];
+
+ // Import the SVG document into the chlor document.
+ [m_svgImporter
+ importData: [svgDocument dataUsingEncoding: NSASCIIStringEncoding]
+ intoDocument: chlorDocument];
+
+ @try
+ {
+ // There must be exactly one layer.
+ STAssertEquals( [[[chlorDocument layers] objects] count], (unsigned) 1, nil );
+
+ // Get the layer.
+ CLayer* layer = (CLayer*) [[[chlorDocument layers] objects] objectAtIndex: 0];
+
+ // There must be exactly one object in the layer.
+ STAssertEquals( [[layer objects] count], (unsigned) 1, nil );
+
+ // Get the object.
+ CObject* object = (CObject*) [[layer objects] objectAtIndex: 0];
+
+ // Check that the object is a group.
+ CGroup* group;
+
+ if( [object isKindOfClass: [CGroup class]] )
+ group = (CGroup*) object;
+ else
+ group = nil;
+
+ STAssertNotNil( group, @"The object must be a CGroup" );
+
+ // There must be exactly one object in this group.
+ STAssertEquals( [[group objects] count], (unsigned) 1, nil );
+
+ // Get the object.
+ object = (CObject*) [[group objects] objectAtIndex: 0];
+
+ // Check that the object is a path.
+ CPath* path;
+
+ if( [object isKindOfClass: [CPath class]] )
+ path = (CPath*) object;
+ else
+ path = nil;
+
+ STAssertNotNil( path, @"The object must be a CPath" );
+
+ // Verify the shape boundary of the path
+ CRect* shapeBoundary = [path shapeBoundary];
+
+ STAssertEqualsWithAccuracy( [shapeBoundary left], -50.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary bottom], (float) [chlorDocument height] - 20.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary width], 50.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary height], 20.0f, [CGeometry accuracy], nil );
+
+ // Check the existance of fill and stroke.
+ STAssertTrue( [path fill] && [[path fill] paint] , @"There should be fill and fill paint" );
+ STAssertTrue( [path stroke] && [[path stroke] paint] , @"There should be stroke and stroke paint" );
+
+ // Check the fill paint.
CSolidPaint* paint;
+ if( [[[path fill] paint] isKindOfClass: [CSolidPaint class]] )
+ paint = (CSolidPaint*) [[path fill] paint];
+ else
+ paint = nil;
+
+ STAssertNotNil( path, @"The fill paint must be a solid paint" );
+
+ // Check the number of fill color components.
+ STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
+
+ if( CGColorGetNumberOfComponents( [paint color] ) == 4 )
+ {
+ // Check the fill color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 0.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ }
+
+ // Check the stroke paint.
if( [[[path stroke] paint] isKindOfClass: [CSolidPaint class]] )
paint = (CSolidPaint*) [[path stroke] paint];
else
@@ -251,13 +396,15 @@
// Check the number of stroke color components.
STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
- // Check the stroke color components.
- const float* components = CGColorGetComponents( [paint color] );
- STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
- STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
- STAssertEqualsWithAccuracy( components[ 2 ], 1.0f, [CGeometry accuracy], @"The blue color component is wrong" );
- STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
- */
+ if( CGColorGetNumberOfComponents( [paint color] ) == 4 )
+ {
+ // Check the stroke color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 1.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 1.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 0.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ }
}
@finally
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-03 13:06:00
|
Revision: 548
http://svn.sourceforge.net/chlor/?rev=548&view=rev
Author: lenny222
Date: 2007-06-03 06:05:58 -0700 (Sun, 03 Jun 2007)
Log Message:
-----------
add another SVG import test
Modified Paths:
--------------
trunk/src/tests/CSvgImportTest.m
Modified: trunk/src/tests/CSvgImportTest.m
===================================================================
--- trunk/src/tests/CSvgImportTest.m 2007-06-02 23:41:08 UTC (rev 547)
+++ trunk/src/tests/CSvgImportTest.m 2007-06-03 13:05:58 UTC (rev 548)
@@ -18,10 +18,13 @@
*/
#import "ChlorDocument.h"
+#import "CFill.h"
#import "CGeometry.h"
#import "CLayer.h"
#import "CLayers.h"
#import "CPath.h"
+#import "CSolidPaint.h"
+#import "CStroke.h"
#import "CSvgImport.h"
#import "CSvgImportTest.h"
@@ -37,7 +40,7 @@
[m_svgImporter release];
}
-// Tests the document import.
+// Tests the document properties.
- (void) testDocument
{
// The SVG document.
@@ -65,7 +68,7 @@
}
}
-// Tests the import of a "rect".
+// Tests the "rect" properties.
- (void) testRect
{
// The SVG document.
@@ -96,6 +99,7 @@
// Get the object.
CObject* object = (CObject*) [[layer objects] objectAtIndex: 0];
+ // Check that the object is a path.
CPath* path;
if( [object isKindOfClass: [CPath class]] )
@@ -103,8 +107,7 @@
else
path = nil;
- // The object must be a CPath.
- STAssertNotNil( path, nil );
+ STAssertNotNil( path, @"The object must be a CPath" );
// Verify the shape boundary of the path
CRect* shapeBoundary = [path shapeBoundary];
@@ -113,6 +116,31 @@
STAssertEqualsWithAccuracy( [shapeBoundary bottom], (float) [chlorDocument height] - 260.75f, [CGeometry accuracy], nil );
STAssertEqualsWithAccuracy( [shapeBoundary width], 54.0f, [CGeometry accuracy], nil );
STAssertEqualsWithAccuracy( [shapeBoundary height], 260.75f, [CGeometry accuracy], nil );
+
+ // Check the existance of fill and stroke.
+ STAssertFalse( [path fill] && [[path fill] paint] , @"There should be no fill or no fill paint" );
+ STAssertTrue( [path stroke] && [[path stroke] paint] , @"There should be stroke and stroke paint" );
+
+ // Check the stroke paint.
+ CSolidPaint* paint;
+
+ if( [[[path stroke] paint] isKindOfClass: [CSolidPaint class]] )
+ paint = (CSolidPaint*) [[path stroke] paint];
+ else
+ paint = nil;
+
+ STAssertNotNil( path, @"The stroke paint must be a solid paint" );
+
+ // Check the number of stroke color components.
+ STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
+
+ // Check the stroke color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 1.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+
}
@finally
{
@@ -120,4 +148,122 @@
}
}
+// Tests nested transformation groups.
+- (void) testNestedTransformationGroups
+{
+ // The SVG document.
+ NSString* svgDocument =
+ @"<svg width=\"300.0\" height=\"400\">"
+ @" <g transform=\"translate(0, 30)\">"
+ @" <g transform=\"translate(-30, 0) scale(2, 3)\">"
+ @" <rect x=\"30\" y=\"0\" width=\"2.5\" height=\"2\" stroke=\"red\" fill=\"blue\" />"
+ @" </g>"
+ @" </g>"
+ @"</svg>";
+
+ // Create the Chlor document.
+ ChlorDocument* chlorDocument = [[ChlorDocument alloc] init];
+
+ // Import the SVG document into the chlor document.
+ [m_svgImporter
+ importData: [svgDocument dataUsingEncoding: NSASCIIStringEncoding]
+ intoDocument: chlorDocument];
+
+ @try
+ {
+ // There must be exactly one layer.
+ STAssertEquals( [[[chlorDocument layers] objects] count], (unsigned) 1, nil );
+
+ // Get the layer.
+ CLayer* layer = (CLayer*) [[[chlorDocument layers] objects] objectAtIndex: 0];
+
+ // There must be exactly one object in the layer.
+ STAssertEquals( [[layer objects] count], (unsigned) 1, nil );
+
+ // Get the object.
+ CObject* object = (CObject*) [[layer objects] objectAtIndex: 0];
+
+ // Check that the object is a group.
+ CGroup* group1;
+
+ if( [object isKindOfClass: [CGroup class]] )
+ group1 = (CGroup*) object;
+ else
+ group1 = nil;
+
+ STAssertNotNil( group1, @"The object must be a CGroup" );
+
+ // There must be exactly one object in this group.
+ STAssertEquals( [[group1 objects] count], (unsigned) 1, nil );
+
+ // Get the object.
+ object = (CObject*) [[group1 objects] objectAtIndex: 0];
+
+ // Check that the object is a group.
+ CGroup* group2;
+
+ if( [object isKindOfClass: [CGroup class]] )
+ group2 = (CGroup*) object;
+ else
+ group2 = nil;
+
+ STAssertNotNil( group2, @"The object must be a CGroup" );
+
+ // There must be exactly one object in this group.
+ STAssertEquals( [[group2 objects] count], (unsigned) 1, nil );
+
+ // Get the object.
+ object = (CObject*) [[group2 objects] objectAtIndex: 0];
+
+ // Check that the object is a path.
+ CPath* path;
+
+ if( [object isKindOfClass: [CPath class]] )
+ path = (CPath*) object;
+ else
+ path = nil;
+
+ STAssertNotNil( path, @"The object must be a CPath" );
+
+ // Verify the shape boundary of the path
+ CRect* shapeBoundary = [path shapeBoundary];
+
+ STAssertEqualsWithAccuracy( [shapeBoundary left], 0.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary bottom], (float) [chlorDocument height] - 36.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary width], 5.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary height], 6.0f, [CGeometry accuracy], nil );
+
+ // Check the existance of fill and stroke.
+ STAssertTrue( [path fill] && [[path fill] paint] , @"There should be fill and fill paint" );
+ STAssertTrue( [path stroke] && [[path stroke] paint] , @"There should be stroke and stroke paint" );
+
+ /*
+ // Check the stroke paint.
+ CSolidPaint* paint;
+
+ if( [[[path stroke] paint] isKindOfClass: [CSolidPaint class]] )
+ paint = (CSolidPaint*) [[path stroke] paint];
+ else
+ paint = nil;
+
+ STAssertNotNil( path, @"The stroke paint must be a solid paint" );
+
+ // Check the number of stroke color components.
+ STAssertEquals( CGColorGetNumberOfComponents( [paint color] ), (size_t) 4, @"There must be 4 color components" );
+
+ // Check the stroke color components.
+ const float* components = CGColorGetComponents( [paint color] );
+ STAssertEqualsWithAccuracy( components[ 0 ], 0.0f, [CGeometry accuracy], @"The red color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 1 ], 0.0f, [CGeometry accuracy], @"The green color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 2 ], 1.0f, [CGeometry accuracy], @"The blue color component is wrong" );
+ STAssertEqualsWithAccuracy( components[ 3 ], 1.0f, [CGeometry accuracy], @"The alpha color component is wrong" );
+ */
+
+ }
+ @finally
+ {
+ [chlorDocument release];
+ }
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-06-02 23:41:24
|
Revision: 547
http://svn.sourceforge.net/chlor/?rev=547&view=rev
Author: lenny222
Date: 2007-06-02 16:41:08 -0700 (Sat, 02 Jun 2007)
Log Message:
-----------
add SVG unit test
Modified Paths:
--------------
trunk/src/Chlor.xcodeproj/project.pbxproj
trunk/src/io/console/CConsoleExport.m
trunk/src/io/svg/import/CSvgImport.m
trunk/src/notes/TODO.txt
Added Paths:
-----------
trunk/src/tests/CSvgImportTest.h
trunk/src/tests/CSvgImportTest.m
Modified: trunk/src/Chlor.xcodeproj/project.pbxproj
===================================================================
(Binary files differ)
Modified: trunk/src/io/console/CConsoleExport.m
===================================================================
--- trunk/src/io/console/CConsoleExport.m 2007-05-28 14:28:28 UTC (rev 546)
+++ trunk/src/io/console/CConsoleExport.m 2007-06-02 23:41:08 UTC (rev 547)
@@ -116,6 +116,7 @@
}
else
{
+ [self output: @"TODO: unhandled paint."];
[self endOutputGroup: @"fill"];
return;
}
Modified: trunk/src/io/svg/import/CSvgImport.m
===================================================================
--- trunk/src/io/svg/import/CSvgImport.m 2007-05-28 14:28:28 UTC (rev 546)
+++ trunk/src/io/svg/import/CSvgImport.m 2007-06-02 23:41:08 UTC (rev 547)
@@ -49,26 +49,19 @@
{
// Create the XML parser using the given data.
NSXMLParser* xmlParser = [[NSXMLParser alloc] initWithData: theData];
-
// Set self as XML delegate.
[xmlParser setDelegate: self];
-
// Parse the XML data. This calls the "parser:" method which creates and fills m_svgDocument.
[xmlParser parse];
-
// Release the XML parser.
[xmlParser release];
- xmlParser = nil;
- // Create the SVG import visitor.
+ // Create the SVG import visitor for the just created internal SVG data.
CSvgImportVisitor* svgImportVisitor = [[CSvgImportVisitor alloc] initWithChlorDocument: aDocument];
-
- // Visit the SVG document.
+ // Visit the internal SVG document data.
[svgImportVisitor visitSvgDocument: m_svgDocument];
-
// Release the SVG import visitor.
[svgImportVisitor release];
- svgImportVisitor = nil;
// TODO: remove after debugging.
#if 1
Modified: trunk/src/notes/TODO.txt
===================================================================
--- trunk/src/notes/TODO.txt 2007-05-28 14:28:28 UTC (rev 546)
+++ trunk/src/notes/TODO.txt 2007-06-02 23:41:08 UTC (rev 547)
@@ -10,7 +10,8 @@
- TODO: draw the CPage
- BUG: clicking in in the bbox of an ellipse selects the ellipse even when the click is outside
(this test fails in CShapeTest)
- - maybe this has something to do with NSArray clear/adding in CSelection
+ - create Unit Tests breaking down to bezier/line interesections
+ - maybe this has something to do with NSArray clear/adding in CSelection?
- BUG: undo/redo of deleting objects doesnt repaint
- TODO: create CUnkownFill, CUnknownStroke, CUnknownPaint
- CGroup's fill: and stroke: need to use these if the group contains many objects
Added: trunk/src/tests/CSvgImportTest.h
===================================================================
--- trunk/src/tests/CSvgImportTest.h (rev 0)
+++ trunk/src/tests/CSvgImportTest.h 2007-06-02 23:41:08 UTC (rev 547)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import <SenTestingKit/SenTestingKit.h>
+@class CSvgImport;
+
+@interface CSvgImportTest : SenTestCase
+{
+ /**
+ * The SVG importer.
+ */
+ CSvgImport* m_svgImporter;
+}
+
+@end
Property changes on: trunk/src/tests/CSvgImportTest.h
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/tests/CSvgImportTest.m
===================================================================
--- trunk/src/tests/CSvgImportTest.m (rev 0)
+++ trunk/src/tests/CSvgImportTest.m 2007-06-02 23:41:08 UTC (rev 547)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "ChlorDocument.h"
+#import "CGeometry.h"
+#import "CLayer.h"
+#import "CLayers.h"
+#import "CPath.h"
+#import "CSvgImport.h"
+#import "CSvgImportTest.h"
+
+@implementation CSvgImportTest
+
+- (void) setUp
+{
+ m_svgImporter = [[CSvgImport alloc] init];
+}
+
+- (void) tearDown
+{
+ [m_svgImporter release];
+}
+
+// Tests the document import.
+- (void) testDocument
+{
+ // The SVG document.
+ NSString* svgDocument =
+ @"<svg width=\"42.0\" height=\"120\">"
+ @"</svg>";
+
+ // Create the Chlor document.
+ ChlorDocument* chlorDocument = [[ChlorDocument alloc] init];
+
+ // Import the SVG document into the chlor document.
+ [m_svgImporter
+ importData: [svgDocument dataUsingEncoding: NSASCIIStringEncoding]
+ intoDocument: chlorDocument];
+
+ @try
+ {
+ // Check the document width and height.
+ STAssertEqualsWithAccuracy( [chlorDocument width], 42.0, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [chlorDocument height], 120.0, [CGeometry accuracy], nil );
+ }
+ @finally
+ {
+ [chlorDocument release];
+ }
+}
+
+// Tests the import of a "rect".
+- (void) testRect
+{
+ // The SVG document.
+ NSString* svgDocument =
+ @"<svg width=\"300.0\" height=\"400\">"
+ @" <rect x=\"1.5\" y=\"0\" width=\"54\" height=\"260.75\" fill=\"none\" stroke=\"blue\" stroke-width=\"2\"/>"
+ @"</svg>";
+
+ // Create the Chlor document.
+ ChlorDocument* chlorDocument = [[ChlorDocument alloc] init];
+
+ // Import the SVG document into the chlor document.
+ [m_svgImporter
+ importData: [svgDocument dataUsingEncoding: NSASCIIStringEncoding]
+ intoDocument: chlorDocument];
+
+ @try
+ {
+ // There must be exactly one layer.
+ STAssertEquals( [[[chlorDocument layers] objects] count], (unsigned) 1, nil );
+
+ // Get the layer.
+ CLayer* layer = (CLayer*) [[[chlorDocument layers] objects] objectAtIndex: 0];
+
+ // There must be exactly one object.
+ STAssertEquals( [[layer objects] count], (unsigned) 1, nil );
+
+ // Get the object.
+ CObject* object = (CObject*) [[layer objects] objectAtIndex: 0];
+
+ CPath* path;
+
+ if( [object isKindOfClass: [CPath class]] )
+ path = (CPath*) object;
+ else
+ path = nil;
+
+ // The object must be a CPath.
+ STAssertNotNil( path, nil );
+
+ // Verify the shape boundary of the path
+ CRect* shapeBoundary = [path shapeBoundary];
+
+ STAssertEqualsWithAccuracy( [shapeBoundary left], 1.5f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary bottom], (float) [chlorDocument height] - 260.75f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary width], 54.0f, [CGeometry accuracy], nil );
+ STAssertEqualsWithAccuracy( [shapeBoundary height], 260.75f, [CGeometry accuracy], nil );
+ }
+ @finally
+ {
+ [chlorDocument release];
+ }
+}
+
+@end
Property changes on: trunk/src/tests/CSvgImportTest.m
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-05-28 14:28:29
|
Revision: 546
http://svn.sourceforge.net/chlor/?rev=546&view=rev
Author: lenny222
Date: 2007-05-28 07:28:28 -0700 (Mon, 28 May 2007)
Log Message:
-----------
add indendation to CConsoleExport
Modified Paths:
--------------
trunk/src/core/ChlorDocument.m
trunk/src/io/console/CConsoleExport.h
trunk/src/io/console/CConsoleExport.m
trunk/src/io/svg/import/core/CSvgFactory.m
trunk/src/io/svg/import/core/CSvgImportVisitor.m
trunk/src/io/svg/import/elements/CSvgDefinitions.h
trunk/src/io/svg/import/elements/CSvgDefinitions.m
trunk/src/io/svg/import/elements/CSvgGroup.m
trunk/src/notes/TODO.txt
trunk/src/tests/CAffineMapTest.m
Modified: trunk/src/core/ChlorDocument.m
===================================================================
--- trunk/src/core/ChlorDocument.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/core/ChlorDocument.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -58,7 +58,7 @@
// Create the layers.
m_layers = [[CLayers alloc] init];
-#if 1
+#if 0
// Add a temporary welcome text.
{
CText* text = [[CText alloc] init];
Modified: trunk/src/io/console/CConsoleExport.h
===================================================================
--- trunk/src/io/console/CConsoleExport.h 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/console/CConsoleExport.h 2007-05-28 14:28:28 UTC (rev 546)
@@ -24,6 +24,25 @@
*/
@interface CConsoleExport : CVisitor
{
+ /**
+ * The level of output indendation.
+ */
+ int m_levelOfOutputIndendation;
}
+/**
+ * Begins a new output group. The level of output indendation is increased by one.
+ */
+- (void) beginOutputGroup: (NSString*) theGroupName;
+
+/**
+ * Ends a new output group. The level of output indendation is increased by one.
+ */
+- (void) endOutputGroup: (NSString*) theGroupName;
+
+/**
+ * Writes an indendet string to the output.
+ */
+- (void) output: (NSString*) theString;
+
@end
Modified: trunk/src/io/console/CConsoleExport.m
===================================================================
--- trunk/src/io/console/CConsoleExport.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/console/CConsoleExport.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -29,37 +29,107 @@
@implementation CConsoleExport
+- (void) beginOutputGroup: (NSString*) theGroupName
+{
+ [theGroupName retain];
+
+ // Write theGroupName to output.
+ [self output: [NSString stringWithFormat: @"begin %@", theGroupName]];
+
+ // Increase the level of indendation.
+ ++m_levelOfOutputIndendation;
+
+ [theGroupName release];
+}
+
+- (void) endOutputGroup: (NSString*) theGroupName
+{
+ [theGroupName retain];
+
+ // Decrease the level of indendation.
+ --m_levelOfOutputIndendation;
+ NSAssert( m_levelOfOutputIndendation >= 0, nil );
+
+ // Write theGroupName to output.
+ [self output: [NSString stringWithFormat: @"end %@", theGroupName]];
+
+ [theGroupName release];
+}
+
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_levelOfOutputIndendation = 0;
+ }
+
+ return self;
+}
+
+- (void) output: (NSString*) theString
+{
+ [theString retain];
+
+ // Create the output string.
+ NSMutableString* outPutString =
+ [[NSMutableString stringWithCapacity: [theString length] + m_levelOfOutputIndendation * 4] retain];
+
+ // Prepend indendation.
+ int i;
+ for( i = 0; i < m_levelOfOutputIndendation; ++i )
+ [outPutString appendString: @" "];
+
+ // Append theString.
+ [outPutString appendString: theString];
+
+ // Write outPutString to output.
+ NSLog( outPutString );
+
+ [outPutString release];
+ [theString release];
+}
+
- (void) visitDocument: (ChlorDocument*) aDocument
{
- NSLog( @"document begin" );
- NSLog( @"width, height: %f %f", [aDocument width], [aDocument height] );
+ [self beginOutputGroup: @"document"];
+ [self output: [NSString stringWithFormat: @"width, height: %f %f", [aDocument width], [aDocument height]]];
+
[super visitDocument: aDocument];
- NSLog( @"document end" );
+
+ [self endOutputGroup: @"document"];
}
- (void) visitFill: (CFill*) aFill
{
NSParameterAssert( aFill != nil );
- NSLog( @"fill begin" );
+ [self beginOutputGroup: @"fill"];
// Is stroke paint a solid paint?.
CSolidPaint* solid = nil;
if( [[aFill paint] isKindOfClass: [CSolidPaint class]] )
+ {
solid = (CSolidPaint*) [aFill paint];
+ }
else
+ {
+ [self endOutputGroup: @"fill"];
return;
+ }
CGColorRef color = [solid color];
const float* components = CGColorGetComponents( color );
- NSLog( @"RGBA:" );
+ [self output: @"RGBA:"];
+
size_t i;
for( i = 0; i < CGColorGetNumberOfComponents( color ); ++i )
- NSLog( @"%f ", components[ i ] );
+ [self output: [NSString stringWithFormat: @"%f ", components[ i ]]];
- NSLog( @"fill end" );
+ [self endOutputGroup: @"fill"];
}
- (void) visitGroup: (CGroup*) aGroup
@@ -69,30 +139,32 @@
- (void) visitLayer: (CLayer*) aLayer
{
- NSLog( @"layer begin" );
- NSLog( @"visible: %i", [aLayer isVisible] );
+ [self beginOutputGroup: @"layer"];
+ [self output: [NSString stringWithFormat: @"visible: %i", [aLayer isVisible]]];
+
[super visitLayer: aLayer];
- NSLog( @"layer end" );
+
+ [self endOutputGroup: @"layer"];
}
- (void) visitPath: (CPath*) aPath
{
- NSLog( @"path begin" );
- NSLog( @"visible: %i", [aPath isVisible] );
-
+ [self beginOutputGroup: @"path"];
+ [self output: [NSString stringWithFormat: @"visible: %i", [aPath isVisible]]];
+
// Export sub paths.
[super visitPath: aPath];
-
+
if( [aPath stroke] )
[self visitStroke: [aPath stroke]];
-
+
if( [aPath fill] )
[self visitFill: [aPath fill]];
-
+
if( [aPath shadow] )
[self visitShadow: [aPath shadow]];
-
- NSLog( @"path end" );
+
+ [self endOutputGroup: @"path"];
}
- (void) visitSegment: (CSegment*) aSegment
@@ -101,22 +173,22 @@
switch( segmentDegree )
{
case 0:
- NSLog( @"moveto %f %f", [[aSegment knot] x], [[aSegment knot] y] );
+ [self output: [NSString stringWithFormat: @"moveto %f %f", [[aSegment knot] x], [[aSegment knot] y]]];
break;
case 1:
- NSLog( @"lineto %f %f", [[aSegment knot] x], [[aSegment knot] y] );
+ [self output: [NSString stringWithFormat: @"lineto %f %f", [[aSegment knot] x], [[aSegment knot] y]]];
break;
case 3:
{
CPathNode* n1 = [[aSegment nodes] objectAtIndex: 1];
CPathNode* n2 = [[aSegment nodes] objectAtIndex: 2];
CPathNode* n3 = [[aSegment nodes] objectAtIndex: 3];
- NSLog(
- @"curveto %f %f %f %f %f %f", [n1 x], [n1 y], [n2 x], [n2 y], [n3 x], [n3 y] );
+
+ [self output: [NSString stringWithFormat: @"curveto %f %f %f %f %f %f", [n1 x], [n1 y], [n2 x], [n2 y], [n3 x], [n3 y]]];
break;
}
default:
- NSLog( @"Error: Unhandled segment degree %@!", [aSegment degree] );
+ [self output: [NSString stringWithFormat: @"Error: Unhandled segment degree %@!", [aSegment degree]]];
}
}
@@ -124,8 +196,8 @@
{
NSParameterAssert( aStroke != nil );
- NSLog( @"stroke begin" );
- NSLog( @"lineWidth: %f", [aStroke lineWidth] );
+ [self beginOutputGroup: @"stroke"];
+ [self output: [NSString stringWithFormat: @"lineWidth: %f", [aStroke lineWidth]]];
// Is stroke paint a solid paint?.
CSolidPaint* solid = nil;
@@ -136,24 +208,30 @@
}
else
{
- NSLog( @"TODO: CConsoleExport visitStroke: unhandled paint." );
+ [self output: @"TODO: unhandled paint."];
+ [self endOutputGroup: @"stroke"];
return;
}
-
+
CGColorRef color = [solid color];
const float* components = CGColorGetComponents( color );
-
- NSLog( @"RGBA:" );
+
+ [self output: @"RGBA:"];
+
size_t i;
for( i = 0; i < CGColorGetNumberOfComponents( color ); ++i )
- NSLog( @"%f ", components[ i ] );
-
- NSLog( @"stroke end" );
+ [self output: [NSString stringWithFormat: @"%f ", components[ i ]]];
+
+ [self endOutputGroup: @"stroke"];
}
- (void) visitText: (CText*) aText
{
- NSLog( @"text" );
+ [self beginOutputGroup: @"text"];
+
+ [self output: [NSString stringWithFormat: @"string: \"%@\"", [aText string]]];
+
+ [self endOutputGroup: @"text"];
}
@end
Modified: trunk/src/io/svg/import/core/CSvgFactory.m
===================================================================
--- trunk/src/io/svg/import/core/CSvgFactory.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/svg/import/core/CSvgFactory.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -133,7 +133,7 @@
// Create the right SVG node.
switch( [entry unsignedIntValue] )
{
- case CSvgElementDescription: svgNode = [CSvgDefinitions alloc]; break;
+ case CSvgElementDescription: svgNode = [CSvgDescription alloc]; break;
case CSvgElementTitle: svgNode = [CSvgGroup alloc]; break;
default:
NSLog( @"Error: CSvgNodeFactory svgDescriptionNodeWithElementName: Unhandled element!" );
Modified: trunk/src/io/svg/import/core/CSvgImportVisitor.m
===================================================================
--- trunk/src/io/svg/import/core/CSvgImportVisitor.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/svg/import/core/CSvgImportVisitor.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -81,6 +81,7 @@
{
NSAssert( theSvgPaint != nil, @"The paint is not given!" );
+ // What is the paint type?
switch( theSvgPaint->m_type )
{
case CSvgPaintColor:
@@ -114,7 +115,7 @@
case CSvgPaintCurrentColor:
NSLog( @"TODO: CSvgImportVisitor chlorPaintForSvgStroke: Unhandled paint type CSvgPaintCurrentColor!" );
return nil;
-
+
case CSvgPaintUri:
NSLog( @"TODO: CSvgImportVisitor chlorPaintForSvgStroke: Unhandled paint type CSvgPaintUri!" );
return nil;
Modified: trunk/src/io/svg/import/elements/CSvgDefinitions.h
===================================================================
--- trunk/src/io/svg/import/elements/CSvgDefinitions.h 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/svg/import/elements/CSvgDefinitions.h 2007-05-28 14:28:28 UTC (rev 546)
@@ -21,6 +21,16 @@
@interface CSvgDefinitions : CSvgContainerNode
{
+ /**
+ * The dictionary mapping object ids to definitions.
+ */
+ NSMutableDictionary* m_definitionsForObjectIds;
}
+/**
+ * Returns the dictionary mapping object ids to definitions.
+ */
+- (NSMutableDictionary*) definitionsForObjectIds;
+
+
@end
Modified: trunk/src/io/svg/import/elements/CSvgDefinitions.m
===================================================================
--- trunk/src/io/svg/import/elements/CSvgDefinitions.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/svg/import/elements/CSvgDefinitions.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -21,6 +21,12 @@
@implementation CSvgDefinitions
+- (void) dealloc
+{
+ [m_definitionsForObjectIds release];
+ [super dealloc];
+}
+
- (id)
initWithParent: (CSvgNode*) theParent
parser: (NSXMLParser*) theParser
@@ -34,10 +40,17 @@
if( self )
{
+ m_definitionsForObjectIds = [[NSMutableDictionary alloc] init];
+
NSLog( @"TODO: CSvgDefinitions!" );
}
return self;
}
+- (NSMutableDictionary*) definitionsForObjectIds
+{
+ return m_definitionsForObjectIds;
+}
+
@end
Modified: trunk/src/io/svg/import/elements/CSvgGroup.m
===================================================================
--- trunk/src/io/svg/import/elements/CSvgGroup.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/io/svg/import/elements/CSvgGroup.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -88,7 +88,7 @@
{
// Add child SVG node.
[self addChild: svgNode];
- }
+ }
// Try to create a SVG container node from the given SVG element name.
else if( ( svgNode =
[CSvgFactory
Modified: trunk/src/notes/TODO.txt
===================================================================
--- trunk/src/notes/TODO.txt 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/notes/TODO.txt 2007-05-28 14:28:28 UTC (rev 546)
@@ -19,7 +19,13 @@
- Write a CGColor => NSColor method
- BUG: draw a shape, click on the fill/stroke selector => a giant shape is drawn
- TODO: the selection should be drawn while rescaling objects with the mouse
-- TODO: while rescaling shapes, they should be rounded to pixels to aoid them be drawn blurry
+- TODO: while rescaling shapes, they should be rounded to pixels to aovid them be drawn blurry
+- TODO: Zoom
+ - Apply a CoreGraphics affine trafo while rendering OR
+ - PRO: the renderer wouldn't be bothered with view details
+ - INT: How to avoid that this scales the line thickness of for exmample the selection rectangle?
+ - Put a scaling factor into the renderer
+ - CON: that's not render business, it's view related
- TODO: Provide settings dialogs for the shape tools (for example to define number of polygon edges etc.)
- BUG: if one rescales objects by dragging the bottonCenter selection handle the upper selection edge moves
- TODO: make the scroll view know the document size
@@ -50,6 +56,7 @@
SVG import
----------
+- TODO: definitions
- TODO: if the document width/heigth are in percent just make the documents the size of the shape boundary box of all included objects
- TODO: write unit tests for SVG import
- TODO: move all NSScanner using code to CSvgScanner
Modified: trunk/src/tests/CAffineMapTest.m
===================================================================
--- trunk/src/tests/CAffineMapTest.m 2007-05-28 13:07:51 UTC (rev 545)
+++ trunk/src/tests/CAffineMapTest.m 2007-05-28 14:28:28 UTC (rev 546)
@@ -48,7 +48,7 @@
// Apply the affine map.
CPoint* result = [[m_affineMap transformedPoint: m_point] retain];
- // Test rotation result.
+ // Test the transformation result.
@try
{
STAssertEqualsWithAccuracy( [result x], 0.0, [CGeometry accuracy], nil );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-05-28 13:07:53
|
Revision: 545
http://svn.sourceforge.net/chlor/?rev=545&view=rev
Author: lenny222
Date: 2007-05-28 06:07:51 -0700 (Mon, 28 May 2007)
Log Message:
-----------
rename transformedPoint + test fixes
Modified Paths:
--------------
trunk/src/CAffineTrafo.m
trunk/src/core/CAffineMap.h
trunk/src/core/CAffineMap.m
trunk/src/core/CLayers.h
trunk/src/core/CObject.h
trunk/src/core/ChlorDocument.m
trunk/src/gui/tools/CSelectionToolMoveState.m
trunk/src/gui/tools/CSelectionToolRectangleState.m
trunk/src/gui/tools/CSelectionToolResizeState.m
trunk/src/gui/tools/CSelectionToolState.h
trunk/src/gui/tools/CShapeTool.h
trunk/src/io/svg/import/core/CSvgContainerNode.h
trunk/src/notes/TODO.txt
trunk/src/tests/CAffineMapTest.m
trunk/src/tests/CGroupTest.m
Modified: trunk/src/CAffineTrafo.m
===================================================================
--- trunk/src/CAffineTrafo.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/CAffineTrafo.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -74,12 +74,12 @@
NSEnumerator* enumerator = [[aSegment nodes] objectEnumerator];
CPathNode* node;
while( node = [enumerator nextObject] )
- [node setPoint: [m_affineMap transformPoint: [node point]]];
+ [node setPoint: [m_affineMap transformedPoint: [node point]]];
}
- (void) visitText: (CText*) aText
{
- [aText setOrigin:[m_affineMap transformPoint:[aText origin]]];
+ [aText setOrigin:[m_affineMap transformedPoint:[aText origin]]];
NSLog( @"TODO: CAffineTrafo: apply to font size (e.g. scaling) as well" );
// Invalidate the boundaries.
Modified: trunk/src/core/CAffineMap.h
===================================================================
--- trunk/src/core/CAffineMap.h 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/core/CAffineMap.h 2007-05-28 13:07:51 UTC (rev 545)
@@ -115,10 +115,10 @@
- (CAffineMap*) skewVertical: (double) angel;
/**
- * Transforms the given point according to the current affine map.
+ * Returns the transformed point.
* @return The transformed point.
*/
-- (CPoint*) transformPoint: (CPoint*) thePoint;
+- (CPoint*) transformedPoint: (CPoint*) thePoint;
/**
* Adds translation to the current affine map.
Modified: trunk/src/core/CAffineMap.m
===================================================================
--- trunk/src/core/CAffineMap.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/core/CAffineMap.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -217,7 +217,7 @@
return self;
}
-- (CPoint*) transformPoint: (CPoint*) thePoint
+- (CPoint*) transformedPoint: (CPoint*) thePoint
{
const double x = m_mat[ 0 ][ 0 ] * [thePoint x] + m_mat[ 0 ][ 1 ] * [thePoint y] + m_vec[ 0 ];
const double y = m_mat[ 1 ][ 0 ] * [thePoint x] + m_mat[ 1 ][ 1 ] * [thePoint y] + m_vec[ 1 ];
Modified: trunk/src/core/CLayers.h
===================================================================
--- trunk/src/core/CLayers.h 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/core/CLayers.h 2007-05-28 13:07:51 UTC (rev 545)
@@ -32,7 +32,7 @@
}
/**
- * Returns the active layer.
+ * Returns the active layer. Creates an active layer if there is none.
*/
- (CLayer*) activeLayer;
Modified: trunk/src/core/CObject.h
===================================================================
--- trunk/src/core/CObject.h 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/core/CObject.h 2007-05-28 13:07:51 UTC (rev 545)
@@ -19,9 +19,9 @@
#import <Cocoa/Cocoa.h>
#import "CAcceptor.h"
+@class CFill;
#import "CHasComplexBoundaries.h"
#import "CIsSelectable.h"
-@class CFill;
@class CRect;
@class CShadow;
@class CStroke;
@@ -29,6 +29,8 @@
/**
* @brief The base class for all graphical objects.
+ *
+ * The base class for all graphical objects.
*/
@interface CObject : NSObject <CAcceptor, CHasComplexBoundaries, CIsSelectable, NSCopying>
{
@@ -149,7 +151,6 @@
@end
-
/**
* @mainpage Chlor Documentation
*
Modified: trunk/src/core/ChlorDocument.m
===================================================================
--- trunk/src/core/ChlorDocument.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/core/ChlorDocument.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -54,17 +54,41 @@
{
// Create an initial color space.
m_colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
-
+
// Create the layers.
m_layers = [[CLayers alloc] init];
+#if 1
+// Add a temporary welcome text.
+{
+ CText* text = [[CText alloc] init];
+ CSolidPaint* paint = [[CSolidPaint alloc] init];
+ {
+ float components[ 4 ] = { 0.0, 0.0, 0.0, 1.0 };
+ CGColorRef color = CGColorCreate( m_colorSpace, components );
+ [paint setColor: color];
+ CGColorRelease( color );
+ }
+
+ CFill* fill = [[CFill alloc] init];
+ [fill setPaint: [paint autorelease]];
+ [text setFill: [fill autorelease]];
+
+ // Set the the Chlor text origin.
+ [text setOrigin: [CPoint pointWithX: 200.0 y: 200.0]];
+ [text setString: @"Welcome"];
+
+ [[m_layers activeLayer] addObject: [text autorelease]];
+}
+#endif
+
// Create the page.
m_page = [[CPage alloc] initWithDocument: self];
-
+
// Create the selection.
m_selection = [[CSelection alloc] initWithDocument: self];
-
- // Get document width and height from the preferences.
+
+ // Get the preferred document width and height from the preferences.
m_height = [[ChlorPreferences sharedPreferences] documentHeight];
m_width = [[ChlorPreferences sharedPreferences] documentWidth];
}
Modified: trunk/src/gui/tools/CSelectionToolMoveState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveState.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/gui/tools/CSelectionToolMoveState.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -26,42 +26,29 @@
@implementation CSelectionToolMoveState
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- m_affineTrafo = [[CAffineTrafo alloc] init];
- m_copiedObjects = nil;
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- [m_copiedObjects release];
- [m_affineTrafo release];
- [super dealloc];
-}
-
- (void) cancel
{
// Release the copied objects.
[m_copiedObjects release];
m_copiedObjects = nil;
-
+
// Get the selection.
CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
-
- // Reshow the selection.
- [selection show];
-
+
// Clear the selection.
[selection clear];
+
+ // Show the selection again.
+ [selection show];
}
+- (void) dealloc
+{
+ [m_copiedObjects release];
+ [m_affineTrafo release];
+ [super dealloc];
+}
+
- (void) drawRect: (NSRect) rect
{
// Convert NSRect to CGRect.
@@ -97,6 +84,19 @@
[[document selection] show];
}
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_affineTrafo = [[CAffineTrafo alloc] init];
+ m_copiedObjects = nil;
+ }
+
+ return self;
+}
+
- (void) updateInternalState
{
// Release the copied objects.
Modified: trunk/src/gui/tools/CSelectionToolRectangleState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolRectangleState.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/gui/tools/CSelectionToolRectangleState.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -25,18 +25,6 @@
@implementation CSelectionToolRectangleState
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- m_selectionRectangle = [[CRect alloc] init];
- }
-
- return self;
-}
-
- (void) cancel
{
}
@@ -101,6 +89,18 @@
}
}
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_selectionRectangle = [[CRect alloc] init];
+ }
+
+ return self;
+}
+
- (void) updateInternalState
{
// Get the selection tool.
Modified: trunk/src/gui/tools/CSelectionToolResizeState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolResizeState.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/gui/tools/CSelectionToolResizeState.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -25,21 +25,6 @@
@implementation CSelectionToolResizeState
-- (id) init
-{
- self = [super init];
-
- // Translate map
- transMap = [[CAffineMap alloc] init];
- scaleTransMap = [[CAffineMap alloc] init];
-
- // Initially, both components of the mouse position are used
- ignoreX = NO;
- ignoreY = NO;
-
- return self;
-}
-
- (void) cancel
{
ignoreX = NO;
@@ -71,6 +56,21 @@
[[document selection] show];
}
+- (id) init
+{
+ self = [super init];
+
+ // Translate map
+ transMap = [[CAffineMap alloc] init];
+ scaleTransMap = [[CAffineMap alloc] init];
+
+ // Initially, both components of the mouse position are used
+ ignoreX = NO;
+ ignoreY = NO;
+
+ return self;
+}
+
- (void) updateInternalState
{
// Release the copied objects.
Modified: trunk/src/gui/tools/CSelectionToolState.h
===================================================================
--- trunk/src/gui/tools/CSelectionToolState.h 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/gui/tools/CSelectionToolState.h 2007-05-28 13:07:51 UTC (rev 545)
@@ -21,7 +21,7 @@
@class CSelectionTool;
/**
- * A base class to representate the different CSelectionTool states.
+ * A base class to represent the different CSelectionTool states.
*/
@interface CSelectionToolState : NSObject
{
Modified: trunk/src/gui/tools/CShapeTool.h
===================================================================
--- trunk/src/gui/tools/CShapeTool.h 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/gui/tools/CShapeTool.h 2007-05-28 13:07:51 UTC (rev 545)
@@ -23,7 +23,7 @@
#import "CTool.h"
/**
- * @brief The base class for GUI tool to create shapes.
+ * @brief The base class for GUI tools to create shapes.
*/
@interface CShapeTool : CTool
{
Modified: trunk/src/io/svg/import/core/CSvgContainerNode.h
===================================================================
--- trunk/src/io/svg/import/core/CSvgContainerNode.h 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/io/svg/import/core/CSvgContainerNode.h 2007-05-28 13:07:51 UTC (rev 545)
@@ -33,6 +33,7 @@
/**
* Adds a SVG child node.
+ * @param theChildNode the child node
*/
- (void) addChild: (CSvgNode*) theChildNode;
Modified: trunk/src/notes/TODO.txt
===================================================================
--- trunk/src/notes/TODO.txt 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/notes/TODO.txt 2007-05-28 13:07:51 UTC (rev 545)
@@ -1,26 +1,25 @@
User experience
---------------
-- BUG: shift dragging while one object is selected moves the object even when clicked/dragged is outside of it
-- TODO: draw the CPage
- BUG: a file saved by Chlor appears empty if loaded by Chlor again
- it works if one removes the "-" in CSvgImportVisitor:
"[[affineTrafo affineMap] translateX: 0.0 Y: -[m_chlorDocument height]];"
but then all other SVG files break
+- BUG: shift dragging while one object is selected moves the object even when clicked/dragged is outside of it
+- TODO: add keyboard short cuts like <Backspace> which deletes the selected objects and <Esc> which cancels the current tool
+ - call CSelectionToolState's "cancel:" method
+- TODO: draw the CPage
- BUG: clicking in in the bbox of an ellipse selects the ellipse even when the click is outside
(this test fails in CShapeTest)
- - maybe it has something to do with NSArray clear/adding in CSelection
+ - maybe this has something to do with NSArray clear/adding in CSelection
- BUG: undo/redo of deleting objects doesnt repaint
-- TODO: we should add the objects to the selection according to "shiftKeyIsDown:"
-- TODO: create CUnkownFill and CUnknownStroke
+- TODO: create CUnkownFill, CUnknownStroke, CUnknownPaint
- CGroup's fill: and stroke: need to use these if the group contains many objects
- Create a case in the CRenderer (e.g. painting questionmarks)
- BUG: update the color in the NSColorPanel from application's fill/stroke
- Write a CGColor => NSColor method
-- TODO: shift click should add objects to the selection
- BUG: draw a shape, click on the fill/stroke selector => a giant shape is drawn
- TODO: the selection should be drawn while rescaling objects with the mouse
- TODO: while rescaling shapes, they should be rounded to pixels to aoid them be drawn blurry
-- TODO: add keyboard short cuts like <Backspace> which deletes the selected objects and <Esc> which cancels the current tool
- TODO: Provide settings dialogs for the shape tools (for example to define number of polygon edges etc.)
- BUG: if one rescales objects by dragging the bottonCenter selection handle the upper selection edge moves
- TODO: make the scroll view know the document size
@@ -30,11 +29,14 @@
Core
----
+- BUG: CText shapeBoundary: get the correct horizontal/vertical bearing
+ - Check whether MacQt does Text boundingbox calculation
- selecting objects gives "error for object 0x374dc0: double free"
- TODO: CCubicBezierSegment shapeBoundary: do exact calculation!
-- BUG: CText shapeBoundary: get the correct horizontal/vertical bearing
- BUG: Check pixel precision of mouse tools (e.g. selection tool vs shapes)
- MAYBE: NSScreen userSpaceScaleFactor is helpfull somewhere?
+- use "hornerBez" algorithm for a future "CSegment pointFor: (double) t" method instead of deCasteljau algorithm
+- increase overall robustness: check method arguments and return values for being nil (see CRect for example) to avoid crashes
Refactoring
-----------
@@ -48,8 +50,6 @@
SVG import
----------
-- BUG: Fix save => load chain. Chlor files cannot be opened: affine trafo issue
- (http://www.w3.org/Graphics/SVG/Test/20030813/htmlframe/full-coords-trans-01-b.html)
- TODO: if the document width/heigth are in percent just make the documents the size of the shape boundary box of all included objects
- TODO: write unit tests for SVG import
- TODO: move all NSScanner using code to CSvgScanner
@@ -66,12 +66,9 @@
- PDF export
- TODO: add support for "do not print" etc flags
-Refactoring and Documentation
------------------------------
+Documentation
+-------------
- Developer FAQ: write down, how MainView's Controller, Window, View, Document can be obtain from each other
-- use "hornerBez" algorithm for a future "CSegment pointFor: (double) t" method instead of deCasteljau algorithm
-- increase overall robustness: check method arguments and return values for being nil (see CRect for example) to avoid crashes
-- Check whether MacQt does Text boundingbox calculation
- Qt has now a boolean clipping algorithm
svn propset svn:keywords Id foo.h
\ No newline at end of file
Modified: trunk/src/tests/CAffineMapTest.m
===================================================================
--- trunk/src/tests/CAffineMapTest.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/tests/CAffineMapTest.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -46,7 +46,7 @@
[m_affineMap rotate: 90.0];
// Apply the affine map.
- CPoint* result = [[m_affineMap transformPoint: m_point] retain];
+ CPoint* result = [[m_affineMap transformedPoint: m_point] retain];
// Test rotation result.
@try
@@ -68,7 +68,7 @@
[m_affineMap rotate: 90.0];
// Apply the affine map.
- CPoint* result = [[m_affineMap transformPoint: m_point] retain];
+ CPoint* result = [[m_affineMap transformedPoint: m_point] retain];
// Test rotation result.
@try
@@ -85,7 +85,7 @@
[m_affineMap rotate: 90.0];
// Apply the affine map.
- result = [[m_affineMap transformPoint: m_point] retain];
+ result = [[m_affineMap transformedPoint: m_point] retain];
// Test rotation result.
@try
@@ -102,7 +102,7 @@
[m_affineMap rotate: 45.0];
// Apply the affine map.
- result = [[m_affineMap transformPoint: m_point] retain];
+ result = [[m_affineMap transformedPoint: m_point] retain];
// Test rotation result.
@try
@@ -123,7 +123,7 @@
[m_affineMap scaleX: -2.0 Y: 3.0];
// Apply the affine map.
- CPoint* result = [[m_affineMap transformPoint: m_point] retain];
+ CPoint* result = [[m_affineMap transformedPoint: m_point] retain];
// Test result.
@try
@@ -147,13 +147,13 @@
[m_affineMap rotate: 45.0];
// Apply the affine map.
- CPoint* result = [[m_affineMap transformPoint: m_point] retain];
+ CPoint* result = [[m_affineMap transformedPoint: m_point] retain];
// Invert the afine map.
[m_affineMap invert];
// Apply the inverted affine mape.
- CPoint* result2 = [[m_affineMap transformPoint: result] retain];
+ CPoint* result2 = [[m_affineMap transformedPoint: result] retain];
// Test result.
@try
Modified: trunk/src/tests/CGroupTest.m
===================================================================
--- trunk/src/tests/CGroupTest.m 2007-05-27 22:18:03 UTC (rev 544)
+++ trunk/src/tests/CGroupTest.m 2007-05-28 13:07:51 UTC (rev 545)
@@ -44,11 +44,17 @@
// Create an empty array.
objects = [[NSArray array] retain];
- // Set the objects.
+ // Set the array.
[m_group setObjects: objects];
- // Compare the group objects with the given objects.
+ // Compare the group objects with the given array.
STAssertEquals( [m_group objects], objects, nil );
+
+ // Clear the group.
+ [m_group clear];
+
+ // The group should be empty.
+ STAssertEquals( [[m_group objects] count], (unsigned) 0, nil );
}
@finally
{
@@ -59,9 +65,10 @@
// Tests the boundaries.
- (void) testBoundary
{
+ // Create a rectangle.
CPath* rectangle = [[CShape rectangleLeft: -52.0f bottom: 13.2f width: 22.0f height: 5.42f] retain];
- // Add the rectangle to the group.
+ // Set the rectangle to the group.
[m_group clear];
[m_group addObject: rectangle];
@@ -104,7 +111,7 @@
group = [m_group copy];
// The group objects should have two objects.
- STAssertEquals( [[m_group objects] count], 2, nil );
+ STAssertEquals( [[m_group objects] count], (unsigned) 2, nil );
}
@finally
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chlor c. to s. <chl...@li...> - 2007-05-27 22:18:06
|
Revision: 544
http://svn.sourceforge.net/chlor/?rev=544&view=rev
Author: lenny222
Date: 2007-05-27 15:18:03 -0700 (Sun, 27 May 2007)
Log Message:
-----------
rename
Modified Paths:
--------------
trunk/src/Chlor.xcodeproj/project.pbxproj
trunk/src/gui/tools/CSelectionTool.m
trunk/src/gui/tools/CSelectionToolResizeState.h
Added Paths:
-----------
trunk/src/gui/tools/CSelectionToolMoveState.h
trunk/src/gui/tools/CSelectionToolMoveState.m
trunk/src/gui/tools/CSelectionToolRectangleState.h
trunk/src/gui/tools/CSelectionToolRectangleState.m
Removed Paths:
-------------
trunk/src/gui/tools/CSelectionToolMoveObjectsState.h
trunk/src/gui/tools/CSelectionToolMoveObjectsState.m
trunk/src/gui/tools/CSelectionToolSelectState.h
trunk/src/gui/tools/CSelectionToolSelectState.m
Modified: trunk/src/Chlor.xcodeproj/project.pbxproj
===================================================================
(Binary files differ)
Modified: trunk/src/gui/tools/CSelectionTool.m
===================================================================
--- trunk/src/gui/tools/CSelectionTool.m 2007-05-27 22:13:22 UTC (rev 543)
+++ trunk/src/gui/tools/CSelectionTool.m 2007-05-27 22:18:03 UTC (rev 544)
@@ -22,8 +22,8 @@
#import "CSelectionTool.h"
#import "CSelectionToolState.h"
#import "CSelectionToolMoveState.h"
+#import "CSelectionToolRectangleState.h"
#import "CSelectionToolResizeState.h"
-#import "CSelectionToolSelectState.h"
@implementation CSelectionTool
@@ -112,7 +112,7 @@
if( [[selection objects] count] < 1 )
{
// Activate the object selection state.
- m_activeState = [CSelectionToolSelectState sharedSelectionToolSelectState];
+ m_activeState = [CSelectionToolRectangleState sharedSelectionToolSelectState];
}
// The document selection is not empty.
else
Deleted: trunk/src/gui/tools/CSelectionToolMoveObjectsState.h
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveObjectsState.h 2007-05-27 22:13:22 UTC (rev 543)
+++ trunk/src/gui/tools/CSelectionToolMoveObjectsState.h 2007-05-27 22:18:03 UTC (rev 544)
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2007 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import <Cocoa/Cocoa.h>
-@class CAffineTrafo;
-@class CSelection;
-#import "CSelectionToolState.h"
-
-/**
- * The selection tool state for moving objects.
- */
-@interface CSelectionToolMoveObjectsState : CSelectionToolState
-{
- /**
- * The resulting affine transformation visitor (@see m_affineMap).
- */
- CAffineTrafo* m_affineTrafo;
-
- /**
- * The manipulated objects which are drawn during object moving.
- */
- CSelection* m_copiedObjects;
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CSelectionToolMoveObjectsState*) sharedSelectionToolMoveObjectsState;
-
-@end
Deleted: trunk/src/gui/tools/CSelectionToolMoveObjectsState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveObjectsState.m 2007-05-27 22:13:22 UTC (rev 543)
+++ trunk/src/gui/tools/CSelectionToolMoveObjectsState.m 2007-05-27 22:18:03 UTC (rev 544)
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2007 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CAffineMap.h"
-#import "CAffineTrafo.h"
-#import "CContourRenderer.h"
-#import "ChlorDocument.h"
-#import "CSelectionTool.h"
-#import "CSelectionToolMoveObjectsState.h"
-
-@implementation CSelectionToolMoveObjectsState
-
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- m_affineTrafo = [[CAffineTrafo alloc] init];
- m_copiedObjects = nil;
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- [m_copiedObjects release];
- [m_affineTrafo release];
- [super dealloc];
-}
-
-- (void) cancel
-{
- // Release the copied objects.
- [m_copiedObjects release];
- m_copiedObjects = nil;
-
- // Get the selection.
- CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
-
- // Reshow the selection.
- [selection show];
-
- // Clear the selection.
- [selection clear];
-}
-
-- (void) drawRect: (NSRect) rect
-{
- // Convert NSRect to CGRect.
- CGRect drawRect = CGRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height );
- // Get context.
- CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
-
- // Draw the copied objects.
- CContourRenderer* copiedObjectsRenderer = [CContourRenderer sharedContourRenderer];
-
- [copiedObjectsRenderer setDrawingBoundary: drawRect];
- [copiedObjectsRenderer setContext: context];
- [copiedObjectsRenderer visitSelection: m_copiedObjects];
-}
-
-- (void) finish
-{
- // Release the copied objects.
- [m_copiedObjects release];
- m_copiedObjects = nil;
-
- // Get the document.
- ChlorDocument* document = [[[[CSelectionTool sharedSelectionTool] view] mainController] document];
-
- // Make the document transform the selection.
- [document transformSelectionFirstBy: [[m_affineTrafo affineMap] copyWithZone:[self zone]]
- thenBy: [[CAffineMap allocWithZone:[self zone]] init]
- actionName: NSLocalizedString(
- @"Move Objects",
- @"Name of undo/redo action for moving objects" )];
-
- // Reshow the selection.
- [[document selection] show];
-}
-
-- (void) updateInternalState
-{
- // Release the copied objects.
- [m_copiedObjects release];
-
- // Get the selection tool.
- CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
-
- // Get the selection.
- CSelection* selection = [[[[selectionTool view] mainController] document] selection];
-
- // Copy the selected objects.
- m_copiedObjects = [selection copy];
-
- // Calculate the movement.
- double dx = [selectionTool currentMousePos].x - [selectionTool mouseDownPos].x;
- double dy = [selectionTool currentMousePos].y - [selectionTool mouseDownPos].y;
-
- // Set the affine map.
- [[m_affineTrafo affineMap] reset];
- [[m_affineTrafo affineMap] translateX: dx Y: dy];
-
- // Apply the affine transformation to the copied objects.
- [m_affineTrafo visitSelection: m_copiedObjects];
-
- // Show the copied objects.
- [m_copiedObjects show];
-}
-
-+ (CSelectionToolMoveObjectsState*) sharedSelectionToolMoveObjectsState
-{
- static CSelectionToolMoveObjectsState* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CSelectionToolMoveObjectsState alloc] init];
-
- return s_instance;
-}
-
-- (void) start
-{
- // Get the document selection.
- CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
-
- // Hide the selection.
- [selection hide];
-}
-
-@end
Added: trunk/src/gui/tools/CSelectionToolMoveState.h
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveState.h (rev 0)
+++ trunk/src/gui/tools/CSelectionToolMoveState.h 2007-05-27 22:18:03 UTC (rev 544)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: CSelectionToolMoveState.h 531 2007-05-27 01:27:33Z lenny222 $
+ */
+
+#import <Cocoa/Cocoa.h>
+@class CAffineTrafo;
+@class CSelection;
+#import "CSelectionToolState.h"
+
+/**
+ * The selection tool state for moving objects.
+ */
+@interface CSelectionToolMoveState : CSelectionToolState
+{
+ /**
+ * The resulting affine transformation visitor (@see m_affineMap).
+ */
+ CAffineTrafo* m_affineTrafo;
+
+ /**
+ * The manipulated objects which are drawn during object moving.
+ */
+ CSelection* m_copiedObjects;
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CSelectionToolMoveState*) sharedSelectionToolMoveObjectsState;
+
+@end
Added: trunk/src/gui/tools/CSelectionToolMoveState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolMoveState.m (rev 0)
+++ trunk/src/gui/tools/CSelectionToolMoveState.m 2007-05-27 22:18:03 UTC (rev 544)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: CSelectionToolMoveState.m 533 2007-05-27 11:19:37Z lenny222 $
+ */
+
+#import "CAffineMap.h"
+#import "CAffineTrafo.h"
+#import "CContourRenderer.h"
+#import "ChlorDocument.h"
+#import "CSelectionTool.h"
+#import "CSelectionToolMoveState.h"
+
+@implementation CSelectionToolMoveState
+
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_affineTrafo = [[CAffineTrafo alloc] init];
+ m_copiedObjects = nil;
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [m_copiedObjects release];
+ [m_affineTrafo release];
+ [super dealloc];
+}
+
+- (void) cancel
+{
+ // Release the copied objects.
+ [m_copiedObjects release];
+ m_copiedObjects = nil;
+
+ // Get the selection.
+ CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
+
+ // Reshow the selection.
+ [selection show];
+
+ // Clear the selection.
+ [selection clear];
+}
+
+- (void) drawRect: (NSRect) rect
+{
+ // Convert NSRect to CGRect.
+ CGRect drawRect = CGRectMake( rect.origin.x, rect.origin.y, rect.size.width, rect.size.height );
+ // Get context.
+ CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
+
+ // Draw the copied objects.
+ CContourRenderer* copiedObjectsRenderer = [CContourRenderer sharedContourRenderer];
+
+ [copiedObjectsRenderer setDrawingBoundary: drawRect];
+ [copiedObjectsRenderer setContext: context];
+ [copiedObjectsRenderer visitSelection: m_copiedObjects];
+}
+
+- (void) finish
+{
+ // Release the copied objects.
+ [m_copiedObjects release];
+ m_copiedObjects = nil;
+
+ // Get the document.
+ ChlorDocument* document = [[[[CSelectionTool sharedSelectionTool] view] mainController] document];
+
+ // Make the document transform the selection.
+ [document transformSelectionFirstBy: [[m_affineTrafo affineMap] copyWithZone:[self zone]]
+ thenBy: [[CAffineMap allocWithZone:[self zone]] init]
+ actionName: NSLocalizedString(
+ @"Move Objects",
+ @"Name of undo/redo action for moving objects" )];
+
+ // Show the selection agin.
+ [[document selection] show];
+}
+
+- (void) updateInternalState
+{
+ // Release the copied objects.
+ [m_copiedObjects release];
+
+ // Get the selection tool.
+ CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
+
+ // Get the selection.
+ CSelection* selection = [[[[selectionTool view] mainController] document] selection];
+
+ // Copy the selected objects.
+ m_copiedObjects = [selection copy];
+
+ // Calculate the movement.
+ double dx = [selectionTool currentMousePos].x - [selectionTool mouseDownPos].x;
+ double dy = [selectionTool currentMousePos].y - [selectionTool mouseDownPos].y;
+
+ // Set the affine map.
+ [[m_affineTrafo affineMap] reset];
+ [[m_affineTrafo affineMap] translateX: dx Y: dy];
+
+ // Apply the affine transformation to the copied objects.
+ [m_affineTrafo visitSelection: m_copiedObjects];
+
+ // Show the copied objects.
+ [m_copiedObjects show];
+}
+
++ (CSelectionToolMoveState*) sharedSelectionToolMoveObjectsState
+{
+ static CSelectionToolMoveState* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CSelectionToolMoveState alloc] init];
+
+ return s_instance;
+}
+
+- (void) start
+{
+ // Get the document selection.
+ CSelection* selection = [[[[[CSelectionTool sharedSelectionTool] view] mainController] document] selection];
+
+ // Hide the document selection.
+ [selection hide];
+}
+
+@end
Copied: trunk/src/gui/tools/CSelectionToolRectangleState.h (from rev 533, trunk/src/gui/tools/CSelectionToolSelectState.h)
===================================================================
--- trunk/src/gui/tools/CSelectionToolRectangleState.h (rev 0)
+++ trunk/src/gui/tools/CSelectionToolRectangleState.h 2007-05-27 22:18:03 UTC (rev 544)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+@class CRect;
+#import "CSelectionToolState.h"
+
+/**
+ * The selection tool state for selecting objects with the selction rectangle.
+ */
+@interface CSelectionToolRectangleState : CSelectionToolState
+{
+ /**
+ * The selection rectangle.
+ */
+ CRect* m_selectionRectangle;
+}
+
+/**
+ * Returns the singleton instance.
+ */
++ (CSelectionToolRectangleState*) sharedSelectionToolSelectState;
+
+@end
Copied: trunk/src/gui/tools/CSelectionToolRectangleState.m (from rev 541, trunk/src/gui/tools/CSelectionToolSelectState.m)
===================================================================
--- trunk/src/gui/tools/CSelectionToolRectangleState.m (rev 0)
+++ trunk/src/gui/tools/CSelectionToolRectangleState.m 2007-05-27 22:18:03 UTC (rev 544)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2007 Lennart Kudling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#import "CFindObjectsInRectangleVisitor.h"
+#import "CRect.h"
+#import "CSelection.h"
+#import "CSelectionTool.h"
+#import "CSelectionToolRectangleState.h"
+
+@implementation CSelectionToolRectangleState
+
+- (id) init
+{
+ self = [super init];
+
+ if( self )
+ {
+ m_selectionRectangle = [[CRect alloc] init];
+ }
+
+ return self;
+}
+
+- (void) cancel
+{
+}
+
+- (void) dealloc
+{
+ [m_selectionRectangle release];
+ [super dealloc];
+}
+
+- (void) drawRect: (NSRect) rect
+{
+ // Get context.
+ CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
+
+ // Fill CGRect for drawing.
+ CGRect drawRect = [m_selectionRectangle rectangle].cgRect;
+ drawRect.origin.x = drawRect.origin.x + 0.5;
+ drawRect.origin.y = drawRect.origin.y + 0.5;
+
+ // Define dash pattern.
+ float dashes[ 2 ] = { 2.0, 2.0 };
+
+ CGContextBeginPath( context );
+ CGContextAddRect( context, drawRect );
+ CGContextSetRGBFillColor( context, 0.0, 0.0, 0.0, 0.1 );
+ CGContextSetRGBStrokeColor( context, 0.0, 0.0, 0.0, 0.7 );
+ CGContextSetLineWidth( context, 1.0 );
+ CGContextSetLineDash( context, 0.0, dashes, 2 );
+ CGContextDrawPath( context, kCGPathFillStroke );
+
+ CGContextAddRect( context, drawRect );
+ CGContextSetRGBStrokeColor( context, 1.0, 1.0, 1.0, 0.7 );
+ CGContextSetLineDash( context, 2.0, dashes, 2 );
+ CGContextStrokePath( context );
+}
+
+- (void) finish
+{
+ if( ![m_selectionRectangle isEmpty] )
+ {
+ // Get the selection tool.
+ CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
+
+ // Get the selection.
+ CSelection* selection = [[[[selectionTool view] mainController] document] selection];
+
+ // Find all objects within m_selectionRectangle.
+ CFindObjectsInRectangleVisitor* findVisior = [[CFindObjectsInRectangleVisitor alloc] init];
+ [findVisior setRectangleOfInterest: m_selectionRectangle];
+ [findVisior visitDocument: [[[selectionTool view] mainController] document]];
+
+ // Clear the selection if the Shift key is not down.
+ if( ![selectionTool shiftKeyIsDown] )
+ [selection clear];
+
+ // Add the found objects to the document selection.
+ [selection addObjectsFromArray: [findVisior objects]];
+
+ // Release the find visitor.
+ [findVisior release];
+ }
+}
+
+- (void) updateInternalState
+{
+ // Get the selection tool.
+ CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
+
+ [m_selectionRectangle
+ setPointX: [selectionTool mouseDownPos].x
+ y: [[CSelectionTool sharedSelectionTool] mouseDownPos].y];
+ [m_selectionRectangle
+ addPointX: [selectionTool currentMousePos].x
+ y: [[CSelectionTool sharedSelectionTool] currentMousePos].y];
+}
+
++ (CSelectionToolRectangleState*) sharedSelectionToolSelectState
+{
+ static CSelectionToolRectangleState* s_instance = nil;
+
+ if( !s_instance )
+ s_instance = [[CSelectionToolRectangleState alloc] init];
+
+ return s_instance;
+}
+
+- (void) start
+{
+ [self updateInternalState];
+}
+
+@end
+
Modified: trunk/src/gui/tools/CSelectionToolResizeState.h
===================================================================
--- trunk/src/gui/tools/CSelectionToolResizeState.h 2007-05-27 22:13:22 UTC (rev 543)
+++ trunk/src/gui/tools/CSelectionToolResizeState.h 2007-05-27 22:18:03 UTC (rev 544)
@@ -28,15 +28,18 @@
/**
* Carries the origin of the transformation (set during start method)
*/
- NSPoint m_resizeOrigin;
+ NSPoint m_resizeOrigin;
+
/**
* The translation map to move the objects to the origin
*/
CAffineMap* transMap;
+
/**
* The translation map to scale and move the objects back to their original position
*/
CAffineMap* scaleTransMap;
+
/**
* If true, limits mouse movements to its x part, ignoring all y values
*/
Deleted: trunk/src/gui/tools/CSelectionToolSelectState.h
===================================================================
--- trunk/src/gui/tools/CSelectionToolSelectState.h 2007-05-27 22:13:22 UTC (rev 543)
+++ trunk/src/gui/tools/CSelectionToolSelectState.h 2007-05-27 22:18:03 UTC (rev 544)
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2007 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-@class CRect;
-#import "CSelectionToolState.h"
-
-/**
- * The selection tool state for selecting objects with the selction rectangle.
- */
-@interface CSelectionToolSelectState : CSelectionToolState
-{
- /**
- * The selection rectangle.
- */
- CRect* m_selectionRectangle;
-}
-
-/**
- * Returns the singleton instance.
- */
-+ (CSelectionToolSelectState*) sharedSelectionToolSelectState;
-
-@end
Deleted: trunk/src/gui/tools/CSelectionToolSelectState.m
===================================================================
--- trunk/src/gui/tools/CSelectionToolSelectState.m 2007-05-27 22:13:22 UTC (rev 543)
+++ trunk/src/gui/tools/CSelectionToolSelectState.m 2007-05-27 22:18:03 UTC (rev 544)
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2007 Lennart Kudling
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-#import "CFindObjectsInRectangleVisitor.h"
-#import "CRect.h"
-#import "CSelection.h"
-#import "CSelectionTool.h"
-#import "CSelectionToolSelectState.h"
-
-@implementation CSelectionToolSelectState
-
-- (id) init
-{
- self = [super init];
-
- if( self )
- {
- m_selectionRectangle = [[CRect alloc] init];
- }
-
- return self;
-}
-
-- (void) cancel
-{
-}
-
-- (void) dealloc
-{
- [m_selectionRectangle release];
- [super dealloc];
-}
-
-- (void) drawRect: (NSRect) rect
-{
- // Get context.
- CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
-
- // Fill CGRect for drawing.
- CGRect drawRect = [m_selectionRectangle rectangle].cgRect;
- drawRect.origin.x = drawRect.origin.x + 0.5;
- drawRect.origin.y = drawRect.origin.y + 0.5;
-
- // Define dash pattern.
- float dashes[ 2 ] = { 2.0, 2.0 };
-
- CGContextBeginPath( context );
- CGContextAddRect( context, drawRect );
- CGContextSetRGBFillColor( context, 0.0, 0.0, 0.0, 0.1 );
- CGContextSetRGBStrokeColor( context, 0.0, 0.0, 0.0, 0.7 );
- CGContextSetLineWidth( context, 1.0 );
- CGContextSetLineDash( context, 0.0, dashes, 2 );
- CGContextDrawPath( context, kCGPathFillStroke );
-
- CGContextAddRect( context, drawRect );
- CGContextSetRGBStrokeColor( context, 1.0, 1.0, 1.0, 0.7 );
- CGContextSetLineDash( context, 2.0, dashes, 2 );
- CGContextStrokePath( context );
-}
-
-- (void) finish
-{
- if( ![m_selectionRectangle isEmpty] )
- {
- // Get the selection tool.
- CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
-
- // Get the selection.
- CSelection* selection = [[[[selectionTool view] mainController] document] selection];
-
- // Find all objects within m_selectionRectangle.
- CFindObjectsInRectangleVisitor* findVisior = [[CFindObjectsInRectangleVisitor alloc] init];
- [findVisior setRectangleOfInterest: m_selectionRectangle];
- [findVisior visitDocument: [[[selectionTool view] mainController] document]];
-
- // Clear the selection if the Shift key is not down.
- if( ![selectionTool shiftKeyIsDown] )
- [selection clear];
-
- // Add the found objects to the document selection.
- [selection addObjectsFromArray: [findVisior objects]];
-
- // Release the find visitor.
- [findVisior release];
- }
-}
-
-- (void) updateInternalState
-{
- // Get the selection tool.
- CSelectionTool* selectionTool = [CSelectionTool sharedSelectionTool];
-
- [m_selectionRectangle
- setPointX: [selectionTool mouseDownPos].x
- y: [[CSelectionTool sharedSelectionTool] mouseDownPos].y];
- [m_selectionRectangle
- addPointX: [selectionTool currentMousePos].x
- y: [[CSelectionTool sharedSelectionTool] currentMousePos].y];
-}
-
-+ (CSelectionToolSelectState*) sharedSelectionToolSelectState
-{
- static CSelectionToolSelectState* s_instance = nil;
-
- if( !s_instance )
- s_instance = [[CSelectionToolSelectState alloc] init];
-
- return s_instance;
-}
-
-- (void) start
-{
- [self updateInternalState];
-}
-
-@end
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|