[gimp] app: fix coding style in the new smoothing code



commit c29aefccc2f1d5e406926bd494927078025d2dee
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jan 8 22:18:56 2011 +0100

    app: fix coding style in the new smoothing code

 app/paint/gimpbrushcore.c        |   10 +++--
 app/paint/gimpink.c              |   15 +++++----
 app/paint/gimpink.h              |    5 +--
 app/paint/gimppaintcore.c        |   65 ++++++++++++++++++++-----------------
 app/paint/gimppaintcore.h        |    1 -
 app/paint/gimppaintoptions.c     |   35 ++++++++++----------
 app/tools/gimppaintoptions-gui.c |    6 ++--
 7 files changed, 72 insertions(+), 65 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 5adfe8b..6cb116c 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -521,10 +521,12 @@ gimp_brush_core_interpolate (GimpPaintCore    *paint_core,
   gimp_paint_core_get_last_coords (paint_core, &last_coords);
   gimp_paint_core_get_current_coords (paint_core, &current_coords);
 
-  if (paint_core->stroke_buffer) {
-    current_coords = gimp_paint_core_get_smoothed_coords(paint_core, paint_options, &current_coords);
-    gimp_paint_core_set_current_coords (paint_core, &current_coords);
-  }
+  if (paint_core->stroke_buffer)
+    {
+      current_coords = gimp_paint_core_get_smoothed_coords (paint_core,
+                                                            paint_options, &current_coords);
+      gimp_paint_core_set_current_coords (paint_core, &current_coords);
+    }
 
   /*Zero sized brushes are unfit for interpolate,
    * so we just let paint core fail onits own
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index cd5af48..a9ff574 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -258,7 +258,8 @@ gimp_ink_motion (GimpPaintCore    *paint_core,
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
-  modified_coords = gimp_paint_core_get_smoothed_coords(paint_core, paint_options, coords);
+  modified_coords = gimp_paint_core_get_smoothed_coords (paint_core,
+                                                         paint_options, coords);
 
   if (! ink->last_blob)
     {
@@ -280,12 +281,12 @@ gimp_ink_motion (GimpPaintCore    *paint_core,
   else
     {
       GimpBlob *blob = ink_pen_ellipse (options,
-                                    modified_coords.x,
-                                    modified_coords.y,
-                                    modified_coords.pressure,
-                                    modified_coords.xtilt,
-                                    modified_coords.ytilt,
-                                    modified_coords.velocity * 100);
+                                        modified_coords.x,
+                                        modified_coords.y,
+                                        modified_coords.pressure,
+                                        modified_coords.xtilt,
+                                        modified_coords.ytilt,
+                                        modified_coords.velocity * 100);
 
       blob_union = gimp_blob_convex_union (ink->last_blob, blob);
 
diff --git a/app/paint/gimpink.h b/app/paint/gimpink.h
index da98393..6cb185b 100644
--- a/app/paint/gimpink.h
+++ b/app/paint/gimpink.h
@@ -21,7 +21,6 @@
 
 #include "gimppaintcore.h"
 #include "gimpink-blob.h"
-#include "gimppaintoptions.h"
 
 
 #define GIMP_TYPE_INK            (gimp_ink_get_type ())
@@ -40,8 +39,8 @@ struct _GimpInk
 
   GimpBlob      *start_blob;   /*  starting blob (for undo)       */
 
-  GimpBlob          *cur_blob;     /*  current blob                   */
-  GimpBlob          *last_blob;    /*  blob for last cursor position  */
+  GimpBlob      *cur_blob;     /*  current blob                   */
+  GimpBlob      *last_blob;    /*  blob for last cursor position  */
 };
 
 struct _GimpInkClass
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 82aa954..326cb93 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -353,14 +353,14 @@ gimp_paint_core_start (GimpPaintCore     *core,
 
   item = GIMP_ITEM (drawable);
 
-  if (core->stroke_buffer != NULL)
-   {
-     g_array_free(core->stroke_buffer, TRUE);
-     core->stroke_buffer = NULL;
-   }
+  if (core->stroke_buffer)
+    {
+      g_array_free (core->stroke_buffer, TRUE);
+      core->stroke_buffer = NULL;
+    }
 
   core->stroke_buffer = g_array_sized_new (TRUE, TRUE,
-                                           sizeof(GimpCoords),
+                                           sizeof (GimpCoords),
                                            STROKE_BUFFER_INIT_SIZE);
 
   core->cur_coords = *coords;
@@ -430,10 +430,11 @@ gimp_paint_core_finish (GimpPaintCore *core,
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
 
-  if (core->stroke_buffer) {
-    g_array_free (core->stroke_buffer, TRUE);
-    core->stroke_buffer = NULL;
-  }
+  if (core->stroke_buffer)
+    {
+      g_array_free (core->stroke_buffer, TRUE);
+      core->stroke_buffer = NULL;
+    }
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
@@ -1250,39 +1251,41 @@ gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
     }
 }
 
