MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
SnapAttrib.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
6 #if !defined(AFX_SNAPATTRIB_H__3704A1F4_AAA3_4021_98F4_087C5A16006B__INCLUDED_)
7 #define AFX_SNAPATTRIB_H__3704A1F4_AAA3_4021_98F4_087C5A16006B__INCLUDED_
8 
9 #if _MSC_VER > 1000
10 #pragma once
11 #endif
12 
13 #include "mg/MGCL.h"
14 #include <bitset>
15 #include <iosfwd>
16 
17 class MGIfstream;
18 class MGOfstream;
21 
26 class MG_DLL_DECLR MGSnapAttrib{
27 public:
28 
29  enum{
30  BIT_END=0,
31  BIT_KNOT=1,
32  BIT_NEAR=2,
33  BIT_VERTEX=3,
34  BIT_CENTER=4,
35  BIT_GRID=5,
36  BIT_ORTHO=6
37  };
38 
40 MG_DLL_DECLR friend std::ostream& operator<< (std::ostream& ostrm, const MGSnapAttrib& atr);
41 
43 MG_DLL_DECLR friend MGOfstream& operator<< (MGOfstream& buf, const MGSnapAttrib& atr);
44 MG_DLL_DECLR friend MGIfstream& operator>> (MGIfstream& buf, MGSnapAttrib& atr);
45 
46  MGSnapAttrib();
47  MGSnapAttrib(float apx, float apy,
48  bool bEnd=false, bool bKnot=false, bool bNear=false, bool bVertex=false,
49  bool bCenter=false, bool bGrid=false, bool bOrtho=false
50  );
52  float apx, float apy,
53  const std::bitset<32>& bits
54  );
55 
57 
58 public:
59 
61  const float* getSnapAperture()const{return m_dSnapAperture;};
62  void setSnapAperture(const float Aperture[2]){
63  m_dSnapAperture[0] = Aperture[0];
64  m_dSnapAperture[1] = Aperture[1];
65  };
66  void setSnapAperture(double x,double y){
67  m_dSnapAperture[0]=float(x);m_dSnapAperture[1]=float(y);};
68 
69  bool getEnd() const {return m_bitset[BIT_END];};
70  void setEnd(bool bEnd) {m_bitset[BIT_END] = bEnd;};
71 
72  bool getKnot() const {return m_bitset[BIT_KNOT];};
73  void setKnot(bool bKnot) {m_bitset[BIT_KNOT] = bKnot;};
74 
75  bool getNear() const {return m_bitset[BIT_NEAR];};
76  void setNear(bool bNear) {m_bitset[BIT_NEAR] = bNear;};
77 
78  bool getVertex() const {return m_bitset[BIT_VERTEX];};
79  void setVertex(bool bVertex) {m_bitset[BIT_VERTEX] = bVertex;};
80 
81  bool getCenter() const { return m_bitset[BIT_CENTER];};
82  void setCenter(bool bCenter) {m_bitset[BIT_CENTER] = bCenter;};
83 
84  bool getGrid() const { return m_bitset[BIT_GRID];};
85  void setGrid(bool bGrid) {m_bitset[BIT_GRID] = bGrid;};
86 
87  bool getOrtho() const{ return m_bitset[BIT_ORTHO];}
88  void setOrtho(bool bOrtho){ m_bitset[BIT_ORTHO] = bOrtho;}
89 
91 
93  bool any() const{ return m_bitset.any();}
94 
96  bool none() const{ return m_bitset.none();}
97 
99  int count() const{ return int(m_bitset.count());}
100 
102  void clear_attrib(){m_bitset.reset();};
103 
105 private:
106  std::bitset<32> m_bitset;
107  float m_dSnapAperture[2];
108 };
109 
110 #endif // !defined(AFX_SNAPATTRIB_H__3704A1F4_AAA3_4021_98F4_087C5A16006B__INCLUDED_)
void setGrid(bool bGrid)
Definition: SnapAttrib.h:85
void setCenter(bool bCenter)
Definition: SnapAttrib.h:82
bool getVertex() const
Definition: SnapAttrib.h:78
void clear_attrib()
clear all the attrib to false;
Definition: SnapAttrib.h:102
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
void setVertex(bool bVertex)
Definition: SnapAttrib.h:79
std::ostream & operator<<(std::ostream &ostrm, const MGisect &is)
Debug Function.
Definition: isect.h:95
void setEnd(bool bEnd)
Definition: SnapAttrib.h:70
void setSnapAperture(double x, double y)
Definition: SnapAttrib.h:66
void setSnapAperture(const float Aperture[2])
Definition: SnapAttrib.h:62
bool getCenter() const
Definition: SnapAttrib.h:81
void setKnot(bool bKnot)
Definition: SnapAttrib.h:73
Defines Snap attributes.
Definition: SnapAttrib.h:26
void setNear(bool bNear)
Definition: SnapAttrib.h:76
bool any() const
Test if any of the attributes are set on. If on, return true.
Definition: SnapAttrib.h:93
bool getNear() const
Definition: SnapAttrib.h:75
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
bool getKnot() const
Definition: SnapAttrib.h:72
bool getEnd() const
Definition: SnapAttrib.h:69
const float * getSnapAperture() const
virtual ~MGSnapAttrib();
Definition: SnapAttrib.h:61
bool getGrid() const
Definition: SnapAttrib.h:84
bool getOrtho() const
Definition: SnapAttrib.h:87
bool none() const
Test if none of the attributes is set on. If none is on, return true.
Definition: SnapAttrib.h:96
void setOrtho(bool bOrtho)
Definition: SnapAttrib.h:88
int count() const
Get the number of attributes that are on.
Definition: SnapAttrib.h:99