LCOV - code coverage report
Current view: top level - pencil/include/draw - draw_classifier_icon.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.56.1_covts Lines: 15 46 32.6 %
Date: 2024-03-23 04:33:35 Functions: 1 7 14.3 %

          Line data    Source code
       1             : /* File: draw_classifier_icon.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_log.h"
       4             : #include <assert.h>
       5             : 
       6           3 : static inline void draw_classifier_icon_init( draw_classifier_icon_t *this_ )
       7             : {
       8           3 :     (*this_).dummy = 0;  /* prevent warnings on uninitialized usage */
       9             : }
      10             : 
      11             : static inline void draw_classifier_icon_destroy( draw_classifier_icon_t *this_ )
      12             : {
      13             : 
      14             : }
      15             : 
      16         256 : static inline geometry_dimensions_t draw_classifier_icon_get_icon_dimensions( const draw_classifier_icon_t *this_,
      17             :                                                                               data_classifier_type_t classifier_type,
      18             :                                                                               const pencil_size_t *pencil_size )
      19             : {
      20         256 :     assert( pencil_size != NULL );
      21         256 :     geometry_dimensions_t result;
      22             : 
      23         256 :     if ( classifier_type == DATA_CLASSIFIER_TYPE_COMPONENT )
      24             :     {
      25           8 :         const double type_icon_height = pencil_size_get_title_font_size( pencil_size );
      26           8 :         geometry_dimensions_init ( &result, DRAW_CLASSIFIER_ICON_COMPONENT_ICON_WIDTH_TO_HEIGHT * type_icon_height, type_icon_height );
      27             :     }
      28         248 :     else if ( classifier_type == DATA_CLASSIFIER_TYPE_ARTIFACT )
      29             :     {
      30           8 :         const double type_icon_height = pencil_size_get_title_font_size( pencil_size );
      31           8 :         geometry_dimensions_init ( &result, DRAW_CLASSIFIER_ICON_ARTIFACT_ICON_WIDTH_TO_HEIGHT * type_icon_height, type_icon_height );
      32             :     }
      33         240 :     else if ( classifier_type == DATA_CLASSIFIER_TYPE_COMMENT )
      34             :     {
      35             :         /* comments do not have icons - but a folded corner at the same place - therefore this placeholder dimension */
      36           8 :         const double corner_width = pencil_size_get_standard_font_size( pencil_size );
      37           8 :         geometry_dimensions_init ( &result, corner_width, corner_width );
      38             :     }
      39             :     else
      40             :     {
      41             :         geometry_dimensions_init ( &result, 0.0, 0.0 );
      42             :     }
      43             : 
      44         256 :     return result;
      45             : }
      46             : 
      47           0 : static inline geometry_rectangle_t draw_classifier_icon_get_component_bounds ( const draw_classifier_icon_t *this_,
      48             :                                                                                double x,
      49             :                                                                                double y,
      50             :                                                                                geometry_h_align_t h_align,
      51             :                                                                                geometry_v_align_t v_align,
      52             :                                                                                double height )
      53             : {
      54           0 :     geometry_rectangle_t result;
      55             : 
      56           0 :     const double width = DRAW_CLASSIFIER_ICON_COMPONENT_ICON_WIDTH_TO_HEIGHT * height;
      57           0 :     geometry_rectangle_init ( &result,
      58             :                               geometry_h_align_get_left( &h_align, width, x, 0.0 ),
      59             :                               geometry_v_align_get_top( &v_align, height, y, 0.0 ),
      60             :                               width,
      61             :                               height
      62             :                             );
      63             : 
      64           0 :     return result;
      65             : }
      66             : 
      67           0 : static inline geometry_rectangle_t draw_classifier_icon_get_artifact_bounds ( const draw_classifier_icon_t *this_,
      68             :                                                                               double x,
      69             :                                                                               double y,
      70             :                                                                               geometry_h_align_t h_align,
      71             :                                                                               geometry_v_align_t v_align,
      72             :                                                                               double height )
      73             : {
      74           0 :     geometry_rectangle_t result;
      75             : 
      76           0 :     const double width = DRAW_CLASSIFIER_ICON_ARTIFACT_ICON_WIDTH_TO_HEIGHT * height;
      77           0 :     geometry_rectangle_init ( &result,
      78             :                               geometry_h_align_get_left( &h_align, width, x, 0.0 ),
      79             :                               geometry_v_align_get_top( &v_align, height, y, 0.0 ),
      80             :                               width,
      81             :                               height
      82             :                             );
      83             : 
      84           0 :     return result;
      85             : }
      86             : 
      87           0 : static inline geometry_rectangle_t draw_classifier_icon_get_actor_bounds ( const draw_classifier_icon_t *this_,
      88             :                                                                            double x,
      89             :                                                                            double y,
      90             :                                                                            geometry_h_align_t h_align,
      91             :                                                                            geometry_v_align_t v_align,
      92             :                                                                            double height )
      93             : {
      94           0 :     geometry_rectangle_t result;
      95             : 
      96           0 :     const double width = height/3.0;
      97           0 :     geometry_rectangle_init ( &result,
      98             :                               geometry_h_align_get_left( &h_align, width, x, 0.0 ),
      99             :                               geometry_v_align_get_top( &v_align, height, y, 0.0 ),
     100             :                               width,
     101             :                               height
     102             :                             );
     103             : 
     104           0 :     return result;
     105             : }
     106             : 
     107           0 : static inline geometry_rectangle_t draw_classifier_icon_get_circle_bounds ( const draw_classifier_icon_t *this_,
     108             :                                                                             double x,
     109             :                                                                             double y,
     110             :                                                                             geometry_h_align_t h_align,
     111             :                                                                             geometry_v_align_t v_align,
     112             :                                                                             double height )
     113             : {
     114           0 :     geometry_rectangle_t result;
     115             : 
     116           0 :     const double width = height;
     117           0 :     geometry_rectangle_init ( &result,
     118             :                               geometry_h_align_get_left( &h_align, width, x, 0.0 ),
     119             :                               geometry_v_align_get_top( &v_align, height, y, 0.0 ),
     120             :                               width,
     121             :                               height
     122             :                             );
     123             : 
     124           0 :     return result;
     125             : }
     126             : 
     127           0 : static inline geometry_rectangle_t draw_classifier_icon_get_time_bounds ( const draw_classifier_icon_t *this_,
     128             :                                                                           double x,
     129             :                                                                           double y,
     130             :                                                                           geometry_h_align_t h_align,
     131             :                                                                           geometry_v_align_t v_align,
     132             :                                                                           double height )
     133             : {
     134           0 :     geometry_rectangle_t result;
     135             : 
     136           0 :     const double width = height/1.732050808;
     137           0 :     geometry_rectangle_init ( &result,
     138             :                               geometry_h_align_get_left( &h_align, width, x, 0.0 ),
     139             :                               geometry_v_align_get_top( &v_align, height, y, 0.0 ),
     140             :                               width,
     141             :                               height
     142             :                             );
     143             : 
     144           0 :     return result;
     145             : }
     146             : 
     147           0 : static inline geometry_rectangle_t draw_classifier_icon_get_sync_bounds ( const draw_classifier_icon_t *this_,
     148             :                                                                           double x,
     149             :                                                                           double y,
     150             :                                                                           geometry_h_align_t h_align,
     151             :                                                                           geometry_v_align_t v_align,
     152             :                                                                           double height,
     153             :                                                                           const pencil_size_t *pencil_size )
     154             : {
     155           0 :     assert( pencil_size != NULL );
     156           0 :     geometry_rectangle_t result;
     157             : 
     158           0 :     const double width = 3.0 * pencil_size_get_bold_line_width( pencil_size );
     159           0 :     geometry_rectangle_init ( &result,
     160             :                               geometry_h_align_get_left( &h_align, width, x, 0.0 ),
     161             :                               geometry_v_align_get_top( &v_align, height, y, 0.0 ),
     162             :                               width,
     163             :                               height
     164             :                             );
     165             : 
     166           0 :     return result;
     167             : }
     168             : 
     169             : 
     170             : /*
     171             : Copyright 2019-2024 Andreas Warnke
     172             : 
     173             : Licensed under the Apache License, Version 2.0 (the "License");
     174             : you may not use this file except in compliance with the License.
     175             : You may obtain a copy of the License at
     176             : 
     177             :     http://www.apache.org/licenses/LICENSE-2.0
     178             : 
     179             : Unless required by applicable law or agreed to in writing, software
     180             : distributed under the License is distributed on an "AS IS" BASIS,
     181             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     182             : See the License for the specific language governing permissions and
     183             : limitations under the License.
     184             : */

Generated by: LCOV version 1.16