-GimpCoords gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
-                                                GimpPaintOptions *paint_options,
-                                                const GimpCoords *original_coords)
+GimpCoords
+gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
+                                     GimpPaintOptions *paint_options,
+                                     const GimpCoords *original_coords)
 {
   GimpSmoothingOptions *smoothing_options = paint_options->smoothing_options;
-  GArray   *history = core->stroke_buffer;
+  GArray               *history           = core->stroke_buffer;
 
-  if (smoothing_options->use_smoothing && smoothing_options->smoothing_quality > 0)
+  if (smoothing_options->use_smoothing &&
+      smoothing_options->smoothing_quality > 0)
     {
-      int i;
-      guint length;
-      gint min_index;
-      GimpCoords result = *original_coords;
-      gdouble gaussian_weight = 0.0;
-      gdouble gaussian_weight2 = SQR (smoothing_options->smoothing_factor);
-      gdouble velocity_sum = 0.0;
-      gdouble scale_sum = 0.0;
+      gint       i;
+      guint      length;
+      gint       min_index;
+      GimpCoords result           = *original_coords;
+      gdouble    gaussian_weight  = 0.0;
+      gdouble    gaussian_weight2 = SQR (smoothing_options->smoothing_factor);
+      gdouble    velocity_sum     = 0.0;
+      gdouble    scale_sum        = 0.0;
 
       result.x = result.y = 0.0;
 
-
       g_array_append_val (history, *original_coords);
 
-      length = MIN(smoothing_options->smoothing_quality, history->len);
+      length = MIN (smoothing_options->smoothing_quality, history->len);
 
       min_index = history->len - length;
 
       if (gaussian_weight2 != 0.0)
         gaussian_weight = 1 / (sqrt (2 * G_PI) * smoothing_options->smoothing_factor);
 
-      for (i = history->len - 1; i >= min_index; i--) {
-          gdouble rate = 0.0;
-          GimpCoords* next_coords = &g_array_index (history,
+      for (i = history->len - 1; i >= min_index; i--)
+        {
+          gdouble     rate        = 0.0;
+          GimpCoords *next_coords = &g_array_index (history,
                                                     GimpCoords, i);
 
           if (gaussian_weight2 != 0.0)
@@ -1295,7 +1298,8 @@ GimpCoords gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
           scale_sum += rate;
           result.x += rate * next_coords->x;
           result.y += rate * next_coords->y;
-      }
+        }
+
       if (scale_sum != 0.0)
         {
           result.x /= scale_sum;
@@ -1304,5 +1308,6 @@ GimpCoords gimp_paint_core_get_smoothed_coords (GimpPaintCore    *core,
 
       return result;
     }
-    return *original_coords;
+
+  return *original_coords;
 }
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 4dbec5a..5eb0f34 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -21,7 +21,6 @@
 
 #include "libgimpmath/gimpvector.h"
 #include "core/gimpobject.h"
-#include "gimppaintoptions.h" /* GimpCircularQueue */
 
 
 #define GIMP_TYPE_PAINT_CORE            (gimp_paint_core_get_type ())
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index 1f9d43e..7d33b87 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -36,6 +36,7 @@
 
 #include "gimp-intl.h"
 
+
 #define DEFAULT_BRUSH_SIZE             20.0
 #define DEFAULT_BRUSH_ASPECT_RATIO     1.0
 #define DEFAULT_BRUSH_ANGLE            0.0
@@ -64,6 +65,7 @@
 #define DEFAULT_SMOOTHING_QUALITY      20
 #define DEFAULT_SMOOTHING_FACTOR       50
 
+
 enum
 {
   PROP_0,
@@ -255,16 +257,15 @@ gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
                                     GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_SMOOTHING_QUALITY,
                                 "smoothing-quality", NULL,
-                                1,
-                                100,
-                                DEFAULT_SMOOTHING_QUALITY,
+                                1, 100, DEFAULT_SMOOTHING_QUALITY,
                                 GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SMOOTHING_FACTOR,
                                    "smoothing-factor", NULL,
-                                   3.0, 1000.0, DEFAULT_SMOOTHING_FACTOR, /* Max velocity is set at 3.
-                                                                           * Allowing for smoothing factor to be
-                                                                           * less than velcoty results in numeric
-                                                                           * instablility */
+                                   3.0, 1000.0, DEFAULT_SMOOTHING_FACTOR,
+                                   /* Max velocity is set at 3.
+                                    * Allowing for smoothing factor to be
+                                    * less than velcoty results in numeric
+                                    * instablility */
                                    GIMP_PARAM_STATIC_STRINGS);
 }
 
@@ -298,9 +299,9 @@ gimp_paint_options_finalize (GObject *object)
 {
   GimpPaintOptions *options = GIMP_PAINT_OPTIONS (object);
 
-  g_slice_free (GimpJitterOptions,   options->jitter_options);
-  g_slice_free (GimpFadeOptions,     options->fade_options);
-  g_slice_free (GimpGradientOptions, options->gradient_options);
+  g_slice_free (GimpJitterOptions,    options->jitter_options);
+  g_slice_free (GimpFadeOptions,      options->fade_options);
+  g_slice_free (GimpGradientOptions,  options->gradient_options);
   g_slice_free (GimpSmoothingOptions, options->smoothing_options);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -312,11 +313,11 @@ gimp_paint_options_set_property (GObject      *object,
                                  const GValue *value,
                                  GParamSpec   *pspec)
 {
-  GimpPaintOptions    *options           = GIMP_PAINT_OPTIONS (object);
-  GimpFadeOptions     *fade_options      = options->fade_options;
-  GimpJitterOptions   *jitter_options    = options->jitter_options;
-  GimpGradientOptions *gradient_options  = options->gradient_options;
-  GimpSmoothingOptions *smoothing_options= options->smoothing_options;
+  GimpPaintOptions    *options            = GIMP_PAINT_OPTIONS (object);
+  GimpFadeOptions     *fade_options       = options->fade_options;
+  GimpJitterOptions   *jitter_options     = options->jitter_options;
+  GimpGradientOptions *gradient_options   = options->gradient_options;
+  GimpSmoothingOptions *smoothing_options = options->smoothing_options;
 
   switch (property_id)
     {
@@ -436,7 +437,7 @@ gimp_paint_options_get_property (GObject    *object,
   GimpFadeOptions      *fade_options      = options->fade_options;
   GimpJitterOptions    *jitter_options    = options->jitter_options;
   GimpGradientOptions  *gradient_options  = options->gradient_options;
-  GimpSmoothingOptions *smoothing_options= options->smoothing_options;
+  GimpSmoothingOptions *smoothing_options = options->smoothing_options;
 
   switch (property_id)
     {
@@ -529,7 +530,7 @@ gimp_paint_options_get_property (GObject    *object,
       break;
 
     case PROP_USE_SMOOTHING:
-      g_value_set_boolean(value, smoothing_options->use_smoothing);
+      g_value_set_boolean (value, smoothing_options->use_smoothing);
       break;
 
     case PROP_SMOOTHING_QUALITY:
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index 0010cef..9f9a8e1 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -173,9 +173,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       gtk_widget_show (frame);
     }
 
-    frame = smoothing_options_gui (options, tool_type);
-    gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
-    gtk_widget_show (frame);
+  frame = smoothing_options_gui (options, tool_type);
+  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+  gtk_widget_show (frame);
 
   /*  the "incremental" toggle  */
   if (tool_type == GIMP_TYPE_PENCIL_TOOL     ||



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]