blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
โŒ€
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
โŒ€
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
โŒ€
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
df97ee90add683fe4f62559b0943ed93a0d7609f
8fbf442d4f16c1f76a3761f152a01d3f99fba5fa
/src/Game.h
2ea706b5ec1140d61c15c56859f0ac51063b47dc
[]
no_license
lukitree/RollHigh
921313d650e46610343a9ad61177f4a9ebff8aa6
46ec11b713d555cc29158f43a929b19018945a02
refs/heads/master
2021-01-21T12:03:28.866272
2015-04-25T23:07:21
2015-04-25T23:07:21
33,465,663
0
0
null
null
null
null
UTF-8
C++
false
false
1,088
h
Game.h
/* * Game.h * * Created on: Apr 1, 2015 * Author: eddy */ #ifndef GAME_H_ #define GAME_H_ #include <ncurses.h> #include <iostream> #include <string> #include "Player.h" #include "UI.h" #include "Roller.h" #include <vector> enum KEY {EXIT = 'q', RESTART = 'r'}; class Game { public: Game(void); ~Game(void); void run(void); void init(void); private: void print_top(const std::string& msg); void get_player_count(void); void get_player_names(void); void get_player_input(void); void pause(void); void spawn_player_window(void); void init_ui(void); void update_player_numbers(void); void check_all_players_done(void); void poll_input(void); void check_numbers(void); void assign_points(void); void reset_players(void); void update_scoreboard(void); void prompt_play_again(void); std::vector<std::pair<int, int>> scores; bool play; bool all_players_done; int player_count; Player p1; Player p2; Player p3; Player p4; UI ui; Roller roll; }; #endif /* GAME_H_ */
eddff614f88e42e935fc13eea82c71f1cc83c291
243146e027ab3504c667b7173887d48d2632c562
/fscachesim-3.0-new/StoreCacheMQ.cc
c69e6a8b0dfbb99ec03b4595066cd840fb5f08bd
[]
no_license
walle0431/testfs
0dd8bbe72c7496c53a03c1b68542153d57f1c10c
7b996a5503ba360dc7b89295d4ae05eaed0cf82d
refs/heads/master
2021-01-20T22:54:48.950512
2013-05-25T09:29:10
2013-05-25T09:29:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,918
cc
StoreCacheMQ.cc
/* RCS: $Header: /afs/cs.cmu.edu/user/tmwong/Cvs/fscachesim/StoreCacheSeg.cc,v 1.4 2002/02/18 00:23:45 tmwong Exp $ Author: T.M. Wong <tmwong+@cs.cmu.edu> */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ #include <math.h> #ifdef HAVE_STDINT_H #include <stdint.h> #endif /* HAVE_STDINT_H */ #include <stdio.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif /* HAVE_STDLIB_H */ #include "IORequest.hh" #include "StoreCacheMQ.hh" #include "util.hh" using Block::block_t; int StoreCacheMQ::blockGetCascade(const block_t& inBlock, unsigned int& freq) { int retval = -1; for (int i = 0; i < cacheSegCount+1 ; i++) { if (cacheSegs[i]->isCached(inBlock)) { cacheSegs[i]->blockGet(inBlock, freq); segHits[i]++; retval = i; break; } } return (retval); } void StoreCacheMQ::blockPutAtSegCascade(const block_t& inBlock, unsigned int freq, int inSeg) { block_t cascadeEjectBlock = inBlock; unsigned int cascadeejectfreq = freq; bool cascadeEjectFlag = true; for (int i = inSeg; i >= 0 && cascadeEjectFlag; i--) { block_t ejectBlock = {0, 0}; unsigned int ejectfreq; cascadeEjectFlag = false; if (cacheSegs[i]->isFull()) { cacheSegs[i]->blockGetAtHead(ejectBlock, ejectfreq); cascadeEjectFlag = true; } // Cache the incoming block at the tail of the queue. cacheSegs[i]->blockPutAtTail(cascadeEjectBlock, cascadeejectfreq); cascadeEjectBlock = ejectBlock; cascadeejectfreq = ejectfreq; } } StoreCacheMQ::StoreCacheMQ(const char *inName, uint64_t inBlockSize, uint64_t inSize, int inSegCount) : StoreCache(inName, inBlockSize,inSize), cacheSegCount(inSegCount) { uint64_t cacheSegSize = inSize / cacheSegCount; uint64_t cacheSizeRemain = inSize; cacheSegs = new FCache *[cacheSegCount+1]; segHits = new uint64_t[cacheSegCount]; for (int i = 1; i < cacheSegCount+1; i++) { uint64_t thisSegSize = (i < cacheSegCount ? cacheSegSize : cacheSizeRemain); cacheSegs[i] = new FCache(thisSegSize); segHits[i] = 0; cacheSizeRemain -= thisSegSize; } if (cacheSizeRemain != 0) { abort(); } cacheSegs[0] = new FCache(inSize/2); } // For the exponential size segments, each segment is inSegMultiplier times // the size of the previous segment. StoreCacheMQ::StoreCacheMQ(const char *inName, uint64_t inBlockSize, uint64_t inSize, int inSegCount, int inSegMultiplier) : StoreCache(inName, inBlockSize,inSize), cacheSegCount(inSegCount) { cacheSegs = new FCache *[cacheSegCount+1]; segHits = new uint64_t[cacheSegCount]; // Track how much cache space remains after allocating space for each // segment. We will sweep remaining space into the tail segment. uint64_t cacheSizeRemain = inSize; // Each cache segment size is a fraction of the cache size. Determine the // denominator of the fractions. For example, if each segment is twice // the size of the previous segment, and there are four segments, the // denominator is: // // 8 4 2 1 = 15 // // Thus, we divide the cache size into fifteen shares, and distribute // shares accordingly. int cacheShareCount = 0; for (int i = 0; i < cacheSegCount; i++) { cacheShareCount += ((int)pow(inSegMultiplier, i)); } uint64_t cacheShareSize = inSize / cacheShareCount; for (int i = 1; i < cacheSegCount+1; i++) { // Assign shares to this segment. The last (tail) segment gets the most // shares, and also any slop hasn't already been allocated due to // round-off. uint64_t thisSegSize = (i < cacheSegCount - 1 ? ((int)(pow(inSegMultiplier, i))) * cacheShareSize : cacheSizeRemain); cacheSegs[i] = new FCache(thisSegSize); segHits[i] = 0; cacheSizeRemain -= thisSegSize; } // Make sure we assigned all of the cache. if (cacheSizeRemain != 0) { abort(); } cacheSegs[0] = new FCache(inSize/2); } StoreCacheMQ::~StoreCacheMQ() { for (int i = 0; i < cacheSegCount+1; i++) { delete cacheSegs[i]; } delete segHits; delete cacheSegs; } void StoreCacheMQ::BlockCache(const IORequest& inIOReq, const Block::block_t& inBlock, list<IORequest>& outIOReqs) { if (inIOReq.opGet() != IORequest::Read) return; unsigned int freq; const char* reqOrig = inIOReq.origGet(); // See if we have cached this block. We only update the ghost hit counts // when we receive a read request. int blockSeg = blockGetCascade(inBlock, freq); if (blockSeg > 0) { readHitsPerOrig[reqOrig]++; readHits++; freq++; } else { if (blockSeg == 0) freq++; else freq = 1; readMissesPerOrig[reqOrig]++; readMisses++; } blockPutAtSegCascade(inBlock, freq, posGet(freq)); } int StoreCacheMQ::posGet(unsigned int freq) { int pos; if (freq > 0) pos = log2((uint64_t)freq) + 1; else abort(); if (pos > cacheSegCount) pos = cacheSegCount; return pos; } void StoreCacheMQ::statisticsReset() { for (int i = 0; i < cacheSegCount; i++) { segHits[i] = 0; } StoreCache::statisticsReset(); } void StoreCacheMQ::statisticsShow() const { printf("{StoreCacheSeg.%s\n", nameGet()); if (mode != Analyze) { printf("\t{size "); uint64_t sizeTotal = 0; for (int i = 0; i < cacheSegCount; i++) { printf("{seg%d=%llu} ", i, cacheSegs[i]->sizeGet() * blockSizeGet()); sizeTotal += cacheSegs[i]->sizeGet(); } printf("{total=%llu} }\n", sizeTotal * blockSizeGet()); printf("\t{segHits "); uint64_t segHitsTotal = 0; for (int i = 0; i < cacheSegCount; i++) { printf("{seg%d=%llu} ", i, segHits[i]); segHitsTotal += segHits[i]; } printf("{total=%llu} }\n", segHitsTotal); } StoreCache::statisticsShow(); if (mode != Analyze) { printf("}\n"); } }
6e14764c4495fd67c99dca2c22186edc56c928c8
63ceee40730bd5b6193f01ba440773832bdb559c
/H34086149_hw11/H34086149_hw11_1.cpp
5c45d5db83ba2ed28b277f7bce5ee8e5988801e8
[]
no_license
visitorckw/computer-science
426160287448ae1a34aeff1d53af56c0c8321a3d
a0faa0997dd5e682bd38990aced175ca609c55e3
refs/heads/master
2023-06-11T16:14:22.062297
2021-07-09T19:05:16
2021-07-09T19:05:16
384,527,233
0
0
null
null
null
null
UTF-8
C++
false
false
686
cpp
H34086149_hw11_1.cpp
//============================================================================ // Name : H34086149_hw11_1.cpp // Author : mr.NTD // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int number; vector<int> arr; cout << "Please input 20 numbers\n"; for(int i = 0; i < 20; i++) { cin >> number; if(find(arr.begin(),arr.end(),number) == arr.end()) arr.push_back(number); } for(auto i:arr) cout << i << ' '; cout << '\n'; return 0; }
ec89968696d4541e7d15c84f96331e2a9906e396
0ffc1b87e74dbce62f399191bcd4278b3677543f
/Project10/Project10/Logo.cpp
cc8f5da936db0b539cc2e660ef0f961e68897330
[]
no_license
ParkHD/school
7b5cba8fca83fd81fb7cf079251988c0891cf780
98fcb43d79aa048b0bcd72882b14dff0587d6a1a
refs/heads/main
2023-03-18T00:17:48.751346
2021-03-10T08:53:01
2021-03-10T08:53:01
337,343,304
0
0
null
null
null
null
UHC
C++
false
false
698
cpp
Logo.cpp
#include "Logo.h" #include"Include.h" #include"SceneManager.h" #include"WindowController.h" #include "DoubleBuffer.h" void Logo::Initialize() { } void Logo::Progress() { if (GetAsyncKeyState(VK_SPACE)) { SceneManager::Instance()->Initialize(MENU); } } void Logo::Render() { for (int y = 0; y < 50; y++) { for (int x = 0; x < 50; x++) { switch (map[y][x]) { case 1: break; case 0: if(y<25) DoubleBuffer::Instance()->WriteBuffer(x, y, "โ– ", ๋ฐ์€ํŒŒ๋ž€์ƒ‰); else DoubleBuffer::Instance()->WriteBuffer(x, y, "โ– ", ๋ฐ์€์ดˆ๋ก์ƒ‰); break; default: break; } } } } void Logo::Release() { }
4c872bad7b96a7b230846e8530c380f5da213858
37616f72dc466cf058cd285bd3b28bcdae9f05b2
/MyJSONVisitor.h
f0dc70c96aacb6176295ef4dea3af7f16f4c2bda
[]
no_license
theochp/antlr4-json-parser
49bbb4a457ecfb37fcf70d1d4da4fad3ba2ad90a
8e36d1eae9c00f5e52e0fbb6b26367d1f35b3086
refs/heads/master
2022-09-23T06:38:36.162460
2020-06-03T07:11:35
2020-06-03T07:11:35
269,022,835
0
0
null
null
null
null
UTF-8
C++
false
false
2,323
h
MyJSONVisitor.h
// Generated from JSON.g4 by ANTLR 4.7.2 #pragma once #include <iostream> #include "antlr4-runtime.h" #include "JSONVisitor.h" using namespace std; /** * This class provides an empty implementation of JSONVisitor, which can be * extended to create a visitor which only needs to handle a subset of the available methods. */ class MyJSONVisitor : public JSONVisitor { public: virtual antlrcpp::Any visitJson(JSONParser::JsonContext *ctx) override { auto value = visit(ctx->value()).as<string>(); cout << value << endl; return value; } virtual antlrcpp::Any visitFullobj(JSONParser::FullobjContext *ctx) override { auto value = visit(ctx->pair(0)).as<string>(); for (int i = 1; i < ctx->pair().size(); ++i) { value += "," + visit(ctx->pair(i)).as<string>(); } return "{" + value + "}"; } virtual antlrcpp::Any visitEmptyobj(JSONParser::EmptyobjContext *ctx) override { return string("{}"); } virtual antlrcpp::Any visitPair(JSONParser::PairContext *ctx) override { return ctx->STRING()->getText() + ":" + visit(ctx->value()).as<string>(); } virtual antlrcpp::Any visitFullarr(JSONParser::FullarrContext *ctx) override { auto value = visit(ctx->value(0)).as<string>(); for (int i = 1; i < ctx->value().size(); ++i) { value += "," + visit(ctx->value(i)).as<string>(); } return "[" + value + "]"; } virtual antlrcpp::Any visitEmptyarr(JSONParser::EmptyarrContext *ctx) override { return string("[]"); } virtual antlrcpp::Any visitStrval(JSONParser::StrvalContext *ctx) override { return ctx->STRING()->getText(); } virtual antlrcpp::Any visitNumval(JSONParser::NumvalContext *ctx) override { return ctx->NUMBER()->getText(); } virtual antlrcpp::Any visitObjval(JSONParser::ObjvalContext *ctx) override { return visit(ctx->obj()); } virtual antlrcpp::Any visitArrval(JSONParser::ArrvalContext *ctx) override { return visit(ctx->arr()); } virtual antlrcpp::Any visitTrueval(JSONParser::TruevalContext *ctx) override { return string("true"); } virtual antlrcpp::Any visitFalseval(JSONParser::FalsevalContext *ctx) override { return string("false"); } virtual antlrcpp::Any visitNullval(JSONParser::NullvalContext *ctx) override { return string("null"); } };
6395dd340f4304d27ea0d938c4237ba117c15e0d
3edf09116e2fba6fdc481af2fc223e4b6f181ec1
/include/is_detected.hpp
1816ca2c620e70138eb158d12ca104f080247c1e
[]
no_license
StefanGroth/template-stuff
67b0b21ae0f76f862c3be15e6545cd8ff260f913
30967d8f5776fae5547180149bcf306a637b1e83
refs/heads/master
2020-04-28T01:22:02.914385
2019-03-10T20:16:48
2019-03-10T20:16:48
174,853,015
0
0
null
null
null
null
UTF-8
C++
false
false
1,202
hpp
is_detected.hpp
#ifndef IS_DETECTED_H #define IS_DETECTED_H #include <utility> template<typename...> using try_to_instantiate = void; // void is used to detect ill-formed types using disregard_this = void; //template<typename T, typename Attempt = void> struct is_incrementable : std::false_type {}; template<template<typename...> class Expression, typename Attempt, typename ... Ts> struct is_detected_impl : std::false_type {}; template<template<typename...> class Expression, typename ... Ts> struct is_detected_impl<Expression, try_to_instantiate<Expression<Ts...>>, Ts...> : std::true_type {}; template<template<typename...> class Expression, typename ... Ts> constexpr bool is_detected = is_detected_impl<Expression, disregard_this, Ts...>::value; template<typename T, typename U> using assign_expression = decltype(std::declval<T&>() = std::declval<U&>()); //references are used here because no temporary is created template<typename T, typename U> constexpr bool are_assignable = is_detected<assign_expression, T, U>; template<typename T> using incremet_expression = decltype(++std::declval<T&>()); template<typename T> constexpr bool is_incrementable = is_detected<incremet_expression, T>; #endif
b335746fff0e647d4c9ff8ace0f716de5ef00c96
dfdcfeadee39e694df0f633aa49270e04cc51d5e
/Sonar_OLED_3_5.ino
fc7d81ebe85cdfbc1bfbfb49de554eaee4776ed3
[]
no_license
wxqwuxiangqian/arduino-Leonardo_2019spring
7977ede1a796be055b517f876b9909e092b25c82
6dbfac394dac547383d6d7791ddd3cc77f9957da
refs/heads/master
2020-05-18T06:33:29.635812
2019-04-13T07:00:48
2019-04-13T07:00:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,394
ino
Sonar_OLED_3_5.ino
//2019.4.12โ€”โ€”โ€”โ€”ๆต‹่ท + ๅฃฐๆŽงใ€ๅ ๆ–นๅ—๏ผˆไปŽไธ‰ไธชไฝ็ฝฎ๏ผ‰ //็”จไธŠไฝๆœบ่ฝฏไปถๅ†™ๅฅฝๅŠจไฝœ็ป„ใ€ไฟๅญ˜ๅˆฐๆŽงๅˆถๆฟ๏ผŒ็จ‹ๅบ็›ดๆŽฅ่ฐƒ็”จๅŠจไฝœ็ป„ #include <NewPing.h> #include <LobotServoController.h> #include "U8glib.h" #define TRIG 9 /*่ถ…ๅฃฐๆณขTRIGๅผ•่„šไธบ 9ๅทIO*/ #define ECHO 8 /*่ถ…ๅฃฐๆณขECHOๅผ•่„šไธบ 8ๅทIO*/ #define MAX_DISTANCE 40 /*ๆœ€ๅคงๆฃ€ๆต‹่ท็ฆปไธบ40cm*/ U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); //ๅฎžไพ‹ๅŒ–OLED็ฑป LobotServoController myse; LobotServoController myse1(Serial1); LobotServoController Controller(Serial1); //ๅฎžไพ‹ๅŒ–่ˆตๆœบๆŽงๅˆถๆฟไบŒๆฌกๅผ€ๅ‘็ฑป,ไฝฟ็”จ1ๅทไธฒๅฃไฝœไธบ้€šไฟกๆŽฅๅฃ NewPing Sonar(TRIG, ECHO, MAX_DISTANCE); //ๅฎžไพ‹ๅŒ–่ถ…ๅฃฐๆณขๆต‹่ท็ฑป int gDistance; //ๅ…จๅฑ€ๅ˜้‡๏ผŒ็”จไบŽๅญ˜ๅ‚จ่ถ…ๅฃฐๆณขๆต‹ๅพ—็š„่ท็ฆป /*Logoๅญ—ๆจกๆ•ฐๆฎ*/ const U8G_PROGMEM unsigned char gImage_mm[1024] = { /* 0X10,0X01,0X00,0X80,0X00,0X40, */ 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X00, 0X00, 0XE0, 0XFF, 0X3F, 0XF0, 0XFF, 0XFF, 0X01, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0X7F, 0X07, 0X00, 0X00, 0XF8, 0XFF, 0XFF, 0XF0, 0XFF, 0XFF, 0X07, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X07, 0X00, 0X00, 0XF8, 0XFF, 0XFF, 0XF1, 0XFF, 0XFF, 0X8F, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X7F, 0X07, 0X00, 0X00, 0X1C, 0X00, 0XC0, 0X31, 0X00, 0X00, 0XCE, 0X03, 0X00, 0X00, 0X00, 0X38, 0X00, 0X07, 0X00, 0X00, 0X0C, 0X00, 0X80, 0X33, 0X00, 0X00, 0XCC, 0X01, 0X00, 0X00, 0X00, 0X38, 0X00, 0X07, 0X00, 0X00, 0X0E, 0X00, 0X00, 0X73, 0X00, 0X00, 0XCE, 0X00, 0X00, 0X70, 0X00, 0X18, 0X00, 0X07, 0X00, 0X00, 0X0E, 0X06, 0X03, 0XF3, 0XFF, 0XFF, 0XC7, 0X00, 0X00, 0X70, 0X00, 0X1C, 0X00, 0X07, 0X00, 0X00, 0X0E, 0X06, 0X03, 0XF3, 0XFF, 0XFF, 0XC7, 0X00, 0X00, 0X70, 0X00, 0X1C, 0X00, 0X07, 0X00, 0X00, 0X0E, 0X00, 0X00, 0X73, 0X00, 0X00, 0XCE, 0X00, 0X00, 0X70, 0X00, 0X1C, 0X00, 0X07, 0X00, 0X00, 0X00, 0X00, 0X80, 0X33, 0X00, 0X00, 0XCC, 0X01, 0X00, 0X38, 0X00, 0X1C, 0X00, 0X07, 0X00, 0X00, 0X00, 0X00, 0XC0, 0X71, 0X00, 0X00, 0X8E, 0X03, 0X00, 0X3C, 0X00, 0X1C, 0X00, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF1, 0XFF, 0XFF, 0X87, 0XFF, 0XFF, 0X1F, 0X00, 0X1C, 0X00, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF0, 0XFF, 0XFF, 0X07, 0XFF, 0XFF, 0X0F, 0X00, 0X1C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XF8, 0X7E, 0X00, 0X80, 0XF9, 0X01, 0X00, 0X20, 0X00, 0X00, 0X08, 0X00, 0X00, 0X00, 0X00, 0X00, 0X04, 0X03, 0X00, 0XC0, 0X00, 0X03, 0X80, 0XFF, 0X1F, 0X00, 0XFC, 0X7F, 0X00, 0X00, 0X00, 0X00, 0X04, 0X01, 0X00, 0X60, 0X00, 0X02, 0X80, 0XFF, 0X0F, 0X00, 0X06, 0X60, 0X00, 0X00, 0X00, 0X00, 0X04, 0X03, 0X00, 0X30, 0X03, 0X02, 0X80, 0X00, 0X10, 0X00, 0X80, 0X01, 0X00, 0X00, 0X00, 0X00, 0X60, 0X4B, 0X00, 0XC0, 0X01, 0X02, 0X80, 0XFF, 0X09, 0X00, 0X8C, 0X31, 0X00, 0X00, 0X00, 0X00, 0X18, 0X21, 0X00, 0X60, 0X06, 0X02, 0X80, 0X01, 0X18, 0X00, 0X8C, 0X21, 0X00, 0X00, 0X00, 0X00, 0X0C, 0X61, 0X00, 0X30, 0X06, 0X02, 0X80, 0X61, 0X08, 0X00, 0X04, 0X21, 0X00, 0X00, 0X00, 0X00, 0XC6, 0XC1, 0X00, 0XF0, 0XC3, 0X03, 0X80, 0X30, 0X18, 0X00, 0XC6, 0X40, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, }; //็”จๅˆฐ็š„ๅญ—ๆจกๆ•ฐๆฎ const u8g_fntpgm_uint8_t chinese_test[] U8G_SECTION(".progmem.chinese_test") = { 0, 16, 16, 0, 254, 0, 0, 0, 0, 0, 161, 165, 0, 14, 254, 0, 0, //"็”ต" 13, 16, 32, 16, 2, 254, 4, 0, 4, 0, 4, 0, 255, 224, 132, 32, 132, 32, 132, 32, 255, 224, 132, 32, 132, 32, 132, 32, 255, 224, 132, 40, 4, 8, 4, 8, 3, 248, //"ๅŽ‹โ€œ 15, 15, 30, 16, 0, 254, 63, 254, 32, 0, 32, 128, 32, 128, 32, 128, 32, 128, 47, 252, 32, 128, 32, 128, 32, 144, 32, 136, 32, 136, 64, 128, 95, 254, 128, 0, //"่ท" 15, 14, 28, 16, 0, 255, 125, 254, 69, 0, 69, 0, 69, 0, 125, 252, 17, 4, 17, 4, 93, 4, 81, 4, 81, 252, 81, 0, 93, 0, 225, 0, 1, 254, //"็ฆปโ€œ 15, 16, 32, 16, 0, 254, 2, 0, 1, 0, 255, 254, 0, 0, 20, 80, 19, 144, 20, 80, 31, 240, 1, 0, 127, 252, 66, 4, 68, 68, 79, 228, 68, 36, 64, 20, 64, 8, //":" 2, 8, 8, 16, 7, 0, 192, 192, 0, 0, 0, 0, 192, 192, }; void draw() { //OLED็ป˜ๅˆถ static uint32_t TimerDraw; //้™ๆ€ๅ˜้‡๏ผŒ็”จไบŽ่ฎกๆ—ถ if (TimerDraw > millis()) //ๅฆ‚ๆžœTimerDraw ๅฐไบŽ ่ฟ่กŒๆ€ปๆฏซ็ง’ๆ•ฐ๏ผŒ่ฟ”ๅ›ž๏ผŒๅฆๅˆ™็ปง็ปญ่ฟ่กŒๆญคๅ‡ฝๆ•ฐ return; u8g.firstPage(); do { u8g.setFont(chinese_test); //่ฎพ็ฝฎๅญ—ไฝ“ไฝchinese_test u8g.drawStr( 0, 20, "\xa1\xa2\xa5"); //ๆ˜พ็คบๅญ—็ฌฆไธฒ ็”ตๅŽ‹ ๏ผš u8g.setFont(u8g_font_unifont); //่ฎพ็ฝฎๅญ—ไฝ“ไธบu8g_font_unifont u8g.setPrintPos(18 * 2 + 10, 20); //่ฎพ็ฝฎไฝ็ฝฎไธบ (46,20) u8g.print(Controller.batteryVoltage); //ๆ˜พ็คบ็”ตๆฑ ็”ตๅŽ‹ u8g.print(" mv"); //ๆ˜พ็คบๅ•ไฝ"mv" u8g.setFont(chinese_test); //่ฎพ็ฝฎๅญ—ไฝ“ไธบchinese_test u8g.drawStr( 0, 19 + 20, "\xa3\xa4\xa5"); //ๆ˜พ็คบๅญ—็ฌฆไธฒ ่ท็ฆป๏ผš u8g.setFont(u8g_font_unifont); //่ฎพ็ฝฎๅญ—ไฝ“ไธบu8g_font_unifont u8g.setPrintPos(18 * 2 + 10, 19 + 20); //่ฎพ็ฝฎไฝ็ฝฎไธบ (46,39) u8g.print(gDistance); //ๆ˜พ็คบ็”ตๆฑ ็”ตๅŽ‹ u8g.print(" cm"); //ๆ˜พ็คบๅ•ไฝ"mv" } while ( u8g.nextPage()); TimerDraw = millis() + 500; //TimerDraw ่ต‹ๅ€ผไธบ ่ฟ่กŒ็š„ๆ€ปๆฏซ็ง’ๆ•ฐ + 500๏ผŒๅฎž็Žฐ500ๆฏซ็ง’ๅŽๅ†ๆฌก่ฟ่กŒ } bool ledON = true; //led็‚นไบฎๆ ‡่ฏ†๏ผŒtrueๆ—ถ็‚นไบฎ๏ผŒfalse็†„็ญ void ledFlash() { static uint32_t Timer; //ๅฎšไน‰้™ๆ€ๅ˜้‡Timer๏ผŒ ็”จไบŽ่ฎกๆ—ถ if (Timer > millis()) //Timer ๅคงไบŽ millis๏ผˆ๏ผ‰๏ผˆ่ฟ่กŒ็š„ๆ€ปๆฏซ็ง’ๆ•ฐ๏ผ‰ๆ—ถ่ฟ”ๅ›ž๏ผŒ return; //Timer ๅฐไบŽ ่ฟ่กŒๆ€ปๆฏซ็ง’ๆ•ฐๆ—ถ็ปง็ปญ if (ledON) { digitalWrite(13, HIGH); //ๅฆ‚ๆžœ็‚นไบฎๆ ‡่ฏ†true๏ผŒ13ๅทIO็ฝฎ้ซ˜็”ตๅนณ,ๆฟไธŠLED็ฏ่ขซ็‚นไบฎ Timer = millis() + 20; //Timer = ๅฝ“ๅ‰่ฟ่กŒ็š„ๆ€ปๆฏซ็ง’ๆ•ฐ + 20 ๅฎž็Žฐ 20ๆฏซ็ง’ๅŽๅ†ๆฌก่ฟ่กŒ ledON = false; //็ฝฎ็‚นไบฎๆ ‡่ฏ†ไธบfalse } else { ledON = false; //ๅฆ‚ๆžœ็‚นไบฎๆ ‡่ฏ†ไธๆ˜ฏtrue๏ผŒ็ฝฎ็‚นไบฎๆ ‡่ฏ†ไธบfalse digitalWrite(13, LOW); //็ฝฎ13ๅทIOไธบไฝŽ็”ตๅนณ๏ผŒๆฟไธŠLED็†„็ญ } } int getDistance() { //่Žทๅพ—่ท็ฆป uint16_t lEchoTime; //ๅ˜้‡ ๏ผŒ็”จไบŽไฟๅญ˜ๆฃ€ๆต‹ๅˆฐ็š„่„‰ๅ†ฒ้ซ˜็”ตๅนณๆ—ถ้—ด lEchoTime = Sonar.ping_median(6); //ๆฃ€ๆต‹6ๆฌก่ถ…ๅฃฐๆณข๏ผŒๆŽ’้™ค้”™่ฏฏ็š„็ป“ๆžœ int lDistance = Sonar.convert_cm(lEchoTime);//่ฝฌๆขๆฃ€ๆต‹ๅˆฐ็š„่„‰ๅ†ฒ้ซ˜็”ตๅนณๆ—ถ้—ดไธบๅŽ˜็ฑณ return lDistance; //่ฟ”ๅ›žๆฃ€ๆต‹ๅˆฐ็š„่ท็ฆป } void updateBatteryState() { //ๆ›ดๆ–ฐ็”ตๆฑ ็”ตๅŽ‹็Šถๆ€ static uint32_t Timer = 0; //้™ๆ€ๅ˜้‡Timer๏ผŒ็”จไบŽ่ฎกๆ—ถ if (Timer > millis()) //ๅฆ‚ๆžœTimerๅฐไบŽ ่ฟ่กŒๆ€ปๆฏซ็ง’ๆ•ฐ๏ผŒ่ฟ”ๅ›ž๏ผŒๅฆๅˆ™็ปง็ปญ่ฟ่กŒๆญคๅ‡ฝๆ•ฐ return; Controller.getBatteryVoltage();//ๅ‘้€่Žทๅพ—็”ตๆฑ ็”ตๅŽ‹ๅ‘ฝไปค Timer = millis() + 1000; //Timer ่ต‹ๅ€ผไธบ ่ฟ่กŒ็š„ๆ€ปๆฏซ็ง’ๆ•ฐ + 1000๏ผŒๅฎž็Žฐ1000ๆฏซ็ง’ๅŽๅ†ๆฌก่ฟ่กŒ } void updateDistance() { //ๆ›ดๆ–ฐ่ท็ฆป static uint32_t Timer = 0; //้™ๆ€ๅ˜้‡Timer๏ผŒ็”จไบŽ่ฎกๆ—ถ if (Timer > millis()) //ๅฆ‚ๆžœTimerๅฐไบŽ ่ฟ่กŒๆ€ปๆฏซ็ง’ๆ•ฐ๏ผŒ่ฟ”ๅ›ž๏ผŒๅฆๅˆ™็ปง็ปญ่ฟ่กŒๆญคๅ‡ฝๆ•ฐ return; gDistance = getDistance(); //่Žทๅพ—่ท็ฆป๏ผŒๅนถๅฐ†่ท็ฆปไฟๅญ˜ๅœจgDistance Timer = millis() + 100; //Timer ่ต‹ๅ€ผไธบ ่ฟ่กŒ็š„ๆ€ปๆฏซ็ง’ๆ•ฐ + 500๏ผŒๅฎž็Žฐ500ๆฏซ็ง’ๅŽๅ†ๆฌก่ฟ่กŒ(ๆ”นๅŠจ๏ผ‰ } void moveBlock () { static uint32_t Timer = 0; //ๅฎšไน‰้™ๆ€ๅ˜้‡Timer ,็”จไบŽ่ฎกๆ—ถ static uint8_t stepx = 0; //ๅฎšไน‰้™ๆ€ๅ˜้‡stepx ,็”จไบŽๆญฅ้ชค่ฎฐๅฝ• if (Timer > millis()) //ๅฆ‚ๆžœTimer ๅฐไบŽ ่ฟ่กŒๆ€ปๆฏซ็ง’ๆ•ฐ๏ผŒ่ฟ”ๅ›ž๏ผŒๅฆๅˆ™็ปง็ปญ่ฟ่กŒๆญคๅ‡ฝๆ•ฐ return; gDistance = getDistance(); //่Žทๅพ—่ท็ฆป๏ผŒๅนถๅฐ†่ท็ฆปไฟๅญ˜ๅœจgDistance switch (stepx) { //ๆ นๆฎstepx ่ฟ›่กŒๅˆ†ๆ”ฏ case 0: if (gDistance >= 5 && gDistance < 14) { //ๅฆ‚ๆžœ่ท็ฆป>=5cmใ€<14cm if (!Controller.isRunning) { //ๅฆ‚ๆžœๆœบๆขฐๆ‰‹ไธๆ˜ฏๅœจ่ฟ่กŒๅŠจไฝœ็ป„ myse.moveServos(6,2000, 1,1500,2,1500,3,1500,4,1500,5,1500,6,1500);delay(100); //ๅคไฝ Controller.runActionGroup(50, 1); ledON = true; //็ฝฎไบฎ็ฏๆ ‡่ฏ†ไธบtrue stepx = 1; } } else { stepx = 1; }//ๆญฅ้ชค่ต‹ๅ€ผไธบ1 break; //้€€ๅ‡บswitch case 1: if (gDistance >= 14 && gDistance < 20) { //ๅฆ‚ๆžœ่ท็ฆป>=14cmใ€<20cm if (!Controller.isRunning) { //ๅฆ‚ๆžœๆœบๆขฐๆ‰‹ไธๆ˜ฏๅœจ่ฟ่กŒๅŠจไฝœ็ป„ myse.moveServos(6,2000, 1,1500,2,1500,3,1500,4,1500,5,1500,6,1500);delay(100); //ๅคไฝ Controller.runActionGroup(51, 1); ledON = true; //็ฝฎไบฎ็ฏๆ ‡่ฏ†ไธบtrue stepx = 2; } } else { stepx = 2; //ๆญฅ้ชค่ต‹ๅ€ผไธบ2 } break; //้€€ๅ‡บswitch case 2: if (gDistance >= 20 && gDistance <= 30) { //ๅฆ‚ๆžœ่ท็ฆป>=20cmใ€<=30cm if (!Controller.isRunning) { //ๅฆ‚ๆžœๆœบๆขฐๆ‰‹ไธๆ˜ฏๅœจ่ฟ่กŒๅŠจไฝœ็ป„ myse.moveServos(6,2000, 1,1500,2,1500,3,1500,4,1500,5,1500,6,1500);delay(100); //ๅคไฝ Controller.runActionGroup(52, 1); ledON = true; //็ฝฎไบฎ็ฏๆ ‡่ฏ†ไธบtrue stepx = 0; } } else { stepx = 0; //ๆญฅ้ชค่ต‹ๅ€ผไธบ0๏ผŒๅ›žๅˆฐ็ฌฌไธ€ๆญฅ } break; //้€€ๅ‡บswitch default: //ๆœชๅฎšไน‰ๆญฅ้ชคๆ—ถ้ป˜่ฎคๆ“ไฝœ๏ผŒๆญฅ้ชคๆ•ฐ่ต‹ๅ€ผ0้‡ๆ–ฐๅ›žๅˆฐ็ฌฌไธ€ๆญฅ stepx = 0; break; } Timer = millis() + 50; //Timer ่ต‹ๅ€ผไธบ ่ฟ่กŒ็š„ๆ€ปๆฏซ็ง’ๆ•ฐ + 50๏ผŒๅฎž็Žฐ50ๆฏซ็ง’ๅŽๅ†ๆฌก่ฟ่กŒ } void setup() { // put your setup code here, to run once u8g.firstPage(); //OLED็ป˜ๅˆถ do { u8g.drawXBMP( 0, 0, 128, 64, gImage_mm); //ๅœจๅทฆไธŠ่ง’(0,0)๏ผŒๅณไธ‹่ง’(128,64)็š„็ฉบ้—ดไธŠ็ป˜ๅˆถๅ›พ็‰‡gImage_mm } while ( u8g.nextPage() ); Serial.begin(9600); //ๅˆๅง‹ๅŒ–0ๅทไธฒๅฃ Serial1.begin(9600); //ๅˆๅง‹ๅŒ–1ๅทไธฒๅฃ pinMode(13, OUTPUT); //่ฎพ็ฝฎๆฟไธŠled 13ๅทIOๅฃไธบ่พ“ๅ‡บ Controller.runActionGroup(0, 1); //่ฟ่กŒ0ๅทๅŠจไฝœ็ป„๏ผŒ ๅ›žๅˆๅง‹ไฝ็ฝฎ**********ๅคไฝไธๅ˜ delay(2000); //ๅปถๆ—ถไธค็ง’๏ผŒ็ฎ€ๅ•ๅปถๆ—ถ๏ผŒ็กฎไฟ0ๅทๅŠจไฝœ็ป„่ฟ่กŒๅฎŒๆฏ• Controller.stopActionGroup(); //ๅœๆญขๅŠจไฝœ่ฟ่กŒ๏ผŒ็กฎไฟๅœๆญข //โ€”โ€”โ€”โ€” ไปฅไธ‹ๆ˜ฏๅฃฐ้Ÿณไผ ๆ„Ÿๅ™จ่ฎพ็ฝฎ โ€”โ€”โ€”โ€” pinMode(7,INPUT_PULLUP); //้…็ฝฎ7ๅทIOๅฃไธบ่พ“ๅ…ฅใ€ๅนถๆ‹‰้ซ˜ใ€‘๏ผŒ่ฆๅฐ†ๅฃฐ้Ÿณไผ ๆ„Ÿๅ™จ็š„OUTๅผ•่„šๆŽฅๅœจ7ๅทIOไธŠ pinMode(13,OUTPUT); //้…็ฝฎArduino ๆฟไธŠledๆ‰€ๅœจ็š„13ๅทIOไธบ่พ“ๅ…ฅ[ๆญคไธบLED็ฏIOๅฃ] } void loop() { // put your main code here, to run repeatedly: updateBatteryState(); //ๆ›ดๆ–ฐ็”ตๆฑ ็”ตๅŽ‹็Šถๆ€ updateDistance(); //ๆ›ดๆ–ฐ่ท็ฆป Controller.receiveHandle(); //ๆŽฅๆ”ถๅค„็†ๅ‡ฝๆ•ฐ๏ผŒไปŽไธฒๅฃๆŽฅๆ”ถ็ผ“ๅญ˜ไธญๅ–ๅ‡บๆ•ฐๆฎ draw(); //OLED็ป˜ๅˆถ if(digitalRead(7) == LOW){ moveBlock(); //็งปๅŠจ็‰ฉไฝ“็š„้€ป่พ‘ๅฎž็Žฐ //delay(2000); //ๅปถๆ—ถไธ€ๆฎตๆ—ถ้—ด๏ผŒ็ญ‰ๅพ…ๅŠจไฝœ็ป„่ฟ่กŒ digitalWrite(13,LOW); //็†„็ญArduinoไธŠ็š„LED็ฏ } //ledFlash(); //led้—ช็ฏ๏ผŒ็”จไบŽ่ฟ่กŒ็Šถๆ€ๆ็คบ }
56ed69c9c5a991d80273ac1a7bc2203024a92934
b9e7a3857cfb48280c2d9810ab2d6cf16e83cab2
/IOMemoryNet/LinkHelper.inl
49c54d8226503608f952090a29675b917fb8d445
[]
no_license
NeuroWhAI/IOMemoryNet
39185022e2373ff19fc59ead1dd4c4489c74d92c
f65526f6c3bf941817232ea9db3b30a854bb8ec4
refs/heads/master
2021-01-10T15:52:46.019915
2015-12-21T07:58:00
2015-12-21T07:58:00
47,960,853
0
0
null
null
null
null
UTF-8
C++
false
false
1,367
inl
LinkHelper.inl
#ifndef __LINK_HELPER_INL__ #define __LINK_HELPER_INL__ #include "LinkHelper.h" #include "Cell.h" #include "Linker.h" #include "LinkerPort.h" template <typename TCell, typename TLinker> bool LinkHelper<TCell, TLinker>::connect(std::shared_ptr<TCell> pInCell, std::shared_ptr<TLinker> pLinker) { if (pInCell->getOutLinkerPort()->addLinker(pLinker, pLinker->getOutCell())) { pLinker->setInCell(pInCell); return true; } return false; } template <typename TCell, typename TLinker> bool LinkHelper<TCell, TLinker>::connect(std::shared_ptr<TLinker> pLinker, std::shared_ptr<TCell> pOutCell) { if (pOutCell->getInLinkerPort()->addLinker(pLinker, pLinker->getInCell())) { pLinker->setOutCell(pOutCell); return true; } return false; } template <typename TCell, typename TLinker> std::shared_ptr<TLinker> LinkHelper<TCell, TLinker>::connect(std::shared_ptr<TCell> pInCell, std::shared_ptr<TCell> pOutCell) { std::shared_ptr<TLinker> pNewLinker(new TLinker()); if (pInCell->getOutLinkerPort()->addLinker(pNewLinker, pOutCell)) { if (pOutCell->getInLinkerPort()->addLinker(pNewLinker, pInCell)) { pNewLinker->setInCell(pInCell); pNewLinker->setOutCell(pOutCell); return pNewLinker; } else { pInCell->getOutLinkerPort()->removeLinker(pOutCell); return nullptr; } } return nullptr; } #endif
599f7f436f34de3ceb3cdaa3f3647a891e3a2c3b
cef2b4199406a719b6a2fac726b83c5b716bed12
/Epsi/include/sdtl/stream/map.hxx
65833f2879f74b8bd6e9aeaf03191d525f4c9038
[ "BSD-2-Clause" ]
permissive
dominiquehli/dm
8fda9f661cff03bcf5b57ece1c5fbe0d2986cd4f
bad4092c97a075a44c19eddd1b7fdfd811a73533
refs/heads/master
2023-05-02T16:16:43.170288
2023-04-18T15:04:36
2023-04-18T15:04:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,443
hxx
map.hxx
/*- * Copyright (c) 2007-2012 Dominique Li <dominique.li@univ-tours.fr> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: map.hxx 627 2020-08-15 14:44:04Z li $ */ #ifndef _SDTL_STREAM_MAP_CC_ #define _SDTL_STREAM_MAP_CC_ #include "util.hxx" #include <iostream> namespace sdtl { template<class _K, class _V> std::ostream &operator<<(std::ostream &, const map<_K, _V> &); template<class _K, class _V> std::istream &operator>>(std::istream &, map<_K, _V> &); //////////////////////////////////////////////////////////////////////////////// // // Map operations. // //////////////////////////////////////////////////////////////////////////////// /** * */ template<class _K, class _V> std::ostream &operator<<(std::ostream &out, const map<_K, _V> &m) { for (size_t i = 0; i < m.size(); i++) { out << m.key(i) << '\t' << m.value(i) << std::endl; } return out; } /** * */ template<class _K, class _V> std::istream &operator>>(std::istream &in, map<_K, _V> &m) { m.clear(); _K k; _V v; while (in >> k) { if (in >> v) { m.set(k, v); } else { throw format_error(); } } return in; } } #endif /* _SDTL_STREAM_MAP_CC_ */
95f5c93013a8737bc3dd6cc24a9c06a7b0c5b750
19fc6e6c6767d91b37775f5707d1536df747369e
/mex/include/wildmagic-5.7/include/Wm5ConvexPolygon2.h
68bd2a651baabf93a5be6ed38f9ae2940a7bb270
[ "BSD-2-Clause" ]
permissive
HanLab-BME-MTU/extern
ef062722ffc3877e5691bc46135d9ff56d7199e6
8f0ab6a554006ebc60e12b1595ecaafd0aec541b
refs/heads/master
2021-04-29T23:51:26.091473
2020-01-31T03:07:12
2020-01-31T03:07:12
121,562,896
1
1
null
null
null
null
UTF-8
C++
false
false
3,974
h
Wm5ConvexPolygon2.h
// Geometric Tools, LLC // Copyright (c) 1998-2011 // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // // File Version: 5.0.0 (2010/01/01) #ifndef WM5CONVEXPOLYGON2_H #define WM5CONVEXPOLYGON2_H #include "Wm5MathematicsLIB.h" #include "Wm5Polygon2.h" #include <set> namespace Wm5 { template <typename Real> class ConvexPolygon2 : public Polygon2<Real> { public: // Construction and destruction. The caller is responsible for ensuring // that the array of vertices represents a convex polygon with // counterclockwise order. // // Polygon2 objects typically share data from other sources. The class // uses smart pointers (Pointer1) to share the input arrays. If you // do not want the class to delete the arrays, use your own smart // pointer for the arrays. // // ConvexPolygon2 stores the lines associated with the edges; the line // normals are inner pointing. The lines may be supplied to the // constructor, in which case a smart pointer is used to share them. If // they are not passed ('lines' is null), the class automatically // generates them. // The line representation Dot(N,X) = c. The 'first' of the pair is a // unit-length normal N to the line. The 'second' of the pair is the line // constant c. X is any point on the line. typedef typename std::pair<Vector2<Real>, Real> NCLine; ConvexPolygon2 (int numVertices, Vector2<Real>* vertices, NCLine* lines); ConvexPolygon2 (const ConvexPolygon2& polygon); virtual ~ConvexPolygon2 (); // Assignment. ConvexPolygon2& operator= (const ConvexPolygon2& polygon); // Read-only member access. const NCLine* GetLines () const; const NCLine& GetLine (int i) const; // Allow vertex modification. The caller must ensure that the polygon // remains convex. After modifying as many vertices as you like, call // UpdateLines(). The modifications are all done via SetVertex, and the // lines are updated only for those edges sharing the modified vertices. virtual void SetVertex (int i, const Vector2<Real>& vertex); void UpdateLines (); // Test for convexity. This function will iterate over the edges of the // polygon and verify for each edge that the polygon vertices are all on // the nonnegative side of the edge line. A signed distance test is used, // so a vertex is on the wrong side of a line (for convexity) when its // signed distance satisfies d < 0. Numerical round-off errors can // generate incorrect convexity tests, so a small negative threshold // t may be passed to this function, in which case the distance test // becomes d < t < 0. bool IsConvex (Real threshold = (Real)0) const; // Point-in-polygon test, performed by which-side queries between the // point and the lines of the edges, an O(n) algorithm for n vertices. // This is not the optimal algorithm. TODO: Move the binary-search-based // algorithm to this class. It is an O(log n) algorithm. bool Contains (const Vector2<Real>& p, Real threshold = (Real)0) const; protected: using Polygon2<Real>::mNumVertices; using Polygon2<Real>::mVertices; using Polygon2<Real>::ComputeVertexAverage; // Support for efficient updating of edge lines. The set stores the // indices for those edges that share modified vertices. void UpdateLine (int i, const Vector2<Real>& average); // The number of lines is the number of vertices. Pointer1<NCLine> mLines; // The sharing edges processed by UpdateLine. std::set<int> mSharingEdges; }; #include "Wm5ConvexPolygon2.inl" typedef ConvexPolygon2<float> ConvexPolygon2f; typedef ConvexPolygon2<double> ConvexPolygon2d; } #endif
69f0d327fc531057222d5fde0a60d6c5fb573c37
591c1150c31fe03e64f319393cde9158008fda61
/som/som.ino
19a731f1a662473cf650a3c12143c16d490d28c2
[]
no_license
jeronimopenha/ExemplosArduino
6476be8f3bcef8f884880a087521c660357dea58
953b0152a06c59e0a62fb042aeeb053e20d77f64
refs/heads/main
2023-02-02T20:36:56.722516
2020-12-23T22:04:32
2020-12-23T22:04:32
323,442,518
0
0
null
null
null
null
UTF-8
C++
false
false
1,531
ino
som.ino
#define SOM 2 #define C 132 #define D 149 #define E 165 #define FA 176 #define G 198 #define A 220 #define B 248 byte nota; byte counter = 0; byte flag = 0; void setup() { Serial.begin(9600); delay(1000); //define o pino 9 como saรญda pinMode(SOM, OUTPUT); Serial.println("Programa Piano Rรบstico :)"); Serial.println(); } void loop() { if (flag) { if (counter > 15) { Serial.println(); counter = 0; } counter++; flag = 0; } if (Serial.available() > 0) { nota = Serial.read(); switch (nota) { case 'c': tone(SOM, C); Serial.write("Do, "); flag = 1; break; case 'd': tone(SOM, D); Serial.write("Re, "); flag = 1; break; case 'e': tone(SOM, E); Serial.write("Mi, "); flag = 1; break; case 'f': tone(SOM, FA); Serial.write("Fa, "); flag = 1; break; case 'g': tone(SOM, G); Serial.write("Sol, "); flag = 1; break; case 'a': tone(SOM, A); Serial.write("La, "); flag = 1; break; case 'b': tone(SOM, B); Serial.write("Si, "); flag = 1; break; case 'o': noTone(SOM); Serial.println(); Serial.write("Desligado"); Serial.println(); flag = 0; counter = 0; break; } } }
ec9585321352ea30d44763d05756db7285c8b1ff
8a3780ddebe102fa8d8db439c18268f9b43b524e
/Motion/moves/ApproachMove.cpp
ab51d29239d28dbd1a0b152a3e3e52b6f63599f7
[]
no_license
Rhoban/kid_size_public
02c89392db808baadf2ba281e048c1072ccc2333
1ad2c2fc23d4582340e06b069c08c8f6fe53cb20
refs/heads/master
2020-07-24T16:33:27.520891
2019-09-12T12:59:46
2019-09-12T12:59:46
207,982,989
7
2
null
null
null
null
UTF-8
C++
false
false
4,642
cpp
ApproachMove.cpp
#include "ApproachMove.h" #include "rhoban_utils/logging/logger.h" #include "KickController.h" #include "Walk.h" #include "Kick.h" #include "scheduler/MoveScheduler.h" #include <services/LocalisationService.h> #include <services/TeamPlayService.h> #include <services/StrategyService.h> #include <services/DecisionService.h> #include <iostream> using csa_mdp::KickZone; using namespace rhoban_utils; using namespace rhoban_geometry; using namespace rhoban_team_play; static rhoban_utils::Logger logger("ApproachMove"); ApproachMove::ApproachMove(Walk* walk_, Kick* kick_) : walk(walk_), kick(kick_), expectedKick("classic") { kmc.loadFile(); } void ApproachMove::initBindings() { bind->bindNew("expectedKick", expectedKick, RhIO::Bind::PushOnly)->defaultValue(expectedKick); bind->bindNew("kickRight", kickRight, RhIO::Bind::PushOnly) ->defaultValue(0.0) ->comment("Does next kick use right foot?"); bind->bindNew("kickScore", kick_score, RhIO::Bind::PushOnly) ->defaultValue(0.0) ->comment("When score reaches 1, robot is allowed to shoot"); bind->bindNew("kickGain", kick_gain, RhIO::Bind::PullOnly) ->defaultValue(1000.0) ->comment("IncreaseRate when ball is kickable (score increases by elapsed * kick_gain)") ->persisted(true); bind->bindNew("noKickGain", no_kick_gain, RhIO::Bind::PullOnly) ->defaultValue(0.5) ->comment("DecreaseRate when ball is not kickable (score decreases by elapsed * no_kick_gain)") ->persisted(true); bind->bindNew("enableLateral", enableLateral, RhIO::Bind::PullOnly) ->defaultValue(true) ->comment("Enable the lateral kicks" "(this option is only used if there is no kick controller)") ->persisted(true); } void ApproachMove::onStart() { } void ApproachMove::onStop() { } Angle ApproachMove::getKickCap() { LocalisationService* loc = getServices()->localisation; Angle playerDir(rad2deg(loc->getFieldOrientation())); if (useKickController()) { Angle kickDirField = getKickController()->getKickDir(); return kickDirField - playerDir; } else { return (loc->getGoalPosField() - loc->getBallPosField()).getTheta() - playerDir; } } double ApproachMove::getKickTolerance() { if (useKickController()) { return getKickController()->getTolerance(); } else { return 0; } } const KickController* ApproachMove::getKickController() const { StrategyService* strategy = getServices()->strategy; return strategy->getActiveKickController(); } std::vector<std::string> ApproachMove::getAllowedKicks() { if (useKickController()) { return getKickController()->getAllowedKicks(); } if (enableLateral) { return { "classic", "lateral" }; } return { "classic" }; } bool ApproachMove::isKickAllowed(const std::string& name) { for (const std::string& kickName : getAllowedKicks()) { if (name == kickName) return true; } return false; } const std::string& ApproachMove::getExpectedKick() const { return expectedKick; } void ApproachMove::requestKick() { // Building message: std::ostringstream oss; oss << "Kick in '" << getName() << "': " << expectedKick << " with " << (kickRight ? "right" : "left") << " foot"; logger.log("%s", oss.str().c_str()); // Sending kick order to walk kick->set(!kickRight, expectedKick, false, true); startMove("kick", 0.0); } bool ApproachMove::useKickController() const { return getKickController() != NULL && getKickController()->isRunning(); } void ApproachMove::updateKickScore(double elapsed) { LocalisationService* loc = getScheduler()->getServices()->localisation; Point ball_pos = loc->getBallPosSelf(); updateKickScore(elapsed, ball_pos); } void ApproachMove::updateKickScore(double elapsed, const Point& ball_pos) { // Updating kick score const KickZone& kick_zone = kmc.getKickModel(expectedKick).getKickZone(); double kick_dir_rad = deg2rad(getKickCap().getSignedValue()); Eigen::Vector3d state(ball_pos.x, ball_pos.y, kick_dir_rad); // Debug std::ostringstream oss; oss << "Ball state: (" << state.transpose() << ") -> "; Eigen::Vector3d wished_pos = kick_zone.getWishedPos(kickRight); oss << " (wished_pos: " << wished_pos.transpose() << ")"; if (kick_zone.canKick(kickRight, state)) { kick_score += elapsed * kick_gain; logger.log("%s", oss.str().c_str()); } else { kick_score -= elapsed * no_kick_gain; if (kick_zone.canKick(!kickRight, state)) { oss << " -> but can kick with other foot"; } } // Bounding kick_score values kick_score = std::max(0.0, std::min(1.0, kick_score)); }
2a9120f34d3c527c819ab0dd1308abcb474e15e8
7ff4b6ca4f9964210398759c73792ac486759439
/Plugins/FaceRecognition/face_recognition/Fisherfaces.h
8e5aaeac7a4d9cf31b48cbbc6ff47c91825f5d6d
[]
no_license
ITU-DASYALab/O3
56f4ee171d876949bf64ae5f5180f1e80916c581
34497af6a32ff154d5dcf61eeba12e24eb1b2d10
refs/heads/master
2022-12-01T22:16:12.332425
2020-08-20T10:29:07
2020-08-20T10:29:07
163,879,664
0
1
null
null
null
null
UTF-8
C++
false
false
773
h
Fisherfaces.h
#ifndef __FISHERFACES_H__ #define __FISHERFACES_H__ #include <iostream> #include <vector> #include <float.h> #include <opencv2/opencv.hpp> #include "ImageList.h" #include "RecImage.h" #include "LDA.h"; #include "../common/common.h" #include "Recognizer.h" using namespace std; using namespace cv; class Fisherfaces: public Recognizer { private: PCA pca; LDA lda; int flags; //ImageList X; vector<Mat> pcaProjTrFaces; vector<Mat> ldaProjTrFaces; Mat eigenvectors; public: Fisherfaces(){}; Fisherfaces(ImageList X, int flags=0); ~Fisherfaces(); void init(ImageList X, int flags); Mat project(Mat &m); vector<RecognizerResult> recognize(const Mat& instance); Mat getEigenvectors(); Mat getEigenvalues(); }; #endif
a863db6349ed09865c18339735ffef9c706a27f3
c2812cc942d353b17cffe4b0e5263371e3b507ea
/BinaryNumber.cpp
fb10f1aa6b15c4efbf8531b40dbf30eceda12b0a
[]
no_license
retro040361/HackerRank_30DaysOfCode
d8b536374d67612f8348897148eb8d9ef9b97cb0
40b795fe6294e4e2b86964e730ccfae3584cd0a3
refs/heads/main
2023-02-06T17:26:44.285433
2020-12-31T18:36:24
2020-12-31T18:36:24
325,854,777
0
0
null
null
null
null
UTF-8
C++
false
false
1,016
cpp
BinaryNumber.cpp
#include <iostream> #include <vector> using namespace std; int main() { long long int n; while (cin >> n) { vector<int> binary; for (int i = 0; n > 0; i++) { binary.push_back(n % 2); n = n / 2; } // binary[i] means 2^i terms int size = binary.size(); int conti = 0; int maxi = 0; for (int i = 0; i < size; i++) { //cout << binary[i]; if (binary[i] == 1) conti++; else { maxi = conti > maxi ? conti : maxi; conti = 0; } } maxi = conti > maxi ? conti : maxi; cout << maxi << endl; } } /* **้ซ˜ๆ‰‹ใ„‰** #include<iostream> using namespace std; int main(void) { int n; cin >> n; int count = 0; while(n){ n = (n&(n<<1)); count++ } cout<<count<<endl; return 0; } */
9eeff9872ee09c534639769be57503446a02a40e
c5905ec8b51a33ab87957d9f33cd48ff6b6e62c3
/align_dlib.h
e8134b600c3da8a3f28f06eeafa74779b30b8455
[]
no_license
dioververa/OpenFaceCPP
c9560f90f4aa958e3fc9c764d44fdaa48c5d0e7d
4b5b44918ae25d44fe0bd09712ba2e538208d7b0
refs/heads/master
2020-05-29T15:12:40.582585
2017-10-18T14:25:23
2017-10-18T14:25:23
63,895,254
16
7
null
null
null
null
UTF-8
C++
false
false
1,171
h
align_dlib.h
#ifndef ALIGNDLIB_H #define ALIGNDLIB_H #include <dlib/image_processing/frontal_face_detector.h> #include <dlib/gui_widgets.h> #include <dlib/image_io.h> #include <dlib/image_processing/render_face_detections.h> #include <dlib/image_processing.h> #include <dlib/opencv.h> #include "opencv2/opencv.hpp" #include <fstream> #include <string> #include <iostream> #include <fstream> #include <string> #include <algorithm> using namespace std; using namespace cv; class AlignDlib { public: AlignDlib(); dlib::array2d<dlib::bgr_pixel> img; dlib::frontal_face_detector detector; dlib::shape_predictor shapePredictor; vector<float> templateMeanX,templateMeanY; void init(const char *faceModelFileName, std::string shapePredictorFileName, int imgDim); void loadShapePredictor(std::string shapePredictorFileName); int loadMeanPointsFromCSV(const char *faceModelName); void checkOpenedFile(std::ifstream &inFile); bool alignDlib(char *imgName, Mat *matAlight); cv::Mat dlibImgtoCV(dlib::array2d<dlib::bgr_pixel> &img); int imgDim; vector<int> OUTER_EYES_AND_NOSE = {36, 45, 33}; }; #endif // ALIGNDLIB_H
07d6ba504dfe6d47f6c5d86edaedcdb47ad196e0
08b8cf38e1936e8cec27f84af0d3727321cec9c4
/data/crawl/git/new_hunk_7717.cpp
68d043410b6bcb59c1f054d4c04991a57f059a13
[]
no_license
ccdxc/logSurvey
eaf28e9c2d6307140b17986d5c05106d1fd8e943
6b80226e1667c1e0760ab39160893ee19b0e9fb1
refs/heads/master
2022-01-07T21:31:55.446839
2018-04-21T14:12:43
2018-04-21T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
177
cpp
new_hunk_7717.cpp
if (amend && initial_commit) die("You have nothing to amend."); if (amend && in_merge) die("You are in the middle of a merge -- cannot amend."); if (use_message) f++;
fe0abaddb17a14d634e2778cd2fb899b15893849
0077a6decee6098b3ca8d44f98987efc60a129c0
/QJsonRpcClient/qjsonrpcclient_private.h
4df27b0cdcaafbe44212529dd41b242c1bc632f4
[ "MIT" ]
permissive
ankertang/qt-rpc-client
9810945739cd069522f72da6b948c05f99dcc31a
afe9441b8d8a7fe5f55255bcfc14d92a7bf3a171
refs/heads/master
2020-05-17T17:41:35.205486
2019-04-26T14:48:24
2019-04-26T14:48:24
183,861,960
1
0
null
2019-04-28T05:51:22
2019-04-28T05:51:21
null
UTF-8
C++
false
false
2,931
h
qjsonrpcclient_private.h
/* ============================================================== // https://github.com/thomas92911 // thomas92911@gmail.com // BTC: 1HDTGpzYCK4BBvA3ik8gX7M1f3oDkX8Aax // // care not the gains but the progress // // MIT License // // Copyright (c) 2019 thomas92911 // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // ==============================================================*/ #ifndef QJSONRPCCLIENT_PRIVATE_H #define QJSONRPCCLIENT_PRIVATE_H #include <QObject> #include <QJsonObject> #include <QJsonArray> #include <QNetworkAccessManager> #include <QNetworkReply> #include <QList> #include <QSslError> #include <QUrl> #include <QMutex> class QJsonRpcClient; #define TIMEOUT_SECOND 5 #define REPLY_ROLE_ID (Qt::UserRole + 1) #define REPLY_ROLE_TIMER (Qt::UserRole + 2) class QJsonRpcClient_private : public QObject { Q_OBJECT friend class QJsonRpcClient; private: QJsonRpcClient_private(QString addr, int port, bool tls, QString subMethod = ""); // rpcCall uint rpcCall(QString method, QJsonObject postData); // build rpc request QJsonObject BuildRpcRequest(QString method, QJsonObject data, uint requestID); // set replay userdata void SetReplyUserdata(QNetworkReply *reply, uint requestID); // release reply void ReleaseReply(QNetworkReply *reply); // new request ID uint NewRequestID(); signals: void rpcReply(uint id, QJsonObject reply); public slots: void sslErrors(QNetworkReply *, const QList<QSslError> &errors); void httpFinished(); void httpReadyRead(); void error(QNetworkReply::NetworkError); private: QNetworkAccessManager _network; QString _addr; int _port; bool _tls; QUrl _url; uint _replyID{0}; QMutex _mutex; }; #endif // QJSONRPCCLIENT_PRIVATE_H
1ca413c90c1cd41ac5241a10dbc89166f81abbfd
22db05b98b98618ecee58dc9ac16047df9207e8a
/Supervisory/Frames/FrameChartView.cpp
ebcaeae7e2fc328a495ef23adb019d760bb40aa5
[]
no_license
andreluizmiotto/ecgmonitoring
f3d78fcc2cd81831b12a0c79530313db0e9e6e28
49b7981c6f296d2a50142e52afa796a183929a01
refs/heads/main
2023-04-13T07:41:44.907101
2021-04-27T17:29:09
2021-04-27T17:29:09
358,887,076
2
0
null
null
null
null
UTF-8
C++
false
false
2,876
cpp
FrameChartView.cpp
//--------------------------------------------------------------------------- #include <fmx.h> #pragma hdrstop #include "FrameChartView.h" #include "IniFiles.hpp" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.fmx" TfraChartView *fraChartView; void (*Callback)(); //--------------------------------------------------------------------------- __fastcall TfraChartView::TfraChartView(TComponent* Owner) : TFrame(Owner) { } //--------------------------------------------------------------------------- void TfraChartView::Init(TBlurEffect *blur, void (*PCallback)()) { FBlur = blur; Callback = PCallback; LoadDefaultValues(); HidePopup(); } //--------------------------------------------------------------------------- void TfraChartView::Save() { TCustomIniFile *vIniFile = new TIniFile("./Config.ini"); try { vIniFile->WriteInteger("ChartView", "Frequency", this->cbeFrequency->ItemIndex); vIniFile->WriteInteger("ChartView", "TimeWindow", this->cbeTimeWindow->ItemIndex); Callback(); } catch(Exception* e) { } delete vIniFile; } //--------------------------------------------------------------------------- void TfraChartView::LoadDefaultValues() { TCustomIniFile *vIniFile = new TIniFile("./Config.ini"); try { this->cbeFrequency->ItemIndex = vIniFile->ReadInteger("ChartView", "Frequency", 2); this->cbeTimeWindow->ItemIndex = vIniFile->ReadInteger("ChartView", "TimeWindow", 2); } catch(Exception* e) { } delete vIniFile; } //--------------------------------------------------------------------------- void __fastcall TfraChartView::ShowPopup() { this->Visible = true; FBlur->Enabled = true; } //--------------------------------------------------------------------------- void TfraChartView::HidePopup() { this->Visible = false; FBlur->Enabled = false; } //--------------------------------------------------------------------------- void __fastcall TfraChartView::btnGoBackClick(TObject *Sender) { LoadDefaultValues(); HidePopup(); } //--------------------------------------------------------------------------- AnsiString TfraChartView::getFrequency() { AnsiString AResult = EmptyAnsiStr; if ((cbeFrequency->ItemIndex >= 0) || (cbeFrequency->Text != EmptyAnsiStr)) AResult = cbeFrequency->Text; return AResult; } //--------------------------------------------------------------------------- AnsiString TfraChartView::getTimeWindow() { AnsiString AResult = EmptyAnsiStr; if ((cbeTimeWindow->ItemIndex >= 0) || (cbeTimeWindow->Text != EmptyAnsiStr)) AResult = cbeTimeWindow->Text; return AResult; } //--------------------------------------------------------------------------- void __fastcall TfraChartView::btnApplyClick(TObject *Sender) { Save(); HidePopup(); } //---------------------------------------------------------------------------
8e0af7847e6a1840f1e1ee4c10fe98dcd5fc9f85
98f9f977a39843e5f7719062f43011ebfd169e42
/Libs/PluginFramework/service/event/ctkEvent.h
128706e4f442246be13f6414830cbdac02925f53
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
txdy077345/CTK
71cab2d77193d09340afe7a50e5dddc3ea66a06d
7cd253376139ea73f0450e1bad75bab41aa1b507
refs/heads/master
2023-05-27T19:20:21.825916
2023-04-29T16:35:03
2023-04-29T16:35:03
276,658,777
1
0
Apache-2.0
2020-07-02T13:50:30
2020-07-02T13:50:29
null
UTF-8
C++
false
false
4,027
h
ctkEvent.h
/*============================================================================= Library: CTK Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =============================================================================*/ #ifndef CTKEVENT_H #define CTKEVENT_H #include "ctkPluginFrameworkExport.h" #include <QMap> #include <QVariant> #include <QStringList> #include <ctkLDAPSearchFilter.h> class ctkEventData; /** * \ingroup EventAdmin * * A CTK event. * * <code>ctkEvent</code> objects are delivered to <code>ctkEventHandler</code> * or Qt slots which subscribe to the topic of the event. */ class CTK_PLUGINFW_EXPORT ctkEvent { QSharedDataPointer<ctkEventData> d; public: /** * Default constructor for use with the Qt meta object system. */ ctkEvent(); ~ctkEvent(); /** * Can be used to check if this ctkEvent instance is valid, * or if it has been constructed using the default constructor. * * @return <code>true</code> if this event object is valid, * <code>false</code> otherwise. */ bool isNull() const; /** * Constructs an event. * * @param topic The topic of the event. * @param properties The event's properties (may be empty). * @throws ctkInvalidArgumentException If topic is not a valid topic name. */ ctkEvent(const QString& topic, const ctkDictionary& properties = ctkDictionary()); ctkEvent(const ctkEvent& event); ctkEvent& operator=(const ctkEvent& other); /** * Compares this <code>ctkEvent</code> object to another object. * * <p> * An event is considered to be <b>equal to</b> another event if the topic * is equal and the properties are equal. * * @param other The <code>ctkEvent</code> object to be compared. * @return <code>true</code> if <code>other</code> is equal to * this object; <code>false</code> otherwise. */ bool operator==(const ctkEvent& other) const; /** * Retrieve the value of an event property. The event topic may be retrieved * with the property name &quot;event.topics&quot;. * * @param name the name of the property to retrieve * @return The value of the property, or an invalid QVariant if not found. */ QVariant getProperty(const QString& name) const; /** * Indicate the presence of an event property. The event topic is present * using the property name &quot;event.topics&quot;. * * @param name The name of the property. * @return <code>true</code> if a property with the specified name is in the * event. This property may have an invalid QVariant value. * <code>false</code> otherwise. */ bool containsProperty(const QString& name) const; /** * Returns a list of this event's property names. The list will include the * event topic property name &quot;event.topics&quot;. * * @return A non-empty list with one element per property. */ QStringList getPropertyNames() const; /** * Returns the topic of this event. * * @return The topic of this event. */ const QString& getTopic() const; /** * Tests this event's properties against the given filter using a case * sensitive match. * * @param filter The filter to test. * @return true If this event's properties match the filter, false * otherwise. */ bool matches(const ctkLDAPSearchFilter& filter) const; }; Q_DECLARE_METATYPE(ctkEvent) #endif // CTKEVENT_H
1a299cfd45f603bf80deda5bbe568f881a3c81d8
a60a76cf75535bdde08a48832f355187ec4ea00e
/recognition/data/avg.cpp
43c461b413ec17a12f3f750f9909fc59a2608fa9
[]
no_license
hlycharles/ece-capstone
9aac6227804b98998b52461bb85f9aa7798aa54e
8b9ea4a1bb8056532a761dcf8866a3f8f60ac562
refs/heads/master
2021-08-28T18:40:03.519079
2017-12-13T00:28:02
2017-12-13T00:28:02
104,920,973
1
0
null
null
null
null
UTF-8
C++
false
false
3,597
cpp
avg.cpp
int avgImg[400] = { 108, 107, 94, 95, 88, 105, 113, 116, 115, 114, 110, 113, 121, 120, 119, 108, 91, 81, 85, 107, 116, 93, 94, 101, 118, 136, 149, 149, 147, 140, 146, 154, 158, 160, 161, 151, 119, 92, 81, 87, 107, 93, 104, 127, 149, 174, 178, 177, 172, 170, 178, 187, 189, 200, 201, 193, 163, 111, 87, 82, 96, 89, 107, 149, 182, 195, 198, 193, 195, 195, 198, 206, 211, 215, 218, 215, 194, 144, 106, 90, 94, 93, 124, 160, 179, 186, 190, 191, 195, 202, 203, 204, 208, 208, 211, 209, 198, 159, 122, 103, 99, 99, 130, 157, 171, 164, 161, 165, 175, 184, 189, 189, 175, 163, 162, 174, 174, 168, 133, 113, 97, 113, 144, 173, 177, 170, 166, 157, 160, 170, 176, 169, 160, 153, 162, 178, 183, 174, 140, 123, 106, 120, 154, 179, 156, 144, 134, 141, 150, 166, 173, 157, 138, 136, 149, 161, 182, 186, 151, 132, 113, 130, 161, 178, 151, 136, 128, 130, 154, 175, 187, 168, 147, 135, 132, 135, 167, 195, 162, 143, 127, 151, 180, 193, 176, 154, 151, 151, 171, 200, 219, 197, 166, 153, 152, 173, 202, 214, 179, 148, 140, 161, 196, 211, 204, 187, 174, 182, 196, 225, 240, 224, 198, 189, 192, 205, 215, 221, 192, 176, 130, 164, 201, 213, 212, 204, 197, 195, 207, 221, 229, 225, 205, 195, 206, 213, 218, 216, 192, 176, 131, 162, 197, 205, 207, 204, 196, 190, 196, 188, 192, 189, 187, 186, 202, 210, 209, 206, 185, 188, 130, 158, 194, 196, 196, 197, 189, 178, 173, 153, 154, 158, 183, 179, 189, 196, 195, 192, 183, 170, 117, 155, 187, 187, 188, 186, 181, 183, 156, 150, 145, 154, 179, 188, 181, 182, 184, 185, 190, 150, 119, 128, 163, 178, 179, 176, 181, 178, 172, 164, 158, 163, 176, 178, 176, 176, 179, 181, 167, 131, 101, 107, 154, 172, 177, 176, 171, 162, 149, 156, 156, 164, 171, 163, 171, 178, 177, 171, 146, 137, 87, 110, 144, 158, 174, 173, 159, 150, 150, 147, 144, 145, 157, 167, 169, 172, 170, 153, 145, 156, 108, 114, 134, 153, 158, 167, 161, 171, 168, 162, 164, 171, 171, 168, 168, 164, 168, 151, 155, 161, 96, 94, 124, 140, 146, 159, 169, 172, 170, 165, 164, 169, 173, 171, 163, 153, 152, 155, 158, 169 };
d5cfaa0d7979da3b807bd8b11158fe5cca7e9135
184cca2b088d0577ecae7ec9873f8ce50eb5c971
/src/MessageLib/SystemMessages.cpp
10af8188b3098c66f740b606545e961055553b14
[]
no_license
ferrin/mmoserver
b4cee672f725b768ef095f2f2af3f7eaf08acdcc
0d31607c60d879737752541a6c007fa9d316aa4e
refs/heads/master
2021-01-17T09:35:29.647731
2010-04-20T03:43:33
2010-04-20T03:43:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,826
cpp
SystemMessages.cpp
/* --------------------------------------------------------------------------------------- This source file is part of swgANH (Star Wars Galaxies - A New Hope - Server Emulator) For more information, see http://www.swganh.org Copyright (c) 2006 - 2010 The swgANH Team --------------------------------------------------------------------------------------- */ #include "MessageLib.h" #include "ZoneServer/ObjectFactory.h" #include "ZoneServer/PlayerObject.h" #include "ZoneServer/WorldManager.h" #include "ZoneServer/PlayerStructure.h" #include "ZoneServer/ZoneOpcodes.h" #include "LogManager/LogManager.h" #include "Common/atMacroString.h" #include "Common/DispatchClient.h" #include "Common/Message.h" #include "Common/MessageDispatch.h" #include "Common/MessageFactory.h" #include "Common/MessageOpcodes.h" //====================================================================================================================== void MessageLib::sendBanktipMail(PlayerObject* playerObject, PlayerObject* targetObject, uint32 amount) { atMacroString* aMS = new atMacroString(); aMS->addMBstf("base_player","prose_wire_mail_target"); aMS->addDI(amount); aMS->addTO(playerObject->getFirstName()); aMS->addTextModule(); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opIsmSendSystemMailMessage); mMessageFactory->addUint64(playerObject->getId()); mMessageFactory->addUint64(playerObject->getId()); mMessageFactory->addString(targetObject->getFirstName()); mMessageFactory->addString(BString("@base_player:wire_mail_subject")); mMessageFactory->addUint32(0); mMessageFactory->addString(aMS->assemble()); delete aMS; Message* newMessage = mMessageFactory->EndMessage(); playerObject->getClient()->SendChannelA(newMessage, playerObject->getAccountId(), CR_Chat, 6); aMS = new atMacroString(); aMS->addMBstf("base_player","prose_wire_mail_self"); aMS->addDI(amount); aMS->addTO(targetObject->getFirstName()); aMS->addTextModule(); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opIsmSendSystemMailMessage); mMessageFactory->addUint64(targetObject->getId()); mMessageFactory->addUint64(targetObject->getId()); mMessageFactory->addString(playerObject->getFirstName()); mMessageFactory->addString(BString("@base_player:wire_mail_subject")); mMessageFactory->addUint32(0); mMessageFactory->addString(aMS->assemble()); delete aMS; newMessage = mMessageFactory->EndMessage(); playerObject->getClient()->SendChannelA(newMessage, playerObject->getAccountId(), CR_Chat, 6); } //====================================================================================================================== void MessageLib::sendBoughtInstantMail(PlayerObject* newOwner, string ItemName, string SellerName, uint32 Credits, string planet, string region, int32 mX, int32 mY) { atMacroString* aMS = new atMacroString(); aMS->addMBstf("auction","buyer_success"); aMS->addTO(ItemName); aMS->addTT(SellerName); aMS->addDI(Credits); aMS->addTextModule(); aMS->addMBstf("auction","buyer_success_location"); aMS->addTT(region); planet.toUpperFirst(); aMS->addTO(planet); aMS->addTextModule(); planet.toLowerFirst(); aMS->setPlanetString(planet); aMS->setWP(static_cast<float>(mX), static_cast<float>(mY), 0, ItemName); aMS->addWaypoint(); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opIsmSendSystemMailMessage); mMessageFactory->addUint64(newOwner->getId()); mMessageFactory->addUint64(newOwner->getId()); mMessageFactory->addString(BString("auctioner")); mMessageFactory->addString(BString("@auction:subject_auction_buyer")); mMessageFactory->addUint32(0); string attachment = aMS->assemble(); mMessageFactory->addString(attachment); Message* newMessage = mMessageFactory->EndMessage(); newOwner->getClient()->SendChannelA(newMessage, newOwner->getAccountId(), CR_Chat, 6); delete aMS; } //====================================================================================================================== void MessageLib::sendSoldInstantMail(uint64 oldOwner, PlayerObject* newOwner, string ItemName, uint32 Credits, string planet, string region) { //seller_success Your auction of %TO has been sold to %TT for %DI credits atMacroString* aMS = new atMacroString(); aMS->addMBstf("auction","seller_success"); aMS->addTO(ItemName); aMS->addTT(newOwner->getFirstName()); aMS->addDI(Credits); aMS->addTextModule(); aMS->addMBstf("auction","seller_success_location"); aMS->addTT(region); planet.toUpperFirst(); aMS->addTO(planet); aMS->addTextModule(); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opIsmSendSystemMailMessage); mMessageFactory->addUint64(oldOwner); mMessageFactory->addUint64(oldOwner); mMessageFactory->addString(BString("auctioner")); mMessageFactory->addString(BString("@auction:subject_instant_seller")); mMessageFactory->addUint32(0); mMessageFactory->addString(aMS->assemble()); delete aMS; Message* newMessage = mMessageFactory->EndMessage(); newOwner->getClient()->SendChannelA(newMessage, newOwner->getAccountId(), CR_Chat, 6); } //====================================================================================================================== void MessageLib::sendConstructionComplete(PlayerObject* playerObject, PlayerStructure* structure) { atMacroString* aMS = new atMacroString(); aMS->addMBstf("player_structure","construction_complete"); aMS->addDI(playerObject->getLots()); aMS->addTOstf(structure->getNameFile(),structure->getName()); aMS->addTextModule(); string planet; planet = gWorldManager->getPlanetNameThis(); planet.toLowerFirst(); string wText = ""; string name = structure->getCustomName(); name.convert(BSTRType_ANSI); wText << name.getAnsi(); if(!structure->getCustomName().getLength()) { //wText = "@player_structure:structure_name_prompt "; wText <<"@"<<structure->getNameFile().getAnsi()<<":"<<structure->getName().getAnsi(); } aMS->setPlanetString(planet); aMS->setWP(static_cast<float>(structure->mPosition.x), static_cast<float>(structure->mPosition.y), 0, wText); aMS->addWaypoint(); mMessageFactory->StartMessage(); mMessageFactory->addUint32(opIsmSendSystemMailMessage); mMessageFactory->addUint64(playerObject->getId()); mMessageFactory->addUint64(playerObject->getId()); //mMessageFactory->addString(targetObject->getFirstName()); mMessageFactory->addString(BString("@player_structure:construction_complete_sender")); mMessageFactory->addString(BString("@player_structure:construction_complete_subject")); mMessageFactory->addUint32(0); mMessageFactory->addString(aMS->assemble()); delete aMS; Message* newMessage = mMessageFactory->EndMessage(); playerObject->getClient()->SendChannelA(newMessage, playerObject->getAccountId(), CR_Chat, 6); }
313a2f3bc17bdaa40fb67050868b8ad4165a0c5f
f90c5ee0272b1cab1a44d0d32ad8fa32f15c7738
/src/readcfg.cpp
4568b02699d9e37541c6b08feb218aee3f965f67
[ "MIT" ]
permissive
lkk7/particles-box
8eab6cb3d38ccc1497715e1b2093fd964b3d14d2
2858c36372b630d6db556c6be14443a70feda99a
refs/heads/master
2021-09-24T18:53:07.033751
2018-10-13T12:05:18
2018-10-13T12:05:18
149,906,415
0
0
MIT
2018-10-13T10:39:58
2018-09-22T18:42:32
C++
UTF-8
C++
false
false
1,231
cpp
readcfg.cpp
#include <fstream> #include <string> #include "readcfg.hpp" bool readcfg(int& win_w, int& win_h, int& particle_px_size, int& number_of_particles, double& particle_speed) { std::ifstream cfg_stream("config.cfg"); if(!cfg_stream.is_open()) { std::cout << "error: couldn't open config.cfg\n"; return 0; } std::string buffer; while (cfg_stream >> buffer) { if (buffer == "WIN_W") { cfg_stream >> buffer; win_w = std::stoi(buffer); } else if (buffer == "WIN_H") { cfg_stream >> buffer; win_h = std::stoi(buffer); } else if (buffer == "PARTICLE_PX_SIZE") { cfg_stream >> buffer; particle_px_size = std::stoi(buffer); } else if (buffer == "NUMBER_OF_PARTICLES") { cfg_stream >> buffer; number_of_particles = std::stoi(buffer); } else if (buffer == "PARTICLE_SPEED") { cfg_stream >> buffer; particle_speed = std::stod(buffer); } else { std::cout << "error: wrong config!"; } } return 1; }
d64fff289a11f5c0fadd3410e1d282e6cd05ad45
2e0d53d64469755352351b7f0ba86d28f1f2464c
/interface/HitSpecObj.h
89b80ce1f8c8bd416e6b843439af59f3f94900a4
[]
no_license
konec/usercode-L1RpcTriggerAnalysis
809c7d9e49b413ee9ddc027748a73c69712c5c96
4e9883c704683034ad4a743f87a7546f9eb2a128
refs/heads/master
2021-01-21T21:39:14.496753
2015-11-24T13:39:50
2015-11-24T13:39:50
12,709,747
1
1
null
null
null
null
UTF-8
C++
false
false
1,047
h
HitSpecObj.h
#ifndef HitSpecObj_H #define HitSpecObj_H #include "TObject.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" class HitSpecObj : public TObject { public: HitSpecObj( unsigned int id=0, const GlobalPoint &pos = GlobalPoint(), const GlobalVector &mom = GlobalVector()) : theRawId(id), pos_x(pos.x()), pos_y(pos.y()),pos_z(pos.z()), mom_x(mom.x()), mom_y(mom.y()),mom_z(mom.z()) {} unsigned int rawId() const { return theRawId; } GlobalPoint position() const { return GlobalPoint(pos_x,pos_y,pos_z); } GlobalVector momentum() const { return GlobalVector(mom_x, mom_y, mom_z); } private: unsigned int theRawId; double pos_x, pos_y, pos_z; double mom_x, mom_y, mom_z; friend std::ostream & operator << (std::ostream &out, const HitSpecObj&o) { out <<" HitSpec DET: "<<o.theRawId<<", GlbPos: "<<o.position()<<", GlbMom: "<<o.momentum(); return out; } ClassDef(HitSpecObj,1) }; #endif
0bf2166672d3dfb0ca9a3daecb90d9c258402f36
4b63d452fdadfa67b179c0c1145d35974e1e0be4
/src/dmmm_to_csv.cpp
e193208f5d4e0f5160298a2311fe970279550430
[ "MIT" ]
permissive
CrowdDynamicsLab/stackoverflow-stream
6adee4112658aa6c9f6f6a9ad0cfc6cfe938ceab
955b8ce50f68b587cff4f5f6d1fa1925ea6ef08d
refs/heads/master
2021-03-24T09:41:08.728816
2019-04-03T14:28:52
2019-04-03T14:28:52
82,353,027
2
0
null
null
null
null
UTF-8
C++
false
false
2,661
cpp
dmmm_to_csv.cpp
/** * @file print_hmm.cpp * Prints the distributions for a HMM model file. */ #include <fstream> #include <iostream> #include "actions.h" #include "meta/io/filesystem.h" #include "meta/io/packed.h" #include "meta/logging/logger.h" #include "meta/stats/multinomial.h" using namespace meta; MAKE_NUMERIC_IDENTIFIER(network_id, uint64_t) int main(int argc, char** argv) { logging::set_cerr_logging(); if (argc < 2) { std::cerr << "Usage: " << argv[0] << " dmmm-prefix network1 [network2] [network3]..." << std::endl; return 1; } std::vector<std::string> args(argv, argv + argc); for (const auto& filename : {args[1], args[1] + "/topics.bin", args[1] + "/topic-proportions.bin"}) { if (!filesystem::exists(filename)) { LOG(fatal) << filename << " does not exist" << ENDLG; return 1; } } std::ifstream topics_file{args[1] + "/topics.bin", std::ios::binary}; auto topics = io::packed::read<std::vector<stats::multinomial<action_type>>>( topics_file); // write topics to CSV filesystem::make_directory("topics"); for (std::size_t i = 0; i < topics.size(); ++i) { std::ofstream topics_csv{"topics/topic" + std::to_string(i + 1) + ".csv"}; topics_csv << "action,probability\n"; topics[i].each_seen_event([&](action_type a) { topics_csv << action_name(a) << "," << topics[i].probability(a) << "\n"; }); } std::ifstream theta_file{args[1] + "/topic-proportions.bin", std::ios::binary}; auto theta = io::packed::read<std::vector<stats::multinomial<topic_id>>>( theta_file); // write topic proportions to CSV filesystem::make_directory("proportions"); for (std::size_t i = 0; i < theta.size(); ++i) { auto filename = args[2 + i].substr(args[2 + i].find_last_of("/") + 1); auto dash_pos = filename.find_last_of("-"); auto num_end = filename.rfind("."); auto num_start = filename.find_first_of("0123456789", dash_pos); filename = filename.substr(0, dash_pos + 1) + filename.substr(num_start, num_end - num_start); std::ofstream topic_prop_csv{"proportions/" + filename + "-proportions.csv"}; topic_prop_csv << "topic,probability\n"; theta[i].each_seen_event([&](topic_id k) { topic_prop_csv << k + 1 << "," << theta[i].probability(k) << "\n"; }); } return 0; }
9f93a9ecf54311381f50939dfd93ee11b2df7b69
6a158b414f487be33476caebdf2559ad49e56249
/src/dungeon_map/dungeon_map.hpp
2345abd5a11f2a2349a625368325d7cb246c69f7
[ "MIT" ]
permissive
victorholt/heatgun
f827c4e3fb49b868a66fde42af8573b39505f1f4
0dadab61d278eb7334b2b2e7a1e88f5151696f9d
refs/heads/master
2021-07-16T08:46:44.185932
2020-05-27T19:08:39
2020-05-27T19:08:39
137,523,619
5
2
null
null
null
null
UTF-8
C++
false
false
9,955
hpp
dungeon_map.hpp
/********************************************************** * Author: Victor Holt * The MIT License (MIT) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * **********************************************************/ #pragma once #include <heatgun/defines.hpp> #include <core/Godot.hpp> #include <Spatial.hpp> #include <Mesh.hpp> #include <StaticBody.hpp> #include <CollisionShape.hpp> #include <Image.hpp> #include <World.hpp> #include <Vector2.hpp> #include <SurfaceTool.hpp> #include <GeometryInstance.hpp> #include <MeshInstance.hpp> // Types of tiles that can be generated. enum TileType { EMPTY = 0, FLOOR, WALL, WATER, MAX_TILE_TYPES }; // Tile neighbors enum Neighbor { NEIGHBOR_NORTH = 0, NEIGHBOR_EAST, NEIGHBOR_SOUTH, NEIGHBOR_WEST, NEIGHBOR_NORTH_EAST, NEIGHBOR_NORTH_WEST, NEIGHBOR_SOUTH_EAST, NEIGHBOR_SOUTH_WEST, MAX_TILE_NEIGHBORS }; // Tile that makes up a level. class Tile { GODOT_CLASS(Tile) public: // Position of the tile. godot::Vector2 id; // Region id for the tile. godot::Vector2 region_id; // Local position relative to the region. godot::Vector2 local_position; // Type of tile when generating the mesh. TileType type = TileType::EMPTY; // Tile Neighbors std::vector<Tile*> neighbors; // AABB for the tile. godot::AABB aabb; // Height of the cell. int height = 0; // Flag for whether or not this is an edge tile. bool is_edge = false; // Transform for the tile. godot::Transform transform; // Has a north tile neighbor. bool has_north_tile = false; // Has a east tile neighbor. bool has_east_tile = false; // Has a south tile neighbor. bool has_south_tile = false; // Has a west tile neighbor. bool has_west_tile = false; // Has a north-east tile neighbor. bool has_north_east_tile = false; // Has a north-west tile neighbor. bool has_north_west_tile = false; // Has a south-east tile neighbor. bool has_south_east_tile = false; // Has a south-west tile neighbor. bool has_south_west_tile = false; inline Tile* GetNeightbor(Neighbor neighbor) { return neighbors[(int)neighbor]; } }; // Regions are groups of tiles. class Region { public: // Position of the region. godot::Vector2 id; // Tiles in the region. std::vector<Tile*> tiles; // AABB for the region. godot::AABB aabb; // Region mesh instance. // godot::RID instance; // Region edge mesh instance. // godot::RID edge_instance; godot::MeshInstance* mesh_instance = nullptr; godot::MeshInstance* edge_mesh_instance = nullptr; // Reference to the land mesh. godot::Ref<godot::Mesh> mesh; // Reference to the edge mesh. godot::Ref<godot::Mesh> edge_mesh; // Reference to the collision body. godot::StaticBody* collision_body = NULL; // Reference to the collision shape. godot::CollisionShape* collision_shape = NULL; // Reference to the collision body. godot::StaticBody* edge_collision_body = NULL; // Reference to the collision shape. godot::CollisionShape* edge_collision_shape = NULL; // Transform for the region. godot::Transform transform; // Whether or not the region needs to be regenerated. bool dirty = true; }; class DungeonMap : public godot::GodotScript<godot::Spatial> { GODOT_CLASS(DungeonMap) private: /// Regions in the map. std::unordered_map<std::string, Region*> regions; /// All tiles on the map (including empty). std::unordered_map<std::string, Tile*> tiles; /// All valid tiles on the map. std::vector<Tile*> valid_tiles; /// Reference to the map image used to build the dungeon. godot::Ref<godot::Image> map_image; /// Reference for the tool building our mesh. godot::Ref<godot::SurfaceTool> surfaceTool; /// Number of regions (region_size * region_size). int region_size = 1; /// Tiles per region. int tiles_per_region = 255; /// Celling height. int ceiling_height = 8; /// Size of a single tile. float tile_size = 1.0f; /// Flag for whether or not the map needs an update. bool dirty = true; // Build the regions/tiles. void _build_regions(); // Build the tiles. void _build_tiles(const godot::Vector2& region_id); // Update the tile neighbors. void _update_tile_neighbors(); // Builds the region meshes. void _build_region_meshes(); // Builds the region mesh edges. void _build_region_mesh_edges(); // Create a collision mesh from a given mesh. void _create_collision(godot::StaticBody*& collision_body, godot::CollisionShape*& collision_shape, godot::Ref<godot::Mesh> mesh, const godot::Transform& transform); // Create the collisions for a region. void _create_region_collision(const godot::Vector2& region_id); // Create the edge collisions for a region. void _create_region_edge_collision(const godot::Vector2& region_id); // Updates the visibility of the node. void _update_visibility(); // Updates the grid transformation. void _update_transform(); // Updates the material for the terrain. void _update_material(); protected: //! Handles notifications to the node. //! \param p_what void _notification(int p_what); //! Handles entering the world. //! \param world void enter_world(godot::World &w); //! Handles exiting the world. void exit_world(); //! Handles the process event. void _process(); public: //! Constructor. DungeonMap(); //! Destructor. ~DungeonMap(); //! Builds the dungeon map mesh. void build(); //! Clears the generated map. void clear(); // Attempts to return a region based on the given coordinates/id. Region* find_region(const godot::Vector2& region_id); // Attempts to return a tile based on the given coordinates/id. Tile* find_tile(const godot::Vector2& tile_id); // Returns a random map location (based on the initial seed). godot::Vector2 get_random_map_location(); // Returns the "snapped" tile position given a position. godot::Vector2 get_tile_position(const godot::Vector2& position); // Checks if a position is valid. bool is_valid_position(const godot::Vector2& position); // Set the map image color for a specific tile. void set_map_tile_color(const godot::Vector2& tile_id, godot::Color color); // Returns an array of the region meshes. godot::Array get_meshes(); // Returns an array of the region edge meshes. godot::Array get_edge_meshes(); // Marks the terrain as dirty. inline void mark_dirty() { dirty = true; } // Check if the terrain is dirty. inline bool is_dirty() { return dirty; } // Sets the size of the region. inline void set_region_size(int size) { mark_dirty(); region_size = size; } // Returns the size of the region. inline int get_region_size() const { return region_size; } // Sets the tiles per region. inline void set_tiles_per_region(int tiles) { mark_dirty(); tiles_per_region = tiles; } // Returns the tile per region. inline int get_tiles_per_region() const { return tiles_per_region; } //! Sets the tile size. //! \param size inline void set_tile_size(float size) { tile_size = size; } //! Returns the tile size. //! \return float inline float get_tile_size() const { return tile_size; } // Set the ceiling height. inline void set_ceiling_height(int height) { ceiling_height = height; } // Returns the ceiling height. inline int get_ceiling_height() const { return ceiling_height; } // Returns all regions in the map. inline const std::unordered_map<std::string, Region*>& get_regions() const { return regions; } // Returns all tiles in the map. inline const std::unordered_map<std::string, Tile*>& get_tiles() const { return tiles; } //! Sets the map image. //! \param image inline void set_map_image(godot::Ref<godot::Image> image) { map_image = image; } //! Sets the surface tool. //! \param tool inline void set_surface_tool(godot::Ref<godot::SurfaceTool> tool) { surfaceTool = tool; } //! Returns a string from a given vector. //! \param vec //! \return std::string inline std::string get_id(const godot::Vector2& vec) { return godot::String(vec).alloc_c_string(); } //! Registers the methods for this class. static void _register_methods(); };
869ab2cd54a63f3163e1449ea78c58b67a08ea60
31c38c6fa9d1aa2ad0ce113e7084cb8c0f7bc956
/SDK/AB_GK_KeyRing_ACC01_functions.cpp
e03a3331f64cc79dac896259fb34e4ba4c9d362c
[]
no_license
xnf4o/DBD_SDK_461
d46feebba60aa71285479e4c71ff5dbf5d57b227
9d4fb29a75b63f4bd8813d4ee0cdb897aa792a58
refs/heads/main
2023-04-12T22:27:19.819706
2021-04-14T22:09:39
2021-04-14T22:09:39
358,058,055
3
1
null
null
null
null
UTF-8
C++
false
false
4,344
cpp
AB_GK_KeyRing_ACC01_functions.cpp
๏ปฟ// Name: DeadByDaylight, Version: 4.6.1 #include "../pch.h" /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Functions //--------------------------------------------------------------------------- // Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.AnimGraph // (HasOutParms, BlueprintCallable, BlueprintEvent) // Parameters: // struct FPoseLink AnimGraph (Parm, OutParm, NoDestructor) void UAB_GK_KeyRing_ACC01_C::AnimGraph(struct FPoseLink* AnimGraph) { static auto fn = nullptr; if (!fn) fn = UObject::FindObject<UFunction>("Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.AnimGraph"); UAB_GK_KeyRing_ACC01_C_AnimGraph_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; if (AnimGraph != nullptr) *AnimGraph = params.AnimGraph; } // Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_542ECAE74D0D8B76C7FE828E18E5BC7E // (BlueprintEvent) void UAB_GK_KeyRing_ACC01_C::EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_542ECAE74D0D8B76C7FE828E18E5BC7E() { static auto fn = nullptr; if (!fn) fn = UObject::FindObject<UFunction>("Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_542ECAE74D0D8B76C7FE828E18E5BC7E"); UAB_GK_KeyRing_ACC01_C_EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_542ECAE74D0D8B76C7FE828E18E5BC7E_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_B7EEB9C24F7F2036418E928AE5283F04 // (BlueprintEvent) void UAB_GK_KeyRing_ACC01_C::EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_B7EEB9C24F7F2036418E928AE5283F04() { static auto fn = nullptr; if (!fn) fn = UObject::FindObject<UFunction>("Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_B7EEB9C24F7F2036418E928AE5283F04"); UAB_GK_KeyRing_ACC01_C_EvaluateGraphExposedInputs_ExecuteUbergraph_AB_GK_KeyRing_ACC01_AnimGraphNode_TransitionResult_B7EEB9C24F7F2036418E928AE5283F04_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.BlueprintUpdateAnimation // (Event, Public, BlueprintEvent) // Parameters: // float DeltaTimeX (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) void UAB_GK_KeyRing_ACC01_C::BlueprintUpdateAnimation(float DeltaTimeX) { static auto fn = nullptr; if (!fn) fn = UObject::FindObject<UFunction>("Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.BlueprintUpdateAnimation"); UAB_GK_KeyRing_ACC01_C_BlueprintUpdateAnimation_Params params; params.DeltaTimeX = DeltaTimeX; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.ExecuteUbergraph_AB_GK_KeyRing_ACC01 // (Final) // Parameters: // int EntryPoint (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) void UAB_GK_KeyRing_ACC01_C::ExecuteUbergraph_AB_GK_KeyRing_ACC01(int EntryPoint) { static auto fn = nullptr; if (!fn) fn = UObject::FindObject<UFunction>("Function AB_GK_KeyRing_ACC01.AB_GK_KeyRing_ACC01_C.ExecuteUbergraph_AB_GK_KeyRing_ACC01"); UAB_GK_KeyRing_ACC01_C_ExecuteUbergraph_AB_GK_KeyRing_ACC01_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
b9e1be9c0c31bdc7a18a8245e454bac0b8a08bce
6ddbc5941d969596d8c06cc2bc08827db175a3a7
/predicate.h
b2852a2bdca26c83be2d7e4d34a75f26d3106ea3
[]
no_license
Emzapp/proj2
99080d14703e99bfbd0d267e3d810dc89eb49603
2d5b4638fd21d51576ec4f9fa2acc5d9f932b3f7
refs/heads/master
2023-08-17T14:01:32.240809
2021-10-02T23:36:58
2021-10-02T23:36:58
412,933,414
0
0
null
null
null
null
UTF-8
C++
false
false
334
h
predicate.h
#pragma once #include "parameter.h" #include <vector> class Predicate { public: void SetName(string theName); vector<Parameter> ReturnVector(); void PushPredicate(Parameter theParameter); string ToString(); private: vector<Parameter> parameterList; string Name; };
44017fc81e6778c3c194a8b7cb5df8c7a966898d
697ece97d86013137f38b6049a6755a7fec6e693
/code/addons/network/multiplayerfeature/multiplayerfeatureunit.cc
1315587669f1c8966e6dc9e8052f8da4969cdc89
[]
no_license
Chinamming/nebuladevice3
6ace3c9fd97632ed43743e8eb7fce151f976a906
1180cec07aff77da1e9f97cedbcfbf5b56c3630d
refs/heads/master
2021-01-10T18:17:09.958301
2012-11-23T19:55:13
2012-11-23T19:55:13
47,537,441
3
2
null
null
null
null
UTF-8
C++
false
false
3,996
cc
multiplayerfeatureunit.cc
//------------------------------------------------------------------------------ // multiplayer/multiplayerfeatureunit.cc // (C) 2008 Radon Labs GmbH //------------------------------------------------------------------------------ #include "stdneb.h" #include "multiplayerfeature/multiplayerfeatureunit.h" #include "multiplayerfeature/distributionnotificationhandler.h" #include "basegamefeature/basegametiming/gametimesource.h" using namespace InternalMultiplayer; using namespace Multiplayer; namespace MultiplayerFeature { __ImplementClass(MultiplayerFeatureUnit, 'MUFU' , Game::FeatureUnit); __ImplementSingleton(MultiplayerFeatureUnit); //------------------------------------------------------------------------------ /** */ MultiplayerFeatureUnit::MultiplayerFeatureUnit(): notificationHandlerRtti(&DistributionNotificationHandler::RTTI) { __ConstructSingleton; } //------------------------------------------------------------------------------ /** */ MultiplayerFeatureUnit::~MultiplayerFeatureUnit() { __DestructSingleton; } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::OnActivate() { FeatureUnit::OnActivate(); // setup multiplayer thread this->internalMpInterface = InternalMultiplayerInterface::Create(); this->internalMpInterface->Open(); // setup manager this->multiplayerManager = Multiplayer::MultiplayerManager::Create(); this->multiplayerManager->Open(); // create and attach default handler Ptr<DistributionNotificationHandler> handler = (DistributionNotificationHandler*)this->notificationHandlerRtti->Create(); this->notificationHandler.Append(handler.cast<Base::MultiplayerNotificationHandlerBase>()); this->multiplayerManager->RegisterNotificationHandler(handler.cast<Base::MultiplayerNotificationHandlerBase>()); // distribution this->distributionManager = DistributionManager::Create(); this->distributionManager->Open(); this->SetRenderDebug(true); } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::OnDeactivate() { this->multiplayerManager->Close(); this->multiplayerManager = 0; this->internalMpInterface->Close(); this->internalMpInterface = 0; this->distributionManager->Close(); this->distributionManager = 0; FeatureUnit::OnDeactivate(); } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::OnRenderDebug() { this->multiplayerManager->RenderDebug(); FeatureUnit::OnRenderDebug(); } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::OnBeginFrame() { IndexT index; for (index = 0; index < this->notificationHandler.Size(); index++) { this->notificationHandler[index]->HandlePendingNotifications(); } // trigger distribution this->distributionManager->OnBeginFrame(); } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::OnFrame() { // trigger multiplayer stuff this->multiplayerManager->Trigger(); this->distributionManager->OnFrame(); FeatureUnit::OnFrame(); } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::OnEndFrame() { this->distributionManager->OnEndFrame(); // flush all messages this->internalMpInterface->FlushBatchedMessages(); Game::FeatureUnit::OnEndFrame(); } //------------------------------------------------------------------------------ /** */ void MultiplayerFeatureUnit::SetNotificationHandlerRtti(Core::Rtti* rtti) { this->notificationHandlerRtti = rtti; } }; // namespace Multiplayer
c10dc54d5354284ac7422d86d35949302eed7a3b
12d15595be8fe44125356f7af09d9e86da0a8601
/Codes/C++/2327.cpp
9d3dbd0c949cc84d6ea617e0357a12cb0117bea5
[]
no_license
Doveqise/Cloud
d919ffab02cd95c95fb0b7185bc9ff9747d5a7ed
86f9d38a52b03c5240568765aa0e50520b6fee9f
refs/heads/master
2020-08-04T23:56:13.051505
2019-10-15T22:40:47
2019-10-15T22:40:47
212,315,989
0
0
null
null
null
null
UTF-8
C++
false
false
793
cpp
2327.cpp
#include<bits/stdc++.h> #define N 10005 using namespace std; int n; int g[N]; int f[N][2][2]; signed main(){ scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&g[i]); f[0][0][0]=f[0][0][1]=1; for(int i=1;i<=n;i++) switch(g[i]) { case 0: f[i][0][0]+=f[i-1][0][0]; break; case 1: f[i][0][0]+=f[i-1][1][0]; f[i][1][0]+=f[i-1][0][1]; f[i][0][1]+=f[i-1][0][0]; break; case 2: f[i][1][1]+=f[i-1][0][1]; f[i][0][1]+=f[i-1][1][0]; f[i][1][0]+=f[i-1][1][1]; break; case 3: f[i][1][1]+=f[i-1][1][1]; break; } printf("%d",f[n][0][0]+f[n][1][0]); return 0; }
a33858ff4db2ead2f52de489c839c107ec09a81d
0ebdd777b0656100397da11f1ed2e1873937fdea
/SonicDistance.cpp
60fa67418e16e7ba5270b45781ff1432fd3ca160
[]
no_license
gigix74/SonicDistance
87034801a4a1715e5dee52d8db1f20a9c5582e57
fe543f79eb1b80137b60d24ac19bbd24432a7af2
refs/heads/master
2020-05-24T15:09:00.113127
2019-05-18T07:00:11
2019-05-18T07:00:11
187,323,943
0
0
null
null
null
null
UTF-8
C++
false
false
1,524
cpp
SonicDistance.cpp
/* SonicDistance.cpp - Library for UltraSonic sensor Created by Gheorghe Nedelcu, April 8, 2019. g_nedelcu@yahoo.com */ #include "Arduino.h" #include "SonicDistance.h" SonicDistance::SonicDistance(int trig, int echo, unsigned long min_limit, unsigned long max_limit) : _time_ms(millis()), _last_distance(1000000) { _trig = trig; _echo = echo; _min_limit = min_limit * 1000; _max_limit = max_limit * 1000; } unsigned long SonicDistance::getDuration() { pinMode(_trig, OUTPUT); digitalWrite(_trig, LOW); delayMicroseconds(2); digitalWrite(_trig, HIGH); delayMicroseconds(10); digitalWrite(_trig, LOW); pinMode(_echo, INPUT); _duration = pulseIn(_echo, HIGH, 6000); if(_duration==0) _duration = 6000; return _duration; } unsigned long SonicDistance::getDistance() { _duration = getDuration(); _distance = _duration * 10000 / 58; _distance = constrain(_distance, _min_limit, _max_limit); return _distance; } unsigned long SonicDistance::getFilteredDistance(int filter_close, int filter_far) { _distance = getDistance(); _filter = -(((_last_distance - _min_limit ) * (filter_close - filter_far))/(_max_limit - _min_limit)) + filter_close; _raise_amount = (millis() - _time_ms) * _filter; _time_ms = millis(); if ( _distance > _last_distance) { if ((_distance - _last_distance) > _raise_amount) { _distance = _last_distance + _raise_amount; } } _distance = constrain(_distance, _min_limit, _max_limit); _last_distance = _distance; return _distance; }
091193ad510ff4f413b58f4cc2aa8cea7a645a59
efcff187361a5c509872bab39ee58630a041730f
/extmem.cpp
cbe4a2feb157ba68fc81632d4b99a8e5c18ea07b
[]
no_license
sscholbe/jextmem
50dad15abc8c0e07135a07c04a9264fc1c8c650c
f29c5395a2d84621e72a18c9b984a9c8c6d50ee2
refs/heads/main
2023-04-25T05:54:32.532517
2021-05-14T14:49:20
2021-05-14T14:49:20
367,379,210
0
0
null
null
null
null
UTF-8
C++
false
false
3,231
cpp
extmem.cpp
#include "extmem.h" #include <Windows.h> #include <sstream> jclass FindWin32Exception(JNIEnv *env) { jclass win32ex = env->FindClass("extmem/Win32Exception"); if (win32ex == NULL) { env->ThrowNew(env->FindClass("java/lang/ClassNotFoundException"), "Win32Exception not found"); return NULL; } return win32ex; } JNIEXPORT jlong JNICALL Java_extmem_Memory_openProcess(JNIEnv *env, jclass obj, jstring windowTitle) { jclass win32ex = FindWin32Exception(env); if (!win32ex) { return -1; } jboolean copy; const char *utf = env->GetStringUTFChars(windowTitle, &copy); // Find the window by its title HWND window = FindWindowA(NULL, utf); if (!window) { env->ThrowNew(win32ex, "Could not find window"); return -1; } if (copy) { env->ReleaseStringUTFChars(windowTitle, utf); } DWORD pid; // Find the process ID of the window GetWindowThreadProcessId(window, &pid); if (!pid) { DWORD err = GetLastError(); std::ostringstream ss; ss << "GetWindowThreadProcessId() failed with error code 0x" << std::hex << err; env->ThrowNew(win32ex, ss.str().c_str()); return -1; } // Open the process using the PID HANDLE handle = OpenProcess(PROCESS_VM_READ, FALSE, pid); if (!handle) { DWORD err = GetLastError(); std::ostringstream ss; ss << "OpenProcess() failed with error code 0x" << std::hex << err; env->ThrowNew(win32ex, ss.str().c_str()); return -1; } return (jlong) handle; } JNIEXPORT void JNICALL Java_extmem_Memory_closeProcess(JNIEnv *env, jclass obj, jlong handle) { jclass win32ex = FindWin32Exception(env); if (!win32ex) { return; } if (!CloseHandle((HANDLE) handle)) { DWORD err = GetLastError(); std::ostringstream ss; ss << "CloseHandle() failed with error code 0x" << std::hex << err; env->ThrowNew(win32ex, ss.str().c_str()); } } JNIEXPORT jbyteArray JNICALL Java_extmem_Memory_readBytes(JNIEnv *env, jclass obj, jlong handle, jlong address, jint count) { jclass win32ex = FindWin32Exception(env); if (!win32ex) { return NULL; } jbyte *data = new jbyte[count]; jbyteArray bytes = env->NewByteArray(count); if (!data || !bytes) { env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), "Could not allocate temporary storage"); return NULL; } SIZE_T read; if (!ReadProcessMemory((HANDLE) handle, (LPCVOID) address, data, count, &read)) { DWORD err = GetLastError(); std::ostringstream ss; ss << "ReadProcessMemory() failed with error code 0x" << std::hex << err; env->ThrowNew(win32ex, ss.str().c_str()); return NULL; } if (count != read) { std::ostringstream ss; ss << "Number of expected (" << count << ") and read (" << read << ") bytes mismatch"; env->ThrowNew(win32ex, ss.str().c_str()); return NULL; } env->SetByteArrayRegion(bytes, 0, count, data); return bytes; }
d5bb0f0a35f40243ae86b80c1dda4765557451e9
1fafb6f2866275ca452b6e5d7443d4fdcc76d70c
/src/utils.cpp
08b4f9be55cc95a0a966bf6c61d693a40d356bb3
[ "Apache-2.0" ]
permissive
Farrael/Math_Solver
27e75acb91a215043a0c438f8dfc9108ed0bf690
fce48594b68837f8c69e178ae68e9d6f45b3cdd2
refs/heads/master
2021-01-25T06:00:49.213916
2015-07-02T15:35:00
2015-07-02T15:35:00
28,956,328
0
0
null
null
null
null
UTF-8
C++
false
false
3,871
cpp
utils.cpp
#include <iostream> #include <string.h> #include <stdlib.h> /* Internal dependencies */ #include "utils.h" using namespace std; char hook[2] = {'[',']'}; char bracket[2] = {'(',')'}; /** * Converts array of char into n. * Returns if it was "successful" */ void toInteger(char* str, int& n){ unsigned int size = strlen(str); n = 0; bool first = true; for(unsigned int i = 0; i < size; i++){ if(!isdigit(str[i])) first = false; if(first && str[i] >= '0' && (char)str[i] <= '9'){ n *= 10; n += (str[i] - '0'); } } } /** * Mathematical function : pow */ int pow(int a) { int mult = 1; for(int b = 0; b < a; b++) mult *= 10; return mult; } /** * Remove unexpected space * str : String to trim */ void trim(char* str) { int start = 0; char* buffer = str; while(*str && *str++ == ' ') ++start; while(*str++); int end = str - buffer - 1; while (end > 0 && buffer[end - 1] == ' ') --end; buffer[end] = 0; if (end <= start || start == 0) return; str = buffer + start; while ((*buffer++ = *str++)); } /** * Add characters to char[] * source : Char[] source * add : Characters to add */ char* addChar(char* source, const char* add){ char* result = (char*) malloc(strlen(source) + strlen(add) + 1); strcpy(result, source); strcat(result, add); return result; } /** * Remove characters from char[] * text : Array of char to split * position : Split position * size : Size of split */ char* substr(char* text, int position, int size){ char* token = (char*) malloc(size+1); strncpy(token, text + position, size); token[size] = '\0'; return token; } /** * Search pattern in string * text : String to split * pattern : 2d array of characters * depth : depth recursion */ Array* regex(char* text, char* pattern, int depth) { int dep = 0, pos = 0; depth++; // Initial depth to 1 Array *result = NULL; for(unsigned int i = 0; i < strlen(text); i++) { if(text[i] == pattern[0] && ++dep == depth){ pos = i; } else if(text[i] == pattern[1] && dep-- == depth) { char* token = substr(text, pos+1, i - pos - 1); if(token != '\0'){ trim(token); result = push_back(result, token); } } } return result; } /** * Split string with delimiter * text : String to cut * pattern : Pattern to validate * delimiter : Cut delimiter * depth : Depth to validate */ Array* cut(char* text, char* pattern, char delimiter, int depth) { bool valid = true; Array *result = NULL; int dep = 0, pos = 0; for(unsigned int i = 0; i <= strlen(text); i++) { if(text[i] == pattern[0] && dep == depth && !valid) return NULL; if(text[i] == pattern[0] && ++dep == depth){ pos = i+1; } else if((text[i] == pattern[1] && dep-- == depth) || (text[i] == delimiter && dep == depth)) { if(text[i] == delimiter) valid = true; if(text[i] == pattern[1]) valid = false; char* token = substr(text, pos, i - pos); trim(token); if(token != '\0' && token[0] != 0) result = push_back(result, token); pos = i+1; } } if(depth == 0){ char* token = substr(text, pos, strlen(text) - pos); trim(token); result = push_back(result, token); } return result; } /** * Add element at the end of the list * list : List to modify * value : Element to add */ Array* push_back(Array *list, char* value){ if(list != NULL){ Array* temp = list; while(temp->next != NULL){ temp = temp->next; } temp->next = new Array; temp->next->value = value; temp->next->next = NULL; } else { list = new Array; list->value = value; list->next = NULL; } return list; } /** * Return the size of a list * list : List to get size */ int size(Array *list){ int i = 0; while(list != NULL){ i++; list = list->next; } return i; }
ca12815a3aa1986fa12c642e3da4159f2e0775a9
3a79db21b576f713b508cd3cde8d26c93a6f26c9
/471B.cpp
03100d9f633912fe67932ca5eb6631f502b22026
[]
no_license
otaGran/codeForces
1c39809baa1aef81bc7265cb7ec6ae2f406b41ee
e5ca5a100fc22127ab4c40254c0b71414e82cde2
refs/heads/master
2021-06-06T04:59:06.335636
2016-08-23T02:52:26
2016-08-23T02:52:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
739
cpp
471B.cpp
#include <bits/stdc++.h> using namespace std; void print(vector<pair<int, int> > &v) { for (int i = 0 ; i < v.size(); ++i) cout << v[i].second + 1 << ' ' ; cout << '\n'; } int main() { vector<pair<int, int> > v; vector<pair<int, int> > troca; int n; int x; cin >> n; for (int i = 0 ; i < n ; ++i) { cin >> x; v.push_back(make_pair(x, i)); } sort(v.begin(), v.end()); for (int i = 1; i < n && troca.size() < 2; ++i) { if (v[i].first == v[i - 1].first) troca.push_back(make_pair(i - 1, i)); } if (troca.size() < 2) cout << "NO\n"; else { cout << "YES\n"; print(v); swap(v[troca[0].first], v[troca[0].second]); print(v); swap(v[troca[1].first], v[troca[1].second]); print(v); } }
e7150f41088acee4e1d1a8efe35b573113153d37
859006ded9e1b0cffc7fa410498e3b8b94c9ad78
/Sensors/Depth/include/Depth/DepthWorker.h
b107d2dd092a8798ce006932914dcc44b17aaf87
[]
no_license
viron11111/sub-2012
608795566c5ee621e0c27ff53399dfb58b26ecf5
761972b1fdb577c59c693a670605b8aaabe90a4d
refs/heads/master
2021-01-01T04:48:48.762686
2012-10-02T23:47:57
2012-10-02T23:47:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
567
h
DepthWorker.h
#ifndef DEPTH_DEPTHWORKER_H #define DEPTH_DEPTHWORKER_H #include "Depth/DataObjects/DepthInfo.h" #include "LibSub/Worker/Worker.h" #include "LibSub/Worker/WorkerEndpoint.h" #include "HAL/HAL.h" namespace subjugator { class DepthWorker : public Worker { public: DepthWorker(HAL &hal, const WorkerConfigLoader &configloader); WorkerSignal<DepthInfo> signal; private: HAL &hal; int publishrate; WorkerEndpoint endpoint; void endpointInitCallback(); void endpointReceiveCallback(const boost::shared_ptr<DataObject> &dobj); }; } #endif
afdd821bbf9acee7cf0a6667ceab61eb01ef291f
fa7636f647a4df7c0e9c1888330293bc54a009ae
/util.hpp
76bf2153fe65f4a2287530bf7375425d8e2e245b
[]
no_license
robryk/parsum
a4ed2ff08586c69ae596ca6d8eff262f834b4dc8
d3433f7f7b137b52a73cfb244d46081528c696c3
refs/heads/master
2021-01-10T22:05:29.864610
2013-03-25T02:56:56
2013-03-25T02:56:56
4,130,334
1
0
null
null
null
null
UTF-8
C++
false
false
1,202
hpp
util.hpp
#ifndef __UTIL_GUARD #define __UTIL_GUARD #include <memory> #include <algorithm> #include <cstring> #include <cstddef> #include <sstream> #include "common.hpp" template<typename T> class permuted_array { private: static const int CACHELINE_SIZE = 128; int size_; int step_; std::unique_ptr<T[]> ptr_; public: permuted_array(int size = 0) : /* We want size to be odd so that step of 1<<something will be OK */ size_(size|1), ptr_(new T[size_]) { step_ = 1; while (step_*sizeof(T) < CACHELINE_SIZE) step_ <<=1; // We might end up with step_ >= size -- then we will not be able to fit stuff nicely, but step_ will still // be relatively prime with size_ and we don't care whether it's larger then size_. } T& operator[](int idx) { return ptr_[(idx*step_)%size_]; } const T& operator[](int idx) const { return ptr_[(idx*step_)%size_]; } }; #ifdef RELACY class log_stream : public std::stringstream { public: log_stream(rl::debug_info_param info) : info_(info) { } ~log_stream() { rl::ctx().exec_log_msg(info_, str().c_str()); } private: rl::debug_info_param info_; }; #define LOG (log_stream(RL_INFO)) #endif // RELACY #endif
a37d3fad121e593d6927a9ec15b51a2998e15b9a
e3d107007955a1a983ad9b646439ed9581d458f8
/XTU_work/1108.cpp
d4fa04a8bfed1c45b5f4431059a478eea52c8146
[]
no_license
xzljyy2021/xtu_shining_xzl_code
98002433f86770bf17b361c49d2e3a614d1990a0
50b416bc64ca60dae4a1c9303d954c76250fcd19
refs/heads/main
2023-03-07T14:43:41.236077
2021-02-10T12:27:34
2021-02-10T12:27:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
664
cpp
1108.cpp
#include <stdio.h> #include <cstring> #include <math.h> using namespace std; char a[37],b[37]; int an,bn; int turn(char s[],int n) { int l=0,len,i,k=1,ans=0,p; len=strlen(s); if(s[0]=='-') l++; for(i=len-1;i>=l;i--) { if(s[i]>='0'&&s[i]<='9') p=s[i]-48; else if(s[i]>='A'&&s[i]<='Z') p=s[i]-55; else if(s[i]>='a'&&s[i]<='z') p=s[i]-61; ans+=k*p; k*=n; } if(s[0]=='-') ans=-ans; return ans; } int main() { int time,A,B; scanf("%d",&time); while(time--) { scanf("%s",&a); scanf("%d",&an); scanf("%s",&b); scanf("%d",&bn); A=turn(a,an); B=turn(b,bn); printf("%d\n",A+B); } return 0; }
35386efc48ddf0b711898342cfb813903ae21e94
a4dc776594a883c818075859a86bb567e18247ca
/2022/Day_15.hpp
0a88d6365a6e744222dcab8457aec5ac1927fb19
[]
no_license
SinisterMJ/AdventOfCode
d46d4bf3877b3ae258c55ee05a00c154c37d4a37
ca421e10dc010c1b82dffb1b14347c582774757d
refs/heads/master
2022-12-27T00:02:32.214757
2022-12-25T10:23:07
2022-12-25T10:23:07
225,685,393
2
0
null
null
null
null
UTF-8
C++
false
false
5,175
hpp
Day_15.hpp
#ifndef ADVENTOFCODE2022_DAY15 #define ADVENTOFCODE2022_DAY15 #include <regex> #include "../includes/aoc.h" #include "../includes/Map2DBase.h" class Day15 { private: std::vector<std::string> inputVector; std::string inputString; struct SensorPair { v2 sensor; int distance = 0; }; std::vector<SensorPair> sensors; std::set<v2> beacons; bool inSensor(v2 position) { for (auto [sensor, dist] : sensors) if ((position - sensor).manhattan() <= dist) return true; return false; } void readData() { std::regex moon_regex("x=(.*), y=(.*): .* x=(.*), y=(.*)"); std::smatch moon_match; for (auto line : inputVector) { // Sensor at x=2765643, y=3042538: closest beacon is at x=2474133, y=3521072 if (std::regex_search(line, moon_match, moon_regex) && moon_match.size() >= 5) { int s_x = std::stoi(moon_match[1]); int s_y = std::stoi(moon_match[2]); int b_x = std::stoi(moon_match[3]); int b_y = std::stoi(moon_match[4]); v2 pos(s_x, s_y); v2 pos_b(b_x, b_y); SensorPair temp; temp.distance = (pos_b - pos).manhattan(); temp.sensor = pos; sensors.push_back(temp); beacons.insert(pos_b); } } } int part1() { std::vector<std::pair<int, int>> ranges; for (auto [sensor, dist] : sensors) { auto d = dist - std::abs((sensor.y - 2'000'000)); if (d >= 0) { int left = sensor.x - d; int right = sensor.x + d; ranges.push_back(std::make_pair(left, right)); } } std::sort(ranges.begin(), ranges.end()); bool merged = true; while (merged) { merged = false; std::vector<std::pair<int, int>> tempRanges; for (int i = 0; i < ranges.size(); i++) { if (i == ranges.size() - 1) { tempRanges.push_back(ranges[i]);; continue; } if (overlap(ranges[i], ranges[i + 1])) { tempRanges.push_back(merge_overlap(ranges[i], ranges[i + 1])); merged = true; i++; } else { tempRanges.push_back(ranges[i]); } } if (tempRanges.size() > 0) ranges = tempRanges; } int sum = 0; for (auto [left, right] : ranges) sum += right - left + 1; // Sensors aren't emtpy space for (auto [sensor, dist] : sensors) if (sensor.y == 2'000'000) sum--; // Beacons are neither for (auto beacon : beacons) if (beacon.y == 2'000'000) sum--; return sum; } int64_t part2() { for (auto [sensor, distance] : sensors) { int x = sensor.x - distance - 1; int y = sensor.y; v2 test_pos(x, y); v2 dir(1, -1); while (test_pos.x != sensor.x) { if (inSensor(test_pos)) test_pos += dir; else return static_cast<int64_t>(test_pos.x) * 4000000 + static_cast<int64_t>(test_pos.y); } dir = v2(1, 1); while (test_pos.y != sensor.y) { if (inSensor(test_pos)) test_pos += dir; else return static_cast<int64_t>(test_pos.x) * 4000000 + static_cast<int64_t>(test_pos.y); } dir = v2(-1, 1); while (test_pos.x != sensor.x) { if (inSensor(test_pos)) test_pos += dir; else return static_cast<int64_t>(test_pos.x) * 4000000 + static_cast<int64_t>(test_pos.y); } dir = v2(-1, -1); while (test_pos.y != sensor.y) { if (inSensor(test_pos)) test_pos += dir; else return static_cast<int64_t>(test_pos.x) * 4000000 + static_cast<int64_t>(test_pos.y); } } return 0; } public: Day15() { inputVector = util::readFileLines("..\\inputs\\2022\\input_15.txt"); inputString = util::readFile("..\\inputs\\2022\\input_15.txt"); } int64_t run() { util::Timer myTime; myTime.start(); readData(); auto result_1 = part1(); auto result_2 = part2(); int64_t time = myTime.usPassed(); std::cout << "Day 15 - Part 1: " << result_1 << '\n' << "Day 15 - Part 2: " << result_2 << '\n'; return time; } }; #endif // ADVENTOFCODE2022_DAY15
47185e678f3b7113f47236864604ee6aa901159f
60b1b24de7f2315bdec25747b0cdb4b0746ce820
/v3/software/FSIM/source/frmKeyboard.h
aeda48dbbaee500713348039ae0f23a83a246563
[]
no_license
robfinch/ANY-1
c436c52a1b7d0adba2d54313596ba030820d8096
0a47c5dc055b85dff92a4ab14a65b7efd16f1196
refs/heads/main
2023-07-24T22:36:06.640147
2021-09-09T04:24:13
2021-09-09T04:24:13
332,168,690
4
1
null
null
null
null
UTF-8
C++
false
false
60,805
h
frmKeyboard.h
#pragma once #include "stdafx.h" #include "clsKeyboard.h" extern clsKeyboard keybd; extern clsPIC pic1; extern volatile unsigned __int8 keybd_status; extern volatile unsigned __int8 keybd_scancode; namespace E64 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for frmKeyboard /// </summary> public ref class frmKeyboard : public System::Windows::Forms::Form { public: frmKeyboard(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~frmKeyboard() { if (components) { delete components; } } private: System::Windows::Forms::Button^ btnQ; protected: private: System::Windows::Forms::Button^ btnW; private: System::Windows::Forms::Button^ btnE; private: System::Windows::Forms::Button^ btnQuest; private: System::Windows::Forms::Button^ btnEnter; private: System::Windows::Forms::Button^ btnR; private: System::Windows::Forms::Button^ btnT; private: System::Windows::Forms::Button^ btnY; private: System::Windows::Forms::Button^ btnU; private: System::Windows::Forms::Button^ btnI; private: System::Windows::Forms::Button^ btnRshift; private: System::Windows::Forms::Button^ btnO; private: System::Windows::Forms::Button^ btnLshift; private: System::Windows::Forms::Button^ btnP; private: System::Windows::Forms::Button^ btnA; private: System::Windows::Forms::Button^ btnS; private: System::Windows::Forms::Button^ btnD; private: System::Windows::Forms::Button^ btnF; private: System::Windows::Forms::Button^ btnG; private: System::Windows::Forms::Button^ btnZ; private: System::Windows::Forms::Button^ btnH; private: System::Windows::Forms::Button^ btnJ; private: System::Windows::Forms::Button^ btnK; private: System::Windows::Forms::Button^ btnL; private: System::Windows::Forms::Button^ btnX; private: System::Windows::Forms::Button^ btnC; private: System::Windows::Forms::Button^ btnV; private: System::Windows::Forms::Button^ btnB; private: System::Windows::Forms::Button^ btnN; private: System::Windows::Forms::Button^ btnM; private: System::Windows::Forms::Button^ btn1; private: System::Windows::Forms::Button^ btn2; private: System::Windows::Forms::Button^ btn3; private: System::Windows::Forms::Button^ btn4; private: System::Windows::Forms::Button^ btn5; private: System::Windows::Forms::Button^ btn6; private: System::Windows::Forms::Button^ btn7; private: System::Windows::Forms::Button^ btn8; private: System::Windows::Forms::Button^ btn9; private: System::Windows::Forms::Button^ btn0; private: System::Windows::Forms::Button^ btnSpace; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::Button^ button5; private: System::Windows::Forms::Button^ button6; private: System::Windows::Forms::Button^ button7; private: System::Windows::Forms::Button^ btnMinus; private: System::Windows::Forms::Button^ button9; private: System::Windows::Forms::Button^ btnBackspace; private: System::Windows::Forms::Button^ btnRctrl; private: System::Windows::Forms::Button^ btnLalt; private: System::Windows::Forms::Button^ button10; private: System::Windows::Forms::Button^ button11; private: System::Windows::Forms::Button^ button12; private: System::Windows::Forms::Button^ button13; private: System::Windows::Forms::Button^ button14; private: System::Windows::Forms::Button^ button15; private: System::Windows::Forms::Button^ button16; private: System::Windows::Forms::Button^ button17; private: System::Windows::Forms::Button^ button18; private: System::Windows::Forms::Button^ button19; private: System::Windows::Forms::Button^ button8; private: System::Windows::Forms::Button^ button20; private: System::Windows::Forms::Button^ buttonLctrl; private: System::Windows::Forms::Button^ buttonEsc; private: System::Windows::Forms::Button^ buttonF1; private: System::Windows::Forms::Button^ buttonF2; private: System::Windows::Forms::Button^ buttonF3; private: System::Windows::Forms::Button^ buttonF4; private: System::Windows::Forms::Button^ buttonF5; private: System::Windows::Forms::Button^ buttonF6; private: System::Windows::Forms::Button^ buttonF7; private: System::Windows::Forms::Button^ buttonF8; private: System::Windows::Forms::Button^ buttonF9; private: System::Windows::Forms::Button^ buttonF10; private: System::Windows::Forms::Button^ buttonF11; private: System::Windows::Forms::Button^ buttonF12; private: System::Windows::Forms::Button^ buttonCapslock; private: System::Windows::Forms::Button^ button21; private: System::Windows::Forms::Button^ button22; private: System::Windows::Forms::Button^ button23; private: System::Windows::Forms::Button^ buttonTab; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->btnQ = (gcnew System::Windows::Forms::Button()); this->btnW = (gcnew System::Windows::Forms::Button()); this->btnE = (gcnew System::Windows::Forms::Button()); this->btnQuest = (gcnew System::Windows::Forms::Button()); this->btnEnter = (gcnew System::Windows::Forms::Button()); this->btnR = (gcnew System::Windows::Forms::Button()); this->btnT = (gcnew System::Windows::Forms::Button()); this->btnY = (gcnew System::Windows::Forms::Button()); this->btnU = (gcnew System::Windows::Forms::Button()); this->btnI = (gcnew System::Windows::Forms::Button()); this->btnRshift = (gcnew System::Windows::Forms::Button()); this->btnO = (gcnew System::Windows::Forms::Button()); this->btnLshift = (gcnew System::Windows::Forms::Button()); this->btnP = (gcnew System::Windows::Forms::Button()); this->btnA = (gcnew System::Windows::Forms::Button()); this->btnS = (gcnew System::Windows::Forms::Button()); this->btnD = (gcnew System::Windows::Forms::Button()); this->btnF = (gcnew System::Windows::Forms::Button()); this->btnG = (gcnew System::Windows::Forms::Button()); this->btnZ = (gcnew System::Windows::Forms::Button()); this->btnH = (gcnew System::Windows::Forms::Button()); this->btnJ = (gcnew System::Windows::Forms::Button()); this->btnK = (gcnew System::Windows::Forms::Button()); this->btnL = (gcnew System::Windows::Forms::Button()); this->btnX = (gcnew System::Windows::Forms::Button()); this->btnC = (gcnew System::Windows::Forms::Button()); this->btnV = (gcnew System::Windows::Forms::Button()); this->btnB = (gcnew System::Windows::Forms::Button()); this->btnN = (gcnew System::Windows::Forms::Button()); this->btnM = (gcnew System::Windows::Forms::Button()); this->btn1 = (gcnew System::Windows::Forms::Button()); this->btn2 = (gcnew System::Windows::Forms::Button()); this->btn3 = (gcnew System::Windows::Forms::Button()); this->btn4 = (gcnew System::Windows::Forms::Button()); this->btn5 = (gcnew System::Windows::Forms::Button()); this->btn6 = (gcnew System::Windows::Forms::Button()); this->btn7 = (gcnew System::Windows::Forms::Button()); this->btn8 = (gcnew System::Windows::Forms::Button()); this->btn9 = (gcnew System::Windows::Forms::Button()); this->btn0 = (gcnew System::Windows::Forms::Button()); this->btnSpace = (gcnew System::Windows::Forms::Button()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->button5 = (gcnew System::Windows::Forms::Button()); this->button6 = (gcnew System::Windows::Forms::Button()); this->button7 = (gcnew System::Windows::Forms::Button()); this->btnMinus = (gcnew System::Windows::Forms::Button()); this->button9 = (gcnew System::Windows::Forms::Button()); this->btnBackspace = (gcnew System::Windows::Forms::Button()); this->btnRctrl = (gcnew System::Windows::Forms::Button()); this->btnLalt = (gcnew System::Windows::Forms::Button()); this->button10 = (gcnew System::Windows::Forms::Button()); this->button11 = (gcnew System::Windows::Forms::Button()); this->button12 = (gcnew System::Windows::Forms::Button()); this->button13 = (gcnew System::Windows::Forms::Button()); this->button14 = (gcnew System::Windows::Forms::Button()); this->button15 = (gcnew System::Windows::Forms::Button()); this->button16 = (gcnew System::Windows::Forms::Button()); this->button17 = (gcnew System::Windows::Forms::Button()); this->button18 = (gcnew System::Windows::Forms::Button()); this->button19 = (gcnew System::Windows::Forms::Button()); this->button8 = (gcnew System::Windows::Forms::Button()); this->button20 = (gcnew System::Windows::Forms::Button()); this->buttonLctrl = (gcnew System::Windows::Forms::Button()); this->buttonEsc = (gcnew System::Windows::Forms::Button()); this->buttonF1 = (gcnew System::Windows::Forms::Button()); this->buttonF2 = (gcnew System::Windows::Forms::Button()); this->buttonF3 = (gcnew System::Windows::Forms::Button()); this->buttonF4 = (gcnew System::Windows::Forms::Button()); this->buttonF5 = (gcnew System::Windows::Forms::Button()); this->buttonF6 = (gcnew System::Windows::Forms::Button()); this->buttonF7 = (gcnew System::Windows::Forms::Button()); this->buttonF8 = (gcnew System::Windows::Forms::Button()); this->buttonF9 = (gcnew System::Windows::Forms::Button()); this->buttonF10 = (gcnew System::Windows::Forms::Button()); this->buttonF11 = (gcnew System::Windows::Forms::Button()); this->buttonF12 = (gcnew System::Windows::Forms::Button()); this->buttonCapslock = (gcnew System::Windows::Forms::Button()); this->button21 = (gcnew System::Windows::Forms::Button()); this->button22 = (gcnew System::Windows::Forms::Button()); this->button23 = (gcnew System::Windows::Forms::Button()); this->buttonTab = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // btnQ // this->btnQ->Location = System::Drawing::Point(83, 90); this->btnQ->Name = L"btnQ"; this->btnQ->Size = System::Drawing::Size(36, 34); this->btnQ->TabIndex = 0; this->btnQ->Text = L"Q"; this->btnQ->UseVisualStyleBackColor = true; this->btnQ->Click += gcnew System::EventHandler(this, &frmKeyboard::btnQ_Click); // // btnW // this->btnW->Location = System::Drawing::Point(125, 90); this->btnW->Name = L"btnW"; this->btnW->Size = System::Drawing::Size(35, 34); this->btnW->TabIndex = 1; this->btnW->Text = L"W"; this->btnW->UseVisualStyleBackColor = true; this->btnW->Click += gcnew System::EventHandler(this, &frmKeyboard::btnW_Click); // // btnE // this->btnE->Location = System::Drawing::Point(166, 90); this->btnE->Name = L"btnE"; this->btnE->Size = System::Drawing::Size(35, 34); this->btnE->TabIndex = 2; this->btnE->Text = L"E"; this->btnE->UseVisualStyleBackColor = true; this->btnE->Click += gcnew System::EventHandler(this, &frmKeyboard::btnE_Click); // // btnQuest // this->btnQuest->Location = System::Drawing::Point(474, 170); this->btnQuest->Name = L"btnQuest"; this->btnQuest->Size = System::Drawing::Size(39, 33); this->btnQuest->TabIndex = 3; this->btnQuest->Text = L"\?/"; this->btnQuest->UseVisualStyleBackColor = true; this->btnQuest->Click += gcnew System::EventHandler(this, &frmKeyboard::btnQuest_Click); // // btnEnter // this->btnEnter->Location = System::Drawing::Point(580, 90); this->btnEnter->Name = L"btnEnter"; this->btnEnter->Size = System::Drawing::Size(46, 74); this->btnEnter->TabIndex = 4; this->btnEnter->Text = L"Enter"; this->btnEnter->UseVisualStyleBackColor = true; this->btnEnter->Click += gcnew System::EventHandler(this, &frmKeyboard::btnEnter_Click); // // btnR // this->btnR->Location = System::Drawing::Point(206, 90); this->btnR->Name = L"btnR"; this->btnR->Size = System::Drawing::Size(34, 34); this->btnR->TabIndex = 5; this->btnR->Text = L"R"; this->btnR->UseVisualStyleBackColor = true; this->btnR->Click += gcnew System::EventHandler(this, &frmKeyboard::btnR_Click); // // btnT // this->btnT->Location = System::Drawing::Point(246, 90); this->btnT->Name = L"btnT"; this->btnT->Size = System::Drawing::Size(35, 34); this->btnT->TabIndex = 6; this->btnT->Text = L"T"; this->btnT->UseVisualStyleBackColor = true; this->btnT->Click += gcnew System::EventHandler(this, &frmKeyboard::btnT_Click); // // btnY // this->btnY->Location = System::Drawing::Point(287, 90); this->btnY->Name = L"btnY"; this->btnY->Size = System::Drawing::Size(34, 34); this->btnY->TabIndex = 7; this->btnY->Text = L"Y"; this->btnY->UseVisualStyleBackColor = true; this->btnY->Click += gcnew System::EventHandler(this, &frmKeyboard::btnY_Click); // // btnU // this->btnU->Location = System::Drawing::Point(327, 90); this->btnU->Name = L"btnU"; this->btnU->Size = System::Drawing::Size(35, 34); this->btnU->TabIndex = 8; this->btnU->Text = L"U"; this->btnU->UseVisualStyleBackColor = true; this->btnU->Click += gcnew System::EventHandler(this, &frmKeyboard::btnU_Click); // // btnI // this->btnI->Location = System::Drawing::Point(368, 90); this->btnI->Name = L"btnI"; this->btnI->Size = System::Drawing::Size(34, 34); this->btnI->TabIndex = 9; this->btnI->Text = L"I"; this->btnI->UseVisualStyleBackColor = true; this->btnI->Click += gcnew System::EventHandler(this, &frmKeyboard::btnI_Click); // // btnRshift // this->btnRshift->Location = System::Drawing::Point(519, 170); this->btnRshift->Name = L"btnRshift"; this->btnRshift->Size = System::Drawing::Size(107, 33); this->btnRshift->TabIndex = 10; this->btnRshift->Text = L"shift"; this->btnRshift->UseVisualStyleBackColor = true; this->btnRshift->Click += gcnew System::EventHandler(this, &frmKeyboard::btnRshift_Click); // // btnO // this->btnO->Location = System::Drawing::Point(408, 90); this->btnO->Name = L"btnO"; this->btnO->Size = System::Drawing::Size(34, 34); this->btnO->TabIndex = 11; this->btnO->Text = L"O"; this->btnO->UseVisualStyleBackColor = true; this->btnO->Click += gcnew System::EventHandler(this, &frmKeyboard::btnO_Click); // // btnLshift // this->btnLshift->Location = System::Drawing::Point(24, 170); this->btnLshift->Name = L"btnLshift"; this->btnLshift->Size = System::Drawing::Size(39, 33); this->btnLshift->TabIndex = 12; this->btnLshift->Text = L"shift"; this->btnLshift->UseVisualStyleBackColor = true; // // btnP // this->btnP->Location = System::Drawing::Point(448, 90); this->btnP->Name = L"btnP"; this->btnP->Size = System::Drawing::Size(38, 34); this->btnP->TabIndex = 13; this->btnP->Text = L"P"; this->btnP->UseVisualStyleBackColor = true; this->btnP->Click += gcnew System::EventHandler(this, &frmKeyboard::btnP_Click); // // btnA // this->btnA->Location = System::Drawing::Point(93, 130); this->btnA->Name = L"btnA"; this->btnA->Size = System::Drawing::Size(34, 34); this->btnA->TabIndex = 14; this->btnA->Text = L"A"; this->btnA->UseVisualStyleBackColor = true; this->btnA->Click += gcnew System::EventHandler(this, &frmKeyboard::btnA_Click); // // btnS // this->btnS->Location = System::Drawing::Point(133, 130); this->btnS->Name = L"btnS"; this->btnS->Size = System::Drawing::Size(36, 34); this->btnS->TabIndex = 15; this->btnS->Text = L"S"; this->btnS->UseVisualStyleBackColor = true; this->btnS->Click += gcnew System::EventHandler(this, &frmKeyboard::btnS_Click); // // btnD // this->btnD->Location = System::Drawing::Point(175, 130); this->btnD->Name = L"btnD"; this->btnD->Size = System::Drawing::Size(35, 34); this->btnD->TabIndex = 16; this->btnD->Text = L"D"; this->btnD->UseVisualStyleBackColor = true; this->btnD->Click += gcnew System::EventHandler(this, &frmKeyboard::btnD_Click); // // btnF // this->btnF->Location = System::Drawing::Point(216, 130); this->btnF->Name = L"btnF"; this->btnF->Size = System::Drawing::Size(33, 34); this->btnF->TabIndex = 17; this->btnF->Text = L"F"; this->btnF->UseVisualStyleBackColor = true; this->btnF->Click += gcnew System::EventHandler(this, &frmKeyboard::btnF_Click); // // btnG // this->btnG->Location = System::Drawing::Point(256, 130); this->btnG->Name = L"btnG"; this->btnG->Size = System::Drawing::Size(36, 34); this->btnG->TabIndex = 18; this->btnG->Text = L"G"; this->btnG->UseVisualStyleBackColor = true; this->btnG->Click += gcnew System::EventHandler(this, &frmKeyboard::btnG_Click); // // btnZ // this->btnZ->Location = System::Drawing::Point(102, 170); this->btnZ->Name = L"btnZ"; this->btnZ->Size = System::Drawing::Size(34, 33); this->btnZ->TabIndex = 19; this->btnZ->Text = L"Z"; this->btnZ->UseVisualStyleBackColor = true; this->btnZ->Click += gcnew System::EventHandler(this, &frmKeyboard::btnZ_Click); // // btnH // this->btnH->Location = System::Drawing::Point(298, 130); this->btnH->Name = L"btnH"; this->btnH->Size = System::Drawing::Size(33, 34); this->btnH->TabIndex = 21; this->btnH->Text = L"H"; this->btnH->UseVisualStyleBackColor = true; this->btnH->Click += gcnew System::EventHandler(this, &frmKeyboard::btnH_Click); // // btnJ // this->btnJ->Location = System::Drawing::Point(339, 130); this->btnJ->Name = L"btnJ"; this->btnJ->Size = System::Drawing::Size(32, 34); this->btnJ->TabIndex = 22; this->btnJ->Text = L"J"; this->btnJ->UseVisualStyleBackColor = true; this->btnJ->Click += gcnew System::EventHandler(this, &frmKeyboard::btnJ_Click); // // btnK // this->btnK->Location = System::Drawing::Point(377, 130); this->btnK->Name = L"btnK"; this->btnK->Size = System::Drawing::Size(34, 34); this->btnK->TabIndex = 23; this->btnK->Text = L"K"; this->btnK->UseVisualStyleBackColor = true; this->btnK->Click += gcnew System::EventHandler(this, &frmKeyboard::btnK_Click); // // btnL // this->btnL->Location = System::Drawing::Point(417, 130); this->btnL->Name = L"btnL"; this->btnL->Size = System::Drawing::Size(39, 34); this->btnL->TabIndex = 24; this->btnL->Text = L"L"; this->btnL->UseVisualStyleBackColor = true; this->btnL->Click += gcnew System::EventHandler(this, &frmKeyboard::btnL_Click); // // btnX // this->btnX->Location = System::Drawing::Point(142, 170); this->btnX->Name = L"btnX"; this->btnX->Size = System::Drawing::Size(42, 33); this->btnX->TabIndex = 20; this->btnX->Text = L"X"; this->btnX->UseVisualStyleBackColor = true; this->btnX->Click += gcnew System::EventHandler(this, &frmKeyboard::btnX_Click); // // btnC // this->btnC->Location = System::Drawing::Point(190, 170); this->btnC->Name = L"btnC"; this->btnC->Size = System::Drawing::Size(32, 33); this->btnC->TabIndex = 25; this->btnC->Text = L"C"; this->btnC->UseVisualStyleBackColor = true; this->btnC->Click += gcnew System::EventHandler(this, &frmKeyboard::btnC_Click); // // btnV // this->btnV->Location = System::Drawing::Point(228, 170); this->btnV->Name = L"btnV"; this->btnV->Size = System::Drawing::Size(34, 33); this->btnV->TabIndex = 26; this->btnV->Text = L"V"; this->btnV->UseVisualStyleBackColor = true; this->btnV->Click += gcnew System::EventHandler(this, &frmKeyboard::btnV_Click); // // btnB // this->btnB->Location = System::Drawing::Point(267, 170); this->btnB->Name = L"btnB"; this->btnB->Size = System::Drawing::Size(35, 33); this->btnB->TabIndex = 27; this->btnB->Text = L"B"; this->btnB->UseVisualStyleBackColor = true; this->btnB->Click += gcnew System::EventHandler(this, &frmKeyboard::btnB_Click); // // btnN // this->btnN->Location = System::Drawing::Point(308, 170); this->btnN->Name = L"btnN"; this->btnN->Size = System::Drawing::Size(34, 33); this->btnN->TabIndex = 28; this->btnN->Text = L"N"; this->btnN->UseVisualStyleBackColor = true; this->btnN->Click += gcnew System::EventHandler(this, &frmKeyboard::btnN_Click); // // btnM // this->btnM->Location = System::Drawing::Point(348, 170); this->btnM->Name = L"btnM"; this->btnM->Size = System::Drawing::Size(36, 33); this->btnM->TabIndex = 29; this->btnM->Text = L"M"; this->btnM->UseVisualStyleBackColor = true; this->btnM->Click += gcnew System::EventHandler(this, &frmKeyboard::btnM_Click); // // btn1 // this->btn1->Location = System::Drawing::Point(69, 48); this->btn1->Name = L"btn1"; this->btn1->Size = System::Drawing::Size(39, 36); this->btn1->TabIndex = 30; this->btn1->Text = L"!1"; this->btn1->UseVisualStyleBackColor = true; this->btn1->Click += gcnew System::EventHandler(this, &frmKeyboard::btn1_Click); // // btn2 // this->btn2->Location = System::Drawing::Point(114, 48); this->btn2->Name = L"btn2"; this->btn2->Size = System::Drawing::Size(37, 36); this->btn2->TabIndex = 31; this->btn2->Text = L"@2"; this->btn2->UseVisualStyleBackColor = true; this->btn2->Click += gcnew System::EventHandler(this, &frmKeyboard::btn2_Click); // // btn3 // this->btn3->Location = System::Drawing::Point(159, 48); this->btn3->Name = L"btn3"; this->btn3->Size = System::Drawing::Size(34, 36); this->btn3->TabIndex = 32; this->btn3->Text = L"#3"; this->btn3->UseVisualStyleBackColor = true; this->btn3->Click += gcnew System::EventHandler(this, &frmKeyboard::btn3_Click); // // btn4 // this->btn4->Location = System::Drawing::Point(199, 48); this->btn4->Name = L"btn4"; this->btn4->Size = System::Drawing::Size(32, 36); this->btn4->TabIndex = 33; this->btn4->Text = L"$4"; this->btn4->UseVisualStyleBackColor = true; this->btn4->Click += gcnew System::EventHandler(this, &frmKeyboard::btn4_Click); // // btn5 // this->btn5->Location = System::Drawing::Point(235, 48); this->btn5->Name = L"btn5"; this->btn5->Size = System::Drawing::Size(36, 36); this->btn5->TabIndex = 34; this->btn5->Text = L"%5"; this->btn5->UseVisualStyleBackColor = true; this->btn5->Click += gcnew System::EventHandler(this, &frmKeyboard::btn5_Click); // // btn6 // this->btn6->Location = System::Drawing::Point(277, 48); this->btn6->Name = L"btn6"; this->btn6->Size = System::Drawing::Size(35, 36); this->btn6->TabIndex = 35; this->btn6->Text = L"^6"; this->btn6->UseVisualStyleBackColor = true; this->btn6->Click += gcnew System::EventHandler(this, &frmKeyboard::btn6_Click); // // btn7 // this->btn7->Location = System::Drawing::Point(317, 48); this->btn7->Name = L"btn7"; this->btn7->Size = System::Drawing::Size(35, 36); this->btn7->TabIndex = 36; this->btn7->Text = L"&&7"; this->btn7->UseVisualStyleBackColor = true; this->btn7->Click += gcnew System::EventHandler(this, &frmKeyboard::btn7_Click); // // btn8 // this->btn8->Location = System::Drawing::Point(358, 48); this->btn8->Name = L"btn8"; this->btn8->Size = System::Drawing::Size(35, 36); this->btn8->TabIndex = 37; this->btn8->Text = L"*8"; this->btn8->UseVisualStyleBackColor = true; this->btn8->Click += gcnew System::EventHandler(this, &frmKeyboard::btn8_Click); // // btn9 // this->btn9->Location = System::Drawing::Point(399, 48); this->btn9->Name = L"btn9"; this->btn9->Size = System::Drawing::Size(32, 36); this->btn9->TabIndex = 38; this->btn9->Text = L"(9"; this->btn9->UseVisualStyleBackColor = true; this->btn9->Click += gcnew System::EventHandler(this, &frmKeyboard::btn9_Click); // // btn0 // this->btn0->Location = System::Drawing::Point(437, 48); this->btn0->Name = L"btn0"; this->btn0->Size = System::Drawing::Size(34, 36); this->btn0->TabIndex = 39; this->btn0->Text = L")0"; this->btn0->UseVisualStyleBackColor = true; this->btn0->Click += gcnew System::EventHandler(this, &frmKeyboard::btn0_Click); // // btnSpace // this->btnSpace->Location = System::Drawing::Point(206, 209); this->btnSpace->Name = L"btnSpace"; this->btnSpace->Size = System::Drawing::Size(250, 33); this->btnSpace->TabIndex = 40; this->btnSpace->UseVisualStyleBackColor = true; this->btnSpace->Click += gcnew System::EventHandler(this, &frmKeyboard::btnSpace_Click); // // button1 // this->button1->Location = System::Drawing::Point(390, 170); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(36, 33); this->button1->TabIndex = 41; this->button1->Text = L"<,"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &frmKeyboard::button1_Click); // // button2 // this->button2->Location = System::Drawing::Point(432, 170); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(36, 33); this->button2->TabIndex = 42; this->button2->Text = L">."; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &frmKeyboard::button2_Click); // // button3 // this->button3->Location = System::Drawing::Point(462, 130); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(39, 34); this->button3->TabIndex = 43; this->button3->Text = L":;"; this->button3->UseVisualStyleBackColor = true; this->button3->Click += gcnew System::EventHandler(this, &frmKeyboard::button3_Click); // // button4 // this->button4->Location = System::Drawing::Point(506, 130); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(39, 34); this->button4->TabIndex = 44; this->button4->Text = L"\"\'"; this->button4->UseVisualStyleBackColor = true; this->button4->Click += gcnew System::EventHandler(this, &frmKeyboard::button4_Click); // // button5 // this->button5->Location = System::Drawing::Point(551, 130); this->button5->Name = L"button5"; this->button5->Size = System::Drawing::Size(39, 34); this->button5->TabIndex = 45; this->button5->Text = L"|\\"; this->button5->UseVisualStyleBackColor = true; this->button5->Click += gcnew System::EventHandler(this, &frmKeyboard::button5_Click); // // button6 // this->button6->Location = System::Drawing::Point(492, 90); this->button6->Name = L"button6"; this->button6->Size = System::Drawing::Size(38, 34); this->button6->TabIndex = 46; this->button6->Text = L"{["; this->button6->UseVisualStyleBackColor = true; this->button6->Click += gcnew System::EventHandler(this, &frmKeyboard::button6_Click); // // button7 // this->button7->Location = System::Drawing::Point(536, 90); this->button7->Name = L"button7"; this->button7->Size = System::Drawing::Size(38, 34); this->button7->TabIndex = 47; this->button7->Text = L"}]"; this->button7->UseVisualStyleBackColor = true; this->button7->Click += gcnew System::EventHandler(this, &frmKeyboard::button7_Click); // // btnMinus // this->btnMinus->Location = System::Drawing::Point(474, 48); this->btnMinus->Name = L"btnMinus"; this->btnMinus->Size = System::Drawing::Size(34, 36); this->btnMinus->TabIndex = 48; this->btnMinus->Text = L"_-"; this->btnMinus->UseVisualStyleBackColor = true; this->btnMinus->Click += gcnew System::EventHandler(this, &frmKeyboard::btnMinus_Click); // // button9 // this->button9->Location = System::Drawing::Point(514, 48); this->button9->Name = L"button9"; this->button9->Size = System::Drawing::Size(34, 36); this->button9->TabIndex = 49; this->button9->Text = L"+="; this->button9->UseVisualStyleBackColor = true; this->button9->Click += gcnew System::EventHandler(this, &frmKeyboard::button9_Click); // // btnBackspace // this->btnBackspace->Location = System::Drawing::Point(554, 48); this->btnBackspace->Name = L"btnBackspace"; this->btnBackspace->Size = System::Drawing::Size(72, 36); this->btnBackspace->TabIndex = 50; this->btnBackspace->Text = L"<--"; this->btnBackspace->UseVisualStyleBackColor = true; this->btnBackspace->Click += gcnew System::EventHandler(this, &frmKeyboard::btnBackspace_Click); // // btnRctrl // this->btnRctrl->Location = System::Drawing::Point(568, 212); this->btnRctrl->Name = L"btnRctrl"; this->btnRctrl->Size = System::Drawing::Size(58, 33); this->btnRctrl->TabIndex = 51; this->btnRctrl->Text = L"Ctrl"; this->btnRctrl->UseVisualStyleBackColor = true; this->btnRctrl->Click += gcnew System::EventHandler(this, &frmKeyboard::btnRctrl_Click); // // btnLalt // this->btnLalt->Location = System::Drawing::Point(142, 209); this->btnLalt->Name = L"btnLalt"; this->btnLalt->Size = System::Drawing::Size(58, 33); this->btnLalt->TabIndex = 52; this->btnLalt->Text = L"Alt"; this->btnLalt->UseVisualStyleBackColor = true; this->btnLalt->Click += gcnew System::EventHandler(this, &frmKeyboard::btnLalt_Click); // // button10 // this->button10->Location = System::Drawing::Point(643, 212); this->button10->Name = L"button10"; this->button10->Size = System::Drawing::Size(36, 33); this->button10->TabIndex = 53; this->button10->Text = L"<"; this->button10->UseVisualStyleBackColor = true; this->button10->Click += gcnew System::EventHandler(this, &frmKeyboard::button10_Click); // // button11 // this->button11->Location = System::Drawing::Point(685, 212); this->button11->Name = L"button11"; this->button11->Size = System::Drawing::Size(36, 33); this->button11->TabIndex = 54; this->button11->Text = L"V"; this->button11->UseVisualStyleBackColor = true; this->button11->Click += gcnew System::EventHandler(this, &frmKeyboard::button11_Click); // // button12 // this->button12->Location = System::Drawing::Point(727, 212); this->button12->Name = L"button12"; this->button12->Size = System::Drawing::Size(36, 33); this->button12->TabIndex = 55; this->button12->Text = L">"; this->button12->UseVisualStyleBackColor = true; this->button12->Click += gcnew System::EventHandler(this, &frmKeyboard::button12_Click); // // button13 // this->button13->Location = System::Drawing::Point(685, 173); this->button13->Name = L"button13"; this->button13->Size = System::Drawing::Size(36, 33); this->button13->TabIndex = 56; this->button13->Text = L"^"; this->button13->UseVisualStyleBackColor = true; this->button13->Click += gcnew System::EventHandler(this, &frmKeyboard::button13_Click); // // button14 // this->button14->Location = System::Drawing::Point(641, 90); this->button14->Name = L"button14"; this->button14->Size = System::Drawing::Size(38, 34); this->button14->TabIndex = 57; this->button14->Text = L"Del"; this->button14->UseVisualStyleBackColor = true; this->button14->Click += gcnew System::EventHandler(this, &frmKeyboard::button14_Click); // // button15 // this->button15->Location = System::Drawing::Point(683, 90); this->button15->Name = L"button15"; this->button15->Size = System::Drawing::Size(38, 34); this->button15->TabIndex = 58; this->button15->Text = L"End"; this->button15->UseVisualStyleBackColor = true; this->button15->Click += gcnew System::EventHandler(this, &frmKeyboard::button15_Click); // // button16 // this->button16->Location = System::Drawing::Point(641, 50); this->button16->Name = L"button16"; this->button16->Size = System::Drawing::Size(38, 34); this->button16->TabIndex = 59; this->button16->Text = L"Ins"; this->button16->UseVisualStyleBackColor = true; this->button16->Click += gcnew System::EventHandler(this, &frmKeyboard::button16_Click); // // button17 // this->button17->Location = System::Drawing::Point(683, 50); this->button17->Name = L"button17"; this->button17->Size = System::Drawing::Size(38, 34); this->button17->TabIndex = 60; this->button17->Text = L"Home"; this->button17->UseVisualStyleBackColor = true; this->button17->Click += gcnew System::EventHandler(this, &frmKeyboard::button17_Click); // // button18 // this->button18->Location = System::Drawing::Point(727, 90); this->button18->Name = L"button18"; this->button18->Size = System::Drawing::Size(38, 34); this->button18->TabIndex = 61; this->button18->Text = L"PgDn"; this->button18->UseVisualStyleBackColor = true; this->button18->Click += gcnew System::EventHandler(this, &frmKeyboard::button18_Click); // // button19 // this->button19->Location = System::Drawing::Point(727, 50); this->button19->Name = L"button19"; this->button19->Size = System::Drawing::Size(38, 34); this->button19->TabIndex = 62; this->button19->Text = L"PgUp"; this->button19->UseVisualStyleBackColor = true; this->button19->Click += gcnew System::EventHandler(this, &frmKeyboard::button19_Click); // // button8 // this->button8->Location = System::Drawing::Point(24, 48); this->button8->Name = L"button8"; this->button8->Size = System::Drawing::Size(39, 36); this->button8->TabIndex = 63; this->button8->Text = L"~`"; this->button8->UseVisualStyleBackColor = true; this->button8->Click += gcnew System::EventHandler(this, &frmKeyboard::button8_Click); // // button20 // this->button20->Location = System::Drawing::Point(462, 209); this->button20->Name = L"button20"; this->button20->Size = System::Drawing::Size(58, 33); this->button20->TabIndex = 64; this->button20->Text = L"Alt"; this->button20->UseVisualStyleBackColor = true; this->button20->Click += gcnew System::EventHandler(this, &frmKeyboard::button20_Click); // // buttonLctrl // this->buttonLctrl->Location = System::Drawing::Point(24, 209); this->buttonLctrl->Name = L"buttonLctrl"; this->buttonLctrl->Size = System::Drawing::Size(58, 33); this->buttonLctrl->TabIndex = 65; this->buttonLctrl->Text = L"Ctrl"; this->buttonLctrl->UseVisualStyleBackColor = true; this->buttonLctrl->Click += gcnew System::EventHandler(this, &frmKeyboard::buttonLctrl_Click); // // buttonEsc // this->buttonEsc->Location = System::Drawing::Point(24, -3); this->buttonEsc->Name = L"buttonEsc"; this->buttonEsc->Size = System::Drawing::Size(39, 36); this->buttonEsc->TabIndex = 66; this->buttonEsc->Text = L"Esc"; this->buttonEsc->UseVisualStyleBackColor = true; this->buttonEsc->Click += gcnew System::EventHandler(this, &frmKeyboard::buttonEsc_Click); // // buttonF1 // this->buttonF1->Location = System::Drawing::Point(112, -3); this->buttonF1->Name = L"buttonF1"; this->buttonF1->Size = System::Drawing::Size(39, 36); this->buttonF1->TabIndex = 67; this->buttonF1->Text = L"F1"; this->buttonF1->UseVisualStyleBackColor = true; this->buttonF1->Click += gcnew System::EventHandler(this, &frmKeyboard::buttonF1_Click); // // buttonF2 // this->buttonF2->Location = System::Drawing::Point(154, -3); this->buttonF2->Name = L"buttonF2"; this->buttonF2->Size = System::Drawing::Size(39, 36); this->buttonF2->TabIndex = 68; this->buttonF2->Text = L"F2"; this->buttonF2->UseVisualStyleBackColor = true; this->buttonF2->Click += gcnew System::EventHandler(this, &frmKeyboard::buttonF2_Click); // // buttonF3 // this->buttonF3->Location = System::Drawing::Point(192, -3); this->buttonF3->Name = L"buttonF3"; this->buttonF3->Size = System::Drawing::Size(39, 36); this->buttonF3->TabIndex = 69; this->buttonF3->Text = L"F3"; this->buttonF3->UseVisualStyleBackColor = true; // // buttonF4 // this->buttonF4->Location = System::Drawing::Point(235, -3); this->buttonF4->Name = L"buttonF4"; this->buttonF4->Size = System::Drawing::Size(39, 36); this->buttonF4->TabIndex = 70; this->buttonF4->Text = L"F4"; this->buttonF4->UseVisualStyleBackColor = true; // // buttonF5 // this->buttonF5->Location = System::Drawing::Point(287, -3); this->buttonF5->Name = L"buttonF5"; this->buttonF5->Size = System::Drawing::Size(39, 36); this->buttonF5->TabIndex = 71; this->buttonF5->Text = L"F5"; this->buttonF5->UseVisualStyleBackColor = true; // // buttonF6 // this->buttonF6->Location = System::Drawing::Point(327, -3); this->buttonF6->Name = L"buttonF6"; this->buttonF6->Size = System::Drawing::Size(39, 36); this->buttonF6->TabIndex = 72; this->buttonF6->Text = L"F6"; this->buttonF6->UseVisualStyleBackColor = true; // // buttonF7 // this->buttonF7->Location = System::Drawing::Point(363, -3); this->buttonF7->Name = L"buttonF7"; this->buttonF7->Size = System::Drawing::Size(39, 36); this->buttonF7->TabIndex = 73; this->buttonF7->Text = L"F7"; this->buttonF7->UseVisualStyleBackColor = true; // // buttonF8 // this->buttonF8->Location = System::Drawing::Point(403, -3); this->buttonF8->Name = L"buttonF8"; this->buttonF8->Size = System::Drawing::Size(39, 36); this->buttonF8->TabIndex = 74; this->buttonF8->Text = L"F8"; this->buttonF8->UseVisualStyleBackColor = true; // // buttonF9 // this->buttonF9->Location = System::Drawing::Point(462, -3); this->buttonF9->Name = L"buttonF9"; this->buttonF9->Size = System::Drawing::Size(39, 36); this->buttonF9->TabIndex = 75; this->buttonF9->Text = L"F9"; this->buttonF9->UseVisualStyleBackColor = true; // // buttonF10 // this->buttonF10->Location = System::Drawing::Point(506, -3); this->buttonF10->Name = L"buttonF10"; this->buttonF10->Size = System::Drawing::Size(39, 36); this->buttonF10->TabIndex = 76; this->buttonF10->Text = L"F10"; this->buttonF10->UseVisualStyleBackColor = true; // // buttonF11 // this->buttonF11->Location = System::Drawing::Point(551, -3); this->buttonF11->Name = L"buttonF11"; this->buttonF11->Size = System::Drawing::Size(39, 36); this->buttonF11->TabIndex = 77; this->buttonF11->Text = L"F11"; this->buttonF11->UseVisualStyleBackColor = true; // // buttonF12 // this->buttonF12->Location = System::Drawing::Point(596, -3); this->buttonF12->Name = L"buttonF12"; this->buttonF12->Size = System::Drawing::Size(39, 36); this->buttonF12->TabIndex = 78; this->buttonF12->Text = L"F12"; this->buttonF12->UseVisualStyleBackColor = true; // // buttonCapslock // this->buttonCapslock->Location = System::Drawing::Point(24, 130); this->buttonCapslock->Name = L"buttonCapslock"; this->buttonCapslock->Size = System::Drawing::Size(63, 33); this->buttonCapslock->TabIndex = 79; this->buttonCapslock->Text = L"CapsLock"; this->buttonCapslock->UseVisualStyleBackColor = true; this->buttonCapslock->Click += gcnew System::EventHandler(this, &frmKeyboard::buttonCapslock_Click); // // button21 // this->button21->Location = System::Drawing::Point(641, -1); this->button21->Name = L"button21"; this->button21->Size = System::Drawing::Size(38, 34); this->button21->TabIndex = 80; this->button21->Text = L"Prt Scr"; this->button21->UseVisualStyleBackColor = true; // // button22 // this->button22->Location = System::Drawing::Point(683, -1); this->button22->Name = L"button22"; this->button22->Size = System::Drawing::Size(38, 34); this->button22->TabIndex = 81; this->button22->Text = L"Scr Lck"; this->button22->UseVisualStyleBackColor = true; // // button23 // this->button23->Location = System::Drawing::Point(727, -1); this->button23->Name = L"button23"; this->button23->Size = System::Drawing::Size(38, 34); this->button23->TabIndex = 82; this->button23->Text = L"Pause"; this->button23->UseVisualStyleBackColor = true; // // buttonTab // this->buttonTab->Location = System::Drawing::Point(24, 90); this->buttonTab->Name = L"buttonTab"; this->buttonTab->Size = System::Drawing::Size(53, 33); this->buttonTab->TabIndex = 83; this->buttonTab->Text = L"Tab <-|"; this->buttonTab->UseVisualStyleBackColor = true; this->buttonTab->Click += gcnew System::EventHandler(this, &frmKeyboard::buttonTab_Click); // // frmKeyboard // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(778, 252); this->Controls->Add(this->buttonTab); this->Controls->Add(this->button23); this->Controls->Add(this->button22); this->Controls->Add(this->button21); this->Controls->Add(this->buttonCapslock); this->Controls->Add(this->buttonF12); this->Controls->Add(this->buttonF11); this->Controls->Add(this->buttonF10); this->Controls->Add(this->buttonF9); this->Controls->Add(this->buttonF8); this->Controls->Add(this->buttonF7); this->Controls->Add(this->buttonF6); this->Controls->Add(this->buttonF5); this->Controls->Add(this->buttonF4); this->Controls->Add(this->buttonF3); this->Controls->Add(this->buttonF2); this->Controls->Add(this->buttonF1); this->Controls->Add(this->buttonEsc); this->Controls->Add(this->buttonLctrl); this->Controls->Add(this->button20); this->Controls->Add(this->button8); this->Controls->Add(this->button19); this->Controls->Add(this->button18); this->Controls->Add(this->button17); this->Controls->Add(this->button16); this->Controls->Add(this->button15); this->Controls->Add(this->button14); this->Controls->Add(this->button13); this->Controls->Add(this->button12); this->Controls->Add(this->button11); this->Controls->Add(this->button10); this->Controls->Add(this->btnLalt); this->Controls->Add(this->btnRctrl); this->Controls->Add(this->btnBackspace); this->Controls->Add(this->button9); this->Controls->Add(this->btnMinus); this->Controls->Add(this->button7); this->Controls->Add(this->button6); this->Controls->Add(this->button5); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Controls->Add(this->btnSpace); this->Controls->Add(this->btn0); this->Controls->Add(this->btn9); this->Controls->Add(this->btn8); this->Controls->Add(this->btn7); this->Controls->Add(this->btn6); this->Controls->Add(this->btn5); this->Controls->Add(this->btn4); this->Controls->Add(this->btn3); this->Controls->Add(this->btn2); this->Controls->Add(this->btn1); this->Controls->Add(this->btnM); this->Controls->Add(this->btnN); this->Controls->Add(this->btnB); this->Controls->Add(this->btnV); this->Controls->Add(this->btnC); this->Controls->Add(this->btnL); this->Controls->Add(this->btnK); this->Controls->Add(this->btnJ); this->Controls->Add(this->btnH); this->Controls->Add(this->btnX); this->Controls->Add(this->btnZ); this->Controls->Add(this->btnG); this->Controls->Add(this->btnF); this->Controls->Add(this->btnD); this->Controls->Add(this->btnS); this->Controls->Add(this->btnA); this->Controls->Add(this->btnP); this->Controls->Add(this->btnLshift); this->Controls->Add(this->btnO); this->Controls->Add(this->btnRshift); this->Controls->Add(this->btnI); this->Controls->Add(this->btnU); this->Controls->Add(this->btnY); this->Controls->Add(this->btnT); this->Controls->Add(this->btnR); this->Controls->Add(this->btnEnter); this->Controls->Add(this->btnQuest); this->Controls->Add(this->btnE); this->Controls->Add(this->btnW); this->Controls->Add(this->btnQ); this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; this->MaximizeBox = false; this->Name = L"frmKeyboard"; this->Text = L"FSIM Keyboard"; this->Load += gcnew System::EventHandler(this, &frmKeyboard::frmKeyboard_Load); this->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &frmKeyboard::frmKeyboard_MouseUp); this->ResumeLayout(false); } #pragma endregion private: System::Void btnQuest_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x4A); keybd.Put(0xF0); keybd.Put(0x4A); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnEnter_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x5A); keybd.Put(0xF0); keybd.Put(0x5A); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnRshift_Click(System::Object^ sender, System::EventArgs^ e) { static bool sh = false; if (sh!=0) keybd.Put(0xF0); keybd.Put(0x59); sh = !sh; keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn1_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x16); keybd.Put(0xF0); keybd.Put(0x16); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnD_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x23); keybd.Put(0xF0); keybd.Put(0x23); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnB_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x32); keybd.Put(0xF0); keybd.Put(0x32); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnG_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x34); keybd.Put(0xF0); keybd.Put(0x34); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnQ_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x15); keybd.Put(0xF0); keybd.Put(0x15); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnT_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x2C); keybd.Put(0xF0); keybd.Put(0x2C); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnS_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x1B); keybd.Put(0xF0); keybd.Put(0x1B); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnM_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x3A); keybd.Put(0xF0); keybd.Put(0x3A); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnMinus_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x4E); keybd.Put(0xF0); keybd.Put(0x4E); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnBackspace_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x66); keybd.Put(0xF0); keybd.Put(0x66); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button14_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x71); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x71); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnJ_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x3B); keybd.Put(0xF0); keybd.Put(0x3B); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnSpace_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x29); keybd.Put(0xF0); keybd.Put(0x29); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button10_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x6B); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x6B); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn2_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x1E); keybd.Put(0xF0); keybd.Put(0x1E); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn3_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x26); keybd.Put(0xF0); keybd.Put(0x26); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn4_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x25); keybd.Put(0xF0); keybd.Put(0x25); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn5_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x2E); keybd.Put(0xF0); keybd.Put(0x2E); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn6_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x36); keybd.Put(0xF0); keybd.Put(0x36); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn7_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x3D); keybd.Put(0xF0); keybd.Put(0x3D); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn8_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x3E); keybd.Put(0xF0); keybd.Put(0x3E); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn9_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x46); keybd.Put(0xF0); keybd.Put(0x46); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btn0_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x45); keybd.Put(0xF0); keybd.Put(0x45); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnA_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x1C); keybd.Put(0xF0); keybd.Put(0x1C); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnC_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x21); keybd.Put(0xF0); keybd.Put(0x21); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnE_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x24); keybd.Put(0xF0); keybd.Put(0x24); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnF_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x2B); keybd.Put(0xF0); keybd.Put(0x2B); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnX_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x22); keybd.Put(0xF0); keybd.Put(0x22); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnRctrl_Click(System::Object^ sender, System::EventArgs^ e) { static bool sh = false; keybd.Put(0xE0); if (sh!=0) keybd.Put(0xF0); keybd.Put(0x14); sh = !sh; keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x55); keybd.Put(0xF0); keybd.Put(0x55); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x0E); keybd.Put(0xF0); keybd.Put(0x0E); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnW_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x1D); keybd_status = 0x80; keybd.Put(0xF0); keybd.Put(0x1D); pic1.irqKeyboard = true; } private: System::Void btnR_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x2D); keybd.Put(0xF0); keybd.Put(0x2D); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnY_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x35); keybd.Put(0xF0); keybd.Put(0x35); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnU_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x3C); keybd.Put(0xF0); keybd.Put(0x3C); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnI_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x43); keybd.Put(0xF0); keybd.Put(0x43); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnO_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x44); keybd.Put(0xF0); keybd.Put(0x44); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnP_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x4D); keybd.Put(0xF0); keybd.Put(0x4D); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnH_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x33); keybd.Put(0xF0); keybd.Put(0x33); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnK_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x42); keybd.Put(0xF0); keybd.Put(0x42); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnL_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x4B); keybd.Put(0xF0); keybd.Put(0x4B); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x4C); keybd.Put(0xF0); keybd.Put(0x4C); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x52); keybd.Put(0xF0); keybd.Put(0x52); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnZ_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x1A); keybd.Put(0xF0); keybd.Put(0x1A); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnV_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x2A); keybd.Put(0xF0); keybd.Put(0x2A); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnN_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x31); keybd.Put(0xF0); keybd.Put(0x31); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x41); keybd.Put(0xF0); keybd.Put(0x41); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x49); keybd.Put(0xF0); keybd.Put(0x49); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x5D); keybd.Put(0xF0); keybd.Put(0x5D); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void btnLalt_Click(System::Object^ sender, System::EventArgs^ e) { static bool sh = false; if (sh!=0) keybd.Put(0xF0); keybd.Put(0x11); sh = !sh; keybd_status = 0x80; pic1.irqKeyboard = true; } // Alt private: System::Void button20_Click(System::Object^ sender, System::EventArgs^ e) { static bool sh = false; keybd.Put(0xE0); if (sh!=0) keybd.Put(0xF0); keybd.Put(0x11); sh = !sh; keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void buttonLctrl_Click(System::Object^ sender, System::EventArgs^ e) { static bool sh = false; if (sh!=0) keybd.Put(0xF0); keybd.Put(0x14); sh = !sh; keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button16_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x70); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x70); keybd_status = 0x80; pic1.irqKeyboard = true; } // Home private: System::Void button17_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x6C); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x6C); keybd_status = 0x80; pic1.irqKeyboard = true; } // End private: System::Void button15_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x69); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x69); keybd_status = 0x80; pic1.irqKeyboard = true; } // Cursor down private: System::Void button11_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x72); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x72); keybd_status = 0x80; pic1.irqKeyboard = true; } // Cursor Up private: System::Void button13_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x75); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x75); keybd_status = 0x80; pic1.irqKeyboard = true; } // Cursor right private: System::Void button12_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x74); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x74); keybd_status = 0x80; pic1.irqKeyboard = true; } // page up private: System::Void button19_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x7D); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x7D); keybd_status = 0x80; pic1.irqKeyboard = true; } // page down private: System::Void button18_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0xE0); keybd.Put(0x7A); keybd.Put(0xE0); keybd.Put(0xF0); keybd.Put(0x7A); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x54); keybd.Put(0xF0); keybd.Put(0x54); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x5B); keybd.Put(0xF0); keybd.Put(0x5B); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void buttonEsc_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x76); keybd.Put(0xF0); keybd.Put(0x76); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void buttonF1_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x05); keybd.Put(0xF0); keybd.Put(0x05); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void buttonF2_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x06); keybd.Put(0xF0); keybd.Put(0x06); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void buttonCapslock_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x58); keybd_status = 0x80; keybd.Put(0xF0); keybd.Put(0x58); pic1.irqKeyboard = true; } private: System::Void frmKeyboard_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) { } private: System::Void buttonTab_Click(System::Object^ sender, System::EventArgs^ e) { keybd.Put(0x0D); keybd.Put(0xF0); keybd.Put(0x0D); keybd_status = 0x80; pic1.irqKeyboard = true; } private: System::Void frmKeyboard_Load(System::Object^ sender, System::EventArgs^ e) { } }; }
a2d6f49edee893c1da917d75e78bee37d2631c9f
cb2df16189c50348a40cf1b20d45c35512ee7907
/Queue/Linked_Queue.cpp
cf7089757365d0069312cb1be673aa1687e6f182
[]
no_license
Hqyanyan/DataStructure
0c9b61b396077cbd521697ec907140f92530eede
195c4c0238aefa741cf33f7acc37e950ad3f37bc
refs/heads/master
2020-04-13T11:57:50.406366
2018-12-25T12:09:51
2018-12-25T12:09:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
78
cpp
Linked_Queue.cpp
// // Created by i_still_mess_up on 2018/10/24. // #include "Linked_Queue.h"
337c2bc35526fe7482b6c45b3737f750d0c95d29
e031b8c2267adf33b75880fc109c40526da2e355
/woody01/Budget.cpp
459299e32fec6da5cb767e012c05d6a1bca26fb8
[]
no_license
kartoshka7777/BFU
3dafd6a4cd110cf4d35815506b2525855c6cda48
e7af3ba3fb164d902153034272cf55b7db022f21
refs/heads/master
2018-01-16T07:11:04.095981
2015-05-09T16:59:09
2015-05-09T16:59:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
690
cpp
Budget.cpp
#include "stdafx.h" #include <iostream> #include <string> #include <fstream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int budget; string filename; cin >> filename >> budget; ifstream input(filename + ".tsv"); vector<string> regionname; vector<int> population; int i = 0; while (!input.eof()){ input >> regionname[i] >> population[i]; i=i+1; } int n = i; int sum = 0; for (int i = 0; i < n; i++){ sum = sum + population[i]; } cout << budget / sum <<"\n" ; ofstream output("output.tsv"); for (int i = 0; i < n; i++){ output << regionname[i] << " " << (population[i] * budget / sum) << "\n"; } input.close(); output.close(); return 0; }
a0e22f4c6c96ddc6515219100f1720ffaaad47e2
fe91ffa11707887e4cdddde8f386a8c8e724aa58
/components/gc/core/globals.h
a736d478765b9f87b634434ccf569bdb3030fed7
[ "BSD-3-Clause" ]
permissive
akshaymarch7/chromium
78baac2b45526031846ccbaeca96c639d1d60ace
d273c844a313b1e527dec0d59ce70c95fd2bd458
refs/heads/master
2023-02-26T23:48:03.686055
2020-04-15T01:20:07
2020-04-15T01:20:07
255,778,651
2
1
BSD-3-Clause
2020-04-15T02:04:56
2020-04-15T02:04:55
null
UTF-8
C++
false
false
1,156
h
globals.h
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_GC_CORE_GLOBALS_H_ #define COMPONENTS_GC_CORE_GLOBALS_H_ #include <stddef.h> #include <stdint.h> namespace gc { namespace internal { using Address = uint8_t*; // Page size of normal pages used for allocation. Actually usable area on the // page depends on pager headers and guard pages. constexpr size_t kPageSizeLog2 = 17; constexpr size_t kPageSize = 1 << kPageSizeLog2; // 128 KiB. constexpr size_t kPageOffsetMask = kPageSize - 1; constexpr size_t kPageBaseMask = ~kPageOffsetMask; // Guard pages are always put into memory. Whether they are actually protected // depends on the allocator provided to the garbage collector. constexpr size_t kGuardPageSize = 4096; static_assert((kPageSize & (kPageSize - 1)) == 0, "kPageSize must be power of 2"); static_assert((kGuardPageSize & (kGuardPageSize - 1)) == 0, "kGuardPageSize must be power of 2"); } // namespace internal } // namespace gc #endif // COMPONENTS_GC_CORE_GLOBALS_H_
e2e53912b87e617221da2503830371240c927f2b
b5934ee80bc502d0a8232819ba1365d3d2471d54
/CityRegionGenerator.h
22ada8a22b18e205bdbf269d35c4a354c5a2f31b
[]
no_license
robcarlan/ProceduralCity
b5f54bf911cffe96dc7e087443150c0f3e9c8a0e
be97a52b6a87647c2e15c209dab64a61c32c5dea
refs/heads/master
2020-12-02T22:19:11.841436
2017-12-07T06:52:21
2017-12-07T06:52:21
44,399,025
3
0
null
null
null
null
UTF-8
C++
false
false
2,732
h
CityRegionGenerator.h
#pragma once #ifndef Q_MOC_RUN #include <boost/foreach.hpp> #endif #include <vector> #include <qdebug.h> #include <QElapsedTimer> #include "BuildingRegion.h" #include "BuildingLot.h" #include "IntersectionGeometry.h" #include "RoadGeometry.h" #include "Road.h" #include "Enums.cpp" class CityRegionGenerator { int maxEdgeTraversal; std::map<roadPtr, bool> anticlockwiseVisited; std::map<roadPtr, bool> clockwiseVisited; bool hasVisited(bool side, bool forwards, const roadPtr traversing); bool isValidRegion(bool side, bool forwards, const roadPtr traversing); bool coversIllegalTerritory(std::list<Point> &bounds); //Checks size of region to see if valid. bool isValidRegion(BuildingRegion& test); void flagRoads(std::list<roadPtr> traversing, std::list<bool> side, bool flagFound); //Region generation Point getRegionPoint(roadPtr r1, roadPtr r2, intersectionPtr intersection, bool cw1, bool cw2, float angle1, float angle2); std::list<Point> toRegion(std::list<roadPtr> &roadList, std::list<bool> &travelDirection, std::list<bool> &side, std::list<float>& angles); buildingStyle getBuildingStyle(Point& pos); float getPopDensity(Point &pos); float getHeight(Point &pos); float getHeightValue(float factor); float getRoadWidth(const roadType &road); //Region data QImage *densitySampler; QImage *buildingTypeSampler; QImage *heightSampler; QImage *geogSampler; float minHeight, heightScale; float mainRoadWidth, streetWidth; float minBuildArea, maxBuildArea, randOffset; float minLotDim, maxLotDim; bool allowLotMerge; int seed; public: //Builds regions std::vector<BuildingRegion> createRegions(std::list<roadPtr> const roads, std::list<intersectionPtr> const intersections); void subdivideRegions(std::vector<BuildingRegion>& buildings); void createLotsFromConvexPoly(BuildingRegion& owner, std::list<Point>& bounds, std::list<bool>& roadAccess, std::unique_ptr<std::vector<BuildingLot>>& out); std::list<Point> subdivideBounds(std::list<Point> &bounds); bool shouldSplitBoundsFurther(std::list<Point> &bounds); //Returns longest edge and roughly parallel other edge std::pair<std::pair<Point, Point>, std::pair<Point, Point>> getLongestEdgePair(const std::list<Point> &bounds, const std::list<bool>& hasRoadAccess); BuildingLot createLot(std::list<Point> bounds, BuildingRegion& owner); void setMaxEdges(int max); void setImageData(QImage& density, QImage& buildingType, QImage& height, QImage& geog); void setParams(float minBuildArea, float maxBuildArea, float randomOffset, float minLotDim, float maxLotDim, float mainRoadWidth, float streetWidth, bool allowLotMerge, float minHeight, float heightScale, int seed); CityRegionGenerator(); ~CityRegionGenerator(); };
1ff9e707101b361ed3d832fc4966881d413b90b4
517cfadc80fe404bca3d243fd6d14db8aaf94c70
/TP7 POO/exo4.cpp
1554ce5d6b7eea33ab2fec3ee6828c2ef412a761
[]
no_license
afadili/CPP
cc9cbf11fc40e9aa1574a05d67025ff9b8997771
a55b6e158027a2884df1f983e0dc11f15c6dffb2
refs/heads/master
2020-04-06T18:26:40.177920
2018-11-15T11:28:51
2018-11-15T11:28:51
157,698,387
0
0
null
null
null
null
UTF-8
C++
false
false
660
cpp
exo4.cpp
/* TP7 - La STL Partie 1 Amina FADILI IMAC2 */ #include <iostream> #include <deque> #include <algorithm> int main(int argc, char const *argv[]) { std::deque<int> file; for(unsigned int i=0; i<5; ++i) { file.push_back(rand()%10); } std::cout << "Initialisation de la deque: " << std::endl; for(unsigned int i=0; i<5; ++i) { std::cout << file[i] << " " ; } for(unsigned int i=0; i<5; ++i){ int r = rand()%10; std::cout << "\nIntroduction de " << r << " :"; file.push_front(r); file.pop_back(); std::cout << " " ; for(float j=0 ; j< 5; j++) { std::cout << file[j] << " " ; } } std::cout << std::endl; return 0; }
952229375a15abb24a381ee8467e4204a3e40bdf
b0559426b69bbd175b9584fc393c718875bba639
/66-Exercise6.10/main.cpp
de62bd00d23d9bddd887f4092114a0d3ac5a66ba
[]
no_license
QuangTran304/Cpp-challenge
ca8e58ed78bb9d66c8d6f8c5b6bf197575c736a8
256691a0d8b7e66c1adc757a3ab89363b22215ca
refs/heads/master
2020-06-07T05:21:23.474750
2019-10-08T03:48:30
2019-10-08T03:48:30
192,934,873
0
0
null
null
null
null
UTF-8
C++
false
false
524
cpp
main.cpp
/* * Author: Quang Tran * Date: July 29, 2019 */ #include <iostream> void swapTwoValues(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } int main() { int x = 2; int y = 5; std::cout << "Value of x before swapping: " << x << std::endl; std::cout << "Value of y before swapping: " << y << std::endl; swapTwoValues(&x, &y); std::cout << "Value of x after swapping: " << x << std::endl; std::cout << "Value of y after swapping: " << y << std::endl; return 0; }
fcdaa879372b245d948889231f3f3bbcb95d3cfa
92739d8d44f8cc323f9295c4a48290671030784a
/src/png_image.cpp
dbde2c827d33602d04c834da435dc626c8d796dd
[ "MIT" ]
permissive
alexd2580/2dmarkov
8646bff6d844e5dbb4d1b6a10f88a83326cc5eb2
b2cd98ab9874392801c0d86e0b8d05843c0b5a2d
refs/heads/master
2016-08-12T06:41:36.313810
2016-04-13T16:24:53
2016-04-13T16:24:53
55,787,511
0
0
null
null
null
null
UTF-8
C++
false
false
4,551
cpp
png_image.cpp
#include <iostream> #include "png_image.hpp" using namespace std; PNG_image::PNG_image(string const& fname) : filename(fname) {} PNG_image::PNG_image(string const& fname, PNG_image& ref) : filename(fname) { height = ref.height; width = ref.width; rows = ref.rows; bytes = ref.bytes; } ostream& PNG_image::log(void) { return cout << "[PNG_image] " << filename << ": "; } ostream& PNG_image::err(void) { return cerr << "[PNG_image] " << filename << ": "; } void PNG_image::allocate(size_t h, size_t w, size_t w_bytes) { log() << "Allocating memory for image: " << h << "*" << w << " (" << w_bytes / w << " bytes per pixel)" << endl; height = h; width = w; png_byte** row_ptr = new png_byte*[h]; auto delpp = [filename = filename](png_byte * *ptr) { cout << "deleting row ptr of " << filename << endl; delete[] ptr; }; rows = shared_ptr<png_byte*>(row_ptr, delpp); png_byte* byte_ptr = new png_byte[w_bytes * h]; auto delp = [filename = filename](png_byte * ptr) { cout << "deleting byte ptr of " << filename << endl; delete[] ptr; }; bytes = shared_ptr<png_byte>(byte_ptr, delp); } size_t PNG_image::get_height(void) { return height; } size_t PNG_image::get_width(void) { return width; } bool PNG_image::load(void) { log() << "Loading image" << endl; FILE* fp = fopen(filename.c_str(), "rb"); if(fp == nullptr) { err() << "File could not be opened for reading" << endl; return false; } png_struct* png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if(png_ptr == nullptr) { err() << "Failed to create read struct" << endl; return false; } png_info* info_ptr = png_create_info_struct(png_ptr); if(info_ptr == nullptr) { err() << "Failed to create info struct" << endl; return false; } if(setjmp(png_jmpbuf(png_ptr))) { err() << "i don't know what that does TODO" << endl; return false; } png_init_io(png_ptr, fp); png_read_info(png_ptr, info_ptr); size_t w = png_get_image_width(png_ptr, info_ptr); size_t h = png_get_image_height(png_ptr, info_ptr); size_t bytes_per_row = png_get_rowbytes(png_ptr, info_ptr); allocate(h, w, bytes_per_row); png_byte** row_ptr = rows.get(); png_byte* byte_ptr = bytes.get(); for(size_t y = 0; y < height; y++) row_ptr[y] = byte_ptr + y * bytes_per_row; png_read_image(png_ptr, row_ptr); fclose(fp); return true; } RowPtr PNG_image::get_data(void) { return rows; } bool PNG_image::unload(void) { log() << "Unloading image" << endl; FILE* fp = fopen(filename.c_str(), "wb"); if(fp == nullptr) { err() << "Could not open write file" << endl; return false; } png_structp png_wptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if(png_wptr == nullptr) { err() << "Failed to create write struct" << endl; return false; } png_infop info_wptr = png_create_info_struct(png_wptr); if(info_wptr == nullptr) { err() << "Failed to create info struct" << endl; return false; } if(setjmp(png_jmpbuf(png_wptr))) { err() << "i don't know what that does TODO" << endl; return false; } png_init_io(png_wptr, fp); // Output is 8bit depth, RGBA format. png_set_IHDR(png_wptr, info_wptr, (png_uint_32)width, (png_uint_32)height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_write_info(png_wptr, info_wptr); // To remove the alpha channel for PNG_COLOR_TYPE_RGB format, // Use png_set_filler(). // png_set_filler(png, 0, PNG_FILLER_AFTER); png_write_image(png_wptr, rows.get()); png_write_end(png_wptr, nullptr); fclose(fp); return true; } bool file_exists(const string& fname) { FILE* file = fopen(fname.c_str(), "r"); if(!file) return false; fclose(file); return true; } string PNG_image::next_free_filename(string const& fname) { string name = fname; if(fname.length() >= 5) { size_t splitpoint = fname.length() - 4; string ext = fname.substr(splitpoint); if(ext.compare(".PNG") == 0 || ext.compare(".png") == 0) name = fname.substr(0, splitpoint); } int suffix = 0; string new_name = name + "_" + std::to_string(suffix) + ".png"; while(file_exists(new_name)) { suffix++; new_name = name + "_" + std::to_string(suffix) + ".png"; } return new_name; }
21a77b649f3efa22013a5a26463a2c91fa1956ee
d15f656f56daa0d1cf9d6bdcac9fab7ddbde393b
/UtilityLib/UtilityGlobal.h
59d97ec2bb26e3ff6e8f90c499a179db185fac52
[]
no_license
ljwdust/fold-hcc
814d02a70bdb4fff90385028a2f76aa2a4ae2bb3
fe371809065c292d6f36a1d70f8c6a415dd2bb6e
refs/heads/master
2020-05-18T13:25:47.359249
2014-11-15T02:34:39
2014-11-15T02:34:39
35,209,422
0
0
null
null
null
null
UTF-8
C++
false
false
883
h
UtilityGlobal.h
#pragma once #include "XmlWriter.h" #include <QtXml/QDomDocument> #include <QSharedPointer> #include <QString> #include <QVector> #include <QQueue> #include <QMap> #include <QSet> #include "SurfaceMeshModel.h" using namespace SurfaceMesh; namespace SurfaceMesh{ typedef Eigen::Vector2i Vector2i; typedef Eigen::Vector2d Vector2; typedef Eigen::Vector4d Vector4; } typedef QSharedPointer<SurfaceMeshModel> MeshPtr; QString qStr(const Vector2 &v, char sep = ' '); QString qStr(const Vector3 &v, char sep = ' '); QString qStr(const Vector4 &v, char sep = ' '); Vector3 toVector3(QString string); typedef QVector< QVector<QString> > StrArray2D; typedef QMap< QString, QVariant > PropertyMap; #ifdef Q_OS_WIN #include <direct.h> #define GetCurrentDir _getcwd #else #include <unistd.h> #define GetCurrentDir getcwd #endif QString getcwd();
22ddf3dff5f5bb313ae139d8ce68201b9c84f57a
5c033b6c9a6c277cc678528c3cda42a36e10ca15
/include/Objeto.hpp
08bbda895d3e367e5b5d227d304eec28dbc090fa
[]
no_license
marciomonteiro/INE5420-CG
5fc85e5cdc8e9d5562efe5d3009126c8c610809c
77741108720eaa26fbaa4e90476f19007687ef02
refs/heads/master
2021-01-19T04:34:12.538113
2017-04-15T12:08:54
2017-04-15T12:08:54
84,434,213
1
1
null
2017-04-15T12:09:31
2017-03-09T11:24:47
C++
UTF-8
C++
false
false
1,573
hpp
Objeto.hpp
/* * ================================================ * FEDERAL UNIVERSITY OF SANTA CATARINA * ================================================ * * $Objeto.hpp * * Created on: $13 de mar de 2017. * Authors: Marcio Monteiro and Rodrigo Pedro Marques. * GitHub: https://github.com/marciomonteiro/INE5420-CG.git * Professor: Dr. rer.nat. Aldo von Wangenheim * * This file is part of a project for the INE5420 Computer Graphics * course lectured in Federal University of Santa Catarina. */ #ifndef INCLUDE_OBJETO_HPP_ #define INCLUDE_OBJETO_HPP_ #include <iostream> #include <gtk/gtk.h> #include <string> #include <vector> #include <algorithm> #include "Coordenadas.hpp" #include "Matriz.hpp" #include "Transformacao2D.hpp" class Objeto{ private: std::string nome, tipo; std::vector<Coordenadas> world_coordenadas; std::vector<Coordenadas> normalized_coordenadas; //Joel Santana Approves protected: void setName(std::string& name); void setTipo(std::string& type); public: Objeto(std::string nomeObjeto, std::string tipoObjeto, std::vector<Coordenadas> coordenadas); virtual ~Objeto(){}; std::string getName(); std::string& getTipo(); std::vector<Coordenadas>* getWorldCoordenadas(); std::vector<Coordenadas>* getNormalizedCoordenadas(); void transformaObjeto(Matriz::Matriz<double> matriz); Coordenadas centroDoObjeto(); void normalizaCoordenadas(Matriz::Matriz<double> normalizadora); virtual void desenhar(cairo_t* surf, std::vector<Coordenadas> coords) = 0; //=0 obriga implementar desenhar }; #endif /* INCLUDE_OBJETO_HPP_ */
d084321eb1884c9f5b8078d1ae133f6dcae3b44d
34c81af880b0012bbe03d4fd99b3b012cacaf857
/V_Engine/ModuleEditor.cpp
6368d0002561bdbe108672c3259b1376a6922f59
[]
no_license
Vulpem/V_Terrains
f8783f60fe437cc446add5db107cd2fc4814ebac
d680d2f0373a0a545bf27d68809b3f986e0bd96d
refs/heads/master
2021-07-16T07:37:50.461246
2018-11-26T15:38:44
2018-11-26T15:38:44
109,832,995
0
0
null
2018-03-07T12:53:52
2017-11-07T12:30:34
C
UTF-8
C++
false
false
22,373
cpp
ModuleEditor.cpp
#include "Globals.h" #include "Application.h" #include "ModuleEditor.h" #include "ModuleWindow.h" #include "ModuleInput.h" #include "ModuleAudio.h" #include "ModuleRenderer3D.h" #include "ModuleCamera3D.h" #include "ModulePhysics3D.h" #include "ModuleGOmanager.h" #include "ModuleResourceManager.h" #include "ModuleTerrainTests.h" #include "AllComponents.h" #include "AllResources.h" #include "Imgui/imgui_impl_sdl_gl3.h" #include "OpenGL.h" ModuleEditor::ModuleEditor() : Module() { } // Destructor ModuleEditor::~ModuleEditor() { } // Called before render is available bool ModuleEditor::Init() { LOG("Init editor gui with imgui lib version %s", ImGui::GetVersion()); //Linking ImGUI and the m_window ImGui_ImplSdlGL3_Init(App->m_window->GetWindow()); return true; } void ModuleEditor::OnEnable() { //ImGui_ImplSdlGL3_NewFrame(App->m_window->GetWindow()); //Initializing the strings used to test the editor strcpy(m_toImport, ""); m_selectedGameObject = nullptr; App->m_renderer3D->FindViewPort(0)->m_active = false; m_singleViewportID = App->m_renderer3D->AddViewPort(float2(0, 0), float2(100, 100), App->m_camera->GetDefaultCam()); m_multipleViewportsIDs[0] = App->m_renderer3D->AddViewPort(float2(0, 0), float2(100, 100), App->m_camera->GetDefaultCam()); m_multipleViewportsIDs[1] = App->m_renderer3D->AddViewPort(float2(0, 0), float2(100, 100), App->m_camera->GetTopCam()); m_multipleViewportsIDs[2] = App->m_renderer3D->AddViewPort(float2(0, 0), float2(100, 100), App->m_camera->GetRightCam()); m_multipleViewportsIDs[3] = App->m_renderer3D->AddViewPort(float2(0, 0), float2(100, 100), App->m_camera->GetFrontCam()); OnScreenResize(App->m_window->GetWindowSize().x, App->m_window->GetWindowSize().y); SwitchViewPorts(); strcpy(m_sceneName, ""); } // Called every draw update UpdateStatus ModuleEditor::PreUpdate() { ImGui_ImplSdlGL3_NewFrame(App->m_window->GetWindow()); ImGuiIO IO = ImGui::GetIO(); App->m_input->m_ignoreMouse = IO.WantCaptureMouse; if (IO.WantCaptureKeyboard || IO.WantTextInput) { App->m_input->m_ignoreKeyboard = true; } else { App->m_input->m_ignoreKeyboard = false; } return UpdateStatus::Continue; } UpdateStatus ModuleEditor::Update() { if (App->m_input->GetMouseButton(SDL_BUTTON_RIGHT) == KEY_DOWN || App->m_input->GetMouseButton(SDL_BUTTON_LEFT) == KEY_DOWN) { ViewPort* port = App->m_renderer3D->HoveringViewPort(); if (port != nullptr) { App->m_camera->SetMovingCamera(port->m_camera); } } SelectByViewPort(); if (App->m_input->GetKey(SDL_SCANCODE_SPACE) == KEY_DOWN) { m_displayMultipleViews = !m_displayMultipleViews; SwitchViewPorts(); } return UpdateStatus::Continue; } UpdateStatus ModuleEditor::PostUpdate() { if (m_isTestWindowOpen) { ImGui::ShowTestWindow(); } UpdateStatus ret = MenuBar(); switch (m_multiWindowDisplay) { default: { Outliner(); break; } case 1: { App->m_terrain->DrawUI(); break; } case 2: { Editor(); break; } } Console(); PlayButtons(); AttributeWindow(); SaveLoadPopups(); ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; return ret; } // Called before quitting void ModuleEditor::OnDisable() { ClearConsole(); ImGui_ImplSdlGL3_Shutdown(); } void ModuleEditor::OnPlay() { SwitchViewPorts(); } void ModuleEditor::OnStop() { SwitchViewPorts(); } // ---- Each ViewPort UI ------------------------------------------------------------------- void ModuleEditor::Render(const ViewPort & port) const { if (port.m_withUI) { //Here we put the UI we'll draw for each viewport, since Render is called one time for each port that's active ViewPortUI(port); App->m_renderer3D->DrawLine(m_selectionRay.a, m_selectionRay.b, float4(1.0f, 1.0f, 1.0f, 1.0f)); App->m_renderer3D->DrawLocator(m_selectedRayPos, float4(0.75f, 0.75f, 0.75f, 1)); App->m_renderer3D->DrawLine(m_selectedRayPos, m_selectedRayPos + m_selectRayNormal * 2, float4(1, 1, 0, 1)); if (m_show0Plane) { P_Plane p(0, 0, 0, 1); p.m_axis = true; p.Render(); } } } void ModuleEditor::OnScreenResize(int width, int heigth) { m_screenW = width; m_screenH = heigth; m_viewPortMax.x = m_screenW - 330; m_viewPortMax.y = m_screenH - 200; m_viewPortMin.x = 300; m_viewPortMin.y = 20; //Setting the single ViewPort data ViewPort* port = App->m_renderer3D->FindViewPort(m_singleViewportID); port->m_pos = m_viewPortMin; port->m_size.x = m_viewPortMax.x - m_viewPortMin.x; port->m_size.y = m_viewPortMax.y - m_viewPortMin.y; //Setting the multiple ViewPort data float2 m_size((m_viewPortMax.x - m_viewPortMin.x) / 2, (m_viewPortMax.y - m_viewPortMin.y) / 2); port = App->m_renderer3D->FindViewPort(m_multipleViewportsIDs[0]); port->m_pos = m_viewPortMin; port->m_size = m_size; port = App->m_renderer3D->FindViewPort(m_multipleViewportsIDs[1]); port->m_pos = m_viewPortMin; port->m_pos.x += m_size.x; port->m_size = m_size; port = App->m_renderer3D->FindViewPort(m_multipleViewportsIDs[2]); port->m_pos = m_viewPortMin; port->m_pos.y += m_size.y; port->m_size = m_size; port = App->m_renderer3D->FindViewPort(m_multipleViewportsIDs[3]); port->m_pos = m_viewPortMin; port->m_pos.x += m_size.x; port->m_pos.y += m_size.y; port->m_size = m_size; } void ModuleEditor::HandleInput(SDL_Event* event) { ImGui_ImplSdlGL3_ProcessEvent(event); } void ModuleEditor::Log(const char* m_input) { m_buffer.appendf(m_input); m_scrollToBottom = true; } void ModuleEditor::ClearConsole() { m_buffer.clear(); m_scrollToBottom = true; } void ModuleEditor::SceneTreeGameObject(const Transform* node) { if (node->m_hiddenOnOutliner == false || m_displayHiddenOutlinerGameobjects == true) { ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick; if (m_selectedGameObject == node->GetGameobject()) { node_flags += ImGuiTreeNodeFlags_Selected; } if (node->GetChilds().empty()) { node_flags += ImGuiTreeNodeFlags_Leaf; } char name[256]; sprintf(name, "%s##%llu", node->GetGameobject()->GetName(), node->GetGameobject()->GetUID()); if (ImGui::TreeNodeEx(name, node_flags)) { if (ImGui::IsItemClicked()) { SelectGameObject(node->GetGameobject()); } std::vector<Transform*> childs = node->GetChilds(); for (auto child : childs) { SceneTreeGameObject(child); } ImGui::TreePop(); } } } void ModuleEditor::SelectGameObject(Gameobject* node) { m_selectedGameObject = node; } void ModuleEditor::UnselectGameObject() { m_selectedGameObject = nullptr; } // ---- UI with IMGUI ViewPort UI ------------------------------------------------------------------- UpdateStatus ModuleEditor::MenuBar() { UpdateStatus ret = UpdateStatus::Continue; if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("New Scene##NewMenuBar")) { m_wantNewScene = true; } if (ImGui::MenuItem("Save Scene##SaveMenuBar")) { m_wantToSaveScene = true; } if (ImGui::MenuItem("Load Scene##LoadMenuBar")) { m_wantToLoadScene = true; } if (ImGui::MenuItem("ClearConsole")) { ClearConsole(); } if (ImGui::MenuItem("Quit")) { ret = UpdateStatus::Stop; } ImGui::EndMenu(); } if (ImGui::BeginMenu("Import")) { ImGui::Checkbox("Auto Refresh", &App->m_resourceManager->m_autoRefresh); if (App->m_resourceManager->m_autoRefresh) { ImGui::Text("Auto Refresh delay(seconds):"); ImGui::DragInt("##autoRefreshDelay", &App->m_resourceManager->m_refreshInterval, 1.0f, 1, 600); } ImGui::Separator(); if (ImGui::MenuItem("Refresh Assets")) { App->m_resourceManager->Refresh(); } ImGui::NewLine(); ImGui::NewLine(); ImGui::Separator(); if (ImGui::MenuItem("Reimport All Assets")) { App->m_resourceManager->ReimportAll(); } ImGui::Separator(); ImGui::Text("It may take some time.\nAlso, it may cause\nsome problems if\nthere are already\nassets loaded.\nRecommended to use refresh\nwhen possible"); ImGui::EndMenu(); } if (ImGui::BeginMenu("View")) { if (ImGui::Checkbox("Multiple Views", &m_displayMultipleViews)) { SwitchViewPorts(); } //ImGui::Checkbox("Edit default shaders", &m_openShaderEditor); ImGui::Checkbox("ImGui TestBox", &m_isTestWindowOpen); ImGui::Checkbox("InGame Plane", &m_show0Plane); ImGui::EndMenu(); } if (ImGui::BeginMenu("Create")) { if (ImGui::MenuItem("Empty##CreateEmpty") == true) { App->m_goManager->CreateEmpty(); } if (ImGui::MenuItem("Camera##CreateEmptyCam") == true) { App->m_goManager->CreateCamera(); } ImGui::EndMenu(); } if (ImGui::BeginMenu("Documentation")) { if (ImGui::MenuItem("MathGeoLib")) { App->OpenBrowser("http://clb.demon.fi/MathGeoLib/nightly/reference.html"); } if (ImGui::MenuItem("ImGui")) { App->OpenBrowser("https://github.com/ocornut/imgui"); } if (ImGui::MenuItem("Bullet")) { App->OpenBrowser("http://bulletphysics.org/Bullet/BulletFull/annotated.html"); } if (ImGui::MenuItem("SDL")) { App->OpenBrowser("https://wiki.libsdl.org/APIByCategory"); } ImGui::EndMenu(); } ImGui::EndMainMenuBar(); } return ret; } void ModuleEditor::PlayButtons() { ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar; if (ImGui::Begin("PlayButtons", 0, ImVec2(500, 300), 0.8f, flags)) { ImGui::SetWindowPos(ImVec2(0.0f, 20.0f)); ImGui::SetWindowSize(ImVec2(300.0f, 30.0f)); if (Time.PlayMode == PlayMode::Stop) { if (ImGui::Button("Play##PlayButton")) { Time.PlayMode = PlayMode::DebugPlay; Time.GameRuntime = 0.0f; App->m_goManager->SaveScene("temp"); } } else { if (ImGui::Button("Pause##PauseButton")) { Time.Pause = true; } ImGui::SameLine(); if (ImGui::Button("Stop##StopButton")) { Time.PlayMode = PlayMode::Stop; Time.Pause = false; Time.gdt = 0.0f; App->m_goManager->LoadScene("temp"); } } ImGui::SameLine(); if (ImGui::BeginMenu("Window displayed:")) { if (ImGui::MenuItem("Outliner")) { m_multiWindowDisplay = 0; } if (ImGui::MenuItem("Terrain configuration")) { m_multiWindowDisplay = 1; } if (ImGui::MenuItem("Editor configuration")) { m_multiWindowDisplay = 2; } ImGui::EndMenu(); } ImGui::End(); } } void ModuleEditor::Editor() { ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; if (ImGui::Begin("Editor", 0, ImVec2(500, 300), 0.8f, flags)) { ImGui::SetWindowPos(ImVec2(0.0f, 50.0f)); ImGui::SetWindowSize(ImVec2(300.0f, m_screenH - 250.0f)); if (ImGui::CollapsingHeader("Application")) { ImGui::Text("Time since startup: %f", Time.AppRuntime); ImGui::Text("Game Time: %f", Time.GameRuntime); ImGui::InputInt("Max Framerate:", &App->m_maxFps, 15); char tmp[256]; sprintf(tmp, "Framerate: %i", int(App->m_framerate[EDITOR_FRAME_SAMPLES - 1])); ImGui::PlotHistogram("##Framerate:", App->m_framerate, EDITOR_FRAME_SAMPLES - 1, 0, tmp, 0.0f, 100.0f, ImVec2(310, 100)); char tmp2[256]; sprintf(tmp2, "Ms: %i", int(App->m_msFrame[EDITOR_FRAME_SAMPLES - 1] * 1000)); ImGui::PlotHistogram("##ms", App->m_msFrame, EDITOR_FRAME_SAMPLES - 1, 0, tmp2, 0.0f, 0.07f, ImVec2(310, 100)); } if (ImGui::CollapsingHeader("Input")) { ImGui::LabelText("label", "MouseX: %i", App->m_input->GetMouseX()); ImGui::LabelText("label", "MouseY: %i", App->m_input->GetMouseY()); } if (ImGui::CollapsingHeader("Camera##CameraModule")) { ImGui::Text("Position"); ImGui::Text("Camera speed"); ImGui::DragFloat("##camSpeed", &App->m_camera->m_camSpeed, 0.1f); ImGui::Text("Sprint speed multiplier"); ImGui::DragFloat("##camsprint", &App->m_camera->m_camSprintMultiplier, 0.1f); } if (ImGui::CollapsingHeader("Render")) { ImGui::Text("Global light direction"); ImGui::DragFloat3("##GlobalLightDirection", App->m_renderer3D->m_sunDirection.ptr(), 0.1f, -1.0f, 1.0f); ImGui::Text("Ambient light intensity"); ImGui::DragFloat("##GlobalLightDirection", &App->m_renderer3D->m_ambientLight.x, 0.1f, -1.0f, 1.0f); if (ImGui::TreeNode("Lights")) { for (int nLight = 0; nLight < MAX_LIGHTS; nLight++) { char lightName[46]; sprintf(lightName, "Light %i", nLight); bool on = App->m_renderer3D->m_lights[nLight].m_on; ImGui::Checkbox(lightName, &on); if (on != App->m_renderer3D->m_lights[nLight].m_on) { App->m_renderer3D->m_lights[nLight].Active(on); } if (App->m_renderer3D->m_lights[nLight].m_on == true) { sprintf(lightName, "Expand##Light_%i", nLight); ImGui::SameLine(); if (ImGui::TreeNode(lightName)) { char tmp[46]; sprintf(tmp, "X##light_%i", nLight); ImGui::DragFloat(tmp, &App->m_renderer3D->m_lights[nLight].m_position.x, 1.0f); sprintf(tmp, "Y##light_%i", nLight); ImGui::DragFloat(tmp, &App->m_renderer3D->m_lights[nLight].m_position.y, 1.0f); sprintf(tmp, "Z##light_%i", nLight); ImGui::DragFloat(tmp, &App->m_renderer3D->m_lights[nLight].m_position.z, 1.0f); ImGui::TreePop(); } } } ImGui::TreePop(); } } if (ImGui::CollapsingHeader("Resource Manager")) { ImGui::Text("Loaded resources:"); const std::vector<Resource*> res = App->m_resourceManager->ReadLoadedResources(); if (res.size() > 0) { std::vector<Resource*>::const_iterator it = res.begin(); ComponentType lastType = ComponentType::none; char name[256]; for (; it != res.end(); it++) { if (lastType != (*it)->GetType()) { lastType = (*it)->GetType(); ImGui::Separator(); switch (lastType) { case (ComponentType::GO): { ImGui::Text("GameObjects:"); break; } case (ComponentType::material): { ImGui::Text("Materials:"); break; } case (ComponentType::mesh): { ImGui::Text("Meshes:"); break; } case (ComponentType::texture): { ImGui::Text("Textures:"); break; } } } sprintf(name, "%s", (*it)->m_name.data()); if (ImGui::TreeNode(name)) { ImGui::Text("N references: %u", (*it)->m_numReferences); ImGui::TreePop(); } } } } if (ImGui::CollapsingHeader("Timers##ReadingTimers")) { std::vector<std::pair<std::string, float>> timers = App->m_timers.GetLastReads(); if (timers.empty() == false) { char lastLetter = '0'; for (std::vector<std::pair<std::string, float>>::iterator it = timers.begin(); it != timers.end(); it++) { if (it->first.data()[0] != lastLetter) { lastLetter = it->first.data()[0]; ImGui::Separator(); } ImGui::Text("%*s: %*0.3f ms", 25, it->first.data(), 5, it->second); } } else { ImGui::Text("No timers initialized"); } } ImGui::End(); } } void ModuleEditor::Console() { ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; if (ImGui::Begin("Console", 0, ImVec2(m_screenW - 330.0f, 200.0f), 0.8f, flags)) { ImGui::SetWindowPos(ImVec2(0.0f, m_screenH - 200.0f)); ImGui::SetWindowSize(ImVec2(m_screenW - 330.0f, 200.0f)); ImGui::PushStyleColor(ImGuiCol(0), ImVec4(0.6f, 0.6f, 1.0f, 1.0f)); ImGui::TextUnformatted(m_buffer.begin()); ImGui::PopStyleColor(); if (m_scrollToBottom) ImGui::SetScrollHere(1.0f); m_scrollToBottom = false; ImGui::End(); } } void ModuleEditor::Outliner() { ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; if (ImGui::Begin("Outliner", 0, ImVec2(500, 300), 0.8f, flags)) { ImGui::SetWindowPos(ImVec2(0.0f, 50.0f)); ImGui::SetWindowSize(ImVec2(300.0f, m_screenH - 250.0f)); ImGui::Checkbox("Show hidden objects", &m_displayHiddenOutlinerGameobjects); for (auto node : App->m_goManager->GetRoot()->GetTransform()->GetChilds()) { SceneTreeGameObject(node); } ImGui::End(); } } void ModuleEditor::AttributeWindow() { ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; if (ImGui::Begin("Attribute Editor", 0, flags)) { ImGui::SetWindowPos(ImVec2(m_screenW - 330, 20.0f)); ImGui::SetWindowSize(ImVec2(330, m_screenH - 20)); if (m_selectedGameObject) { m_selectedGameObject->DrawAttributeEditorContent(); ImGui::Separator(); if (ImGui::Button("Look at")) { float3 toLook = m_selectedGameObject->GetTransform()->GetGlobalPos(); App->m_camera->LookAt(float3(toLook.x, toLook.y, toLook.z)); } ImGui::NewLine(); ImGui::Text("Danger Zone:"); if (ImGui::Button("Delete##DeleteGO")) { App->m_goManager->DeleteGameObject(m_selectedGameObject); m_selectedGameObject = nullptr; } } ImGui::End(); } } void ModuleEditor::SwitchViewPorts() { App->m_renderer3D->FindViewPort(m_singleViewportID)->m_active = !m_displayMultipleViews; for (int n = 0; n < 4; n++) { App->m_renderer3D->FindViewPort(m_multipleViewportsIDs[n])->m_active = m_displayMultipleViews; } } void ModuleEditor::ViewPortUI(const ViewPort & port) const { ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize; char tmp[256]; sprintf(tmp, "ViewPortMenu##%i", port.m_ID); ImGui::Begin(tmp, 0, flags); if (ImGui::BeginMenuBar()) { ImGui::SetWindowPos(ImVec2(port.m_pos.x, port.m_pos.y)); ImGui::SetWindowSize(ImVec2(port.m_size.x, 0)); sprintf(tmp, "Display##ViewPort%i", port.m_ID); if (ImGui::BeginMenu(tmp)) { ViewPort* editPort = App->m_renderer3D->FindViewPort(port.m_ID); ImGui::Checkbox("Wired", &editPort->m_useOnlyWires); ImGui::Checkbox("Lightning", &editPort->m_useLighting); ImGui::Checkbox("Render Terrain Heightmap", &editPort->m_renderHeightMap); ImGui::Checkbox("Single sided faces", &editPort->m_useSingleSidedFaces); ImGui::Checkbox("Render Terrain", &editPort->m_renderTerrain); ImGui::Checkbox("Render Terrain Collision", &editPort->m_renderTerrainCollisions); ImGui::Checkbox("Render Chunk Borders", &editPort->m_renderChunkBorders); ImGui::Checkbox("Render Bounding boxes", &editPort->m_renderBoundingBoxes); ImGui::Checkbox("Render QuadTree", &editPort->m_renderQuadTree); ImGui::EndMenu(); } sprintf(tmp, "Camera##ViewPort%i", port.m_ID); if (ImGui::BeginMenu(tmp)) { if (ImGui::BeginMenu("Current Camera")) { ImGui::Text("Name:"); ImGui::Text(port.m_camera->GetOwner()->m_name); ImGui::Separator(); ImGui::NewLine(); if (ImGui::MenuItem("Switch view type")) { App->m_renderer3D->FindViewPort(port.m_ID)->m_camera->SwitchViewType(); } ImGui::EndMenu(); } if (ImGui::BeginMenu("Link new camera")) { std::vector<Camera*> cameras = App->m_goManager->GetComponentsByType<Camera>(ComponentType::camera); for(auto cam : cameras) { if (ImGui::MenuItem(cam->GetOwner()->m_name)) { App->m_renderer3D->FindViewPort(port.m_ID)->m_camera = cam; } } ImGui::EndMenu(); } ImGui::EndMenu(); } sprintf(tmp, "Switch View Type:##%i", port.m_ID); ImGui::EndMenuBar(); } ImGui::End(); } bool ModuleEditor::SaveLoadPopups() { ImGui::SetWindowSize(ImVec2(300, 120)); if (ImGui::BeginPopupModal("New scene")) { m_selectedGameObject = nullptr; bool close = false; ImGui::Text("Save current scene?"); if (ImGui::Button("Yes##saveCurrentButton")) { m_wantToSaveScene = true; m_clearAfterSave = true; } ImGui::SameLine(); if (ImGui::Button("No##NotSaveCurrentButton")) { App->m_goManager->ClearScene(); close = true; } ImGui::SameLine(); if (close || ImGui::Button("Cancel##CancelSaveCurrentButton")) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } ImGui::SetWindowSize(ImVec2(300, 120)); if (ImGui::BeginPopupModal("Save scene")) { bool close = false; ImGui::Text("Scene name:"); ImGui::InputText("##saveSceneInputText", m_sceneName, 256); if (ImGui::Button("Save##saveButton") && m_sceneName[0] != '\0') { App->m_goManager->SaveScene(m_sceneName); close = true; if (m_clearAfterSave) { App->m_goManager->ClearScene(); } } ImGui::SameLine(); if (close || ImGui::Button("Cancel##cancelSaveScene")) { strcpy(m_sceneName, ""); m_clearAfterSave = false; ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } ImGui::SetWindowSize(ImVec2(300, 120)); if (ImGui::BeginPopupModal("Load Scene")) { m_selectedGameObject = nullptr; ImGui::Text("Scene name:"); ImGui::InputText("##saveSceneInputText", m_sceneName, 256); bool close = false; if (ImGui::Button("Load##loadButton") && m_sceneName[0] != '\0') { App->m_goManager->LoadScene(m_sceneName); close = true; } ImGui::SameLine(); if (close || ImGui::Button("Cancel##cancelLoadScene")) { strcpy(m_sceneName, ""); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } if (m_wantNewScene) { ImGui::OpenPopup("New scene"); m_wantNewScene = false; } if (m_wantToSaveScene) { ImGui::OpenPopup("Save scene"); m_wantToSaveScene = false; } if (m_wantToLoadScene) { ImGui::OpenPopup("Load Scene"); m_wantToLoadScene = false; } return false; } void ModuleEditor::SelectByViewPort() { if (App->m_input->GetMouseButton(SDL_BUTTON_LEFT) == KEY_DOWN) { ViewPort* port = nullptr; float2 portPos = App->m_renderer3D->ScreenToViewPort(float2(App->m_input->GetMouseX(), App->m_input->GetMouseY()), &port); //Checking the click was made on a port if (port != nullptr) { //Normalizing the mouse position in port to [-1,1] portPos.x = portPos.x / (port->m_size.x / 2) - 1; portPos.y = portPos.y / (port->m_size.y / 2) - 1; //Generating the LineSegment we'll check for collisions m_selectionRay = port->m_camera->GetFrustum()->UnProjectLineSegment(portPos.x, -portPos.y); Gameobject* out_go = NULL; if (App->m_goManager->RayCast(m_selectionRay, &out_go, &m_selectedRayPos, &m_selectRayNormal, false)) { SelectGameObject(out_go); } else { SelectGameObject(nullptr); } } } }
f077716f57323b1521baf37dcf811b49ddf1c7f7
82b950c78dffdc4ac35c2612f049b8fdbac6c1ef
/engine/file_system/manager/io_manager.h
f9ebf0132d02bc490614e211937971cb94281c60
[]
no_license
OndrejRitomsky/Engine
bdd115cee1b1a8051e158af5c380bb12c10a61c2
a6f7cde9cdb06127f25cb3eaee6ddb0b14b615e3
refs/heads/master
2021-10-10T19:19:58.492770
2019-01-15T17:48:36
2019-01-15T17:48:36
125,720,977
0
0
null
null
null
null
UTF-8
C++
false
false
883
h
io_manager.h
#pragma once #include <core/collection/hashmap.h> #include "../file_system_event.h" #include "../internal/file_system_wrapper.h" namespace eng { class StringHashBank; struct FileSystemEventLoad; class IOManager { private: struct LoadData; public: IOManager(); ~IOManager(); void Init(core::IAllocator* allocator, const StringHashBank* stringBank); void Load(const FileSystemEventLoad* loadEvents, u32 eventsCount); void Update(); void QueryEventsByType(FileSystemEventType type, void* outEvents); void ClearPendingEvents(); private: // @TODO this should be refactored into separate soa structure FileSystemLoadedEvents _loadsFinished; const StringHashBank* _stringBank; FileSystemWrapper _fileSystem; core::HashMap<core::Handle> _resourceToHandleMap; core::HashMap<LoadData> _resourceToLoadData; core::IAllocator* _allocator; }; }
d483134326e60c1f376d65a3e3b1150e9447b7c2
556bc516271dfe48b13850d51a6f65dce425adc4
/acm.timus.ru/1005. Stone Pile/stonepile-2.cpp
6267ebb69c14291683e3155a9571d231c63780a3
[]
no_license
nur-alam/Problem-Solving
4fae30499b5dd802854b7efa0b702b3f173fa236
b0db93d597142590010b60bfa2054409a6ca6754
refs/heads/master
2021-01-13T11:10:06.766089
2019-01-16T12:01:52
2019-01-16T12:01:52
77,365,261
2
0
null
null
null
null
UTF-8
C++
false
false
533
cpp
stonepile-2.cpp
#include <iostream> using namespace std; int bin[100]; int a[30]; void toBin(int x) { int i=0; while(x!=0) { i++; bin[i]=x%2; x=x/2; } } int abs1(int x) { if(x<0) return -x; return x; } int main() { int i,n,m,b,c,d,e,f,sum1,sum2,j,ans=10000000; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<= (1<<n); i++) { toBin(i); sum1=0; sum2=0; for(j=1;j<=n;j++) if(bin[j]==1) sum1=sum1+a[j]; else sum2=sum2+a[j]; ans=min(ans,abs1(sum1-sum2)); } cout<<ans; // your code goes here return 0; }
09800865c7a817ad049ee6ac51c02c2229b1a442
4a2bffbddfdf046ebc4c4c39b42f55bd87962ab2
/J_Server/ActionGame.cpp
8ee85ae18fdfba63d0fc927924441d8dbf210724
[ "MIT" ]
permissive
Inexika/Source-Priston-Tale
cac5ad0cfae10eeb2e5012cfb0bedd04c111d37a
b3061c945273bd48dd7c3d838703cc3e5478f76e
refs/heads/master
2017-12-13T01:12:34.515767
2015-09-06T16:15:26
2015-09-06T16:15:26
null
0
0
null
null
null
null
UHC
C++
false
false
8,878
cpp
ActionGame.cpp
#include "smlib3d\\smd3d.h" #include "smwsock.h" #include "character.h" #include "avictrl.h" #include "playmain.h" #include "srcsound\\dxwav.h" #include "fileread.h" #include "particle.h" #include "netplay.h" #include "sinbaram\\sinlinkheader.h" #include "hobaram\\holinkheader.h" #include "field.h" #include "effectsnd.h" #include "record.h" #include "playsub.h" #include "resource.h" #include "drawsub.h" #include "skillsub.h" #include "language.h" #include "srcserver\\onserver.h" #include "actiongame.h" int ActionKeyAngle; int ActionKeyFlag = 0; int ActionKeySpace = 0; int ActionKeyControl = 0; int ActionKeyDash = 0; DWORD dwActionKeyTime = 0; int ActionDashMode = 0; int ActionKeyOld = 0; short ActionMouseClick[2] = { 0 , 0 }; smCHAR *agFindAttack(); scITEM *agFindItem(); smCHAR *agFindUser(); int ActionGameMain() { int KeyFlag = 0; DWORD dwKeyBitFlag = 0; ActionKeyAngle = 0; if ( lpCurPlayer->MotionInfo->State<0x100 ) { if ( VRKeyBuff[VK_UP] ) { ActionKeyOld = VK_UP; dwKeyBitFlag |= 1; KeyFlag++; } else if ( VRKeyBuff[VK_DOWN] ) { ActionKeyOld = VK_DOWN; dwKeyBitFlag |= 2; KeyFlag++; } if ( VRKeyBuff[VK_RIGHT] ) { if ( !ActionKeyOld && ActionKeyDash==VK_RIGHT && (dwPlayTime-dwActionKeyTime)<500 ) { //๋ฐ์‹œ ์Šคํƒ€ํŠธ ActionDashMode = TRUE; } if ( ActionDashMode && ActionKeyDash!=VK_RIGHT ) ActionDashMode = FALSE; ActionKeyOld = VK_RIGHT; dwKeyBitFlag |= 4; KeyFlag++; } else if ( VRKeyBuff[VK_LEFT] ) { if ( !ActionKeyOld && ActionKeyDash==VK_LEFT && (dwPlayTime-dwActionKeyTime)<500 ) { //๋ฐ์‹œ ์Šคํƒ€ํŠธ ActionDashMode = TRUE; } if ( ActionDashMode && ActionKeyDash!=VK_LEFT ) ActionDashMode = FALSE; ActionKeyOld = VK_LEFT; dwKeyBitFlag |= 8; KeyFlag++; } else { if ( ActionDashMode ) { ActionKeyOld = 0; ActionDashMode = FALSE; } } } if ( !KeyFlag ) { if ( ActionKeyOld ) { ActionKeyDash = ActionKeyOld; dwActionKeyTime = dwPlayTime; ActionKeyOld = 0; } } switch( dwKeyBitFlag ) { case 1: if ( lpCurPlayer->Angle.y<ANGLE_180 ) ActionKeyAngle = 1; else ActionKeyAngle = (-1)&ANGCLIP; break; case 2: if ( lpCurPlayer->Angle.y<ANGLE_180 ) ActionKeyAngle = ANGLE_180-1; else ActionKeyAngle = ANGLE_180+1; break; case 4: ActionKeyAngle = ANGLE_90; break; case 5: ActionKeyAngle = ANGLE_45; break; case 6: ActionKeyAngle = ANGLE_90+ANGLE_45; break; case 8: ActionKeyAngle = ANGLE_270; break; case 9: ActionKeyAngle = ANGLE_270+ANGLE_45; break; case 10: ActionKeyAngle = ANGLE_270-ANGLE_45; break; } if ( KeyFlag ) { lpCurPlayer->Angle.y = ActionKeyAngle; lpCurPlayer->MoveFlag = TRUE; ActionKeyFlag = TRUE; } else if ( ActionKeyFlag==TRUE ) { lpCurPlayer->MoveFlag = FALSE; ActionKeyFlag = FALSE; CancelAttack(); } if ( VRKeyBuff[VK_SPACE] || ActionMouseClick[0]==2 ) { if ( (!ActionKeySpace || ActionMouseClick[0]==2) && lpCurPlayer->MotionInfo->State!=CHRMOTION_STATE_ATTACK ) { smCHAR *lpChar = agFindAttack(); if ( lpChar ) { lpCharSelPlayer = lpChar; lpSelItem = 0; SelMouseButton = 1; TraceAttackPlay(); } else { scITEM *lpItem = agFindItem(); if ( lpItem ) { lpCharSelPlayer = 0; lpSelItem = lpItem; SelMouseButton = 1; TraceAttackPlay(); } else { if ( lpCurPlayer->MotionInfo->State<0x100 ) { lpCurPlayer->SetMotionFromCode(CHRMOTION_STATE_ATTACK); lpCurPlayer->chrAttackTarget = 0; lpCurPlayer->AttackCritcal = -1; } } } } ActionKeySpace = TRUE; ActionMouseClick[0] = 0; } else ActionKeySpace = FALSE; if ( VRKeyBuff[VK_CONTROL] || ActionMouseClick[1] ) { if ( (!ActionKeyControl || ActionMouseClick[1]) && lpCurPlayer->MotionInfo->State!=CHRMOTION_STATE_ATTACK ) { KeyFlag = 1; //๋งˆ์šฐ์Šค ์˜ค๋ฅด์ชฝ ๋ฒ„ํŠผ ๋ˆ„๋ฆ„๊ณผ ๊ฐ™์Œ if ( sinSkill.pRightSkill && lpCurPlayer->MotionInfo->State != CHRMOTION_STATE_ATTACK && lpCurPlayer->MotionInfo->State!=CHRMOTION_STATE_SKILL ) { if ( lpCurPlayer->MotionInfo->State!=CHRMOTION_STATE_EAT) { //์Šคํ‚ฌ ์‚ฌ์šฉ if ( OpenPlaySkill( sinSkill.pRightSkill ) ) KeyFlag = 0; } } if ( KeyFlag ) { smCHAR *lpChar; if ( sinSkill.pRightSkill && ( sinSkill.pRightSkill->CODE==SKILL_HEALING || sinSkill.pRightSkill->CODE==SKILL_ENCHANT_WEAPON || sinSkill.pRightSkill->CODE==SKILL_VIRTUAL_LIFE || sinSkill.pRightSkill->CODE==SKILL_TRIUMPH_OF_VALHALLA ) ) { lpChar = agFindUser(); } else lpChar = agFindAttack(); if ( lpChar ) { lpCharSelPlayer = lpChar; lpSelItem = 0; SelMouseButton = 2; TraceAttackPlay(); } else { scITEM *lpItem = agFindItem(); if ( lpItem ) { lpCharSelPlayer = 0; lpSelItem = lpItem; SelMouseButton = 1; TraceAttackPlay(); } else { if ( lpCurPlayer->MotionInfo->State<0x100 ) { lpCurPlayer->SetMotionFromCode(CHRMOTION_STATE_ATTACK); lpCurPlayer->chrAttackTarget = 0; lpCurPlayer->AttackCritcal = -1; } } } } } ActionKeyControl = TRUE; ActionMouseClick[1] = FALSE; } else ActionKeyControl = FALSE; /* if ( lpCurPlayer->MoveFlag ) { if ( MsTraceMode ) { lpCurPlayer->Angle.y = GetMouseSelAngle(); //if ( ay>=0) lpCurPlayer->Angle.y = ay; } else { lpCurPlayer->Angle.y = GetPlayMouseAngle(); } } */ return TRUE; } smCHAR *agFindAttack() { int cnt; int x,z; int flag; smCHAR *lpSelChar = 0; int AttackRange = 50*fONE; //๋งจ์† ๊ณต๊ฒฉ ๊ฑฐ๋ฆฌ if ( lpCurPlayer->dwActionItemCode ) { AttackRange += lpCurPlayer->AttackToolRange; //๋ฌด๊ธฐ ๊ธธ์ด ๋”ํ•จ } //์›๊ฑฐ๋ฆฌ ๊ณต๊ฒฉ ๊ฑฐ๋ฆฌ if ( lpCurPlayer->ShootingMode ) { AttackRange = lpCurPlayer->smCharInfo.Shooting_Range*fONE; } int lpSelRange = AttackRange; for(int cnt=0;cnt<OTHER_PLAYER_MAX;cnt++) { if ( chrOtherPlayer[cnt].Flag && chrOtherPlayer[cnt].DisplayFlag && chrOtherPlayer[cnt].MotionInfo->State!=CHRMOTION_STATE_DEAD && chrOtherPlayer[cnt].smCharInfo.State!=smCHAR_STATE_USER && chrOtherPlayer[cnt].RendSucess && chrOtherPlayer[cnt].smCharInfo.Brood!=smCHAR_MONSTER_USER ) { flag = 0; z = (lpCurPlayer->pZ - chrOtherPlayer[cnt].pZ)>>FLOATNS; x = abs(lpCurPlayer->pX - chrOtherPlayer[cnt].pX); if ( abs(z)<32 ) flag++; if ( x<AttackRange ) flag++; if ( lpCurPlayer->Angle.y<ANGLE_180 && lpCurPlayer->pX<chrOtherPlayer[cnt].pX ) flag++; else if ( lpCurPlayer->Angle.y>=ANGLE_180 && lpCurPlayer->pX>chrOtherPlayer[cnt].pX ) flag++; if ( flag>=3 ) { if ( !lpSelChar || lpSelRange>x ) { lpSelChar = &chrOtherPlayer[cnt]; lpSelRange = x; } } } } return lpSelChar; } smCHAR *agFindUser() { int cnt; int x,z; int flag; smCHAR *lpSelChar = 0; int AttackRange = 50*fONE; //๋งจ์† ๊ณต๊ฒฉ ๊ฑฐ๋ฆฌ if ( lpCurPlayer->dwActionItemCode ) { AttackRange += lpCurPlayer->AttackToolRange; //๋ฌด๊ธฐ ๊ธธ์ด ๋”ํ•จ } //์›๊ฑฐ๋ฆฌ ๊ณต๊ฒฉ ๊ฑฐ๋ฆฌ if ( lpCurPlayer->ShootingMode ) { AttackRange = lpCurPlayer->smCharInfo.Shooting_Range*fONE; } int lpSelRange = AttackRange; for(int cnt=0;cnt<OTHER_PLAYER_MAX;cnt++) { if ( chrOtherPlayer[cnt].Flag && chrOtherPlayer[cnt].DisplayFlag && chrOtherPlayer[cnt].MotionInfo->State!=CHRMOTION_STATE_DEAD && chrOtherPlayer[cnt].RendSucess && (chrOtherPlayer[cnt].smCharInfo.State==smCHAR_STATE_USER || chrOtherPlayer[cnt].smCharInfo.Brood==smCHAR_MONSTER_USER) ) { flag = 0; z = (lpCurPlayer->pZ - chrOtherPlayer[cnt].pZ)>>FLOATNS; x = abs(lpCurPlayer->pX - chrOtherPlayer[cnt].pX); if ( abs(z)<32 ) flag++; if ( x<AttackRange ) flag++; if ( lpCurPlayer->Angle.y<ANGLE_180 && lpCurPlayer->pX<chrOtherPlayer[cnt].pX ) flag++; else if ( lpCurPlayer->Angle.y>=ANGLE_180 && lpCurPlayer->pX>chrOtherPlayer[cnt].pX ) flag++; if ( flag>=3 ) { if ( !lpSelChar || lpSelRange>x ) { lpSelChar = &chrOtherPlayer[cnt]; lpSelRange = x; } } } } return lpSelChar; } scITEM *agFindItem() { int cnt; int x,z; int flag; scITEM *lpSelItem = 0; int GetRange = 32*fONE; //๋งจ์† ๊ณต๊ฒฉ ๊ฑฐ๋ฆฌ int lpSelRange = GetRange; for(cnt=0;cnt<DISP_ITEM_MAX;cnt++) { if ( scItems[cnt].Flag ) { flag = 0; z = (lpCurPlayer->pZ - scItems[cnt].pZ)>>FLOATNS; x = abs(lpCurPlayer->pX - scItems[cnt].pX); if ( abs(z)<16 ) flag++; if ( x<GetRange ) flag++; //if ( lpCurPlayer->Angle.y<ANGLE_180 && lpCurPlayer->pX<scItems[cnt].pX ) flag++; //else if ( lpCurPlayer->Angle.y>=ANGLE_180 && lpCurPlayer->pX>scItems[cnt].pX ) flag++; if ( flag>=2 ) { if ( !lpSelItem || lpSelRange>x ) { lpSelItem = &scItems[cnt]; lpSelRange = x; } } } } return lpSelItem; }
b0c7be9576d41015a819c4b0b635d45dea465b7a
16c16c50b0af4a7c8cd2cb47f6ec7a8bb03246b6
/file program1.cpp
f6adf618e4344ba5f312ff46144b17eb4d22be42
[]
no_license
satyaaditya/My_C
74c546125ad971d9383ebdf3de9c8b629ce6c6fa
9e7217b2f16f57c47b90e7bf7ced142c8e6baa9a
refs/heads/master
2021-08-14T18:07:33.073993
2017-11-16T11:59:50
2017-11-16T11:59:50
110,708,720
0
0
null
null
null
null
UTF-8
C++
false
false
329
cpp
file program1.cpp
#include<stdio.h> #include<conio.h> int main() { FILE *fp1; char c; fp1=fopen("input.c", "w"); FILE *fp2 = fopen("spam.cpp", "r"); while ((c = getc(fp2)) != EOF) putc(c, fp1); fclose(fp1); fclose(fp2); fp1 = fopen("input", "r"); rewind(fp1); while ((c = getc(fp1)) != EOF) printf("%c", c); fclose(fp1); getch(); }
b7e82fa7c11c2a9549f0611624c436da6d67fbf0
ff5425426a001f6b4450ca3ec067ff666b7f2a1a
/JS-Jet/JetNconstituents/working/JetNconstituents.cc
3db68b40bd4d3c0dfe6981b00abe73c855888ade
[]
no_license
starsdong/analysis
8a07eeffb78e05e3bf8700738ca2eab275ec5b3c
ea8aa2b3806e30f974a0c14fd2d28a1ad5114196
refs/heads/master
2023-06-07T22:34:43.856887
2023-05-24T21:19:41
2023-05-24T21:19:41
78,267,960
0
0
null
2017-01-07T08:30:53
2017-01-07T08:30:53
null
UTF-8
C++
false
false
11,867
cc
JetNconstituents.cc
//____________________________________________________________________________.. #include "JetNconstituents.h" #include <fun4all/Fun4AllReturnCodes.h> #include <fun4all/PHTFileServer.h> #include <phool/PHCompositeNode.h> #include <phool/getClass.h> #include <g4jets/JetMap.h> #include <g4jets/Jetv1.h> #include <centrality/CentralityInfo.h> #include <calobase/RawTower.h> #include <calobase/RawTowerContainer.h> #include <calobase/RawTowerGeom.h> #include <calobase/RawTowerGeomContainer.h> #include <jetbackground/TowerBackground.h> #include <TH2D.h> #include <TH1D.h> #include <iostream> #include <string> #include <vector> //____________________________________________________________________________.. JetNconstituents::JetNconstituents(const std::string &recojetnameR02, const std::string &recojetnameR04, const std::string &recojetnameR06, const std::string &outputfilename): SubsysReco("JetNconstituents_AllR") , m_recojetnameR02(recojetnameR02) , m_recojetnameR04(recojetnameR04) , m_recojetnameR06(recojetnameR06) , m_outputFileName(outputfilename) , m_etaRange(-1.1, 1.1) , m_ptRange(5, 100) { std::cout << "JetNconstituents::JetNconstituents(const std::string& recojetname, const std::string& outputfilename) Calling ctor" << std::endl; } //____________________________________________________________________________.. JetNconstituents::~JetNconstituents() { std::cout << "JetNconstituents::~JetNconstituents() Calling dtor" << std::endl; } //____________________________________________________________________________.. int JetNconstituents::Init(PHCompositeNode *topNode) { std::cout << "JetNconstituents::Init(PHCompositeNode *topNode) Initializing" << std::endl; PHTFileServer::get().open(m_outputFileName, "RECREATE"); std::cout << "JetValidation::Init - Output to " << m_outputFileName << std::endl; // configure Tree h2d_nConstituent_vs_R = new TH2D("h2d_nConstituent_vs_R", "h2d_nConstituent_vs_R", 3, 0, 3, 300, 0, 300); // replace x-axis labels with jet radii h2d_nConstituent_vs_R->GetXaxis()->SetBinLabel(1, "R=0.2"); h2d_nConstituent_vs_R->GetXaxis()->SetBinLabel(2, "R=0.4"); h2d_nConstituent_vs_R->GetXaxis()->SetBinLabel(3, "R=0.6"); h2d_nConstituent_vs_R->GetXaxis()->SetTitle("Jet Radius"); h2d_nConstituent_vs_R->GetYaxis()->SetTitle("Number of Constituents"); h2d_FracEnergy_vs_CaloLayer_R02 = new TH2D("h2d_FracEnergy_vs_CaloLayer_R02", "h2d_FracEnergy_vs_CaloLayer_R02", 3, 0, 3, 100, 0, 1); h2d_FracEnergy_vs_CaloLayer_R02->GetXaxis()->SetTitle("Calorimeter Layer ID"); h2d_FracEnergy_vs_CaloLayer_R02->GetYaxis()->SetTitle("Fraction of Jet Energy"); // replace x-axis labels with calorimeter layer IDs h2d_FracEnergy_vs_CaloLayer_R02->GetXaxis()->SetBinLabel(1, "EMCal"); h2d_FracEnergy_vs_CaloLayer_R02->GetXaxis()->SetBinLabel(2, "HCalIn"); h2d_FracEnergy_vs_CaloLayer_R02->GetXaxis()->SetBinLabel(3, "HCalOut"); h2d_FracEnergy_vs_CaloLayer_R04 = new TH2D("h2d_FracEnergy_vs_CaloLayer_R04", "h2d_FracEnergy_vs_CaloLayer_R04", 5, 0, 3, 100, 0, 1); h2d_FracEnergy_vs_CaloLayer_R04->GetXaxis()->SetTitle("Calorimeter Layer ID"); h2d_FracEnergy_vs_CaloLayer_R04->GetYaxis()->SetTitle("Fraction of Jet Energy"); // replace x-axis labels with calorimeter layer IDs h2d_FracEnergy_vs_CaloLayer_R04->GetXaxis()->SetBinLabel(1, "EMCal"); h2d_FracEnergy_vs_CaloLayer_R04->GetXaxis()->SetBinLabel(2, "HCalIn"); h2d_FracEnergy_vs_CaloLayer_R04->GetXaxis()->SetBinLabel(3, "HCalOut"); h2d_FracEnergy_vs_CaloLayer_R06 = new TH2D("h2d_FracEnergy_vs_CaloLayer_R06", "h2d_FracEnergy_vs_CaloLayer_R06", 5, 0, 3, 100, 0, 1); h2d_FracEnergy_vs_CaloLayer_R06->GetXaxis()->SetTitle("Calorimeter Layer ID"); h2d_FracEnergy_vs_CaloLayer_R06->GetYaxis()->SetTitle("Fraction of Jet Energy"); // replace x-axis labels with calorimeter layer IDs h2d_FracEnergy_vs_CaloLayer_R06->GetXaxis()->SetBinLabel(1, "EMCal"); h2d_FracEnergy_vs_CaloLayer_R06->GetXaxis()->SetBinLabel(2, "HCalIn"); h2d_FracEnergy_vs_CaloLayer_R06->GetXaxis()->SetBinLabel(3, "HCalOut"); h1d_nConstituent_R02 = new TH1D("h1d_nConstituent_R02", "h1d_nConstituent_R02", 350, 0, 350); h1d_nConstituent_R02->GetXaxis()->SetTitle("Number of Constituents"); h1d_nConstituent_R02->GetYaxis()->SetTitle("Number of Jets"); h1d_nConstituent_R04 = new TH1D("h1d_nConstituent_R04", "h1d_nConstituent_R04", 350, 0, 350); h1d_nConstituent_R04->GetXaxis()->SetTitle("Number of Constituents"); h1d_nConstituent_R04->GetYaxis()->SetTitle("Number of Jets"); h1d_nConstituent_R06 = new TH1D("h1d_nConstituent_R06", "h1d_nConstituent_R06", 350, 0, 350); h1d_nConstituent_R06->GetXaxis()->SetTitle("Number of Constituents"); h1d_nConstituent_R06->GetYaxis()->SetTitle("Number of Jets"); return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. int JetNconstituents::InitRun(PHCompositeNode *topNode) { std::cout << "JetNconstituents::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl; return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. int JetNconstituents::process_event(PHCompositeNode *topNode) { //std::cout << "JetValidation::process_event(PHCompositeNode *topNode) Processing Event" << std::endl; std::vector<std::string> m_recojetname_string = {m_recojetnameR02, m_recojetnameR04, m_recojetnameR06}; std::vector<float> m_jet_radii = {0.2, 0.4, 0.6}; int n_radii = m_jet_radii.size(); RawTowerContainer *towersEM3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER"); RawTowerContainer *towersIH3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN"); RawTowerContainer *towersOH3 = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT"); RawTowerGeomContainer *tower_geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN"); RawTowerGeomContainer *tower_geomOH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT"); if(!towersEM3 || !towersIH3 || !towersOH3){ std::cout <<"MyJetAnalysis::process_event - Error can not find raw tower node " << std::endl; exit(-1); } if(!tower_geom || !tower_geomOH){ std::cout <<"MyJetAnalysis::process_event - Error can not find raw tower geometry " << std::endl; exit(-1); } for(int i_radii =0; i_radii<n_radii; i_radii++){ // get reco jet name std::string recojetname = m_recojetname_string[i_radii]; //std::cout << recojetname << std::endl; // get DST reco jet map JetMap* jets = findNode::getClass<JetMap>(topNode, recojetname); if(!jets){ std::cout << "JetNconstituents::process_event - Error can not find DST Reco JetMap node " << recojetname << std::endl; continue; } // loop over jets for(JetMap::Iter iter = jets->begin(); iter != jets->end(); ++iter){ // get jet object Jet* jet = iter->second; // apply eta and pt cuts bool eta_cut = (jet->get_eta() >= m_etaRange.first) and (jet->get_eta() <= m_etaRange.second); bool pt_cut = (jet->get_pt() >= m_ptRange.first) and (jet->get_pt() <= m_ptRange.second); if ((not eta_cut) or (not pt_cut)) continue; // to remove noise jets if(jet->get_pt() < 1) continue; // fill nConstituent vs R if(i_radii==0) h2d_nConstituent_vs_R->Fill(0., jet->size_comp()); else if(i_radii==1) h2d_nConstituent_vs_R->Fill(1., jet->size_comp()); else if(i_radii==2) h2d_nConstituent_vs_R->Fill(2., jet->size_comp()); if(i_radii==0) h1d_nConstituent_R02->Fill(jet->size_comp()); else if(i_radii==1) h1d_nConstituent_R04->Fill(jet->size_comp()); else if(i_radii==2) h1d_nConstituent_R06->Fill(jet->size_comp()); //int n_constituents = 0; float ohcal_energy_sum = 0; float ihcal_energy_sum = 0; float emcal_energy_sum = 0; float jet_energy = jet->get_e(); int n_constituents_emcal = 0; int n_constituents_ihcal = 0; int n_constituents_ohcal = 0; for (Jet::ConstIter comp = jet->begin_comp(); comp != jet->end_comp(); ++comp) { RawTower *tower; if ((*comp).first == 15){ tower = towersIH3->getTower((*comp).second); if(!tower || !tower_geom){ continue; } ihcal_energy_sum += tower->get_energy(); n_constituents_ihcal++; } else if ((*comp).first == 16){ tower = towersOH3->getTower((*comp).second); if(!tower || !tower_geomOH) { continue; } ohcal_energy_sum += tower->get_energy(); n_constituents_ohcal++; } else if ((*comp).first == 14){ tower = towersEM3->getTower((*comp).second); if(!tower || !tower_geom){ continue; } emcal_energy_sum += tower->get_energy(); n_constituents_emcal++; } } float o_hcal_sum = ohcal_energy_sum/jet_energy; float i_hcal_sum = ihcal_energy_sum/jet_energy; float emcal_sum = emcal_energy_sum/jet_energy; if(i_radii==0) { h2d_FracEnergy_vs_CaloLayer_R02->Fill(2., o_hcal_sum); h2d_FracEnergy_vs_CaloLayer_R02->Fill(0., emcal_sum); h2d_FracEnergy_vs_CaloLayer_R02->Fill(1., i_hcal_sum); } else if(i_radii==1) { h2d_FracEnergy_vs_CaloLayer_R04->Fill(2., o_hcal_sum); h2d_FracEnergy_vs_CaloLayer_R04->Fill(0., emcal_sum); h2d_FracEnergy_vs_CaloLayer_R04->Fill(1., i_hcal_sum); } else if(i_radii==2){ h2d_FracEnergy_vs_CaloLayer_R06->Fill(2., o_hcal_sum); h2d_FracEnergy_vs_CaloLayer_R06->Fill(0., emcal_sum); h2d_FracEnergy_vs_CaloLayer_R06->Fill(1., i_hcal_sum); } } } return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. int JetNconstituents::ResetEvent(PHCompositeNode *topNode) { // std::cout << "JetNconstituents::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << std::endl; return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. int JetNconstituents::EndRun(const int runnumber) { std::cout << "JetNconstituents::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl; std::cout << "JetValidation::End - Output to " << m_outputFileName << std::endl; PHTFileServer::get().cd(m_outputFileName); h2d_nConstituent_vs_R->Write(); h1d_nConstituent_R02->Write(); h1d_nConstituent_R04->Write(); h1d_nConstituent_R06->Write(); h2d_FracEnergy_vs_CaloLayer_R02->Write(); h2d_FracEnergy_vs_CaloLayer_R04->Write(); h2d_FracEnergy_vs_CaloLayer_R06->Write(); std::cout << "JetValidation::End(PHCompositeNode *topNode) This is the End..." << std::endl; return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. int JetNconstituents::End(PHCompositeNode *topNode) { std::cout << "JetNconstituents::End(PHCompositeNode *topNode) This is the End..." << std::endl; return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. int JetNconstituents::Reset(PHCompositeNode *topNode) { //std::cout << "JetNconstituents::Reset(PHCompositeNode *topNode) being Reset" << std::endl; return Fun4AllReturnCodes::EVENT_OK; } //____________________________________________________________________________.. void JetNconstituents::Print(const std::string &what) const { std::cout << "JetNconstituents::Print(const std::string &what) const Printing info for " << what << std::endl; }
fabed061dba2871228846c07c23ede16aae9ca6c
44b927b09f8287f4cc79f78040d5fc4effc5e819
/ShaderHandler/flatshader.cpp
97b335ddf33d155e8b4499b0782b3bdb9764019d
[]
no_license
QtOpenGL/Renderable
b6f81855b7e0d4be5d0bab4ed841754591f7f389
abc8c180e609dc02a8737d9af366885995bee264
refs/heads/master
2021-07-12T01:06:23.028736
2017-10-08T21:32:31
2017-10-08T21:32:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
941
cpp
flatshader.cpp
#include "flatshader.h" FlatShader::FlatShader(QObject *parent) : QOpenGLShaderProgram(parent) { } void FlatShader::updateUniforms(QMatrix4x4 &projectionMatrix, QMatrix4x4 &modelViewMatrix) { setUniformValue(m_modelViewMatrixUniform, modelViewMatrix); setUniformValue(m_projecionMatrixUniform, projectionMatrix); } void FlatShader::init() { static_cast<QOpenGLShaderProgram *>(this)->addShaderFromSourceFile(QOpenGLShader::Vertex, "../Renderable/shaders/vert_flat.glsl"); static_cast<QOpenGLShaderProgram *>(this)->addShaderFromSourceFile(QOpenGLShader::Fragment, "../Renderable/shaders/frag_flat.glsl"); static_cast<QOpenGLShaderProgram *>(this)->link(); m_projecionMatrixUniform = uniformLocation("projectionMatrix"); m_modelViewMatrixUniform = uniformLocation("modelViewMatrix"); }
c02ab5b84503d24559ed7ebc2d608b2dcb385d31
bf29f90905c1aa85b6505025679e65e6f910b027
/Code_SASA ์ €์žฅ์†Œ/์ „์ฒด/2231 ๊ฑฐ์Šค๋ฆ„๋ˆ(Q).cpp
acb552bd7c8896a3cc5a21d3e8cdca82910eb71d
[]
no_license
Pentagon03/Code-SASA
a56c7a3703bf3342ebc85fa83fbd5ee77fb99b98
ffecf9f8f70722f58abbcb0f71fb0b9feacc2f79
refs/heads/master
2022-12-14T16:59:42.704313
2020-09-10T08:52:34
2020-09-10T08:52:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
565
cpp
2231 ๊ฑฐ์Šค๋ฆ„๋ˆ(Q).cpp
#include <stdio.h> #include <memory.h> #include <queue> using namespace std; queue<int> Q; int m, n, coin[10]; int main() { scanf("%d %d", &m, &n); for(int i=0; i<n; i++) scanf("%d", &coin[i]); int v[100000],flag=0; for(int i=1;i<=m;i++) v[i]=0; Q.push(0); v[0]=0; while(!Q.empty()){ int x=Q.front(); Q.pop(); for(int i=n-1;i>=0;i--){ int k=x+coin[i]; if((k<=m)&&!v[k]) v[k]=v[x]+1,Q.push(k); if(k==m){ flag=1; break; } } if(flag) break; } printf("%d",v[m]?v[m]:99999); return 0; }
944de88c4787f25dab7d2f00fbb650afb7d66cfc
9a6dee1aebf98224ef631d009d63c4490d5d85a2
/include/AABB.h
04933fb56e52b29ea74449ff0d06f6c3587a4f33
[]
no_license
agjaeger/rt-one-weekend
f8a80464c4bf9afffec6acb99e9993160b948eb4
fa9d0a0bee67c940eb2be9a35edfd8ddebc82c04
refs/heads/master
2020-04-05T01:24:40.555143
2018-11-06T19:19:11
2018-11-06T19:19:11
156,435,051
0
0
null
null
null
null
UTF-8
C++
false
false
779
h
AABB.h
#pragma once #include "Vector3.h" #include "Ray.h" using namespace rtow::math; namespace rtow { namespace scene { inline float min (float a, float b) { return a < b ? a : b; } inline float max (float a, float b) { return a > b ? a : b; } class AABB { public: AABB (); AABB (Vector3 min, Vector3 max); Vector3 min (); Vector3 max (); bool intersect (Ray r, float tMin, float tMax); private: Vector3 m_min; Vector3 m_max; }; AABB surroundingBox (AABB box1, AABB box2); }; };
bfe8394f6d731e673e4de1b696dd305ad57e63c0
59683a2da3eab2b0eaa63f7f538ec7a487aaaee2
/v2offer/07_ConstructBinaryTree/main.cc
f5a699c6f3e09c9eb5d850c26568ca3690745a64
[]
no_license
abowloflrf/ALGS
19767c221141a996299972ad2ec8ba61e00d27fa
246dfed4aa37d77f2c39b9fbd3dd400ef1cd69b9
refs/heads/master
2021-12-29T07:42:59.426186
2021-10-25T09:55:28
2021-10-25T09:55:28
104,883,900
0
0
null
null
null
null
UTF-8
C++
false
false
2,218
cc
main.cc
#include <iostream> #include <vector> using namespace std; class BinaryTreeNode { public: int data; BinaryTreeNode *lchild, *rchild; BinaryTreeNode(int val) { this->data = val; this->rchild = this->lchild = NULL; } }; BinaryTreeNode* constructCore(int* startPreOrder, int* endPreOrder, int* startInOrder, int* endInOrder) { //ๅ‰ๅบ้ๅކ็š„็ฌฌไธ€ไธช่Š‚็‚นๅฐฑๆ˜ฏๆ ‘็š„ๆ น่Š‚็‚น int rootData = startPreOrder[0]; BinaryTreeNode* root = new BinaryTreeNode(rootData); //ๆ ‘ๅชๆœ‰ไธ€ไธช่Š‚็‚น if (startPreOrder == endPreOrder) { if (startInOrder == endInOrder) return root; else { cout << "Invalid Input" << endl; exit; } } //ๅœจไธญๅบไธญๆ‰พๅˆฐๆ น่Š‚็‚น int* rootInOrder = startInOrder; while (rootInOrder <= endInOrder && *rootInOrder != rootData) rootInOrder++; //ๅœจไธญๅบไธญๆœชๆ‰พๅˆฐๆ น่Š‚็‚นๅˆ™ๆŠ›ๅ‡บ้”™่ฏฏ if (rootInOrder == startInOrder && *rootInOrder != rootData) { cout << "Invalid Input" << endl; exit; } int leftLength = rootInOrder - startInOrder; //ๅทฆๅญๆ ‘้•ฟๅบฆ int* leftPreOrderEnd = startPreOrder + leftLength; //ๅ‰ๅบไธญๅทฆๅญๆ ‘็ป“ๆŸๆŒ‡้’ˆ //ๅทฆๅญๆ ‘้•ฟๅบฆๅคงไบŽ0ๅˆ™ๆž„ๅปบๅทฆๅญๆ ‘ if (leftLength > 0) { root->lchild = constructCore(startPreOrder + 1, leftPreOrderEnd, startInOrder, rootInOrder - 1); } //ๅณๅญๆ ‘ๅ•†้ƒฝๅคงไบŽ0ๅˆ™ๆž„ๅปบๅณๅญๆ ‘ if (leftLength < endPreOrder - startPreOrder) { root->rchild = constructCore(leftPreOrderEnd + 1, endPreOrder, rootInOrder + 1, endInOrder); } return root; } BinaryTreeNode* construct(int* preOrder, int* inOrder, int length) { if (preOrder == NULL || inOrder == NULL || length == 0) return NULL; return constructCore(preOrder, preOrder + length - 1, inOrder, inOrder + length - 1); }; int main() { int preOrder[] = {1, 2, 4, 7, 3, 5, 6, 8}; int inOrder[] = {4, 7, 2, 1, 5, 3, 8, 6}; int length = 8; BinaryTreeNode* root = construct(preOrder, inOrder, length); return 0; }
4fdda6a8c0f699db18ff9d099c3f7a3101a389ee
d6249a6c85101170b3e0dd548ca6982bc8a94fbd
/Chef/NOV17/PERPALIN.cpp
9e5fbe916ed1c74e1ac72054ba526b58386ac4e9
[]
no_license
anshumanv/Competitive
bb5c387168095f3716cabc6c591c3b7697da64da
828d07ad5217de06736ae538f54524092ec99af4
refs/heads/master
2021-08-19T08:35:30.019660
2017-11-25T14:38:38
2017-11-25T14:38:38
81,228,891
0
0
null
null
null
null
UTF-8
C++
false
false
438
cpp
PERPALIN.cpp
#include<bits/stdc++.h> #define newl "\n" #define MODULO 1000000007 using namespace std; int main(){ std::ios::sync_with_stdio(false); int t; cin >> t; while(t--) { int n, p; cin >> n >> p; if(p <3 || n < 3) cout << "impossible" << newl; else { int rep = n/p; string s = "a"; for(int i = 0; i<p-2; i++) s+='b'; s+='a'; for(int i = 0; i<rep; i++) cout << s; cout << newl; } } return 0; }
0b236294a29d0384158c4b6627d63b3488a30004
234343824d174f1d985e6ff5e0c13426f2bed717
/VijverSpoeling.ino
4a93a55b529c9bce0507916147c56a8746a735d8
[]
no_license
Arno-Z/VijverSpoeling
a67d69f6fad5d509d0e7f3172d49ef35cef3caf9
46dc44a40ec0a91dd4899e5d5a633226a44a5977
refs/heads/master
2021-08-10T13:26:25.402840
2017-11-12T16:01:32
2017-11-12T16:01:32
110,445,646
0
0
null
null
null
null
UTF-8
C++
false
false
1,856
ino
VijverSpoeling.ino
// the setup function runs once when you press reset or power the board int levelSensorClean=2; int levelSensorAlarm=3; int motorRelais=10; int solenoirRelais=11; int alarmRelais=4; int pollingTime = 5000; //ms int cycleTime = 30000; //ms bool alarmState = false; void setup() { // initialize digital pin LED_BUILTIN as an output. Serial.begin(9600); pinMode(levelSensorClean, INPUT_PULLUP); pinMode(levelSensorAlarm, INPUT_PULLUP); pinMode(solenoirRelais, OUTPUT); pinMode(motorRelais, OUTPUT); pinMode(alarmRelais,OUTPUT); pinMode(13, OUTPUT); digitalWrite(solenoirRelais, HIGH); digitalWrite(motorRelais, HIGH); } // the loop function runs over and over again forever void loop() { int sensorValClean = digitalRead(levelSensorClean); if (sensorValClean == HIGH) { //Initialize the flush cycle Serial.println("Reinigen"); if (alarmState == false){ performClean(); } else { Serial.println("Reinigen negeren, laag niveau alarm"); } //Check if level did not recuce during clean int sensorValAlarm = digitalRead(levelSensorAlarm); if (sensorValAlarm == HIGH) { Serial.println("Laag niveau alarm"); digitalWrite(alarmRelais,HIGH); alarmState = true; } else { digitalWrite(alarmRelais,LOW); alarmState = false; } } else { Serial.println("Wacht"); }; delay(pollingTime); } void performClean(){ Serial.println("Start reinigen"); digitalWrite(LED_BUILTIN, HIGH); digitalWrite(solenoirRelais, LOW); digitalWrite(motorRelais, LOW); delay(cycleTime); Serial.println("Reinigen voltooid"); digitalWrite(LED_BUILTIN, LOW); digitalWrite(solenoirRelais, HIGH); digitalWrite(motorRelais, HIGH); }
045d31933c834c93160f2f1d70e3bd691600713f
d379f49b5a35d7816de80bc6467583979f7311a9
/src/graphics/sdl/sdl_level.hh
eec225944f5c4c8902d41086fa62bdb8a7b7d297
[]
no_license
hansottowirtz/pacman
aee8bda98fef95e0273a25dca63f9657739c11be
f34b83a3e7c3660fa36d1975d58995424ee1d8bb
refs/heads/master
2021-01-24T04:42:52.495337
2018-06-25T11:59:41
2018-06-25T11:59:41
122,947,289
0
0
null
null
null
null
UTF-8
C++
false
false
400
hh
sdl_level.hh
#pragma once #include "../../core/level.hh" #include "../../core/map_ref.hh" #include "./sdl_window.hh" #include <string> class SDLLevel : public Level { public: SDLLevel(LevelRef ref); void setWindow(SDLWindow* window); void setLevel(MapRef mapRef); void visualize(); void rerender(); private: SDLWindow* window; SDLLevel* level; };
4cb5ac4ce42fe161a3776354cb18fa4a3cceeb5d
1c7af5c70acff9b0699ad6241b151c30b31d1423
/src/core/game_object/include/dog.h
fdf30d56d82c715cd9dd6574b151b590c2175cf6
[]
no_license
vkaytsanov/DuckHunt
79a2512972d9b6b315e2df629d6e150325ff04fa
dede24c70db7165b93fb1918e0524b7f40cf4854
refs/heads/master
2023-03-01T11:13:07.145655
2021-02-09T21:32:55
2021-02-09T21:32:55
321,346,083
0
0
null
null
null
null
UTF-8
C++
false
false
746
h
dog.h
// // Created by Viktor on 17.1.2021 ะณ.. // #ifndef DOG_H #define DOG_H #include "../generic/include/entity_animated.h" #include "../generic/include/sprite_parsable.h" enum DogState{ Sniffing, Jumping, Laughing, OneDuck, TwoDucks }; class Dog : public EntityAnimated, public SpriteParsable{ private: int RENDERING_WIDTH = 120; int RENDERING_HEIGHT = 100; float stateTime = 0.0f; Animation<TextureRegion> animations[3]; TextureRegion ducks[2]; DogState currentState; bool drawBefore = false; public: void loadEntity(Assets& assets) override; void processAnimation(float dt) override; void setState(DogState state); void resetStateTime(); bool isDrawBefore() const; void setDrawBefore(bool drawBefore); }; #endif //DOG_H
6e95d717d704b4dfc8018e8eb3fc7f90bddd664b
cb838e41a4ae8f21860cfe5a17a80a105915734a
/temp_sensor/code.cpp
e1e00f4c8d11f4e4d3f891aff56d3e4d609d766f
[ "BSD-2-Clause" ]
permissive
UCLA-ECE209AS-2018W/Dinggao-Ying
0b63b6032105a9200aa8816b35336e470e8c7b1a
87e2de985880e1c549ce5babdaf14842c76bb886
refs/heads/master
2021-04-06T19:38:51.542814
2018-03-26T05:14:37
2018-03-26T05:14:37
125,327,371
1
0
null
null
null
null
UTF-8
C++
false
false
5,146
cpp
code.cpp
/* ###*B*### * Erika Enterprise, version 3 * * Copyright (C) 2017 Evidence s.r.l. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License, version 2, for more details. * * You should have received a copy of the GNU General Public License, * version 2, along with this program; if not, see * <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html >. * * This program is distributed to you subject to the following * clarifications and special exceptions to the GNU General Public * License, version 2. * * THIRD PARTIES' MATERIALS * * Certain materials included in this library are provided by third * parties under licenses other than the GNU General Public License. You * may only use, copy, link to, modify and redistribute this library * following the terms of license indicated below for third parties' * materials. * * In case you make modified versions of this library which still include * said third parties' materials, you are obligated to grant this special * exception. * * The complete list of Third party materials allowed with ERIKA * Enterprise version 3, together with the terms and conditions of each * license, is present in the file THIRDPARTY.TXT in the root of the * project. * ###*E*### */ /** \file code.cpp * \brief Main application. * * This file contains the code of main application for Erika Enterprise. * * \author Giuseppe Serano * \date 2017 */ /* ERIKA Enterprise. */ #include "ee.h" /* Arduino SDK. */ #include "Arduino.h" #include "OneWire.h" #include "DallasTemperature.h" #include "mcp_can.h" /* * Pin 13 has an LED connected on most Arduino boards. * give it a name: */ int led = 13; unsigned int volatile TaskL1_count; #define ONE_WIRE_BUS 9 const int SPI_CS_PIN = 10; unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; boolean volatile stk_wrong = false; OsEE_addr volatile old_sp; extern "C" { DeclareTask(TaskL1); DeclareTask(TaskL2); MCP_CAN CAN(SPI_CS_PIN); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); DeviceAddress deviceAddress; void idle_hook (void); } #if (defined(OSEE_API_DYNAMIC)) TaskType TaskL1; //TaskType TaskL2; #endif /* OSEE_API_DYNAMIC */ void loop(void) { ActivateTask(TaskL1); if ( !stk_wrong ) { if (!old_sp) { old_sp = osEE_get_SP(); } else if (old_sp != osEE_get_SP()) { stk_wrong = true; digitalWrite(led, HIGH); } } } void setup(void) { /* initialize the digital pin as an output. */ //pinMode(led, OUTPUT); Serial.begin(115200); while (CAN_OK != CAN.begin(CAN_500KBPS)) { Serial.println("CAN BUS Shield init fail"); Serial.println(" Init CAN BUS Shield again"); delay(100); } Serial.println("CAN BUS Shield init ok!"); Serial.println("Arduino Digital Temperature // Serial Monitor Version"); //Print a message sensors.begin(); sensors.getAddress(deviceAddress, 0); } void idle_hook (void) { loop(); if (serialEventRun) serialEventRun(); } int main(void){ init(); setup(); #if defined(USBCON) USBDevice.attach(); #endif #if (defined(OSEE_API_DYNAMIC)) CreateTask( &TaskL1, /* taskIdRef */ OSEE_TASK_TYPE_BASIC, /* taskType */ TASK_FUNC(TaskL1), /* taskFunc */ 1U, /* readyPrio */ 1U, /* dispatchPrio */ 1U, /* maxNumOfAct */ OSEE_SYSTEM_STACK /* stackSize */ ); //CreateTask( //&TaskL2, /* taskIdRef */ //OSEE_TASK_TYPE_BASIC, /* taskType */ //TASK_FUNC(TaskL2), /* taskFunc */ //2U, /* readyPrio */ //2U, /* dispatchPrio */ //1U, /* maxNumOfAct */ //OSEE_SYSTEM_STACK /* stackSize */ //); SetIdleHook(idle_hook); #endif /* OSEE_API_DYNAMIC */ StartOS(OSDEFAULTAPPMODE); return 0; } TASK(TaskL1) { sensors.requestTemperatures(); Serial.print("Temperature is: "); Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire temp_num = sensors.getTemp(deviceAddress); // hex temp stmp[0] = (temp_num >> 56) & 0xFF; stmp[1] = (temp_num >> 48) & 0xFF; stmp[2] = (temp_num >> 40) & 0xFF; stmp[3] = (temp_num >> 32) & 0xFF; stmp[4] = (temp_num >> 24) & 0xFF; stmp[5] = (temp_num >> 16) & 0xFF; stmp[6] = (temp_num >> 8) & 0xFF; stmp[7] = temp_num & 0xFF; Serial.write(stmp, 8); Serial.write("\n"); while(Serial.read() == 'i') { for (int i = 0; i < 8; i++) { stmp[i] = Serial.read(); // Serial.print(stmp[i]); } // Serial.print(" was send. \n"); } CAN.sendMsgBuf(0x01,0, 8, stmp); delay(1000); ++TaskL1_count; TerminateTask(); };
9db7398499defbd2ebb0994e00583f9ff9943fa5
e8a39f1ddefae7f39f9fba4cd8a188c08fbf2a06
/admin.cpp
38b5393d861d300152618c5ddd7bcb38ce1f742e
[]
no_license
Asmaroth/Mediatheque
3673f2f96f94e052664d43b9a006ea69e3071767
80227ad31fc714ca83b429fabd7f79d0de5988a0
refs/heads/master
2021-01-19T22:08:42.732426
2017-05-16T08:56:58
2017-05-16T08:56:58
88,759,038
0
0
null
null
null
null
UTF-8
C++
false
false
933
cpp
admin.cpp
#include "admin.hpp" admin::admin(){ id = "200"; nom = "Inconnu"; prenom = "Inconnu"; initTableau(resReservee, LIMITE_RESERVATION); resRendue; initTableau(resEmpruntee, LIMITE_EMPRUNT); initTableau(dateEmprunt, LIMITE_EMPRUNT); mdp = "aaaaaaaa"; //8 a } /*admin::admin(int _id, std::string _nom, std::string _prenom, std::string *_resReservee, media *_resRendue, std::string _resEmpruntee, int *_dateEmprunt, std::string _mdp, std::string _mdp){ id = _id nom = _nom; prenom = _prenom; initTableau(resReservee, LIMITE_RESERVATION); initTableau(resEmpruntee, LIMITE_EMPRUNT); initTableau(dateEmprunt, LIMITE_EMPRUNT); mdp = "aaaaaaaa"; //8 a }*/ admin::~admin(){} void admin::setMdp(std::string _mdp){ mdp = _mdp; } std::string admin::getMdp(){ return mdp; } void admin::info(){ std::cout << "(" << id << ") ADMIN " << nom << " " << prenom << std::endl; } void reset ();
f98d57959e63144f6bd28a2106aaffa40d735c20
461a108796fafb8483faafdc6dc114782d55a1cc
/STL/indianMoney_change.cpp
f3149a808774b799a7a4b4107b64fbbbff1f5107
[]
no_license
aryansin08/DS-Algo
1c099f0a97acbfa3af8719445ed7ce7eb589afb4
0da2c10b7b48f24da967a3ffc6550091b80c6b7e
refs/heads/master
2021-09-15T14:19:29.888202
2021-08-17T10:37:32
2021-08-17T10:37:32
244,914,502
0
0
null
null
null
null
UTF-8
C++
false
false
418
cpp
indianMoney_change.cpp
#include<bits/stdc++.h> using namespace std; bool compare(int a, int b) { return a<=b; } int main() { int coins[] = {1, 2, 5, 10, 20, 50, 100, 200, 500, 2000}; int money; cout<<"Enter amount : "; cin>>money; cout<<endl; int n = sizeof(coins)/sizeof(coins[0]); while(money>0) { int lb = lower_bound(coins, coins + n, money, compare) - coins - 1; cout<<" "<<coins[lb]; money-=coins[lb]; } cout<<endl; }
c3949d24ec3f7839f3145a0ed9de37bbc4e7b401
93f7082e22b059f189311343f7bcf3f3f2db17b8
/day04/ex01/RadScorption.cpp
077a22036d5e17fd2e14444030f7505c19265d5c
[]
no_license
Kronx12/CPP
b68f3ee615d3c760214946f19d9d00f5c04280aa
f10ffcd83f3abf12cc4531c45e4ae553ccab4101
refs/heads/master
2023-02-07T13:46:26.270608
2020-12-29T13:45:42
2020-12-29T13:45:42
252,364,287
2
0
null
null
null
null
UTF-8
C++
false
false
1,417
cpp
RadScorption.cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* RadScorption.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gbaud <gbaud@42lyon.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/03/17 11:18:38 by gbaud #+# #+# */ /* Updated: 2020/12/15 06:51:42 by gbaud ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include "RadScorpion.hpp" RadScorpion::RadScorpion() : Enemy(80, "RadScropion") { std::cout << "* click click click *" << std::endl; } RadScorpion::RadScorpion(const RadScorpion &sm) : Enemy(sm.getHP(), sm.getType()) { std::cout << "* click click click *" << std::endl; } RadScorpion &RadScorpion::operator=(const RadScorpion &sm) { Enemy::operator=(sm); std::cout << "* click click click *" << std::endl; return (*this); } RadScorpion::~RadScorpion() { std::cout << "* SPROTCH *" << std::endl; }
477faad5d4c74dad1393f591d2cf5f5322dbdeb2
8de14e73eae2ef2876c87d2de787234bc8c52706
/ISeeYou/ISeeYouHook/dllMain.cpp
497e1d6957a18c8acb0beb000b04192330b3aeb6
[]
no_license
erthalion/Examples-of-code
d612e16c19b7512e13066859e045095fad6e624d
09b28b92974a9d7d39d3d6dad2f72a5faa60d3c0
refs/heads/master
2016-09-11T13:33:59.624471
2012-08-19T09:30:55
2012-08-19T09:30:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,119
cpp
dllMain.cpp
// dllmain.cpp : Defines the entry point for the DLL application. #include <Windows.h> #pragma data_seg("SHARED") HHOOK hook; #pragma data_seg() #pragma comment(linker, "/SECTION:SHARED,RWS") HINSTANCE instance; BOOL CALLBACK ChangeNameEnum(HWND hwnd,LPARAM lparam){ SendMessageW(hwnd, WM_SETTEXT, 0, LPARAM(L"ะฏ ะทะฐ ั‚ะพะฑะพะน ะฝะฐะฑะปัŽะดะฐัŽ...")); return true; } LRESULT CALLBACK WndHook(int code,WPARAM wParam,LPARAM lParam) { if(code==HCBT_CREATEWND){ EnumWindows(&ChangeNameEnum,0); } return CallNextHookEx(hook, code, wParam, lParam); } extern "C" __declspec(dllexport) void installHook() { hook = SetWindowsHookEx(WH_CBT,WndHook, instance, 0); if(hook==0){ //error } } extern "C" __declspec(dllexport) void uninstallHook() { if(UnhookWindowsHookEx(hook)==0){ //error } } extern "C" __declspec(dllexport) BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: instance=hModule; break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
a3280ebf4507e05b3318d2a45e9e70fb4ac66efc
4e0b17789bff7798250d82d593b4d421ffa72460
/c++/3.cpp
0b5da83a7ca755b15cf0ffd80b4ad852b101b7ba
[]
no_license
talentlyb/Leetcode
edf7324cb4e22093d897628712a189f74fff5a19
f4999033e0aed7df0e748debd8d6a351bc3f5f0b
refs/heads/master
2016-09-06T09:57:53.538389
2016-01-17T10:23:23
2016-01-17T10:23:23
33,287,262
0
0
null
null
null
null
UTF-8
C++
false
false
627
cpp
3.cpp
/** First time. 4/19/2015 */ class Solution { public: int lengthOfLongestSubstring(string s) { unordered_map<char, int> hash; int len = 0; int start = 0; int maxLen = 0; for (int i = 0; i < s.length(); ++i) { if (hash.find(s[i]) != hash.end() && hash[s[i]] >= start) { if (i == hash[s[i]]+1) { start = i; } else { start = hash[s[hash[s[i]]+1]]; } len = i - start; } hash[s[i]] = i; ++len; if (len > maxLen) { maxLen = len; } } return maxLen; } };
51ccf1610d9b57a6eea469142fcee5da0a506569
5ddd0ec20099a9c3ffe865c835dcceb5b7fd0332
/of_v0.8.0_vs_release-gesture-recognizer/apps/myApps/GRT_Predict/src/testApp.cpp
b2893fd5d340c0eb799453cd8c27577d1194540b
[ "MIT" ]
permissive
MarkusKonk/Geographic-Interaction
af81f9f4c7c201dd55843d4dd0d369f2f407d480
b74f6f04656611df8dc4ebdea43f263cea67b366
refs/heads/master
2020-12-30T10:36:34.414880
2014-02-03T12:37:45
2014-02-03T12:37:45
13,868,029
2
1
null
null
null
null
UTF-8
C++
false
false
5,980
cpp
testApp.cpp
#include "testApp.h" MouseControl mouseControl; GRT_Recognizer recognizer; GRT_Recognizer oneHandrecognizer; Nite_HandTracker tracker; GrabProxie grab; openniProxie openniP; //-------------------------------------------------------------- void testApp::setup(){ //mouseControl.startMouseControl(); recognizer.initPipeline("TrainingData_v3_zoomIn_ZoomOut.txt", 6); oneHandrecognizer.initPipeline("TrainingData_A_X_S.txt", 3); openniP.initOpenNi(); tracker.initHandTracker(); grab.initGrabDetector(openniP.m_device); } //-------------------------------------------------------------- void testApp::update(){ float xnew, ynew; VectorDouble inputGRT(6); VectorDouble inputGRT2(3); //retrieve data from HandTracker tracker.updateHandTracker(); openniP.update(); if(tracker.isRightHandTracked()){ inputGRT2[0] = inputGRT[0] = xnew = tracker.getRightHandCoordinates().x; inputGRT2[1] = inputGRT[1] = ynew = tracker.getRightHandCoordinates().y; inputGRT2[2] = inputGRT[2] = tracker.getRightHandCoordinates().z; mouseControl.updateMouseControl(xnew, ynew); GestureRecognitionPipeline &pipeline = oneHandrecognizer.pipeline; pipeline.predict(inputGRT2); //printf("Input: (%d, %d, %d)\n", inputGRT2[0], inputGRT2[1], inputGRT2[2]); string message = oneHandrecognizer.oneHandedLabelMapping(pipeline.getPredictedClassLabel()); double likelyhood= pipeline.getMaximumLikelihood(); if(message != "" && likelyhood>0.7) printf("\nGesture: %s\n", message.c_str()); bool lost = false; bool track = true; grab.updateAlgorithm(lost, track, tracker.getRightHandCoordinates(), openniP.m_depthFrame, openniP.m_colorFrame); if(tracker.isLeftHandTracked()){ inputGRT[3] = tracker.getLeftHandCoordinates().x; inputGRT[4] = tracker.getLeftHandCoordinates().y; inputGRT[5] = tracker.getLeftHandCoordinates().z; GestureRecognitionPipeline &pipeline = recognizer.pipeline; pipeline.predict(inputGRT); string message = recognizer.twoHandedLabelMapping(pipeline.getPredictedClassLabel()); double likelyhood= pipeline.getMaximumLikelihood(); if(message != "" && likelyhood>0.9) printf("\nGesture: %s\n", message.c_str()); } } } //-------------------------------------------------------------- void testApp::draw(){ ofBackground(0, 0, 0); string text; int textX = 20; int textY = 20; //Draw the training info ofSetColor(255, 255, 255); text = "------------------- Prediction Info -------------------"; ofDrawBitmapString(text, textX,textY); GestureRecognitionPipeline &pipeline = recognizer.pipeline; /*textY += 15; text = pipeline.getTrained() ? "Model Trained: YES" : "Model Trained: NO"; ofDrawBitmapString(text, textX,textY);*/ textY += 15; text = "PredictedClassLabel: " + ofToString(pipeline.getPredictedClassLabel()); ofDrawBitmapString(text, textX,textY); textY += 15; text = "Likelihood: " + ofToString(pipeline.getMaximumLikelihood()); ofDrawBitmapString(text, textX,textY); textY += 15; text = "------------------- Prediction Info2 -------------------"; ofDrawBitmapString(text, textX,textY); GestureRecognitionPipeline &pipeline2 = oneHandrecognizer.pipeline; /*textY += 15; text = pipeline2.getTrained() ? "Model Trained: YES" : "Model Trained: NO"; ofDrawBitmapString(text, textX,textY);*/ textY += 15; text = "PredictedClassLabel: " + ofToString(pipeline2.getPredictedClassLabel()); ofDrawBitmapString(text, textX,textY); textY += 15; text = "Likelihood: " + ofToString(pipeline2.getMaximumLikelihood()); ofDrawBitmapString(text, textX,textY); textY += 15; text = "SampleRate: " + ofToString(ofGetFrameRate(),2); ofDrawBitmapString(text, textX,textY); /* //Draw the info text textY += 30; text = "InfoText: " + infoText; ofDrawBitmapString(text, textX,textY);*/ //Draw number of hands currently dragged ofSetColor(255, 0, 0); textY += 15; text = "Left Hand is tracked: "+ ofToString(tracker.isLeftHandTracked()); ofDrawBitmapString(text, textX,textY); textY += 15; text = "Right Hand is tracked: "+ ofToString(tracker.isRightHandTracked()); ofDrawBitmapString(text, textX,textY); ofSetColor(255, 255, 255); //Draw the timeseries data // if( record && noOfHands == noOfTrackedHands){ ofFill(); //double r = ofMap(i,0,timeseries.getNumRows(),0,255); //double g = 0; //double b = 255-r; //ofSetColor(r,g,b); ofSetColor(250,0,0); int x = tracker.getLeftHandCoordinates().x; int y = tracker.getLeftHandCoordinates().y; ofEllipse(250+x,500-y,5,5); // if(noOfHands >= 2){ ofSetColor(0,80,255); x = tracker.getRightHandCoordinates().x; y = tracker.getRightHandCoordinates().y; ofEllipse(350+x,500-y,5,5); //} // } } //-------------------------------------------------------------- void testApp::keyPressed(int key){ } //-------------------------------------------------------------- void testApp::keyReleased(int key){ } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void testApp::dragEvent(ofDragInfo dragInfo){ }
4b22d86b16226f88d7d7bee9711e265d7e0e450a
43687c4dddc36da47122c2e9291a1c65e2bd45d7
/zippedbufferpool.cpp
5f5bd30a176979ce208ac3388099843e91be15bb
[]
no_license
stefhack/FileCompressorMultiThreaded
98e7dad89944f8e7e89c3c6d27a6f9be00b8ec56
4071baab63d4e5e040006b2a1203e03c74a6903d
refs/heads/master
2021-01-11T00:20:38.278079
2016-09-25T15:53:30
2016-09-25T15:53:30
69,173,918
0
0
null
null
null
null
UTF-8
C++
false
false
1,112
cpp
zippedbufferpool.cpp
#include "zippedbufferpool.h" #include <memory> #include "zippedbuffer.h" #include <QPair> #include <QDebug> using namespace std; ZippedBufferPool::ZippedBufferPool() { _allZippersHasDone=false; } void ZippedBufferPool::put(ZippedBuffer* buffer){ QMutexLocker locker(&_mutex); _dataCompressed.push_back(buffer); _fileAdded.wakeOne(); } vector<ZippedBuffer*> ZippedBufferPool::getDataCompressed(){ return _dataCompressed; } unique_ptr<ZippedBuffer> ZippedBufferPool::tryGet(){ unique_ptr<ZippedBuffer> pair=nullptr; QMutexLocker locker(&_mutex); if(_allZippersHasDone==false && _dataCompressed.size()==0){ _fileAdded.wait(&_mutex); } if(_dataCompressed.size()!=0){ ZippedBuffer* buffer = _dataCompressed.front(); pair = unique_ptr<ZippedBuffer>(buffer); _dataCompressed.erase(_dataCompressed.begin(),_dataCompressed.begin()+1); } return pair; } void ZippedBufferPool::done(){ _allZippersHasDone = true; _fileAdded.wakeAll(); } int ZippedBufferPool::size(){ return _dataCompressed.size(); }
58348aa6808bae65b9d9cf6b3e03b0b2515186b7
a0d97e57842892f29e77fb477441f86078d3a356
/sources/tools/GroupTool/grouptool.cpp
b6b4acf028ce28be1323f993d96f5927e46d2a68
[]
no_license
ymahinc/MyTypon
89cac5385edeed2d171392e2160b62bf6ed2fd7f
5fa2548d2cfa909575797474c66361772c9ce397
refs/heads/master
2020-04-27T21:03:20.178564
2019-03-09T10:56:12
2019-03-09T10:56:12
174,682,329
0
0
null
null
null
null
UTF-8
C++
false
false
1,888
cpp
grouptool.cpp
#include "grouptool.h" #include "ui_grouptool.h" #include "editgroupundocommand.h" #include "global.h" #include "items/myitembase.h" GroupTool::GroupTool(QWidget *parent, MYItemBase *item) : MYToolBase(parent), ui(new Ui::GroupTool){ ui->setupUi(this); m_group = item; ui->tableWidget->setCellWidget(0,1,ui->nameLineEdit); // set a pointer to this on the item so we can update widgets values when item properties change m_group->setGroupTool(this); updateGroup(); connect(ui->nameLineEdit,SIGNAL(textChanged(QString)),this,SLOT(onNameChanged())); } GroupTool::~GroupTool(){ delete ui; m_group->setGroupTool(0); } // change name value, can only occured on an existing item on the scene void GroupTool::onNameChanged(){ EditGroupUndoCommand *textGroupCommand = new EditGroupUndoCommand(m_group,ui->nameLineEdit->text()); qApp->undoGroup()->activeStack()->push(textGroupCommand); emit nameChanged(m_group); } void GroupTool::updateGroup(){ disconnect(ui->nameLineEdit,SIGNAL(textChanged(QString)),this,SLOT(onNameChanged())); ui->nameLineEdit->setText(m_group->itemName()); emit nameChanged(m_group); connect(ui->nameLineEdit,SIGNAL(textChanged(QString)),this,SLOT(onNameChanged())); } void GroupTool::handleMousePressEvent(QMouseEvent *event){ Q_UNUSED(event) } void GroupTool::handleMouseReleaseEvent(QMouseEvent *event){ Q_UNUSED(event) } void GroupTool::handleMouseMoveEvent(QMouseEvent *event){ Q_UNUSED(event) } void GroupTool::handleWheelEvent(QWheelEvent * event){ Q_UNUSED(event) } void GroupTool::handleEnterEvent(QEvent * event){ Q_UNUSED(event) } void GroupTool::handleLeaveEvent(QEvent * event){ Q_UNUSED(event) } void GroupTool::handleKeyPressEvent(QKeyEvent *event){ Q_UNUSED(event) } void GroupTool::handleKeyReleaseEvent(QKeyEvent *event){ Q_UNUSED(event) }
2e64f1bd6dff88291fa054ac7be2c5c51512c1e2
43f466020ab52772a07827a766bd4061b1609765
/Flowers Flourish from France.cpp
ff0ebb7ec0d474651154af8e870ad7666798bc07
[]
no_license
ALTOHA/COJ
d86a53e16aaf00831472c4247756cc5be3fc5bf5
4cbb2d348f60880a4c9d98c523e6ffe51c17dca3
refs/heads/master
2020-06-15T03:04:11.649928
2020-01-23T17:29:34
2020-01-23T17:29:34
75,335,741
0
0
null
null
null
null
UTF-8
C++
false
false
611
cpp
Flowers Flourish from France.cpp
#include <cstdio> #include <cstring> using namespace std; int main(){ char letras[100], texto[100000]; int tamano, ascci[100], cont=0, i, j, l=0; do{ gets(texto); if (texto[0]!='*'){ tamano=strlen(texto); for (i=0; i<tamano; i++){ if (texto[i-1]==' ' || i==0){ ascci[l]=texto[i]; l++; } } for (j=0; j<l; j++){ if (j<=l-2){ (ascci[j]==ascci[j+1] || ascci[j]==ascci[j+1]+32 || ascci[j]==ascci[j+1]-32)?cont++: j=l+1; } } (cont==l-1)?printf ("Y\n"):printf("N\n"); } cont=l=0; }while (texto[0]!='*'); return 0; }
1a1591dfc7290115a2ea402beacf6ec05e443c8f
644ade2af173ac318aedaabee1e7a8b1c720b0b9
/Source/Common/Shared.h
885974e18a592311d8695ade1eebd84083e25b14
[]
no_license
Met-CH4-An/FUNEngine
0fc488407cabab713da98aeab289f78e62a05741
0c8eeda18e2992934e4f6ae2d7642b1aa0bb8eb9
refs/heads/master
2020-05-07T10:05:39.604956
2019-04-20T06:21:44
2019-04-20T06:21:44
179,972,181
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
881
h
Shared.h
#ifndef SHARED__H #define SHARED__H //////////////////////////////////////////////////////////////// // ัะตะบั†ะธั ะบะพะผะฟะธะปัั†ะธั ั„ะฐะนะปะฐ //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // ัะตะบั†ะธั ั€ะพะดะธั‚ะตะปัŒัะบะพะณะพ ะบะปะฐััะฐ //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // ัะตะบั†ะธั ั„ะพั€ะฒะฐั€ะด-ะดะตะบะปะฐั€ะฐั†ะธะธ //////////////////////////////////////////////////////////////// #include "FCommon.h" //////////////////////////////////////////////////////////////// // ัะตะบั†ะธั ะดะปั ะพัั‚ะฐะปัŒะฝะพะณะพ //////////////////////////////////////////////////////////////// namespace FE { namespace COMMON { } // namespace COMMON } // namespace FE #endif // SHARED__H
2e2df9ff682c71dd7fafc1048832f3f3eea39d7a
25310dec58e2197ac0a2501b9a8e13e5207e7898
/MQTTServer/datastore.h
1f153ac35193320d7272722027dd264e72fc85d0
[]
no_license
Undertoe/CPE647Project
572224a112eca283f5467f10a1f9af20af2e907d
807be2e5c7cb48fcb3cb74fc555c645f4411b352
refs/heads/master
2020-05-18T02:21:08.981656
2019-04-29T18:23:53
2019-04-29T18:23:53
184,112,129
0
0
null
null
null
null
UTF-8
C++
false
false
2,405
h
datastore.h
#ifndef DATASTORE_H #define DATASTORE_H #include <deque> #include <vector> #include <map> #include <chrono> #include <memory> #include <optional> #include <iostream> #include <QString> #include "singleton.hh" #include "container_helpers.hh" #include "circularlockedqueue.h" #include "semaphorefix.h" #include "sensorinfo.h" #include "imusensor.h" struct MQTTStrings { const QString ServerPingBase = "server/ping/"; const QString ServerPongBase = "server/pong/"; const QString SensorPingBase = "sensor/ping/"; const QString SensorPongBase = "sensor/pong/"; const QString SensorBase = "sensors/"; const QString SensorRequestTopic = "server/TopicRequest"; const QString SensorRequestTopicResponse = "server/TopicResponse"; }; struct MQTTDataPoint { QString _source; QByteArray _data; SensorType sensorType; }; class DataStore { public: bool Quitting = false; CircularLockedQueue<MQTTDataPoint> queuedData; CircularLockedQueue<QString> newDataStreamsProcessing; CircularLockedQueue<QString> newDataStreamsNotifications; /// in all of this, a TAG is known as a subscribed sensor ID, /// while the topic is the actual full string. /// For example: we have 3 IUMs /// Tag for each will be: IMU_1, IMU_2, IMU_3 /// However, the topic will be as follows: /// /// sensors/IMU_1 sensors/IMU_2 sensors/IMU_3 /// list of active sensors std::vector<std::unique_ptr<AbstractSensor>> activeSensors; /// <sensorType ID, vector<TAG>> std::map<SensorType, std::vector<QString>> sensorTags; /// <tag , duration since last ping> std::map<QString, std::chrono::seconds> lastPongs; /// list of active tags we have available std::vector<QString> tags; /// <tags, topics> std::map<QString, QString> tagTopicMap; std::map<QString, QString> ServerPingRequestStrings; std::map<QString, QString> ServerPongResponseStrings; std::map<QString, QString> SensorPingRequestStrings; std::map<QString, QString> SensorPongResponseStrings; MQTTStrings mqttStrings; QString Directory = directory output; DataStore(); void Subscribe(const QString &tag, SensorType type); void Unsubscribe(const QString &tag, SensorType type); AbstractSensor* getSensor(const QString &tag); }; using GlobalDataStore = Terryn::Singleton<DataStore>; #endif // DATASTORE_H
550297b87410164e54a5e4073c69f0bd5005fd75
54d3f758fbf17d49144fd1b3f017a9697a3a8938
/easy/test/0028_implement-strstr.cc
7d92de981a5fbe5569cd432b59a7f5aaf5e9b6cb
[]
no_license
xs-han/leetcode-cpp
4b8d34b9c64530615f24441d78c9ee494844645b
7ffb917e5ada5c2186cb7f8c20434df046e4db19
refs/heads/master
2020-12-20T04:41:12.255847
2020-04-16T17:15:44
2020-04-16T17:15:44
235,965,984
0
0
null
null
null
null
UTF-8
C++
false
false
274
cc
0028_implement-strstr.cc
// // Created by xushen on 2/10/20. // #include <gtest/gtest.h> #include "0028_implement-strstr.h" TEST(T_0028, SOLUTION) { std::string haystack = "aa", needle = "aaa"; Q_0028::Solution s; int n = s.strStr(haystack, needle); std::cout << n << std::endl; }
572d7229e2067f2b5159a5a2f197ab52b9e45d42
a4a018a69e15e2edd43d1c4331b611c46f7a9277
/Others/101hack30_FourPrimes.cpp
c13e4752cb43f848e5b9f62f3a607fcfea84232f
[]
no_license
sanchitkum/algorithmic-solutions
207765580d02869cd59ec577db8662a6752a40e2
b1eebee2ca3a012caf5f3cb6aa5cd799113218e8
refs/heads/master
2016-09-05T17:17:55.031903
2016-03-01T02:10:18
2016-03-01T02:10:18
40,711,722
11
1
null
null
null
null
UTF-8
C++
false
false
1,194
cpp
101hack30_FourPrimes.cpp
#include <bits/stdc++.h> typedef long long ll; #define all(c) (c).begin(), (c).end() #define pb push_back #define FOR(i,a,b) for( ll i = a; i <= b; i++ ) #define ROF(i,a,b) for( ll i = a; i >= b; i-- ) #define debug(x) cerr << "[DEBUG] " << #x << " = " << x << endl #define F first #define S second #define mp make_pair #define INPFILE freopen("input.in","r",stdin) using namespace std; #define N 9000 vector<ll> mark(N+1,1); vector<ll> ans(2*N,0); // Initially none is answer; vector<ll> prime; void sieve(){ for(ll i = 2; i <= N; i++){ if(mark[i]){ prime.pb(i); for(ll j = i*i; j <= N; j += i) mark[j] = 0; } } } int main(){ sieve(); FOR(i,0,prime.size()-1) { // From 1 prime ans[ prime[i] ] = 1; } FOR(i,0,prime.size()-1){ // From 2 prime FOR(j,i,prime.size()-1){ ans[ prime[i] | prime[j] ] = 1; } } FOR(i,1,N){ // From 3 prime if(ans[i]){ FOR(j,0,prime.size()-1){ ans[ i | prime[j] ] = 1; } } } FOR(i,1,N){ // From 4 prime if(ans[i]){ FOR(j,0,prime.size()-1){ ans[ i | prime[j] ] = 1; } } } ll t; cin >> t; while(t--){ ll n; cin >> n; if(ans[n]) cout << "YES"; else cout << "NO"; cout << '\n'; } }
402a59b31f1e63250158ed66ed8dffda37c3ee3e
fb397d527ad0ef6508e20cf911f239533593e2be
/Source/roomConnector.h
d769d8403a80f4057949aa1ce7d95b0a165fecfb
[]
no_license
AnzoDK/C-TxtRPG
733587dfa55e8ffbe020b4f7eab15bc8a254f768
87d7e8bc37260080a8f650f2718e545dc84928af
refs/heads/master
2021-02-12T10:13:39.462781
2020-03-10T13:21:13
2020-03-10T13:21:13
244,585,232
0
1
null
null
null
null
UTF-8
C++
false
false
381
h
roomConnector.h
#pragma once #include "dungeon.h" class Room; class RoomConnector { public: RoomConnector(); //int right; //int left; //int forward; //int backwards; Room* r_right; //= Room(); Room* r_left; //= Room(); Room* r_forward; //= Room(); Room* r_backwards; // = Room(); //long comesFrom; };
0527080d2b5fbea6324590445ef52d571c047132
80e36f6f4c2231be022d8ea84ca4a85d77d2c282
/CursoWIK/ChatRepos/ServerPartDLL/ServerPartDLL/ServerPart.h
d78fa233dc2c4db7c442c415cfa4e2bf1e087cce
[]
no_license
HypeVLSU/CourseWork
3f97f5155cf4c3c8117007fe250ee9c6fcc59136
e0007e6a6f9fd32e33abcb1b2df0cb8e17a51d1a
refs/heads/master
2020-03-19T00:28:26.440368
2018-05-30T23:43:27
2018-05-30T23:43:27
135,483,301
0
0
null
null
null
null
UTF-8
C++
false
false
1,383
h
ServerPart.h
๏ปฟ#pragma once #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> #include <stdlib.h> #include <stdio.h> #include <iostream> #include <string> #include <thread> #include <chrono> #include <Windows.h> #include <fstream> #include <Evolution.h> #include <vector> #include <boost/functional/hash/hash.hpp> #pragma comment (lib, "Ws2_32.lib") #include <algorithm> #define MSG_LEN 512 #define HASH_K 5 extern "C" __declspec(dllexport) void Recieving(SOCKET * Sock); // ะŸะพะปัƒั‡ะตะฝะธะต ัะพะพะฑั‰ะตะฝะธะน class Client // ะšะปะฐัั ะบะปะธะตะฝั‚ะฐ { private: SOCKET socket; // ัะพะบะตั‚ std::string user_name; // ะธะผั public: Client(SOCKET * in, std::string _name) :socket(*in), user_name(_name) {} Client() {} SOCKET GetSock() { return socket; } std::string GetName() { return user_name; } friend bool operator==(const Client& c1, const Client& c2) { return c1.socket == c2.socket; } friend bool operator!=(const Client& c1, const Client& c2) { return !(c1 == c2); } }; extern "C" __declspec(dllexport) void ReSendForAll(Client* source, std::string msg, std::vector<Client>& Connection); extern "C" __declspec(dllexport) void SystemSend(Client* client, std::vector<Client>& Connection, int & Count); extern "C" __declspec(dllexport) size_t GetHash(std::string input);
e8f51fd2ab3921cc2a1c27687842bc0ac6e1f06a
aa4733448f2768f936ae98379fa6555025e37dff
/Render/Video/CCRRR/Source/DDraw/CBaseRender.h
84fad83bdf094ab60dab3c2872268a4f0910e546
[]
no_license
schreibikus/nmPlayer
0048599d6e5fc60cc44f480fed85f9cf6446cfb4
1e6f3fb265ab8ec091177c8cd8f3c6e384df7edc
refs/heads/master
2020-04-01T20:34:56.120981
2017-05-06T08:33:55
2017-05-06T08:33:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,626
h
CBaseRender.h
/************************************************************************ * * * VisualOn, Inc. Confidential and Proprietary, 2003 * * * ************************************************************************/ /******************************************************************************* File: CBaseRender.h Contains: CBaseRender header file Written by: Bangfei Jin Change History (most recent first): 2008-10-28 JBF Create file *******************************************************************************/ #ifndef __CBaseRender_H__ #define __CBaseRender_H__ #include "DDraw.h" #include "voCCRRR.h" //#define _TEST_PERFORMANCE //#define _OUTPUT_DEBUG typedef HRESULT (WINAPI * DDCREATE) (GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter); static DDPIXELFORMAT YUYVFormats = {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','Y','V'),0,0,0,0,0}; // YUYV static DDPIXELFORMAT UYVYFormats = {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('U','Y','V','Y'),0,0,0,0,0}; // UYVY static DDPIXELFORMAT YV12Formats = {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','V','1','2'),0,0,0,0,0}; // YUV420 static DDPIXELFORMAT NV12Formats = {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('N','V','1','2'),0,0,0,0,0}; // YUV420 static DDPIXELFORMAT RGB565Formats = {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x07e0, 0x001F, 0}; // RGB565 typedef enum { DDVIDEO_YV12 = 0, DDVIDEO_NV12 = 1, DDVIDEO_YUYV = 2, DDVIDEO_UYVY = 3, DDVIDEO_UNKNOWN = 100 } DDVIDEOTYPE; class CBaseRender { public: CBaseRender(VO_PTR hInst, VO_PTR hView, VO_MEM_OPERATOR * pMemOP); virtual ~CBaseRender(void); virtual VO_U32 GetProperty (VO_CCRRR_PROPERTY * pProperty); virtual VO_U32 GetInputType (VO_IV_COLORTYPE * pColorType, VO_U32 nIndex); virtual VO_U32 GetOutputType (VO_IV_COLORTYPE * pColorType, VO_U32 nIndex); virtual VO_U32 SetColorType (VO_IV_COLORTYPE nInputColor, VO_IV_COLORTYPE nOutputColor); virtual VO_U32 SetCCRRSize (VO_U32 * pInWidth, VO_U32 * pInHeight, VO_U32 * pOutWidth, VO_U32 * pOutHeight, VO_IV_RTTYPE nRotate); virtual VO_U32 Process (VO_VIDEO_BUFFER * pVideoBuffer, VO_VIDEO_BUFFER * pOutputBuffer, VO_S64 nStart, VO_BOOL bWait); virtual VO_U32 WaitDone (void); virtual VO_U32 SetCallBack (VOVIDEOCALLBACKPROC pCallBack, VO_PTR pUserData); virtual VO_U32 GetVideoMemOP (VO_MEM_VIDEO_OPERATOR ** ppVideoMemOP); virtual VO_U32 SetParam (VO_U32 nID, VO_PTR pValue); virtual VO_U32 GetParam (VO_U32 nID, VO_PTR pValue); protected: virtual VO_U32 Init(); virtual VO_U32 Close (void); virtual int CreateDrawSurface (void); virtual VO_U32 ShowOverlay (bool bShow); virtual bool FillMem (VO_VIDEO_BUFFER * inData, LPBYTE pOutBuffer, int nOutStride); virtual bool PackUV(void* dstUV, void* srcU, void* srcV, int strideU, int strideV, int rows, int width); virtual int GetThreadTime (HANDLE hThread); void GetPropertyFromCfg(); protected: VO_CCRRR_PROPERTY m_prop; VO_MEM_OPERATOR * m_pMemOP; HWND m_hWnd; VO_IV_COLORTYPE m_nInputColor; VO_IV_COLORTYPE m_nOutputColor; VO_IV_RTTYPE m_nRotate; int m_nInWidth; int m_nInHeight; int m_nOutWidth; int m_nOutHeight; VO_BOOL mbUpsideDown; VOVIDEOCALLBACKPROC m_fCallBack; VO_PTR m_pUserData; protected: HMODULE m_hDDLib; DDCREATE m_fDDCreate; #ifdef _WIN32_WCE #ifdef _WIN32_WCE50 IDirectDraw4 * m_pDD; IDirectDrawSurface4 * m_pPrmSurface; IDirectDrawSurface4 * m_pDrwSurface; DDSURFACEDESC2 m_DDSurfaceDesc; #else IDirectDraw * m_pDD; IDirectDrawSurface * m_pPrmSurface; IDirectDrawSurface * m_pDrwSurface; DDSURFACEDESC m_DDSurfaceDesc; #endif // _WIN32_WCE50 #else LPDIRECTDRAW7 m_pDD; LPDIRECTDRAWSURFACE7 m_pPrmSurface; LPDIRECTDRAWSURFACE7 m_pDrwSurface; DDSURFACEDESC2 m_DDSurfaceDesc; #endif // _WIN32_WCE DDCAPS m_DDCaps; DDOVERLAYFX m_ddOverlayFX; DDBLTFX m_ddBltFX; DDVIDEOTYPE m_ddVideoType; bool m_bOverlay; bool m_bOverlayUpdate; bool m_bOverlayShow; bool m_bOverride; int m_nSurfaceWidth; int m_nSurfaceHeight; int m_nScreenWidth; int m_nScreenHeight; RECT m_rcWnd; RECT m_rcVideo; int m_nRenderFrames; int mnAlignBoundarySrc; int mnAlignSizeSrc; int mnAlignBoundaryDest; int mnAlignSizeDest; TCHAR * mstrWorkPath; }; #endif //__CBaseRender_H__
b90dddcad958e936d2fd3e9c9f01ed8326798c3f
e7ea789e64db77239ccc4b2ee7294b0d48ea8ddc
/Source/Oscillator.cpp
654809aff240a46fa55a33fef5a860c520396223
[]
no_license
Snazzie/SynthVst
a0c48b2a879e39b45ff24b4c5020964bc9f00825
5b562b36daac9748dfd955ea1060e819fa1228fd
refs/heads/master
2023-02-21T01:43:21.689091
2019-05-09T00:50:42
2019-05-09T00:50:42
184,957,970
0
0
null
null
null
null
UTF-8
C++
false
false
1,344
cpp
Oscillator.cpp
/* ============================================================================== Oscillator.cpp Created: 5 May 2019 5:58:52pm Author: acoop ============================================================================== */ #include "../JuceLibraryCode/JuceHeader.h" #include "Oscillator.h" //============================================================================== Oscillator::Oscillator(NewProjectAudioProcessor& p) : processor(p) { setSize(200, 200); StringArray types = StringArray({ "Sine","Saw","Square" }); for (int i = 0; i < types.size(); i++) { oscMenu.addItem(types[i], i + 1); // + 1 because Juce treats 1 as start of array, this will normalize to 0 when sent to processor } oscMenu.setJustificationType(Justification::centred); addAndMakeVisible(&oscMenu); oscMenu.addListener(this); waveSelection = new AudioProcessorValueTreeState::ComboBoxAttachment(processor.tree, "waveType", oscMenu); // make connection } Oscillator::~Oscillator() { } void Oscillator::paint(Graphics & g) { g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId)); // clear the background } void Oscillator::resized() { Rectangle<int> area = getLocalBounds().reduced(40, 40); oscMenu.setBounds(area.removeFromTop(20)); } void Oscillator::comboBoxChanged(ComboBox * comboBoxThatHasChanged) { }
cceff6ebbc61c14604fca7a0cd52166c1227b1a2
fa4a1e5d5b2a4dddc73aac2b2828b92f4e3c520f
/Managers/ModelManager.cpp
38a1ee1ccf53cd565cdf0c50f7766b0fe534e850
[ "MIT" ]
permissive
GuMiner/agow
f733aa771cdf3e865871f353184ad27c478909fe
b8665d5879f43a6bcb6e878827b3b25af9cc1b1d
refs/heads/master
2020-04-12T06:41:26.948141
2017-03-25T18:05:43
2017-03-25T18:05:43
60,741,504
0
0
null
null
null
null
UTF-8
C++
false
false
10,634
cpp
ModelManager.cpp
#include <limits> #include <glm\gtc\matrix_transform.hpp> #include "Generators\PhysicsGenerator.h" #include "logging\Logger.h" #include "ModelLoader.h" #include "ModelManager.h" ModelManager::ModelManager(ImageManager* imageManager) : imageManager(imageManager), nextModelId(1), frameId(1) { } unsigned int ModelManager::LoadModel(const char* rootFilename) { ModelLoader modelLoader(imageManager); TextureModel textureModel; if (!modelLoader.LoadModel(rootFilename, &textureModel)) { Logger::Log("Error loading model '", rootFilename, "'."); return 0; } glBindVertexArray(vao); glActiveTexture(GL_TEXTURE1); GLuint mvMatrixImageId = imageManager->CreateEmptyTexture(MODEL_TEXTURE_SIZE, MODEL_TEXTURE_SIZE, GL_RGBA32F); glActiveTexture(GL_TEXTURE2); GLuint shadingColorAndSelectionImageId = imageManager->CreateEmptyTexture(MODEL_TEXTURE_SIZE, MODEL_TEXTURE_SIZE, GL_RGBA32F);\ models.push_back(textureModel); dynamicRenderStore.push_back(TrackingRenderStore(mvMatrixImageId, shadingColorAndSelectionImageId)); ++nextModelId; return nextModelId - 1; } const TextureModel& ModelManager::GetModel(unsigned int id) { return models[id - 1]; } // Retrieves the model ID given the name used to load the model, 0 if not found. unsigned int ModelManager::GetModelId(std::string name) const { for (unsigned int i = 0; i < models.size(); i++) { if (_stricmp(models[i].name.c_str(), name.c_str()) == 0) { return i + 1; } } return 0; } unsigned int ModelManager::GetCurrentModelCount() const { return nextModelId; } void ModelManager::RenderModelImmediate(const glm::mat4& projectionMatrix, Model* model) { glm::mat4 mvMatrix = glm::scale(PhysicsGenerator::GetBodyMatrix(model->body), model->scaleFactor); glUseProgram(directModelRenderProgram); glBindVertexArray(vao); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, models[model->modelId - 1].textureId); glUniform1i(directTextureLocation, 0); glUniform4f(directShadingColorLocation, model->color.x, model->color.y, model->color.z, model->color.w); glUniformMatrix4fv(directProjLocation, 1, GL_FALSE, &projectionMatrix[0][0]); glUniformMatrix4fv(directMvLocation, 1, GL_FALSE, &mvMatrix[0][0]); glUniform1f(directSelectionFactorLocation, model->selected ? 0.40f : 0.0f); glDrawElements(GL_TRIANGLES, models[model->modelId - 1].vertices.indices.size(), GL_UNSIGNED_INT, (const void*)(models[model->modelId - 1].indexOffset * sizeof(GL_UNSIGNED_INT))); } void ModelManager::RenderModel(const glm::mat4& projectionMatrix, Model* model) { if (model->internalId == -1 || model->frameId != frameId - 1) { // Untracked. Add the model. AddNewModelToRenderStore(model); } else { // Known model. Only update if we detect it as dynamic. int activationState = model->analysisBody == nullptr ? model->body->getActivationState() : model->analysisBody->getActivationState(); if (activationState == ACTIVE_TAG || activationState == DISABLE_DEACTIVATION || activationState == WANTS_DEACTIVATION) { UpdateModelInRenderStore(model); } } dynamicRenderStore[model->modelId - 1].renderedIds.insert(model->internalId); model->frameId = frameId; } void ModelManager::AddNewModelToRenderStore(Model* model) { if (dynamicRenderStore[model->modelId - 1].freeIds.size() != 0) { model->internalId = *(dynamicRenderStore[model->modelId - 1].freeIds.begin()); dynamicRenderStore[model->modelId - 1].freeIds.erase(dynamicRenderStore[model->modelId - 1].freeIds.begin()); } else { model->internalId = dynamicRenderStore[model->modelId - 1].backingStore.GetInstanceCount(); } UpdateModelInRenderStore(model); } void ModelManager::UpdateModelInRenderStore(Model* model) { // Update in our backing store. dynamicRenderStore[model->modelId - 1].backingStore.InsertInModelStore(model->internalId, model); // Update in OpenGL. const ImageTexture& mvMatrixImage = imageManager->GetImage(dynamicRenderStore[model->modelId - 1].backingStore.mvMatrixImageId); const ImageTexture& shadingImage = imageManager->GetImage(dynamicRenderStore[model->modelId - 1].backingStore.shadingColorAndSelectionImageId); int x4 = (model->internalId * 4) % MODEL_TEXTURE_SIZE; int y4 = (model->internalId * 4) / MODEL_TEXTURE_SIZE; int x2 = (model->internalId * 2) % MODEL_TEXTURE_SIZE; int y2 = (model->internalId * 2) / MODEL_TEXTURE_SIZE; glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, mvMatrixImage.textureId); glTexSubImage2D(GL_TEXTURE_2D, 0, x4, y4, 4, 1, GL_RGBA, GL_FLOAT, &dynamicRenderStore[model->modelId - 1].backingStore.matrixStore[model->internalId * 4]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadingImage.textureId); glTexSubImage2D(GL_TEXTURE_2D, 0, x2, y2, 2, 1, GL_RGBA, GL_FLOAT, &dynamicRenderStore[model->modelId - 1].backingStore.shadingColorSelectionStore[model->internalId * 2]); } void ModelManager::ZeroIndex(unsigned int modelId, unsigned int idx) { // TODO reconsider. // I'm not fixing this for now. Reasons: // -- For now, it only appears in one frame. // -- This is a performance hit, which so far it doesn't seem that I need. } // Finalizes rendering (and actually renders) all models. void ModelManager::FinalizeRender(const glm::mat4& projectionMatrix) { ++frameId; glUseProgram(modelRenderProgram); glBindVertexArray(vao); glUniformMatrix4fv(projLocation, 1, GL_FALSE, &projectionMatrix[0][0]); // Always send dynamic data to the GPU, every frame. for (unsigned int i = 0; i < dynamicRenderStore.size(); i++) { // Remove what didn't render and zero it's data for reuse. for (unsigned int j = 0; j < dynamicRenderStore[i].backingStore.matrixStore.size(); j++) { if (dynamicRenderStore[i].freeIds.find(j) == dynamicRenderStore[i].freeIds.end() && dynamicRenderStore[i].renderedIds.find(j) == dynamicRenderStore[i].renderedIds.end()) { // Didn't render, zero it. dynamicRenderStore[i].freeIds.insert(j); ZeroIndex(i, j); } } if (dynamicRenderStore[i].backingStore.matrixStore.size() != 0) { // Bind everything; at this point, we've already sent everything to OpenGL. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, models[i].textureId); glUniform1i(textureLocation, 0); int mvMatrixImageId = dynamicRenderStore[i].backingStore.mvMatrixImageId; int shadingImageId = dynamicRenderStore[i].backingStore.shadingColorAndSelectionImageId; const ImageTexture& mvMatrixImage = imageManager->GetImage(mvMatrixImageId); const ImageTexture& shadingImage = imageManager->GetImage(shadingImageId); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, mvMatrixImage.textureId); glUniform1i(mvLocation, 1); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, shadingImage.textureId); glUniform1i(shadingColorLocation, 2); // Draw all the models of the specified type. glDrawElementsInstanced(GL_TRIANGLES, models[i].vertices.indices.size(), GL_UNSIGNED_INT, (const void*)(models[i].indexOffset * sizeof(GL_UNSIGNED_INT)), dynamicRenderStore[i].backingStore.GetInstanceCount()); } } } // Initializes the OpenGL resources bool ModelManager::InitializeOpenGlResources(ShaderFactory& shaderManager) { if (!shaderManager.CreateShaderProgram("modelRender", &modelRenderProgram)) { Logger::LogError("Could not create the model shader!"); return false; } textureLocation = glGetUniformLocation(modelRenderProgram, "modelTexture"); mvLocation = glGetUniformLocation(modelRenderProgram, "mvMatrix"); projLocation = glGetUniformLocation(modelRenderProgram, "projMatrix"); shadingColorLocation = glGetUniformLocation(modelRenderProgram, "shadingColorAndFactor"); if (!shaderManager.CreateShaderProgram("directModelRender", &directModelRenderProgram)) { Logger::LogError("Could not create the direct model shader!"); return false; } directTextureLocation = glGetUniformLocation(directModelRenderProgram, "modelTexture"); directMvLocation = glGetUniformLocation(directModelRenderProgram, "mvMatrix"); directProjLocation = glGetUniformLocation(directModelRenderProgram, "projMatrix"); directShadingColorLocation = glGetUniformLocation(directModelRenderProgram, "shadingColor"); directSelectionFactorLocation = glGetUniformLocation(directModelRenderProgram, "selectionFactor"); glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &positionBuffer); glGenBuffers(1, &uvBuffer); glGenBuffers(1, &indexBuffer); return true; } // Finalizes the list of loaded models we know of, sending the data to OpenGL. void ModelManager::FinalizeLoadedModels() { glBindVertexArray(vao); universalVertices temporaryCopyVertices; unsigned int indexPositionReferralOffset = 0; unsigned int indexOffset = 0; for (unsigned int i = 0; i < models.size(); i++) { models[i].indexOffset = indexOffset; temporaryCopyVertices.positions.insert(temporaryCopyVertices.positions.end(), models[i].vertices.positions.begin(), models[i].vertices.positions.end()); temporaryCopyVertices.uvs.insert(temporaryCopyVertices.uvs.end(), models[i].vertices.uvs.begin(), models[i].vertices.uvs.end()); for (unsigned int j = 0; j < models[i].vertices.indices.size(); j++) { temporaryCopyVertices.indices.push_back(models[i].vertices.indices[j] + indexPositionReferralOffset); } indexPositionReferralOffset += models[i].vertices.positions.size(); indexOffset += models[i].vertices.indices.size(); } temporaryCopyVertices.TransferStaticPositionToOpenGl(positionBuffer); temporaryCopyVertices.TransferStaticUvsToOpenGl(uvBuffer); temporaryCopyVertices.TransferStaticIndicesToOpenGl(indexBuffer); } // Deletes all initialized OpenGL resources. ModelManager::~ModelManager() { glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &positionBuffer); glDeleteBuffers(1, &uvBuffer); glDeleteBuffers(1, &indexBuffer); }
c4bba7dc104a0b3442a66112069efc2b9a74d4ba
dce62d2c4ec575b4ddea35325c51ebdac41c3788
/Engine/Core/Clock.cpp
29b02934ad1d0cc3f3b181b2f956c1c1527a7568
[]
no_license
wvennes/BeatDetection
19c1778fc8885e3ef6b87a5f9755e7121365fc0d
cec72979aec3d97686563aa805861bf3258abe37
refs/heads/master
2021-01-10T02:22:35.901252
2016-01-26T05:51:37
2016-01-26T05:51:37
50,263,103
4
1
null
null
null
null
UTF-8
C++
false
false
4,093
cpp
Clock.cpp
//--------------------------------------------------------------------------- // Clock.cpp //--------------------------------------------------------------------------- #include "Engine/Core/EngineCommon.hpp" #include "Engine/Core/TimeSystem.hpp" #include "Engine/Core/Clock.hpp" #define STATIC STATIC Clock* Clock::s_root = nullptr; STATIC int Clock::s_id = 0; //--------------------------------------------------------------------------- Clock::Clock() : m_isPaused( false ) , m_clockID( s_id ++ ) , m_parent( nullptr ) , m_timeScale( 1.f ) , m_currentTime( GetAbsoluteTimeSeconds() ) { } //--------------------------------------------------------------------------- Clock::Clock( Clock* parent ) : m_isPaused( false ) , m_clockID( s_id ++ ) , m_parent( parent ) , m_timeScale( 1.f ) , m_currentTime( parent->GetCurrentTimeSeconds() ) { parent->m_children.push_back( this ); } //--------------------------------------------------------------------------- Clock::~Clock() { // // if there is a parent, remove from their child list // RemoveSelfFromParentChildList(); //TODO: Fix so that parent doesn't hold garbage references //DestroyClock(); //RemoveSelfFromParentChildList(); } //--------------------------------------------------------------------------- void Clock::DestroyClock() { DestroyClock( this, this ); } //--------------------------------------------------------------------------- void Clock::DestroyClock( Clock* node, Clock* root ) { for ( unsigned int index = 0; index < ( unsigned int ) node->m_children.size(); ++ index ) { DestroyClock( node->m_children[ index ], root ); } if ( node != root ) { delete node; } else { RemoveSelfFromParentChildList(); } } //--------------------------------------------------------------------------- STATIC void Clock::DestroyRootClock() { if ( s_root ) { s_root->DestroyClock(); delete s_root; } s_root = nullptr; } //--------------------------------------------------------------------------- STATIC Clock* Clock::GetRootClock() { if ( !s_root ) s_root = new Clock(); return s_root; } //--------------------------------------------------------------------------- void Clock::SetAlarm( const char* alarmName, double duration, bool isRepeating /* = false */ ) { m_alarms.push_back( Alarm( alarmName, duration, isRepeating ) ); } //--------------------------------------------------------------------------- void Clock::ChangeClockParent( Clock* newParent ) { // remove from child list of old parent if exists RemoveSelfFromParentChildList(); m_parent = newParent; } //--------------------------------------------------------------------------- void Clock::RemoveClockFromHierarchyAndReparentChildren() { for ( ChildClocks::iterator iter = m_children.begin(); iter != m_children.end(); ++ iter ) { ( *iter )->ChangeClockParent( m_parent ); } ChangeClockParent( nullptr ); } //--------------------------------------------------------------------------- void Clock::RemoveSelfFromParentChildList() { if ( !m_parent ) return; ChildClocks& parentChildVector = m_parent->m_children; for ( ChildClocks::iterator iter = parentChildVector.begin(); iter != parentChildVector.end(); ++ iter ) { if ( *iter == this ) { parentChildVector.erase( iter ); break; } } } //--------------------------------------------------------------------------- void Clock::AdvanceTime( double deltaSeconds ) { if ( m_isPaused ) return; double internalDeltaSeconds = deltaSeconds * ( double ) ( m_timeScale ); m_currentTime += internalDeltaSeconds; for ( Alarms::iterator alarmIter = m_alarms.begin(); alarmIter != m_alarms.end(); ) { Alarm& currentAlarm = *alarmIter; currentAlarm.AdvanceAlarm( internalDeltaSeconds ); if ( currentAlarm.IsAlarmFinished() && !currentAlarm.IsAlarmRepeating() ) { alarmIter = m_alarms.erase( alarmIter ); } else { ++ alarmIter; } } for ( ChildClocks::iterator clockIter = m_children.begin(); clockIter != m_children.end(); ++ clockIter ) { ( *clockIter )->AdvanceTime( internalDeltaSeconds ); } }
e995cc4ea4cef7b2f8106deb07704c6c908a9ba5
f72ad6d50a4e0c9e6310f9b8e740e04c12cd81b7
/kicad/sk561-light2cv/sk561-firmware/sk561-firmware.ino
7d426314e6c1bb1d1c42f365f7784e12cf5f6a83
[]
no_license
mirdej/synkie
53c20b4876a8ddfa220ae477012654190f1bea9d
f53f9b1cc55554d5ac0b0e49424c736633e7a2af
refs/heads/master
2023-04-16T16:39:52.466322
2023-04-08T20:17:37
2023-04-08T20:17:37
48,944,902
30
3
null
null
null
null
UTF-8
C++
false
false
4,443
ino
sk561-firmware.ino
//---------------------------------------------------------------------------------------- // // sk561 Firmware // // Target MCU: ATMEGA88 // Copyright: 2021 Michael Egger, me@anyma.ch // License: This is FREE software (as in free speech, not necessarily free beer) // published under gnu GPL v.3 // //---------------------------------------------------------------------------------------- #include <SPI.h> #include "Wire.h" #define VEML3328_I2C_ADDRESS 0x10 #define CODE_CLEAR 0x04 #define CODE_RED 0x05 #define CODE_GREEN 0x06 #define CODE_BLUE 0x07 #define CODE_IR 0x08 #define PIN_DAC_CS 10 const int ad_pin[4] = {14,16,15,17}; const int veml_code[4] = {CODE_RED,CODE_GREEN,CODE_BLUE,CODE_IR}; int dac_value[4]; int ad_value[4]; int ad_idx; //--------------------------------------------------------------------------------------------- void power_on_dac() { static int sendval; int cs_pin; SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE2)); sendval = 0xf010; digitalWrite(PIN_DAC_CS,LOW); delay(1); SPI.transfer16(sendval); digitalWrite(PIN_DAC_CS,HIGH); delay(100); digitalWrite(PIN_DAC_CS,LOW); delay(1); SPI.transfer16(sendval); digitalWrite(PIN_DAC_CS,HIGH); SPI.endTransaction(); } //--------------------------------------------------------------------------------------------- void dac_send(int channel, int send_val) { digitalWrite(PIN_DAC_CS,LOW); send_val = send_val << 2; send_val &= 1023 << 2; send_val |= channel << 12; SPI.transfer16(send_val); digitalWrite(PIN_DAC_CS,HIGH); } //--------------------------------------------------------------------------------------------- void scan(){ byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); nDevices++; } else if (error==4) { Serial.print("Unknow error at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); } } if (nDevices == 0) { Serial.println("No I2C devices found\n"); } else { Serial.println("done\n"); } } void power_on_veml(){ Wire.beginTransmission(VEML3328_I2C_ADDRESS); Wire.write(0x00); uint16_t command_code; // command_code = (1 << 11) | (1 << 10); command_code = (1 << 11); Wire.write(command_code & 0xFF); Wire.write((command_code >> 8) & 0xFF); Wire.endTransmission(); } int read_veml(byte code) { int data; Wire.beginTransmission(VEML3328_I2C_ADDRESS); Wire.write(code); Wire.endTransmission(false); Wire.requestFrom(VEML3328_I2C_ADDRESS,2); while(Wire.available()) { data = Wire.read(); // data |= Wire.read_veml() << 8; } // Serial.println(data); return data; } //======================================================================================== //---------------------------------------------------------------------------------------- // SETUP void setup() { Serial.begin(115200); Serial.println("Hello"); pinMode(PIN_DAC_CS,OUTPUT); SPI.begin(); power_on_dac(); Wire.begin(); scan(); power_on_veml(); } //======================================================================================== //---------------------------------------------------------------------------------------- // LOOP void loop() { long loop_start = millis(); ad_idx++; ad_idx %= 4; ad_value[ad_idx] = 1023-analogRead(ad_pin[ad_idx]); dac_value[ad_idx] = read_veml( veml_code[ad_idx]); dac_value[ad_idx] = constrain(dac_value[ad_idx] , ad_value[0], ad_value[1]); dac_value[ad_idx] = map(dac_value[ad_idx] , ad_value[0], ad_value[1], ad_value[2], ad_value[3]); dac_send(ad_idx, dac_value[ad_idx]); Serial.printf("%d %d %d %d\n", dac_value[0],dac_value[1],dac_value[2],dac_value[3]); //Serial.printf("%d %d %d %d\n", ad_value[0], ad_value[1], ad_value[2], ad_value[3]); //delay(10); // Serial.println(millis()-loop_start); }
2a637ff992618bed3019745845db0c36b7ac4079
d2471190088b1b8d876acb5a004296865a1ecb30
/src/vediorecorde/realtimevedioplay.h
391650c504a56e3127724c3102472226e3aea253
[]
no_license
VideosWorks/player-ffmpeg-sdl2
bd8fdc4bdf30e7b91ce28e04518cf01dad1937fc
cb4299b44841e5a9d6fa3543283934de9622dfda
refs/heads/master
2020-09-23T21:29:14.626287
2019-11-21T01:14:38
2019-11-21T01:14:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,639
h
realtimevedioplay.h
#ifndef REALTIMEVEDIOPLAY_H #define REALTIMEVEDIOPLAY_H #include <QImage> #include <QObject> #include <QThread> #include "sdlplaywidget.h" #include "rtmpplugflow.h" extern "C"{ #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libavutil/pixfmt.h> #include <libswscale/swscale.h> #include <libavutil/fifo.h> #include <libavdevice/avdevice.h> #include <libavutil/mem.h> #include <SDL2/SDL.h> } namespace eink { class RealTimeVedioPlayPrivate; class RealTimeVedioPlay : public QThread { Q_OBJECT public: RealTimeVedioPlay(QObject *parent = 0); ~RealTimeVedioPlay(); void saveFile(); void stop(); public: void InitEvn(); void startWork(); void setFormatCtx( AVFormatContext **ctx); void setWorkingState(bool ); void setSdlPlayWidget(eink::SdlPlayWidget *); void decodeVedioPacket( AVPacket *dataPacket); void setRtmpPusher(RtmpPlugFlow *); void startRtmpPushVedio(); private: void findStream(); void setConvertFormat(); void parseFrameToImage(); void freeMemory(); void parseVedioData(); void setFileName(); void tramslationToYuvSdlPlay(); void setTramslationToYuvSdlInfo(); void setTransToRgbInfo(); protected: void run(); signals: void sendImageSig(QImage ); private: RealTimeVedioPlayPrivate *d; }; } #endif
d9768d8cc64c15372d42ecb17a2afd4ce4d775f7
fd42254832b12b647fd3b394f2afad9d333f2b0d
/E/gerador.cpp
f3994e839e0173ca227b69326a2b763119b927e9
[]
no_license
ruybrito106/IO_OPEI_2017
53a786055f36ede15c3dfcac1739deee77f17fa9
aa3cfcabeba37bb1d2a99f1f863ff3633c51d805
refs/heads/master
2021-07-21T08:52:34.443094
2017-10-31T02:13:30
2017-10-31T02:13:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
493
cpp
gerador.cpp
#include <bits/stdc++.h> #define fr(a, b, c) for(int a = b; a < c; ++a) using namespace std; int main( int argc, char *argv[] ) { int N = stoi(argv[1])+1, M = stoi(argv[2])+1, K = stoi(argv[3])+1; cout << N << ' ' << M << endl << K << endl; int a, b, c, d; fr(i, 0, K) { a = rand() % N; b = rand() % M; c = rand() % (N - a); d = rand() % (M - b); a++, b++; cout << a << ' ' << b << ' ' << a+c << ' ' << b+d << endl; } return 0; }
842cf733f1015f63ecfd761b5f24751354e81644
2cf4ad3f38acf122f8792325c73248dd4504e3b6
/SourceCode/TankWar/Action/Hide.h
2492bf0b604574878c36f0e62ea7e5cf6e1f120f
[]
no_license
irvin518/FCEngine
4313a1b7850bda8fa0b564a3f3833a139bf75b05
824bb89825dd3fa0803c70f85b489777a94cf387
refs/heads/master
2021-01-19T14:30:01.354823
2014-05-16T11:33:47
2014-05-16T11:33:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
430
h
Hide.h
#ifndef TANKWAR_ACTION_HIDE_H_INCLUDE #define TANKWAR_ACTION_HIDE_H_INCLUDE #include "ActionBase.h" class CHide : public CActionBase { typedef CActionBase super; DECLARE_REFLECT_GUID(CHide, 0xB0BD8DA3, CActionBase) public: CHide(); virtual ~CHide(); virtual void ReflectData(CSerializer& serializer) override; public: virtual void Execute(SAIPackage& package); }; #endif//!TANKWAR_ACTION_HIDE_H_INCLUDE
10e6afee9c372884ad570678a393b81e18b173c1
bae21e89328126be65abc33a3a8b50cd445edd6b
/Source/Editor/OrbitEditor.h
74fc6c063ad4eacb7a6dea8490ea8c20db6117c9
[]
no_license
Janix4000/PlanetSimulator
dd982cf30f098348c1d5f5e843f0bb71245d1a7c
ee6de08757391bdf013708bd7b247020070ee3c0
refs/heads/master
2021-04-26T23:34:34.193391
2021-04-06T16:54:30
2021-04-06T16:54:30
123,822,543
0
0
null
2018-03-08T16:49:47
2018-03-04T19:44:24
C++
UTF-8
C++
false
false
1,017
h
OrbitEditor.h
#pragma once #include "BaseEditor.h" #include "Orbit.h" class OrbitEditor : public BaseEditor { public: OrbitEditor(PlanetHolder& holder) : BaseEditor(Key::O, holder) {} void handleInput(const sf::RenderWindow& window) override { if (isActive()) { orbit.setOrbiterPos(getRealMousePos(window)); } } void render(sf::RenderTarget& renderer) const override { if (isActive()) { orbit.render(renderer); } } void update(float dt) override { if (isActive()) { if (sf::Keyboard::isKeyPressed(sf::Keyboard::Add)) { orbit.addToEFactor(dt); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Subtract)) { orbit.addToEFactor(-dt); } } } private: void init() override { orbit.setSun(getPlanet()); auto& newOrbiter = addPlanet(); const float sunRadius = getPlanet().getRadius(); float newRadius = sunRadius / 4.f; newOrbiter.setRadius(newRadius); orbit.setOrbiter(newOrbiter); } void end() override { orbit.free(); } Orbit orbit; };
07cdceb202972c19c9c7370abf73e35a589ce74d
cf7ae4ac2644daa52e0f7c5ae30c72b66d15fc7f
/GenerateMakeLists/STL/mySafeVector.h
d24818cbd68d27e26dfb061c0813ef3b9045cdee
[]
no_license
ZHOURUIH/GameEditor
13cebb5037a46d1c414c944b4f0229b26d859fb5
eb391bd8c2bec8976c29047183722f90d75af361
refs/heads/master
2023-08-21T10:56:59.318660
2023-08-10T16:33:40
2023-08-10T16:33:40
133,002,663
18
21
null
null
null
null
UTF-8
C++
false
false
2,281
h
mySafeVector.h
๏ปฟ#ifndef _MY_SAFE_VECTOR_H_ #define _MY_SAFE_VECTOR_H_ #include "mySTL.h" #include "myVector.h" // ๅฆ‚ๆžœValueๆ˜ฏๅผ•็”จๆ•ฐๆฎ็ฑปๅž‹,ๅˆ™ๅฐฝ้‡่ฎพ็ฝฎไธบๆŒ‡้’ˆ,ๅฆๅˆ™ๅœจๅŒๆญฅๆ—ถๅฏ่ƒฝๆ— ๆณ•่Žทๅ–ๆญฃ็กฎ็š„็ป“ๆžœ template<typename T> struct VectorModify { T mValue; bool mAdd; VectorModify(const T& value, bool add) { mValue = value; mAdd = add; } }; template<typename T> class mySafeVector : public mySTL { public: mySafeVector() { mForeaching = false; } virtual ~mySafeVector(){ clear(); } const myVector<T>& startForeach() { if (mForeaching) { directError("ๆญฃๅœจ้ๅކๅˆ—่กจ,ๆ— ๆณ•ๅ†ๆฌกๅผ€ๅง‹้ๅކ"); return mUpdateList; } mForeaching = true; uint modifyCount = mModifyList.size(); if (modifyCount < mMainList.size()) { FOR_I(modifyCount) { auto& modifyValue = mModifyList[i]; if (modifyValue.mAdd) { mUpdateList.push_back(modifyValue.mValue); } else { mUpdateList.eraseElement(modifyValue.mValue); } } } else { mUpdateList.clear(); mUpdateList.merge(mMainList); } mModifyList.clear(); if (mUpdateList.size() != mMainList.size()) { ERROR("ๅŒๆญฅๅคฑ่ดฅ"); mUpdateList.clear(); mUpdateList.merge(mMainList); } return mUpdateList; } void endForeach() { mForeaching = false; } // ่Žทๅ–ไธปๅˆ—่กจ,ๅญ˜ๅ‚จ็€ๅฝ“ๅ‰ๅฎžๆ—ถ็š„ๆ•ฐๆฎๅˆ—่กจ,ๆ‰€ๆœ‰็š„ๅˆ ้™คๅ’Œๆ–ฐๅขž้ƒฝไผš็ซ‹ๅณๆ›ดๆ–ฐๆญคๅˆ—่กจ // ไธ่ƒฝ็”จไธปๅˆ—่กจ่ฟ›่กŒ้ๅކ,่ฆ้ๅކๅบ”่ฏฅไฝฟ็”จGetUpdateList const myVector<T>& getMainList() const { return mMainList; } void push_back(const T& value) { mMainList.push_back(value); mModifyList.push_back(VectorModify<T>(value, true)); } void eraseElement(const T& value) { if (!mMainList.eraseElement(value)) { return; } mModifyList.push_back(VectorModify<T>(value, false)); } // ๆธ…็ฉบๆ‰€ๆœ‰ๆ•ฐๆฎ,ไธ่ƒฝๆญฃๅœจ้ๅކๆ—ถ่ฐƒ็”จ void clear() { mMainList.clear(); mUpdateList.clear(); mModifyList.clear(); } uint size() const { return mMainList.size(); } T* data() const { return mMainList.data(); } protected: myVector<VectorModify<T>> mModifyList; // ่ฎฐๅฝ•ๆ“ไฝœ็š„ๅˆ—่กจ myVector<T> mUpdateList; // ็”จไบŽ้ๅކๆ›ดๆ–ฐ็š„ๅˆ—่กจ myVector<T> mMainList; // ็”จไบŽๅญ˜ๅ‚จๅฎžๆ—ถๆ•ฐๆฎ็š„ๅˆ—่กจ bool mForeaching; }; #endif
ae72552cad853e44bb58184a30c34d6fecbff213
4950f533671492606403c519ce6c8ad967df433e
/path_planning/src/solver.cpp
926912589ffb185db8e212ab842487d3fed7e962
[]
no_license
koseng-lc/tugas-robotika
3b02d7e011f8dcea367bee8f730ce112d83fd7e6
fe659f38eff1293506a9816d878006485f49fed1
refs/heads/master
2020-07-29T22:50:20.562077
2019-11-01T08:15:39
2019-11-01T08:15:39
209,990,645
6
0
null
null
null
null
UTF-8
C++
false
false
2,182
cpp
solver.cpp
#include "path_planning/solver.h" Solver::Solver() : graph_(new Graph(CELL_ROWS * CELL_COLS)) , ogm_(new OGM(CELL_COLS, CELL_ROWS)) , finished_(false){ initGraph(); } Solver::~Solver(){ } void Solver::initGraph(){ std::cout << "Initializing Graph..." << std::endl; constexpr auto sqrt_2 = std::sqrt(2); for(int y(0); y < CELL_ROWS; y++){ for(int x(0); x < CELL_COLS; x++){ // Vertex curr = boost::add_vertex(VertexProp{x,y,Unvisited}, *graph_); Vertex curr = boost::vertex(flatIdx(x,y),*graph_); (*graph_)[curr].x = x; (*graph_)[curr].y = y; (*graph_)[curr].state = Unvisited; (*graph_)[curr].prev_idx = -1; (*graph_)[curr].total_dist = std::numeric_limits<double>::max(); if(x+1 < CELL_COLS && y-1 >= 0){ // Vertex nb1 = boost::add_vertex(VertexProp{x+1,y-1,Unvisited}, *graph_); Vertex nb1 = boost::vertex(flatIdx(x+1,y-1), *graph_); boost::add_edge(curr, nb1, EdgeProp{sqrt_2}, *graph_); } if(x+1 < CELL_COLS){ // Vertex nb2 = boost::add_vertex(VertexProp{x+1,y,Unvisited}, *graph_); Vertex nb2 = boost::vertex(flatIdx(x+1,y), *graph_); boost::add_edge(curr, nb2, EdgeProp{1.0}, *graph_); } if(x+1 < CELL_COLS && y+1 < CELL_ROWS){ // Vertex nb3 = boost::add_vertex(VertexProp{x+1,y+1,Unvisited}, *graph_); Vertex nb3 = boost::vertex(flatIdx(x+1,y+1), *graph_); boost::add_edge(curr, nb3, EdgeProp{sqrt_2}, *graph_); } if(y+1 < CELL_ROWS){ // Vertex nb4 = boost::add_vertex(VertexProp{x,y+1,Unvisited}, *graph_); Vertex nb4 = boost::vertex(flatIdx(x,y+1), *graph_); boost::add_edge(curr, nb4, EdgeProp{1.0}, *graph_); } // auto e = boost::edge(curr, nb1, *graph_); } } std::cout << " > Num of vertices : " << boost::num_vertices(*graph_) << std::endl; std::cout << " > Num of edges : " << boost::num_edges(*graph_) << std::endl; }
035ea46b54e1bce3a2ee32c4cdc634d0abe9fd8d
c18e3cba4f445613b2ed7503061cdfe088d46da5
/docs/mfc/codesnippet/CPP/how-to-make-a-type-safe-collection_5.h
53d17b1dfa54222d4aa1a6fd6e9b32140360bf48
[ "CC-BY-4.0", "MIT" ]
permissive
MicrosoftDocs/cpp-docs
dad03e548e13ca6a6e978df3ba84c4858c77d4bd
87bacc85d5a1e9118a69122d84c43d70f6893f72
refs/heads/main
2023-09-01T00:19:22.423787
2023-08-28T17:27:40
2023-08-28T17:27:40
73,740,405
1,354
1,213
CC-BY-4.0
2023-09-08T21:27:46
2016-11-14T19:38:32
PowerShell
UTF-8
C++
false
false
198
h
how-to-make-a-type-safe-collection_5.h
class CPersonList : public CObList { public: void AddHeadPerson(CPerson* person) { AddHead(person); } const CPerson* GetHeadPerson() { return (CPerson*)GetHead(); } };
39d854ba36b82021a3072774cf04260280d1ea51
c0860afe6c3f3b25c6d344d6ce7f715e1139c9a2
/big_integer_opt/vector_optimized.cpp
478af9eb56f026ca2323f394284c82ece684d396
[]
no_license
softitova/cpp_asm
2edf1e5f11483dc6ffda98f61c8157da3beb4219
136f3d042e945a115ed97046afd5a4ca36669025
refs/heads/master
2021-06-23T19:01:42.143003
2017-09-07T22:54:57
2017-09-07T22:54:57
92,619,040
0
0
null
null
null
null
UTF-8
C++
false
false
5,321
cpp
vector_optimized.cpp
#include "vector_optimized.h" #include <iostream> #include <cassert> #include <bits/stdc++.h> opt_vector::opt_vector() : small_number(0), opt_size(0), is_big(false) {} opt_vector::opt_vector(const opt_vector& other) : opt_size(other.opt_size), is_big(other.is_big) { if(!other.is_big) { small_number = other.small_number; } else { other.big_number->link_counter++; big_number = other.big_number; } } opt_vector::opt_vector(size_t sz, unsigned val) : opt_size(sz) { if(sz>1) { is_big = true; big_number = new my_vector(); big_number->data.push_back(val); big_number->data.resize(sz); big_number->link_counter = 1; } else { is_big = false; small_number = val; } } void opt_vector::safe_delete() { if(big_number->link_counter > 1) { big_number->link_counter--; } else { delete big_number; } } void opt_vector::make_alone(){ if(is_big && big_number->link_counter>1) { my_vector* new_vector = new my_vector(); big_number->link_counter--; new_vector->data = big_number->data; new_vector->link_counter = 1; std::swap(new_vector, big_number); } } opt_vector::~opt_vector() { if(is_big && big_number -> link_counter > 0) { safe_delete(); } } void swap(opt_vector& a, opt_vector& b) { swap(a.is_big, b.is_big); swap(a.opt_size, b.opt_size); swap(a.big_number, b.big_number); } opt_vector &opt_vector::operator=(opt_vector const &other) { opt_vector r(other); swap(*this, r); return *this; } unsigned& opt_vector::operator[](size_t index) { assert(index<opt_size); make_alone(); return (is_big) ? big_number->data[index] : small_number; } unsigned const& opt_vector::operator[](size_t index) const { assert(index<opt_size); return (is_big) ? big_number->data[index] : small_number; } size_t opt_vector::size() const { return opt_size; } unsigned &opt_vector::back() { make_alone(); return (is_big) ? big_number->data.back() : small_number; } unsigned const &opt_vector::back() const { return (is_big) ? big_number->data.back() : small_number; } void opt_vector::resize(size_t new_size) { if (is_big) { make_alone(); big_number -> data.resize(new_size); } else if(new_size > 1){ unsigned temp = small_number; big_number = new my_vector(); big_number -> data.resize(new_size, 0); big_number -> link_counter = 1; if (opt_size != 0) big_number -> data[0] = temp; is_big = true; } else if (opt_size == 0) { small_number = 0; } opt_size = new_size; } void opt_vector::push_back(unsigned a) { if (is_big) { make_alone(); big_number -> data.push_back(a); } else if (opt_size == 1){ unsigned temp = small_number; big_number = new my_vector(); big_number -> data.emplace_back(temp); big_number -> data.emplace_back(a); big_number->link_counter = 1; is_big = true; } else { small_number = a; } opt_size++; } void opt_vector::pop_back() { if (is_big) { make_alone(); big_number -> data.pop_back(); } else if (opt_size == 0) { throw "Zero pop back"; } opt_size--; } void opt_vector::clear() { if (is_big) { make_alone(); big_number -> data.clear(); } opt_size = 0; } void opt_vector::push_front(unsigned x) { if (!is_big) { make_alone(); push_back(x); all_reverse(); } else { big_number->data.insert(big_number->data.begin(), x); opt_size++; } } void opt_vector::all_reverse() { if (is_big) { make_alone(); std::reverse(big_number->data.begin(), big_number->data.end()); } } bool opt_vector::empty() { return opt_size == 0; } // int main () { // srand(time(0)); // opt_vector a; // vector<unsigned> x; // a.resize(4); // cout << a.is_big << "\n"; // cout << a.big_number->link_counter << "\n"; // // for (int i = 1; i <= 200; i++) { // // int op = rand() % 6; // // // cout << op; // // if (op == 1) { // // unsigned y = rand(); // // a.push_back(y); // // x.push_back(y); // // } else if (op == 0) { // // unsigned y = rand(); // // a.push_front(y); // // x.insert(x.begin(), y); // // } else if (op == 2) { // // int y = rand() % 20 ; // // a.resize(y); // // x.resize(y); // // } else if (op == 4) { // // a.clear(); // // x.clear(); // // } else if (op == 3) { // // a.all_reverse(); // // reverse(x.begin(), x.end()); // // } else { // // opt_vector qwe = a; // // qwe.push_back(1); // // } // // if (a.size() != x.size()) { // // cout << "Bad\n"; // // return 0; // // } // // for (int i = 0; i < a.size(); i++) // // if (a[i] != x[i]) { // // cout << "Bad\n"; // // return 0; // // } // // } // // cout << "\n"; // }
ad9f5735de00500d355403a26725409860b15152
3ef2c6f7dea91b29427eefa5397bac170da1320e
/Creating.cpp
cdf3e5206de1d363efa2173c30868dc382907046
[]
no_license
ouaddani/Creating-and-writing-to-a-file1
e39d1ae85c5a7d4a1a3c52f5b397cafc7940cbdc
11d74b1afa33f525e6a8f7020251a90efdd79868
refs/heads/master
2021-05-08T02:10:34.323333
2017-10-25T20:44:49
2017-10-25T20:44:49
107,976,612
0
0
null
null
null
null
UTF-8
C++
false
false
1,121
cpp
Creating.cpp
#include <iostream> #include <fstream> #include <vector> using namespace std; int main() { int n; cout<<"\n-------------------------------------------------------\n"; cout<<"\n---------------------Write your data-------------------\n"; cout<<"\n-------------------------------------------------------\n"; cout<< "Please enter an integer <100:" << endl; cin >>n; vector<int> tableau(n); for(int i=0;i<n;i++) { tableau[i]=i*i; } ofstream text("data.txt"); text << "Here is the square:" << endl; for(int i=0;i<n;i++) { text << i <<": " <<tableau[i] << endl; } text.close(); // print and read the file ifstream fichier("data.txt"); cout<<"\n-------------------------------------------------------\n"; cout<<"\n--------------------Read Your File---------------------\n"; cout<<"\n-------------------------------------------------------\n"; if(fichier) { string ligne; cout<<" while(getline(fichier, ligne)) { cout << ligne << endl; } } else cerr << "Impossible to open the file !" << endl; return 0; }
d8d355dc5aa2612543c7f10bd38afd03919c7718
229bc416fba574212edf87112d309b3b9ac3c629
/ไธบ่ฟ็ฎ—่กจ่พพๅผ่ฎพ่ฎกไผ˜ๅ…ˆ็บง/ไธบ่ฟ็ฎ—่กจ่พพๅผ่ฎพ่ฎกไผ˜ๅ…ˆ็บง/test.cpp
d7456d8583707193461bf441a74c880ae44f5e07
[]
no_license
lucky529/Leetcode
1a1d105c29c28f9db3ad7c3bd139038f42a65bdd
f4f19f680b05f5f4ec26fdfeb55439f288bb39ff
refs/heads/master
2020-05-04T06:04:46.357478
2020-03-03T08:52:55
2020-03-03T08:52:55
178,998,077
0
0
null
null
null
null
GB18030
C++
false
false
1,186
cpp
test.cpp
//ๅ›žๆบฏๆœ็ดขใ€‚่ฏฅ้—ฎ้ข˜็‰ตๆถ‰ๅˆฐๆ‹ฌๅท็š„็ป„ๅˆ้—ฎ้ข˜๏ผŒไธ€่ˆฌไฝฟ็”จ้€’ๅฝ’ + ๅ›žๆบฏ็š„ๆ€ๆƒณใ€‚ไธป่ฆๆƒณๆณ•๏ผš // //ๅ…ถไธ€๏ผŒ้€’ๅฝ’ๅ›žๆบฏใ€‚ๅฏไปฅไบง็”Ÿๆ‰€ๆœ‰็š„็ป„ๅˆๆ–นๅผใ€‚ // //ๅ…ถไบŒ๏ผŒๆฏไธชๅฐ็ป„ๅˆๆ–นๅผ็›ธๅฝ“ไบŽไธ€ไธชๅญ้›†๏ผŒไธๆ–ญ็š„ๅฐ†่ฎก็ฎ—็ป“ๆžœ่ฟ”ๅ›ž็ป™ไธŠไธ€ๅฑ‚ใ€‚ // //ไธพไพ‹๏ผša + (b - (c * d))ไผšไธๆ–ญ็š„ๅ˜ๆˆa + (b - (res1 * res2))->a + (res1 - res2)->res1 + res2 // //ไผผไนŽ่ฎก็ฎ—็ป“ๆžœไธ้œ€่ฆforๅพช็Žฏ๏ผŸๅ…ถๅฎžๆœ‰่ฟ™็งๆƒ…ๅ†ต๏ผŒa + (b - (c * d))ๅ’Œa + (b - c) * d))๏ผŒ่ฟ™้‡Œ a + res2 //๏ผŒres2ๅฐฑๅฏ่ƒฝๆœ‰ๅคš็งๆƒ…ๅ†ตใ€‚ class Solution { public: vector<int> diffWaysToCompute(string input) { vector<int> ret; for (int i = 0; i < input.size(); i++) { char c = input[i]; if (c == '+' || c == '-' || c == '*') { auto l = diffWaysToCompute(input.substr(0, i)); auto r = diffWaysToCompute(input.substr(i + 1)); for (auto ll : l) { for (auto rr : r) { if (c == '+') { ret.push_back(ll + rr); } else if (c == '-') { ret.push_back(ll - rr); } else if (c == '*') { ret.push_back(ll*rr); } } } } } if (ret.empty()) ret.push_back(stoi(input)); return ret; } };
7fba441b7245d65b6356135f9b058a795cf3c54f
f862ae64559a336b5876a788dae4bb3bad56b7a7
/Tutorial05/Include/NsCore/BaseKernelSystem.h
afe75543cc654f88c5403dd4c0ea01ecb99ff108
[]
no_license
nitianxiaoshuai/NoesisDemo
ef9485f4f015707cae15e017fcd8593ebc4fd216
dc949eb8058361fbba0d6be58503bef824216453
refs/heads/master
2020-06-17T06:14:36.282909
2016-12-01T00:09:25
2016-12-01T00:09:25
75,034,645
1
8
null
2016-12-07T01:13:31
2016-11-29T02:28:47
C++
UTF-8
C++
false
false
1,454
h
BaseKernelSystem.h
//////////////////////////////////////////////////////////////////////////////////////////////////// // Noesis Engine - http://www.noesisengine.com // Copyright (c) 2009-2010 Noesis Technologies S.L. All Rights Reserved. // [CR #931] //////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef __CORE_BASEKERNELSYSTEM_H__ #define __CORE_BASEKERNELSYSTEM_H__ #include <Noesis.h> #include <NsCore/KernelApi.h> #include <NsCore/BaseComponent.h> #include <NsCore/ReflectionDeclare.h> #include <NsCore/NSTLForwards.h> #include <NsCore/Symbol.h> namespace Noesis { namespace Core { //////////////////////////////////////////////////////////////////////////////////////////////////// /// Base class for kernel systems //////////////////////////////////////////////////////////////////////////////////////////////////// class NS_CORE_KERNEL_API BaseKernelSystem: public BaseComponent { public: BaseKernelSystem(); ~BaseKernelSystem(); /// Indicates if system is initialized NsBool IsInitialized() const; /// Initializes the system virtual void Init(); /// Shuts down the system virtual void Shutdown(); /// Systems with higher priority are initialized first virtual NsSize GetPriority() const; private: NsBool mInitialized; NS_DECLARE_REFLECTION(BaseKernelSystem, BaseComponent) }; } } #endif
8443fcb989a98045e351e2f8bc222d80ccd99e10
5fef97704be8e4fdaf74babb02e9a79c3702c953
/tscr/winlist.h
70f9b9bc6b4f95f5aa893a356ca4b5f6b3d5a3d9
[ "BSD-2-Clause" ]
permissive
kotohvost/yui
44f8044d361fb3ef7189dc00349ead61e3456609
bbe0e63c47901f0ab4657396f7d435cc2312d482
refs/heads/master
2020-04-26T06:28:35.068298
2014-09-21T22:41:58
2014-09-21T22:41:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
440
h
winlist.h
/* $Id: winlist.h,v 3.2.2.2 2007/07/24 11:28:12 shelton Exp $ */ #ifndef _WINDOWS_LIST #define _WINDOWS_LIST #include "listbox.h" class winList : public listBox { protected: int *no; void setSelectedWin(); public: winList( int *n ); ~winList(); virtual void resizeScreen( Rect &old ); virtual int isType(long typ); long handleKey( int long, void *&ptr ); int init( void *data=0 ); }; #endif /* _WINDOWS_LIST */
04e848493393fd320dacd8518391095790f8dd26
69ada3404842e83e09fc740876cf1c1f8a03d14b
/TestingGrounds/Source/TestingGrounds/Private/Terrain/Tile.cpp
f708c155ee6fb1ea67fa74d5c6125f92a8a05d78
[]
no_license
DEM0N194/05_TestingGrounds
4da913bffde6bedfa18ce7fdeb91388d6d9afd4d
ee88f29ea42c735b3d9a5134a7435f4b904ac1ba
refs/heads/master
2020-03-23T00:54:29.890625
2018-09-28T15:36:37
2018-09-28T15:36:37
140,775,603
0
0
null
null
null
null
UTF-8
C++
false
false
4,033
cpp
Tile.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "Terrain/Tile.h" #include "Engine/World.h" #include "DrawDebugHelpers.h" #include "ActorPool.h" #include "NavigationSystem.h" // Sets default values ATile::ATile() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; } void ATile::SetPool(UActorPool* ActorPool) { Pool = ActorPool; PositionNavMeshBoundsVolume(); UNavigationSystemV1::GetCurrent(GetWorld())->Build(); } void ATile::PositionNavMeshBoundsVolume() { NavMeshBoundsVolume = Pool->Checkout(); if (NavMeshBoundsVolume == nullptr) { UE_LOG(LogTemp, Warning, TEXT("[%s] Not enough actors in pool."), *GetName()); return; } UE_LOG(LogTemp, Warning, TEXT("[%s] Checked out: %s"), *GetName(), *NavMeshBoundsVolume->GetName()); NavMeshBoundsVolume->SetActorLocation(GetActorLocation()+FVector(2000.0f, 0.0f, 0.0f)); } template<class T> void ATile::RandomlyPlaceActors(TSubclassOf<T> ToSpawn, const FSpawnParams& SpawnParams) { TArray<FSpawnPosition> SpawnPositions; int32 NumberToSpawn = FMath::RandRange(SpawnParams.MinSpawn, SpawnParams.MaxSpawn); for (size_t i = 0; i < NumberToSpawn; i++) { FSpawnPosition SpawnPosition; SpawnPosition.Scale = FMath::RandRange(SpawnParams.MinScale, SpawnParams.MaxScale); if (FindEmptyLocation(SpawnPosition.Location, SpawnParams.Radius * SpawnPosition.Scale)) { SpawnPosition.Rotation = FMath::RandRange(-180.0f, 180.0f); PlaceActor(ToSpawn, SpawnPosition); } } } void ATile::PlaceActors(TSubclassOf<AActor> ToSpawn, const FSpawnParams& SpawnParams) { RandomlyPlaceActors(ToSpawn, SpawnParams); } void ATile::PlaceAIPawns(TSubclassOf<APawn> ToSpawn, const FSpawnParams& SpawnParams) { RandomlyPlaceActors(ToSpawn, SpawnParams); } // Called when the game starts or when spawned void ATile::BeginPlay() { Super::BeginPlay(); } void ATile::EndPlay(const EEndPlayReason::Type EndPlayReason) { Super::EndPlay(EndPlayReason); Pool->Return(NavMeshBoundsVolume); } // Called every frame void ATile::Tick(float DeltaTime) { Super::Tick(DeltaTime); } bool ATile::FindEmptyLocation(FVector& OutLocation, float Radius) { FVector Min(0, -2000, 0); FVector Max(4000, 2000, 0); FBox Bounds(Min, Max); const int32 MAX_ATTEMPTS = 25; for (int i = 0; i < MAX_ATTEMPTS; i++) { FVector CandidateSpot = FMath::RandPointInBox(Bounds); if (CanSpawnAtLocation(CandidateSpot, Radius)) { OutLocation = CandidateSpot; return true; } } return false; } void ATile::PlaceActor(TSubclassOf<AActor> ToSpawn, const FSpawnPosition& SpawnPosition) { AActor* Spawned = GetWorld()->SpawnActor<AActor>(ToSpawn); if (Spawned == nullptr) return; Spawned->SetActorRelativeLocation(SpawnPosition.Location); Spawned->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false)); Spawned->SetActorRotation(FRotator(0.0f, SpawnPosition.Rotation, 0.0f)); Spawned->SetActorScale3D(FVector(SpawnPosition.Scale)); } void ATile::PlaceActor(TSubclassOf<APawn> ToSpawn, const FSpawnPosition& SpawnPosition) { APawn* Spawned = GetWorld()->SpawnActor<APawn>(ToSpawn); if (Spawned == nullptr) return; Spawned->SetActorRelativeLocation(SpawnPosition.Location); Spawned->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false)); Spawned->SetActorRotation(FRotator(0.0f, SpawnPosition.Rotation, 0.0f)); Spawned->SpawnDefaultController(); } bool ATile::CanSpawnAtLocation(FVector Location, float Radius) { FHitResult HitResult; FVector GlobalLocation = ActorToWorld().TransformPosition(Location); bool HasHit = GetWorld()->SweepSingleByChannel( HitResult, GlobalLocation, GlobalLocation, FQuat::Identity, ECC_GameTraceChannel2, FCollisionShape::MakeSphere(Radius) ); FColor ResultColor = HasHit ? FColor::Red : FColor::Green; // DrawDebugCapsule(GetWorld(), GlobalLocation, 0, Radius, FQuat::Identity, ResultColor, true, 100); return !HasHit; }
40a962686c78d0bbb480da740f11cbf527753c28
f83ef53177180ebfeb5a3e230aa29794f52ce1fc
/ACE/ACE_wrappers/TAO/orbsvcs/orbsvcs/Scheduler_Utilities.inl
c662025627ebe26e8892864cd9d551dee55626ec
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-sun-iiop" ]
permissive
msrLi/portingSources
fe7528b3fd08eed4a1b41383c88ee5c09c2294ef
57d561730ab27804a3172b33807f2bffbc9e52ae
refs/heads/master
2021-07-08T01:22:29.604203
2019-07-10T13:07:06
2019-07-10T13:07:06
196,183,165
2
1
Apache-2.0
2020-10-13T14:30:53
2019-07-10T10:16:46
null
UTF-8
C++
false
false
1,399
inl
Scheduler_Utilities.inl
// ============================================================================ // ============================================================================ // Construct a helper class instance from values for // the fields of the IDL struct it wraps. ACE_INLINE ACE_RT_Info::ACE_RT_Info (const char* entry_point_, RtecScheduler::Time worst_time_, RtecScheduler::Time typical_time_, RtecScheduler::Time cached_time_, RtecScheduler::Period_t period_, RtecScheduler::Importance_t importance_, RtecScheduler::Quantum_t quantum_, CORBA::Long threads_) { // Cannot use the initialization list, as these are members of the wrapped base // class. This wrapper class must assign them in the constructor body. this->entry_point = entry_point_; this->worst_case_execution_time = worst_time_; this->typical_execution_time = typical_time_; this->cached_execution_time = cached_time_; this->period = period_; this->importance = importance_; this->quantum = quantum_; this->threads = threads_; } // Construct a helper class instance from the IDL struct it wraps. ACE_INLINE ACE_RT_Info::ACE_RT_Info (const RtecScheduler::RT_Info& rt_info) : RtecScheduler::RT_Info (rt_info) { }
a4dd77fc91f1b08e217c6c5b2dd2e203b5d3d03f
a6a8ebf205181f9d370d3a603e7f7fd7b2f30fa3
/Lab-10/Lab-10q1.cpp
3ba53457657b91e33885dd25b76c270f8ff43693
[]
no_license
rajatkhanna1999/DSA-CSL-106
46fd57bb3de3cd5823a6fdb2f143a1218a4a0c2d
3a13917fdde82cddb2f86a18a3a7ed5fd0a8bd14
refs/heads/master
2021-10-10T06:01:33.802049
2019-01-07T13:38:36
2019-01-07T13:38:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,799
cpp
Lab-10q1.cpp
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define pb push_back #define mp make_pair #define PI 3.14159265358979323 #define debug(x) cout<<"Case "<<x<<": " #define For(i,n) for(long long i=0;i<n;i++) #define Frabs(i,a,b) for(long long i = a; i < b; i++) #define Frabr(i,a,b) for(long long i = a; i >=b; i--) #define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; typedef vector <int> vi; typedef vector <ll> vll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef vector < pii > vpii; typedef vector < pll > vpll; typedef vector <string> vs; //Handle:cyber_rajat int main(int argc, char const *argv[]) { ll n,q; cin>>n>>q; ll arr[n+5]; memset(arr,-1,sizeof(arr)); while(q--) { ll t; cin>>t; if(t==1) { ll v; cin>>v; ll index=v%n; if(arr[index]==-1) arr[index]=v; else { ll j=1; while(arr[index]!=-1 && arr[index]!=-2){ index=(v+j*j)%n; j++; } arr[index]=v; } } else if(t==2) { ll v; cin>>v; ll index=v%n; bool flag=true; ll probes=0,j=1; while(1) { if(arr[index]==v) { probes++; break; } else if(arr[index]==-1) { probes++; break; } else { index=(v+j*j)%n; j++; probes++; } } cout<<probes<<endl; } else if(t==3) { ll v; cin>>v; ll j=1; ll index=v%n; while(1) { if(arr[index]==v) { arr[index]=-2; break; } else if(arr[index]==-1) { arr[index]=-1; break; } else { index=(v+j*j)%n; j++; } } } else { for(ll i=0;i<n;i++) { if(arr[i]!=-1 && arr[i]!=-2) cout<<arr[i]<<" "; else cout<<"NULL"<<" "; } cout<<endl; } } return 0; }
b2e82d6c8af3d40001eb64a7a55972acf2ec1941
bf276c6108d219d29bab60ccfcefdde4d9c1b65d
/kernel/include/bs_vector_shared.h
89a9eaf929b10f4a8073894624ada431d27a7b75
[]
no_license
brbr520/bluesky
4a66be03337a4bbae013489495a9a072ce308692
a69bda4bf10364a32d9ae2557e6ab4ef5b7ee21a
refs/heads/master
2021-01-23T22:06:19.260739
2013-04-27T12:53:17
2013-04-27T12:53:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,672
h
bs_vector_shared.h
// This file is part of BlueSky // // BlueSky is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; either version 3 // of the License, or (at your option) any later version. // // BlueSky is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with BlueSky; if not, see <http://www.gnu.org/licenses/>. #ifndef BS_VECTOR_SHARED_8W625HOK #define BS_VECTOR_SHARED_8W625HOK #include "bs_array_shared.h" namespace blue_sky { /*----------------------------------------------------------------- * Make array around plain buffer optionally held by bs_arrbase-compatible container *----------------------------------------------------------------*/ template< class T > class BS_API bs_vector_shared : public bs_array_shared< T >, public bs_vecbase< T > { public: typedef bs_array_shared< T > base_t; // traits for bs_array typedef bs_arrbase< T > arrbase; typedef typename base_t::container container; typedef bs_vector_shared< T > bs_array_base; typedef smart_ptr< bs_array_base, true > sp_vector_shared; typedef typename arrbase::sp_arrbase sp_arrbase; // ensure we create a vector container typedef bs_array< T, vector_traits > def_cont_impl; typedef Loki::Type2Type< def_cont_impl > def_cont_tag; //typedef typename base_t::def_cont_impl def_cont_impl; //typedef typename base_t::def_cont_tag def_cont_tag; typedef bs_vecbase< T > vecbase_t; typedef typename arrbase::value_type value_type; typedef typename arrbase::key_type key_type; typedef typename arrbase::size_type size_type; typedef typename arrbase::pointer pointer; typedef typename arrbase::reference reference; typedef typename arrbase::const_pointer const_pointer; typedef typename arrbase::const_reference const_reference; typedef typename arrbase::iterator iterator; typedef typename arrbase::const_iterator const_iterator; typedef typename arrbase::reverse_iterator reverse_iterator; typedef typename arrbase::const_reverse_iterator const_reverse_iterator; // ctors, array ownes data bs_vector_shared(size_type n = 0, const value_type& v = value_type()) : base_t(n, v, def_cont_tag()) { pvec_ = container2vecbase(); } template< class container_t > bs_vector_shared( size_type n = 0, const value_type& v = value_type(), const Loki::Type2Type< container_t >& t = def_cont_tag() ) : base_t(n, v, t) { pvec_ = container2vecbase(); } template< class input_iterator, class container_t > bs_vector_shared( input_iterator start, input_iterator finish, const Loki::Type2Type< container_t >& t = def_cont_tag() ) : base_t(start, finish, t) { pvec_ = container2vecbase(); } // more convinient factory functions - no need to use Loki::Type2Type template< class container_t > static sp_vector_shared create(size_type n = 0, const value_type& v = value_type()) { return new bs_vector_shared(n, v, Loki::Type2Type< container_t >()); } // more convinient factory functions - no need to use Loki::Type2Type template< class container_t, class input_iterator > static sp_vector_shared create(input_iterator start, input_iterator finish) { return new bs_vector_shared(start, finish, Loki::Type2Type< container_t >()); } // ctor with external data // use dynamic cast to obtain bs_vecbase iface bs_vector_shared(const container& c) : base_t(c) { init_inplace(c); } void init_inplace(const container& c) { if(!c.get()) return; // try to dynamically cast from c to vecbase pvec_ = const_cast< vecbase_t* >(dynamic_cast< const vecbase_t* >(c.get())); if(pvec_) base_t::init_inplace(c); else { // if container is not vector-based then make a copy of data base_t::init(def_cont_tag(), c->begin(), c->end()); pvec_ = container2vecbase(); } } void push_back(const value_type& v) { pvec_->push_back(v); } void pop_back() { pvec_->pop_back(); } iterator insert(iterator pos, const value_type& v) { return pvec_->insert(pos, v); } void insert(iterator pos, size_type n, const value_type& v) { pvec_->insert(pos, n, v); } //template< class input_iterator > //void insert(iterator pos, input_iterator start, input_iterator finish) { // pvec_->insert(pos, start, finish); //} iterator erase(iterator pos) { return pvec_->erase(pos); } iterator erase(iterator start, iterator finish) { return pvec_->erase(start, finish); } // overloads from bs_vecbase bool insert(const key_type& key, const value_type& value) { return pvec_->insert(key, value); } bool insert(const value_type& value) { return pvec_->insert(value); } void erase(const key_type& key) { pvec_->erase(key); } void clear() { pvec_->clear(); } void reserve(size_type sz) { pvec_->reserve(sz); } // explicitly make array copy sp_arrbase clone() const { return create< def_cont_impl >(this->begin(), this->end()); } private: using base_t::buf_holder_; // we can use dynamic_cast or store pointer to bs_vecbase iface vecbase_t* pvec_; inline vecbase_t* container2vecbase() const { if(buf_holder_.get()) return const_cast< vecbase_t* >( static_cast< const vecbase_t* >((const def_cont_impl*)buf_holder_.get()) ); else return NULL; } }; } // eof blue_sky #endif /* end of include guard: BS_VECTOR_SHARED_8W625HOK */
5468e8f511c2c7d6983625105d7504ea28cf10e1
0924811574db23b20df99efa3e8e2b4e314c92c1
/src/njoy21/input/BROADR/Card2/Temp1.hpp
62a47ae24b8807a096b451460b5a9e006a2fce87
[ "BSD-2-Clause" ]
permissive
McStasMcXtrace/NJOY21
32b0eb8c442f8a2f244be620a1d389ea6f8f0961
c4c2657c8dcc3629bcdc35ba6b3707c91ae030e9
refs/heads/master
2021-01-09T05:23:27.780319
2018-06-14T12:11:43
2018-06-14T12:11:43
80,757,654
1
0
null
2018-06-14T12:11:44
2017-02-02T18:53:52
C++
UTF-8
C++
false
false
679
hpp
Temp1.hpp
struct Temp1 { using Value_t = Quantity< Kelvin >; static std::string name(){ return "temp1"; } static std::string description(){ return "temp1 is an optional argument specifying a temperature in Kelvin.\n" "The argument value specifies the reference temperature from which\n" "broadening operations should begin. This useful when the input PENDF\n" "tape is a result of a previous BROADR command (which may contain\n" "multiple temperature values). When unspecified, temp1 defaults to\n" "zero kelvin"; } static Value_t defaultValue(){ return 0.0 * kelvin; } static bool verify( Value_t v ){ return v >= (0.0 * kelvin); } };
c7e76a4deca6184999fdeaa3689812e0c9d7654b
8a0273fa6c3a5929cd6aed71b42bf8dd98bd2f32
/tasks/ImuTask.cpp
d4f5e37e8fa27c731575347a315483bf0cf01ac1
[]
no_license
joaobrittoneto/simulation-orogen-rock_gazebo
9b352632357773b2ac6b1f9547202039008dcc73
6c0956c51900dd39d62ce8c6c14de836dd2e678d
refs/heads/master
2021-04-15T08:10:20.522104
2018-03-02T13:19:26
2018-03-02T13:19:26
126,485,839
0
0
null
2018-03-23T13:00:52
2018-03-23T13:00:52
null
UTF-8
C++
false
false
3,412
cpp
ImuTask.cpp
/* Generated from orogen/lib/orogen/templates/tasks/Task.cpp */ #include "ImuTask.hpp" #include <gazebo/sensors/ImuSensor.hh> #include <gazebo/sensors/SensorsIface.hh> #include "Gazebo7Shims.hpp" using namespace std; using namespace gazebo; using namespace rock_gazebo; typedef ignition::math::Pose3d IgnPose3d; typedef ignition::math::Vector3d IgnVector3d; typedef ignition::math::Quaterniond IgnQuaterniond; ImuTask::ImuTask(std::string const& name) : ImuTaskBase(name) { } ImuTask::ImuTask(std::string const& name, RTT::ExecutionEngine* engine) : ImuTaskBase(name, engine) { } ImuTask::~ImuTask() { } void ImuTask::setGazeboModel(ModelPtr model, sdf::ElementPtr sdfSensor) { ImuTaskBase::setGazeboModel(model, sdfSensor); initialOrientation = GzGetIgn((*(gazeboLink)), WorldPose, ()).Rot(); } /// The following lines are template definitions for the various state machine // hooks defined by Orocos::RTT. See ImuTask.hpp for more detailed // documentation about them. bool ImuTask::configureHook() { if (! ImuTaskBase::configureHook()) return false; topicSubscribe(&ImuTask::readInput, baseTopicName + "/imu"); return true; } bool ImuTask::startHook() { if (! ImuTaskBase::startHook()) return false; samples.clear(); gazebo::sensors::SensorPtr sensor = gazebo::sensors::get_sensor(sensorFullName); gazebo::sensors::ImuSensor* imu = dynamic_cast<gazebo::sensors::ImuSensor*>(sensor.get()); if (_reference.get() == REFERENCE_HORIZONTAL_PLANE) { IgnVector3d euler = initialOrientation.Euler(); IgnQuaterniond q = IgnQuaterniond::EulerToQuaternion(0, 0, euler.Z()); imu->SetWorldToReferenceOrientation(q); } else if (_reference.get() == REFERENCE_ABSOLUTE) { imu->SetWorldToReferenceOrientation(IgnQuaterniond::Identity); } return true; } void ImuTask::updateHook() { ImuTaskBase::updateHook(); Samples samples; { lock_guard<mutex> readGuard(readMutex); samples = move(this->samples); } for (auto const& sample : samples) { _orientation_samples.write(sample.first); _imu_samples.write(sample.second); } } void ImuTask::errorHook() { ImuTaskBase::errorHook(); } void ImuTask::stopHook() { ImuTaskBase::stopHook(); } void ImuTask::cleanupHook() { ImuTaskBase::cleanupHook(); } void ImuTask::readInput( ConstIMUPtr & imuMsg) { lock_guard<mutex> readGuard(readMutex); const gazebo::msgs::Quaternion &quat = imuMsg->orientation(); const gazebo::msgs::Vector3d& avel = imuMsg->angular_velocity(); const gazebo::msgs::Vector3d& linacc = imuMsg->linear_acceleration(); base::Time stamp = getCurrentTime(imuMsg->stamp()); base::samples::IMUSensors imu_sensors; base::samples::RigidBodyState orientation; orientation.time = stamp; orientation.sourceFrame = _imu_frame.value(); orientation.targetFrame = _world_frame.value(); orientation.orientation = base::Orientation(quat.w(),quat.x(),quat.y(),quat.z()); orientation.angular_velocity = base::Vector3d(avel.x(),avel.y(),avel.z()); imu_sensors.time = stamp; imu_sensors.mag = base::getEuler(orientation.orientation); imu_sensors.gyro = base::Vector3d(avel.x(),avel.y(),avel.z()); imu_sensors.acc = base::Vector3d(linacc.x(), linacc.y(), linacc.z()); samples.push_back(make_pair(orientation, imu_sensors)); }