LCOV - code coverage report
Current view: top level - pencil/include/layout - layout_visible_classifier.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.71.2_covts Lines: 65.3 % 121 79
Test Date: 2026-08-22 19:47:36 Functions: 69.2 % 26 18

            Line data    Source code
       1              : /* File: layout_visible_classifier.inl; Copyright and License: see below */
       2              : 
       3              : #include <assert.h>
       4              : 
       5          151 : static inline void layout_visible_classifier_init ( layout_visible_classifier_t *this_, const data_visible_classifier_t *visible_classifier_data )
       6              : {
       7          151 :     assert ( NULL != visible_classifier_data );
       8              : 
       9          151 :     geometry_rectangle_init_empty( &((*this_).symbol_box) );
      10          151 :     geometry_rectangle_init_empty( &((*this_).space) );
      11          151 :     geometry_rectangle_init_empty( &((*this_).label_box) );
      12          151 :     geometry_rectangle_init_empty( &((*this_).icon_box) );
      13          151 :     geometry_rectangle_init_empty( &((*this_).compartments) );
      14          151 :     geometry_rectangle_init_empty( &((*this_).envelope_box_cache) );
      15          151 :     (*this_).label_h_anchor = GEOMETRY_H_ALIGN_CENTER;  /* most labels are centered */
      16          151 :     (*this_).label_v_anchor = GEOMETRY_V_ALIGN_TOP;  /* most labels are fixed to the top */
      17          151 :     (*this_).data = visible_classifier_data;
      18          151 : }
      19              : 
      20            0 : static inline void layout_visible_classifier_copy( layout_visible_classifier_t *this_, const layout_visible_classifier_t *original )
      21              : {
      22            0 :     assert ( NULL != original );
      23            0 :     assert ( NULL != (*original).data );
      24              : 
      25            0 :     geometry_rectangle_copy( &((*this_).symbol_box), &((*original).symbol_box) );
      26            0 :     geometry_rectangle_copy( &((*this_).space), &((*original).space) );
      27            0 :     geometry_rectangle_copy( &((*this_).label_box), &((*original).label_box) );
      28            0 :     geometry_rectangle_copy( &((*this_).icon_box), &((*original).icon_box) );
      29            0 :     geometry_rectangle_copy( &((*this_).compartments), &((*original).compartments) );
      30            0 :     geometry_rectangle_copy( &((*this_).envelope_box_cache), &((*original).envelope_box_cache) );
      31            0 :     (*this_).label_h_anchor = (*original).label_h_anchor;
      32            0 :     (*this_).label_v_anchor = (*original).label_v_anchor;
      33            0 :     (*this_).data = (*original).data;
      34            0 : }
      35              : 
      36              : static inline void layout_visible_classifier_move( layout_visible_classifier_t *this_, layout_visible_classifier_t *that )
      37              : {
      38              :     assert ( NULL != that );
      39              :     assert ( NULL != (*that).data );
      40              : 
      41              :     geometry_rectangle_move( &((*this_).symbol_box), &((*that).symbol_box) );
      42              :     geometry_rectangle_move( &((*this_).space), &((*that).space) );
      43              :     geometry_rectangle_move( &((*this_).label_box), &((*that).label_box) );
      44              :     geometry_rectangle_move( &((*this_).icon_box), &((*that).icon_box) );
      45              :     geometry_rectangle_move( &((*this_).compartments), &((*that).compartments) );
      46              :     geometry_rectangle_move( &((*this_).envelope_box_cache), &((*that).envelope_box_cache) );
      47              :     (*this_).label_h_anchor = (*that).label_h_anchor;
      48              :     (*this_).label_v_anchor = (*that).label_v_anchor;
      49              :     (*this_).data = (*that).data;
      50              : 
      51              :     (*that).data = NULL;
      52              : }
      53              : 
      54              : static inline void layout_visible_classifier_replace( layout_visible_classifier_t *this_, const layout_visible_classifier_t *original )
      55              : {
      56              :     assert ( NULL != original );
      57              :     assert ( NULL != (*original).data );
      58              : 
      59              :     geometry_rectangle_replace( &((*this_).symbol_box), &((*original).symbol_box) );
      60              :     geometry_rectangle_replace( &((*this_).space), &((*original).space) );
      61              :     geometry_rectangle_replace( &((*this_).label_box), &((*original).label_box) );
      62              :     geometry_rectangle_replace( &((*this_).icon_box), &((*original).icon_box) );
      63              :     geometry_rectangle_replace( &((*this_).compartments), &((*original).compartments) );
      64              :     geometry_rectangle_replace( &((*this_).envelope_box_cache), &((*original).envelope_box_cache) );
      65              :     (*this_).label_h_anchor = (*original).label_h_anchor;
      66              :     (*this_).label_v_anchor = (*original).label_v_anchor;
      67              :     (*this_).data = (*original).data;
      68              : }
      69              : 
      70            0 : static inline void layout_visible_classifier_replacemove( layout_visible_classifier_t *this_, layout_visible_classifier_t *that )
      71              : {
      72            0 :     assert ( NULL != that );
      73            0 :     assert ( NULL != (*that).data );
      74              : 
      75            0 :     geometry_rectangle_replacemove( &((*this_).symbol_box), &((*that).symbol_box) );
      76            0 :     geometry_rectangle_replacemove( &((*this_).space), &((*that).space) );
      77            0 :     geometry_rectangle_replacemove( &((*this_).label_box), &((*that).label_box) );
      78            0 :     geometry_rectangle_replacemove( &((*this_).icon_box), &((*that).icon_box) );
      79            0 :     geometry_rectangle_replacemove( &((*this_).compartments), &((*that).compartments) );
      80            0 :     geometry_rectangle_replacemove( &((*this_).envelope_box_cache), &((*that).envelope_box_cache) );
      81            0 :     (*this_).label_h_anchor = (*that).label_h_anchor;
      82            0 :     (*this_).label_v_anchor = (*that).label_v_anchor;
      83            0 :     (*this_).data = (*that).data;
      84              : 
      85            0 :     (*that).data = NULL;
      86            0 : }
      87              : 
      88          151 : static inline void layout_visible_classifier_destroy ( layout_visible_classifier_t *this_ )
      89              : {
      90          151 :     geometry_rectangle_destroy( &((*this_).symbol_box) );
      91          151 :     geometry_rectangle_destroy( &((*this_).space) );
      92          151 :     geometry_rectangle_destroy( &((*this_).label_box) );
      93          151 :     geometry_rectangle_destroy( &((*this_).icon_box) );
      94          151 :     geometry_rectangle_destroy( &((*this_).compartments) );
      95          151 :     geometry_rectangle_destroy( &((*this_).envelope_box_cache) );
      96          151 :     (*this_).data = NULL;
      97          151 : }
      98              : 
      99         4432 : static inline bool layout_visible_classifier_is_valid ( const layout_visible_classifier_t *this_ )
     100              : {
     101              :     bool result;
     102         4432 :     if ( (*this_).data == NULL )
     103              :     {
     104            0 :         result = false;  /* cannot happen on initialized objects */
     105              :     }
     106              :     else
     107              :     {
     108         4432 :         result = data_visible_classifier_is_valid( (*this_).data );
     109              :     }
     110         4432 :     return result;
     111              : }
     112              : 
     113          366 : static inline const geometry_rectangle_t *layout_visible_classifier_get_symbol_box_const ( const layout_visible_classifier_t *this_ )
     114              : {
     115          366 :     return &((*this_).symbol_box);
     116              : }
     117              : 
     118          192 : static inline void layout_visible_classifier_set_symbol_box ( layout_visible_classifier_t *this_, const geometry_rectangle_t *symbol_box )
     119              : {
     120          192 :     geometry_rectangle_replace( &((*this_).symbol_box), symbol_box );
     121              : 
     122              :     /* update the cached value of envelope_box */
     123          192 :     layout_visible_classifier_private_update_envelope_box( this_ );
     124          192 : }
     125              : 
     126          192 : static inline const geometry_rectangle_t *layout_visible_classifier_get_compartments_const ( const layout_visible_classifier_t *this_ )
     127              : {
     128          192 :     return &((*this_).compartments);
     129              : }
     130              : 
     131          192 : static inline void layout_visible_classifier_set_compartments ( layout_visible_classifier_t *this_, const geometry_rectangle_t *compartments )
     132              : {
     133          192 :     geometry_rectangle_replace( &((*this_).compartments), compartments );
     134              : 
     135              :     /* update the cached value of envelope_box */
     136          192 :     layout_visible_classifier_private_update_envelope_box( this_ );
     137          192 : }
     138              : 
     139          238 : static inline const geometry_rectangle_t *layout_visible_classifier_get_space_const ( const layout_visible_classifier_t *this_ )
     140              : {
     141          238 :     return &((*this_).space);
     142              : }
     143              : 
     144          192 : static inline void layout_visible_classifier_set_space ( layout_visible_classifier_t *this_, const geometry_rectangle_t *space )
     145              : {
     146          192 :     geometry_rectangle_replace( &((*this_).space), space );
     147              : 
     148              :     /* update the cached value of envelope_box */
     149          192 :     layout_visible_classifier_private_update_envelope_box( this_ );
     150          192 : }
     151              : 
     152          174 : static inline const geometry_rectangle_t *layout_visible_classifier_get_label_box_const ( const layout_visible_classifier_t *this_ )
     153              : {
     154          174 :     return &((*this_).label_box);
     155              : }
     156              : 
     157          192 : static inline void layout_visible_classifier_set_label_box ( layout_visible_classifier_t *this_, const geometry_rectangle_t *label_box )
     158              : {
     159          192 :     geometry_rectangle_replace( &((*this_).label_box), label_box );
     160              : 
     161              :     /* update the cached value of envelope_box */
     162          192 :     layout_visible_classifier_private_update_envelope_box( this_ );
     163          192 : }
     164              : 
     165          192 : static inline void layout_visible_classifier_set_label_anchor ( layout_visible_classifier_t *this_,
     166              :                                                                 geometry_h_align_t label_h_anchor,
     167              :                                                                 geometry_v_align_t label_v_anchor )
     168              : {
     169          192 :     (*this_).label_h_anchor = label_h_anchor;
     170          192 :     (*this_).label_v_anchor = label_v_anchor;
     171          192 : }
     172              : 
     173            0 : static inline const geometry_rectangle_t *layout_visible_classifier_get_icon_box_const ( const layout_visible_classifier_t *this_ )
     174              : {
     175            0 :     return &((*this_).icon_box);
     176              : }
     177              : 
     178          192 : static inline void layout_visible_classifier_set_icon_box ( layout_visible_classifier_t *this_, const geometry_rectangle_t *icon_box )
     179              : {
     180          192 :     geometry_rectangle_replace( &((*this_).icon_box), icon_box );
     181              : 
     182              :     /* update the cached value of envelope_box */
     183          192 :     layout_visible_classifier_private_update_envelope_box( this_ );
     184          192 : }
     185              : 
     186          128 : static inline geometry_rectangle_t layout_visible_classifier_get_envelope_box ( const layout_visible_classifier_t *this_ )
     187              : {
     188          128 :     return (*this_).envelope_box_cache;
     189              : }
     190              : 
     191            0 : static inline const geometry_rectangle_t *layout_visible_classifier_get_envelope_box_const ( const layout_visible_classifier_t *this_ )
     192              : {
     193              :     /* return the cached value */
     194            0 :     return &((*this_).envelope_box_cache);
     195              : }
     196              : 
     197           64 : static inline void layout_visible_classifier_shift ( layout_visible_classifier_t *this_, const geometry_offset_t *offset )
     198              : {
     199           64 :     assert( offset != NULL );
     200           64 :     const double delta_x = geometry_offset_get_dx( offset );
     201           64 :     const double delta_y = geometry_offset_get_dy( offset );
     202              : 
     203           64 :     geometry_rectangle_shift( &((*this_).symbol_box), delta_x, delta_y );
     204           64 :     geometry_rectangle_shift( &((*this_).compartments), delta_x, delta_y );
     205           64 :     geometry_rectangle_shift( &((*this_).space), delta_x, delta_y );
     206           64 :     geometry_rectangle_shift( &((*this_).label_box), delta_x, delta_y );
     207           64 :     geometry_rectangle_shift( &((*this_).icon_box), delta_x, delta_y );
     208              : 
     209              :     /* update the cached value of envelope_box */
     210           64 :     geometry_rectangle_shift( &((*this_).envelope_box_cache), delta_x, delta_y );
     211           64 : }
     212              : 
     213        33435 : static inline const data_visible_classifier_t *layout_visible_classifier_get_data_const ( const layout_visible_classifier_t *this_ )
     214              : {
     215        33435 :     return (*this_).data;
     216              : }
     217              : 
     218            0 : static inline const data_classifier_t *layout_visible_classifier_get_classifier_const ( const layout_visible_classifier_t *this_ )
     219              : {
     220            0 :     return data_visible_classifier_get_classifier_const ( (*this_).data );
     221              : }
     222              : 
     223            0 : static inline const data_diagramelement_t *layout_visible_classifier_get_diagramelement_const ( const layout_visible_classifier_t *this_ )
     224              : {
     225            0 :     return data_visible_classifier_get_diagramelement_const ( (*this_).data );
     226              : }
     227              : 
     228       152477 : static inline data_row_t layout_visible_classifier_get_classifier_id ( const layout_visible_classifier_t *this_ )
     229              : {
     230       152477 :     return data_classifier_get_row( data_visible_classifier_get_classifier_const ( (*this_).data ) );
     231              : }
     232              : 
     233            0 : static inline data_row_t layout_visible_classifier_get_diagramelement_id ( const layout_visible_classifier_t *this_ )
     234              : {
     235            0 :     return data_diagramelement_get_row( data_visible_classifier_get_diagramelement_const ( (*this_).data ) );
     236              : }
     237              : 
     238            0 : static inline bool layout_visible_classifier_is_equal_diagramelement_id ( const layout_visible_classifier_t *this_,
     239              :                                                                           const layout_visible_classifier_t *that )
     240              : {
     241            0 :     const data_row_t this_diagele_id = layout_visible_classifier_get_diagramelement_id( this_ );
     242            0 :     const data_row_t that_diagele_id = layout_visible_classifier_get_diagramelement_id( that );
     243            0 :     return ( this_diagele_id == that_diagele_id );
     244              : }
     245              : 
     246          960 : static inline void layout_visible_classifier_private_update_envelope_box ( layout_visible_classifier_t *this_ )
     247              : {
     248              :     geometry_rectangle_t intermediate;
     249          960 :     geometry_rectangle_init_by_bounds( &intermediate, &((*this_).symbol_box), &((*this_).label_box) );
     250              :     /* Note: the icon_box is always contained within the symbol_box */
     251          960 :     geometry_rectangle_init_by_bounds( &((*this_).envelope_box_cache), &intermediate, &((*this_).compartments) );
     252          960 :     geometry_rectangle_init_by_bounds( &((*this_).envelope_box_cache), &intermediate, &((*this_).space) );
     253          960 : }
     254              : 
     255              : 
     256              : /*
     257              : Copyright 2018-2026 Andreas Warnke
     258              : 
     259              : Licensed under the Apache License, Version 2.0 (the "License");
     260              : you may not use this file except in compliance with the License.
     261              : You may obtain a copy of the License at
     262              : 
     263              :     http://www.apache.org/licenses/LICENSE-2.0
     264              : 
     265              : Unless required by applicable law or agreed to in writing, software
     266              : distributed under the License is distributed on an "AS IS" BASIS,
     267              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     268              : See the License for the specific language governing permissions and
     269              : limitations under the License.
     270              : */
        

Generated by: LCOV version 2.0-1