LCOV - code coverage report
Current view: top level - pencil/include/layout - layout_visible_classifier.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 59 95 62.1 %
Date: 2024-04-07 11:14:42 Functions: 15 22 68.2 %

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

Generated by: LCOV version 1.16