1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef GRAPHIC_LTE_VERTEX_GENERATE_DASH_H 16 #define GRAPHIC_LTE_VERTEX_GENERATE_DASH_H 17 18 #include "gfx_utils/diagram/common/common_basics.h" 19 #include "gfx_utils/diagram/vertexprimitive/geometry_vertex_sequence.h" 20 21 namespace OHOS { 22 /** 23 * @brief dash Segment generator 24 * @since 1.0 25 * @version 1.0 26 */ 27 class VertexGenerateDash { 28 #if defined(GRAPHIC_ENABLE_DASH_GENERATE_FLAG) && GRAPHIC_ENABLE_DASH_GENERATE_FLAG 29 enum Status { 30 INITIAL, 31 READY, 32 POLYLINE, 33 STOP 34 }; 35 36 public: 37 38 VertexGenerateDash(); 39 40 VertexGenerateFlags GetGenerateFlags(); 41 42 /** 43 * @brief Remove all dashes 44 * @since 1.0 45 * @version 1.0 46 */ 47 void RemoveAllDashes(); 48 /** 49 * @brief Add dash 50 * @param dashLen segment length 51 * @param gapLen Notch length 52 * @since 1.0 53 * @version 1.0 54 */ 55 void AddDash(float dashLen, float gapLen); 56 /** 57 * @brief Set dashstart_ 58 * @param Set value 59 * @since 1.0 60 * @version 1.0 61 */ 62 void DashStart(float ds); 63 /** 64 * @brief Set shortcut_ 65 * @param Set value 66 * @since 1.0 67 * @version 1.0 68 */ Shorten(float s)69 void Shorten(float s) 70 { 71 shorten_ = s; 72 } 73 /** 74 * @brief Get storten_ 75 * @return shorten_ 76 * @since 1.0 77 * @version 1.0 78 */ Shorten()79 float Shorten() const 80 { 81 return shorten_; 82 } 83 /** 84 * @brief Remove all vertices 85 * @since 1.0 86 * @version 1.0 87 */ 88 void RemoveAll(); 89 /** 90 * @brief add vertex 91 * @param x x-coordinate 92 * @param y y-coordinate 93 * @param cmd Instruction type 94 * @since 1.0 95 * @version 1.0 96 */ 97 void AddVertex(float x, float y, uint32_t cmd); 98 99 void Rewind(uint32_t pathId); 100 101 uint32_t GenerateVertex(float* x, float* y); 102 103 void CompareSize(); 104 105 void CompareVertexSize(); 106 private: 107 VertexGenerateDash(const VertexGenerateDash&); 108 const VertexGenerateDash& operator=(const VertexGenerateDash&); 109 110 void CalcDashStart(float ds); 111 112 float dashes_[MAX_DASHES]; 113 float totalDashLen_; 114 uint32_t numDashes_; 115 float dashStart_; 116 float shorten_; 117 float currDashStart_; 118 uint32_t currDash_; 119 float currRest_; 120 const VertexDist* vertexDist1_; 121 const VertexDist* vertexDist2_; 122 GeometryVertexSequence srcVertices_; 123 uint32_t closed_; 124 Status status_; 125 uint32_t srcVertex_; 126 #endif 127 }; 128 } // namespace OHOS 129 130 #endif 131