~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/display/curve.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * Released under GNU GPL
16
16
 */
17
17
 
18
 
 
 
18
#include <string.h>
19
19
#include <glib/gmem.h>
20
20
#include <display/curve.h>
21
21
#include <libnr/n-art-bpath.h>
22
22
#include <libnr/nr-point-matrix-ops.h>
23
23
#include <libnr/nr-translate-ops.h>
 
24
#include <cstring>
 
25
#include <string>
24
26
 
25
27
#define SP_CURVE_LENSTEP 32
26
28
 
124
126
    return curve;
125
127
}
126
128
 
 
129
SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect)
 
130
{
 
131
    g_return_val_if_fail(rect, NULL);
 
132
 
 
133
    SPCurve *c = sp_curve_new();
 
134
 
 
135
    NR::Point p = rect->corner(0);
 
136
    sp_curve_moveto(c, p);
 
137
 
 
138
    for (int i=3; i>=0; i--) {
 
139
        sp_curve_lineto(c, rect->corner(i));
 
140
    }
 
141
    sp_curve_closepath_current(c);
 
142
 
 
143
    return c;
 
144
}
 
145
 
127
146
/**
128
147
 * Increase refcount of curve.
129
148
 *
141
160
 
142
161
/**
143
162
 * Decrease refcount of curve, with possible destruction.
144
 
 * 
 
163
 *
145
164
 * \todo should this be shared with other refcounting code?
146
165
 */
147
166
SPCurve *
232
251
    return new_curve;
233
252
}
234
253
 
235
 
/** 
 
254
/**
236
255
 * Returns a list of new curves corresponding to the subpaths in \a curve.
237
256
 */
238
257
GSList *
559
578
    curve->closed = true;
560
579
 
561
580
    for (NArtBpath const *bp = curve->_bpath; bp->code != NR_END; bp++) {
562
 
        /** \todo 
563
 
         * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of 
 
581
        /** \todo
 
582
         * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of
564
583
         * the closed boolean).
565
584
         */
566
585
        if (bp->code == NR_MOVETO_OPEN) {
599
618
    curve->closed = true;
600
619
 
601
620
    for (NArtBpath const *bp = curve->_bpath; bp->code != NR_END; bp++) {
602
 
        /** \todo 
603
 
         * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of 
 
621
        /** \todo
 
622
         * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of
604
623
         * the closed boolean).
605
624
         */
606
625
        if (bp->code == NR_MOVETO_OPEN) {
721
740
    return c == NR_MOVETO || c == NR_MOVETO_OPEN;
722
741
}
723
742
 
724
 
/** 
725
 
 * Returns \a curve but drawn in the opposite direction.  
 
743
/**
 
744
 * Returns \a curve but drawn in the opposite direction.
726
745
 * Should result in the same shape, but
727
746
 * with all its markers drawn facing the other direction.
728
747
 **/
851
870
             && ( fabs( bs->y3 - be->y3 ) <= tolerance ) )
852
871
        {
853
872
            /** \todo
854
 
             * fixme: Strictly we mess in case of multisegment mixed 
855
 
             * open/close curves 
 
873
             * fixme: Strictly we mess in case of multisegment mixed
 
874
             * open/close curves
856
875
             */
857
876
            bool closed = false;
858
877
            for (bs = bs + 1; bs->code != NR_END; bs++) {
1036
1055
 * \brief
1037
1056
 *
1038
1057
 * \todo
1039
 
 * fixme: this is bogus -- it doesn't check for nr_moveto, which will indicate 
1040
 
 * a closing of the subpath it's nonsense to talk about a path as a whole 
1041
 
 * being closed, although maybe someone would want that for some other reason?  
1042
 
 * Oh, also, if the bpath just ends, then it's *open*.  I hope nobody is using 
 
1058
 * fixme: this is bogus -- it doesn't check for nr_moveto, which will indicate
 
1059
 * a closing of the subpath it's nonsense to talk about a path as a whole
 
1060
 * being closed, although maybe someone would want that for some other reason?
 
1061
 * Oh, also, if the bpath just ends, then it's *open*.  I hope nobody is using
1043
1062
 * this code for anything.
1044
1063
 */
1045
1064
static bool sp_bpath_closed(NArtBpath const bpath[])
1066
1085
           double const threshold)
1067
1086
{
1068
1087
    /** \todo
1069
 
     * The SVG spec claims that a closed form exists, but for the moment I'll 
 
1088
     * The SVG spec claims that a closed form exists, but for the moment I'll
1070
1089
     * use a stupid algorithm.
1071
1090
     */
1072
1091
    double const lbound = L2( c3 - c0 );
1132
1151
    return ret;
1133
1152
}
1134
1153
 
1135
 
/** 
1136
 
 * Like sp_curve_distance_including_space(), but ensures that the 
 
1154
/**
 
1155
 * Like sp_curve_distance_including_space(), but ensures that the
1137
1156
 * result >= 1e-18:  uses 1 per segment if necessary.
1138
1157
 */
1139
1158
static double
1218
1237
  fill-column:99
1219
1238
  End:
1220
1239
*/
1221
 
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
 
1240
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :