LCOV - code coverage report
Current view: top level - pencil/include/layout - layout_relationship.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 36 78 46.2 %
Date: 2024-04-07 11:14:42 Functions: 3 18 16.7 %

          Line data    Source code
       1             : /* File: layout_relationship.inl; Copyright and License: see below */
       2             : 
       3             : #include <assert.h>
       4             : 
       5        2136 : static inline void layout_relationship_init ( layout_relationship_t *this_,
       6             :                                               const data_relationship_t *relationship_data,
       7             :                                               layout_visible_classifier_t *from_classifier,
       8             :                                               layout_visible_classifier_t *to_classifier,
       9             :                                               layout_feature_t *from_feature,
      10             :                                               layout_feature_t *to_feature )
      11             : {
      12        2136 :     assert ( NULL != relationship_data );
      13        2136 :     assert ( NULL != from_classifier );
      14        2136 :     assert ( NULL != to_classifier );
      15             : 
      16        2136 :     (*this_).visible = PENCIL_VISIBILITY_HIDE;
      17        2136 :     geometry_connector_init_empty( &((*this_).shape) );
      18        2136 :     geometry_rectangle_init_empty( &((*this_).label_box) );
      19        2136 :     (*this_).data = relationship_data;
      20        2136 :     (*this_).from_classifier = from_classifier;
      21        2136 :     (*this_).to_classifier = to_classifier;
      22        2136 :     (*this_).from_feature = from_feature;
      23        2136 :     (*this_).to_feature = to_feature;
      24        2136 : }
      25             : 
      26        2136 : static inline void layout_relationship_destroy ( layout_relationship_t *this_ )
      27             : {
      28        2136 :     geometry_connector_destroy( &((*this_).shape) );
      29        2136 :     geometry_rectangle_destroy( &((*this_).label_box) );
      30        2136 :     (*this_).data = NULL;
      31        2136 : }
      32             : 
      33        4272 : static inline bool layout_relationship_is_valid ( const layout_relationship_t *this_ )
      34             : {
      35             :     bool result;
      36        4272 :     if (( (*this_).data == NULL )||( (*this_).from_classifier == NULL )||( (*this_).to_classifier == NULL ))
      37             :     {
      38           0 :         result = false;  /* cannot happen on initialized objects */
      39             :     }
      40             :     else
      41             :     {
      42        4272 :         const data_row_id_t from_classifier_id = data_relationship_get_from_classifier_row_id( (*this_).data );
      43        4272 :         const data_row_id_t to_classifier_id = data_relationship_get_to_classifier_row_id( (*this_).data );
      44        4272 :         const data_row_id_t from_feature_id = data_relationship_get_from_feature_row_id( (*this_).data );
      45        4272 :         const data_row_id_t to_feature_id = data_relationship_get_to_feature_row_id( (*this_).data );
      46        8544 :         const bool from_feature_ok = ( NULL == (*this_).from_feature )
      47             :             ? ( from_feature_id == DATA_ROW_ID_VOID )
      48        4272 :             : ( from_feature_id == layout_feature_get_feature_id( (*this_).from_feature ) );
      49        8544 :         const bool to_feature_ok = ( NULL == (*this_).to_feature )
      50             :             ? ( to_feature_id == DATA_ROW_ID_VOID )
      51        4272 :             : ( to_feature_id == layout_feature_get_feature_id( (*this_).to_feature ) );
      52        8544 :         result = data_relationship_is_valid( (*this_).data )
      53        4272 :             && layout_visible_classifier_is_valid( (*this_).from_classifier )
      54        4272 :             && layout_visible_classifier_is_valid( (*this_).to_classifier )
      55        4272 :             && ( from_classifier_id == layout_visible_classifier_get_classifier_id( (*this_).from_classifier ) )
      56        4272 :             && ( to_classifier_id == layout_visible_classifier_get_classifier_id( (*this_).to_classifier ) )
      57        4272 :             && from_feature_ok
      58        8544 :             && to_feature_ok;
      59             :     }
      60        4272 :     return result;
      61             : }
      62             : 
      63           0 : static inline pencil_visibility_t layout_relationship_get_visibility ( const layout_relationship_t *this_ )
      64             : {
      65           0 :     return (*this_).visible;
      66             : }
      67             : 
      68           0 : static inline void layout_relationship_set_visibility ( layout_relationship_t *this_, pencil_visibility_t visible )
      69             : {
      70           0 :     (*this_).visible = visible;
      71           0 : }
      72             : 
      73           0 : static inline const geometry_connector_t *layout_relationship_get_shape_const ( const layout_relationship_t *this_ )
      74             : {
      75           0 :     return &((*this_).shape);
      76             : }
      77             : 
      78           0 : static inline void layout_relationship_set_shape ( layout_relationship_t *this_, const geometry_connector_t *shape )
      79             : {
      80           0 :     geometry_connector_replace ( &((*this_).shape), shape );
      81           0 : }
      82             : 
      83           0 : static inline geometry_point_t layout_relationship_get_middle ( const layout_relationship_t *this_ )
      84             : {
      85           0 :     double connector_length = geometry_connector_get_length( &((*this_).shape) );
      86           0 :     return geometry_connector_calculate_waypoint( &((*this_).shape), connector_length/2.0 );
      87             : }
      88             : 
      89           0 : static inline const geometry_rectangle_t *layout_relationship_get_label_box_const ( const layout_relationship_t *this_ )
      90             : {
      91           0 :     return &((*this_).label_box);
      92             : }
      93             : 
      94           0 : static inline void layout_relationship_set_label_box ( layout_relationship_t *this_, const geometry_rectangle_t *label_box )
      95             : {
      96           0 :     geometry_rectangle_replace( &((*this_).label_box), label_box );
      97           0 : }
      98             : 
      99           0 : static inline const data_relationship_t *layout_relationship_get_data_const ( const layout_relationship_t *this_ )
     100             : {
     101           0 :     assert ( NULL != (*this_).data );
     102           0 :     return (*this_).data;
     103             : }
     104             : 
     105           0 : static inline layout_visible_classifier_t *layout_relationship_get_from_classifier_ptr ( const layout_relationship_t *this_ )
     106             : {
     107           0 :     return (*this_).from_classifier;
     108             : }
     109             : 
     110           0 : static inline layout_visible_classifier_t *layout_relationship_get_to_classifier_ptr ( const layout_relationship_t *this_ )
     111             : {
     112           0 :     return (*this_).to_classifier;
     113             : }
     114             : 
     115           0 : static inline layout_feature_t *layout_relationship_get_from_feature_ptr ( const layout_relationship_t *this_ )
     116             : {
     117           0 :     return (*this_).from_feature;
     118             : }
     119             : 
     120           0 : static inline layout_feature_t *layout_relationship_get_to_feature_ptr ( const layout_relationship_t *this_ )
     121             : {
     122           0 :     return (*this_).to_feature;
     123             : }
     124             : 
     125           0 : static inline data_row_id_t layout_relationship_get_relationship_id ( const layout_relationship_t *this_ )
     126             : {
     127           0 :     return data_relationship_get_row_id( (*this_).data );
     128             : }
     129             : 
     130           0 : static inline const geometry_rectangle_t *layout_relationship_get_from_symbol_box_const ( const layout_relationship_t *this_ )
     131             : {
     132             :     const geometry_rectangle_t *result;
     133             : 
     134           0 :     if ( NULL != (*this_).from_feature )
     135             :     {
     136           0 :         result = layout_feature_get_symbol_box_const( (*this_).from_feature );
     137             :     }
     138             :     else
     139             :     {
     140           0 :         result = layout_visible_classifier_get_symbol_box_const( (*this_).from_classifier );
     141             :     }
     142             : 
     143           0 :     return result;
     144             : }
     145             : 
     146           0 : static inline const geometry_rectangle_t *layout_relationship_get_to_symbol_box_const ( const layout_relationship_t *this_ )
     147             : {
     148             :     const geometry_rectangle_t *result;
     149             : 
     150           0 :     if ( NULL != (*this_).to_feature )
     151             :     {
     152           0 :         result = layout_feature_get_symbol_box_const( (*this_).to_feature );
     153             :     }
     154             :     else
     155             :     {
     156           0 :         result = layout_visible_classifier_get_symbol_box_const( (*this_).to_classifier );
     157             :     }
     158             : 
     159           0 :     return result;
     160             : }
     161             : 
     162             : 
     163             : /*
     164             : Copyright 2018-2024 Andreas Warnke
     165             : 
     166             : Licensed under the Apache License, Version 2.0 (the "License");
     167             : you may not use this file except in compliance with the License.
     168             : You may obtain a copy of the License at
     169             : 
     170             :     http://www.apache.org/licenses/LICENSE-2.0
     171             : 
     172             : Unless required by applicable law or agreed to in writing, software
     173             : distributed under the License is distributed on an "AS IS" BASIS,
     174             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     175             : See the License for the specific language governing permissions and
     176             : limitations under the License.
     177             : */

Generated by: LCOV version 1.16