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.63.2_covts Lines: 63.3 % 109 69
Test Date: 2025-05-01 10:10:14 Functions: 66.7 % 24 16

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

Generated by: LCOV version 2.0-1