void BasicScene::myAddChild(Sprite* s, const int type) { if (s == nullptr) return; // 根据类型将指针添加到CollisionController中 if (type == TYPE_ACTOR) { Actor* ac = static_cast<Actor*> (s); ac->setTag(1); cc.addActor(ac); } else if (type == TYPE_HAT) { Hat* h = static_cast<Hat*> (s); h->setTag(0); cc.addHat(h); } else if (type == TYPE_FAN) { Fan* fan = dynamic_cast<Fan*> (s); fan->setTag(max_fan_tag++); } // 将实例添加到Layer中 this->addChild(s); }
void DrawCmd::DrawLocalFan() { AcDbObjectId objId = ArxUtilHelper::SelectObject( _T( "请选择一条巷道:" ) ); if( objId.isNull() ) return; if( !ArxUtilHelper::IsEqualType( _T( "LinkedGE" ), objId ) ) return; //if( !ArxUtilHelper::IsEqualType( _T( "Chimney" ), objId ) ) return; AcDbObjectIdArray objIds; DrawHelper::GetTagGEById2( objId, _T( "LocalFan" ), objIds ); //if( !objIds.isEmpty() ) //{ // AfxMessageBox( _T( "该掘进工作面已设置了局部通风机!" ) ); // return; //} AcGePoint3d pt,insertPt; double angle; //if( !GetClosePtAndAngle( objId, pt, angle ) ) return; if( !ArxUtilHelper::PromptPt( _T( "\n请指定局扇的插入点坐标:" ), pt ) ) return; insertPt = pt; if( !GetClosePtAndAngle( objId, pt, angle ) ) return; Fan* pFan = new LocalFan( insertPt, angle ); if( pFan == 0 ) return; pFan->setRelatedGE( objId ); // 关联巷道 // 初始化并提交到数据库 if( !ArxUtilHelper::PostToModelSpace( pFan ) ) delete pFan; }
void DrawCmd::DrawLocalFan() { AcDbObjectId objId = ArxUtilHelper::SelectObject( _T( "请选择一个掘进工作面:" ) ); if( objId.isNull() ) return; if( !ArxUtilHelper::IsEqualType( _T( "TTunnel" ), objId ) ) return; AcDbObjectIdArray objIds; DrawHelper::GetTagGEById2( objId, _T( "LocalFan" ), objIds ); if( !objIds.isEmpty() ) { AfxMessageBox( _T( "该掘进工作面已设置了局部通风机!" ) ); return; } AcGePoint3d pt; if( !ArxUtilHelper::PromptPt( _T( "\n请指定局扇的插入点坐标:" ), pt ) ) return; Fan* pFan = new LocalFan( pt, 0 ); // 目前假设局扇的角度为0(实际绘图中局扇是没有方向的) if( pFan == 0 ) return; pFan->setRelatedGE( objId ); // 关联巷道 // 初始化并提交到数据库 if( !ArxUtilHelper::PostToModelSpace( pFan ) ) delete pFan; }
int main() { //set up basisvectors std::vector<std::vector<double> > basis(2,std::vector<double>(2)); basis[0][0] = 1; basis[0][1] = 0; basis[1][0] = 0; basis[1][1] = 1; //define lattice Lattice myLattice(2,basis); //set up cones Cone Sigma0 = Cone({{1,0},{0,1}},myLattice); Cone Sigma11 = Cone({{0,1},{-1,0}},myLattice); Cone Sigma12 = Cone({{-1,0},{-1,-1}},myLattice); Cone Sigma13 = Cone({{-1,-1},{-2,-3}},myLattice); Cone Sigma21 = Cone({{-2,-3},{-1,-2}},myLattice); Cone Sigma22 = Cone({{-1,-2},{0,-1}},myLattice); Cone Sigma23 = Cone({{0,-1},{1,0}},myLattice); //Define fan std::vector<Cone> myCones = {Sigma0, Sigma11, Sigma12, Sigma13, Sigma21, Sigma22, Sigma23}; Fan myFan(myCones,myLattice); //Get dual fan Fan myDualFan = myFan.getCorrespondingDualFan(); std::vector<Cone> myDualCones = myDualFan.getCones(); std::cout << "CONES OF THE DUAL FAN" << std::endl; std::cout << "----------------------" << std::endl; for(int i = 0; i < myDualCones.size();++i) { std::cout << "Cone nr = " << i << std::endl; Cone myDualCone = myDualCones[i]; std::vector<std::vector<double> > myBVs = myDualCone.getBasisVectors(); std::cout << " " << myBVs[0][0] << std::endl; std::cout << "Ray 1 = " << myBVs[0][1] << std::endl; std::cout << " " << myBVs[0][2] << std::endl; std::cout << "" << std::endl; std::cout << " " << myBVs[1][0] << std::endl; std::cout << "Ray 2 = " << myBVs[1][1] << std::endl; std::cout << " " << myBVs[1][2] << std::endl; std::cout << "----------------------" << std::endl; } myFan.drawFan(); myDualFan.drawFan(); return 0; }
RoomObject* XmlWorldBuilder::parseRoomFan(TiXmlElement* e) { float r, s; e->QueryFloatAttribute("radius", &r); e->QueryFloatAttribute("speed", &s); Fan* f = new Fan( parseVector(e->FirstChildElement("x")), parseVector(e->FirstChildElement("v")), r, s); const char* material = e->Attribute("material"); if (material != NULL) { f->setMaterial(*materials_[material]); } return f; }
int main() { cout << "First fan properties: " << endl; Fan fan; //Fan 0 settings fan.setSpeed(3); fan.setRadius(10); fan.setOn(true); //Fan 0 output cout << "Fan speed: " << fan.getSpeed() << endl; cout << "Fan radius: " << fan.getRadius() << endl; cout << "Fan on? " << fan.isOn() << endl; Fan fan1; //fan 1 settings fan1.setSpeed(2); fan1.setRadius(5); fan1.setOn(false); //Fan 1 output cout << "\nSecond fan properties: " << endl; cout << "Fan speed: " << fan1.getSpeed() << endl; cout << "Fan radius: " << fan1.getRadius() << endl; cout << "Fan on? " << fan1.isOn() << endl; return 0; }
int main() { //constructs a fan based on default values Fan defaultFan; //outputs respective values of speed, on, and radius for constructed default fan cout << defaultFan.getspeed() << " " << defaultFan.geton() << " " << defaultFan.getradius() << endl; //constructs a fan to test set functions Fan customFan(3, true, 8); //outputs values of custom fan cout << customFan.getspeed() << " " << customFan.geton() << " " << customFan.getradius() << endl; //changes value of custom fan using setters //Derek - nice job using these setters, they look great well done :) customFan.setspeed(2); customFan.seton(false); customFan.setradius(9); //outputs values of custom fan cout << customFan.getspeed() << " " << customFan.geton() << " " << customFan.getradius() << endl; return 0; }
const std::string RmmKeyGenerator::generate_key(const Fan& fan, const NetworkInterface& zone_network_interface) { const auto zone_nic_mac = zone_network_interface.get_mac_address(); const auto slot_id = fan.get_slot_id(); if (!zone_nic_mac.has_value()) { throw KeyValueMissingError("Zone NIC MAC address is missing."); } return generate_key_base(fan) + zone_nic_mac.value() + std::to_string(static_cast<unsigned int>(slot_id)); }
void DrawCmd::DrawMainFan() { AcDbObjectId objId = ArxUtilHelper::SelectObject( _T( "请选择一条巷道:" ) ); if( objId.isNull() ) return; if( !ArxUtilHelper::IsEqualType( _T( "Tunnel" ), objId ) ) return; AcGePoint3d pt; if( !PromptInsertPt( objId, pt ) ) return; double angle; if( !GetClosePtAndAngle( objId, pt, angle ) ) return; Fan* pFan = new MainFan( pt, angle ); if( pFan == 0 ) return; pFan->setRelatedGE( objId ); // 关联巷道 // 初始化并提交到数据库 if( !ArxUtilHelper::PostToModelSpace( pFan ) ) delete pFan; }
void everyms () { button1. update() ; //更新按钮状态 if ( button1.getStat() == 3 ) { if ( direction == 0 ) L13.write ( fan1.down() ) ; //减速 else L13.write ( fan1.up () ) ; //加速 } //长按 else if (button1.getStat() == 2 ) { if ( fan1.getStat() == 1 ){ fan1.shutdown(); //关机 } else{ fan1.startup (); //开机 } } //单击 else { L13.write ( 0 ) ; } //没按键 fan1.update() ; }
void SymbolModel::init() { const SHPHandle& hSHP = _shpLoader->getHandle(); const DBFHandle& hDBF = _dbfLoader->getHandle(); float maxVal = -99999999999, minVal = 99999999999; std::vector<float2> xy; // 2d定位点 std::vector<std::vector<float> > table; std::vector<float> colsum; for (int i = 0; i < hSHP->nRecords; i++) // 遍历记录 { SHPObject* psShape = SHPReadObject(hSHP, i); // 每个记录存放一个点 float v[] = { psShape->padfX[0], psShape->padfY[0] }; // 定位点 xy.push_back(v); SHPDestroyObject(psShape); std::vector<float> row; float sum = 0; for (int j = 0; j < _fieldIndices.size(); j++) { float val = DBFReadDoubleAttribute(hDBF, i + 1, _fieldIndices[j]); sum += val; row.push_back(val); } if (maxVal < sum) { maxVal = sum; } if (minVal > sum) { minVal = sum; } colsum.push_back(sum); table.push_back(row); } LinearScaler hScaler(_valueScaler.getBottom()/* + 0.1*/, _valueScaler.getTop()); hScaler.setBound(minVal, maxVal); for (int i = 0; i < hSHP->nRecords; i++) { float pos[] = { xy[i][0], xy[i][1], 0 }; float top = hScaler(colsum[i]); switch (_chartType) { case SPHERE: { Sphere* sphere = new Sphere(pos, _colors.front()); sphere->setLinearScaler(LinearScaler(_valueScaler.getBottom(), top)); _container.add(sphere); } break; case BAR: { Fan* fan = new Fan; fan->set(0, 360, _colors.front(), pos, 1.1); fan->setLinearScaler(LinearScaler(_valueScaler.getBottom(), top)); fan->init(); _container.add(fan); } break; case STACKEDBAR: { StackedBar* bar = new StackedBar; bar->set(table[i], _colors, pos, 1.1); bar->setLinearScaler(LinearScaler(_valueScaler.getBottom(), top)); bar->init(); _container.add(bar); } break; case PIE: { Pie* pie = new Pie; pie->set(table[i], _colors, pos, 1.1); pie->setLinearScaler(_valueScaler); // 应该同高度 pie->init(); _container.add(pie); } break; default:; } } }