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
2ce496513d36e9c71c26769536fe38f654bd374c
b39dba38a99bc970d7c861517ab82bb92f5fc548
/unarchiver/archive.h
87b508b1e4356d38878f36e84c434371c2ac5d4c
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
OpenMPT/openmpt
711aef385c6a098a9a2aaefa25f6563e4501d2e8
41c5bde364ed61afb414ac38792715ee9433c01c
refs/heads/master
2023-09-01T21:37:18.329917
2023-09-01T10:10:22
2023-09-01T10:10:22
82,913,630
501
87
BSD-3-Clause
2023-07-14T08:47:12
2017-02-23T10:04:01
C++
UTF-8
C++
false
false
2,181
h
archive.h
/* * archive.h * --------- * Purpose: archive loader * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ #pragma once #include "openmpt/all/BuildSettings.hpp" #include "../common/FileReader.h" #include <string> #include <vector> OPENMPT_NAMESPACE_BEGIN enum class ArchiveFileType { Invalid, Normal, Special, }; struct ArchiveFileInfo { mpt::PathString name; ArchiveFileType type = ArchiveFileType::Invalid; uint64 size = 0; mpt::ustring comment; uint64 cookie1 = 0; uint64 cookie2 = 0; }; class IArchive { public: using const_iterator = std::vector<ArchiveFileInfo>::const_iterator; protected: IArchive() {} public: virtual ~IArchive() {} public: virtual bool IsArchive() const = 0; virtual mpt::ustring GetComment() const = 0; virtual bool ExtractFile(std::size_t index) = 0; virtual FileReader GetOutputFile() const = 0; virtual std::size_t size() const = 0; virtual IArchive::const_iterator begin() const = 0; virtual IArchive::const_iterator end() const = 0; virtual const ArchiveFileInfo & operator [] (std::size_t index) const = 0; }; class ArchiveBase : public IArchive { protected: FileReader inFile; mpt::ustring comment; std::vector<ArchiveFileInfo> contents; std::vector<char> data; public: ArchiveBase(const FileReader &inFile) : inFile(inFile) { return; } ~ArchiveBase() override { return; } bool ExtractFile(std::size_t index) override { MPT_UNREFERENCED_PARAMETER(index); return false; } // overwrite this public: bool IsArchive() const override { return !contents.empty(); } mpt::ustring GetComment() const override { return comment; } FileReader GetOutputFile() const override { return FileReader(mpt::byte_cast<mpt::const_byte_span>(mpt::as_span(data))); } std::size_t size() const override { return contents.size(); } IArchive::const_iterator begin() const override { return contents.begin(); } IArchive::const_iterator end() const override { return contents.end(); } const ArchiveFileInfo & operator [] (std::size_t index) const override { return contents[index]; } }; OPENMPT_NAMESPACE_END
8b6e4d9573ed64d0463dd9e9641ad1710c6b6b3b
90245c66be4d9f57b8a794582d6552c73de76a59
/学习整理/Qt代码/学生信息管理系统/源代码/StudentDataBase/WeatherData/weatherdata.h
8007f8f443489bdc68c9d9b9ca828f4724325f38
[]
no_license
dowerwang/Study
aba592dcd1054954d9ab3a1b45caf17ad75c2150
a293032fd2cd4720f1cd55429749bbe5d98bdd7f
refs/heads/master
2023-03-16T07:53:40.435765
2017-07-27T07:51:57
2017-07-27T07:51:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,481
h
weatherdata.h
#ifndef WEATHERDATA_H #define WEATHERDATA_H #include <QWidget> #include <QString> #include <QSqlDriver> #include <QSqlRecord> #include <QSqlQuery> #include <QSqlDatabase> #include <QtXml> #include <QFile> #include <QIODevice> #include <QDomNodeList> #include <QtScript> #include <QNetworkAccessManager> #include <QNetworkReply> #include <QJsonDocument> #include <QScriptValue> #include <QVariantMap> #include <QPaintEvent> #include <QPainter> #include <QScriptEngine> #include "QCustomPlot/qcustomplot.h" typedef struct DataWeather { QString type; //天气 QString date; //时间 QString fengLi; //风力 QString fengXiang;//风向 }DataWeather; namespace Ui { class WeatherData; } class WeatherData : public QWidget { Q_OBJECT public: explicit WeatherData(QWidget *parent = 0); ~WeatherData(); /**********************查询数据*************************/ void selectData(QString cityName); /**********************读取Xml文件**********************/ bool readXML(); /**********************连接数据库***********************/ bool dataCnn(); /**********************解析JSON数据********************/ void analyseJson(); /**********************画图函数************************/ void paintEvent(QPaintEvent *event); void getWeather(QString cityNumber); private: Ui::WeatherData *ui; QString cityNumber; //城市编号 QString dataBaseName; //数据库名称 QString dataBaseVersion; //数据库版本 QString ip; //ip地址 QString port; //端口 QString userName; //用户名 QString passWord; //密码 QSqlDatabase db; //定义数据库对象 QNetworkAccessManager *manager;//网络获取数据对象 QByteArray weather; //存储获取的数据 QString strJson; //存储JSON数据 QVector<double>highTemp; //高温数据 QVector<double>lowTemp; //低温数据 QVector<double>dataX; //横轴数据 DataWeather dataWeather[5]; //未来数据 QMovie *movie; //播放gif private slots: /*****************获取JSON数据****************/ void GetWebJsonData(QNetworkReply *reply); void on_pushButtonSelectData_clicked(); void on_pushButtonShang_clicked(); void on_pushButtonNext_clicked(); }; #endif // WEATHERDATA_H
f9af203bf7e6e3164fbe97c1c92c174b9a54c404
83c4652d4d4e1d4d3eb5e6b8a7fc15c17a85b4c8
/common/src/golden_cudgel.cpp
467d3dee36f78263fa1d92e6ca156d79f92a9568
[]
no_license
vengine/XGC
8af20955766a28694f23c22b825fccd5c183c836
71b685b436c3ff9d0dff9e1ab4bb2fe8f8e1d520
refs/heads/master
2016-09-08T00:34:16.783851
2013-11-10T14:48:42
2013-11-10T14:48:42
13,206,428
1
1
null
null
null
null
UTF-8
C++
false
false
2,422
cpp
golden_cudgel.cpp
#include "pch.h" #include "golden_cudgel.h" #include "emem.h" #include <windows.h> struct _golden_cudgel { unsigned char* mem; unsigned char* tail; euint ele_size; euint ele_count; }; #define MEMORY_PAGE_SIZE 4 * 1024 #define MEMORY_RESERVE_SIZE 128 * 1024 * 1024 ///static unsigned char* mem_begin_addr = (unsigned char*)0x00000000; GoldenCudgel GoldenCudgel_new(euint ele_size) { if (MEMORY_PAGE_SIZE / ele_size < 16) return NULL; vptr mem = VirtualAlloc(NULL, MEMORY_RESERVE_SIZE, MEM_RESERVE, PAGE_READWRITE); if (mem) { ///mem_begin_addr += MEMORY_RESERVE_SIZE; GoldenCudgel ret = (GoldenCudgel)SMalloc(sizeof(struct _golden_cudgel)); ret->mem = (unsigned char*)mem; ret->tail = (unsigned char*)mem; ret->ele_size = ele_size; ret->ele_count = 0; return ret; } else return NULL; } void GoldenCudgel_delete(GoldenCudgel self) { VirtualFree(self->mem, 0, MEM_RELEASE); Mfree(self); } void GoldenCudgel_grow_up(GoldenCudgel self, vptr eles, euint ele_count) { VirtualAlloc(self->tail, self->ele_size * ele_count, MEM_COMMIT, PAGE_READWRITE); memcpy(self->tail, eles, self->ele_size * ele_count); self->tail += self->ele_size * ele_count; self->ele_count += ele_count; } void GoldenCudgel_grow_up_not_fill(GoldenCudgel self, euint ele_count) { VirtualAlloc(self->tail, self->ele_size * ele_count, MEM_COMMIT, PAGE_READWRITE); self->tail += self->ele_size * ele_count; self->ele_count += ele_count; } void GoldenCudgel_cut_down(GoldenCudgel self, euint ele_count) { if (self->tail - self->ele_size * ele_count >= self->mem) { self->ele_count -= ele_count; self->tail = (unsigned char*)(self->ele_size * self->ele_count); VirtualFree(self->tail, self->ele_size * ele_count, MEM_DECOMMIT); } } vptr GoldenCudgel_get_element_pointer(GoldenCudgel self, euint i) { if (i < self->ele_count) { return self->mem + self->ele_size * i; } else { return NULL; } } void GoldenCudgel_grow_to(GoldenCudgel self, vptr to) { if (to > (vptr)self->tail) { ref_ptr grow = (ref_ptr)to - (ref_ptr)self->tail; euint num_eles = grow / self->ele_size; if (grow % self->ele_size) { num_eles++; } GoldenCudgel_grow_up_not_fill(self, num_eles); } }
5b0eb37cc64f3c5fc04cadab0eb45aa412357339
9f26c9047a25c1c43763d59526219bea5d5c9266
/src/Kernel/KMathA.CC
5105a6d80dff610f3f4b943bae85e5fd653399fa
[ "Unlicense" ]
permissive
y4my4my4m/ZenithOS
fec98491badb10d799e60d87aac578dc38651271
861b19b51e9878baabc3c9c900abb29576e913b6
refs/heads/master
2022-10-28T14:19:54.217394
2020-06-12T07:30:56
2020-06-12T07:30:56
271,889,926
0
0
Unlicense
2020-06-12T21:04:29
2020-06-12T21:04:28
null
UTF-8
C++
false
false
13,160
cc
KMathA.CC
asm { //************************************ _D3_NORM:: PUSH RBP MOV RBP,RSP MOV RDX,U64 SF_ARG1[RBP] FLD U64 [RDX] FMUL ST0,ST0 FLD U64 8[RDX] FMUL ST0,ST0 FADDP ST1,ST0 FLD U64 16[RDX] FMUL ST0,ST0 FADDP ST1,ST0 FSQRT FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _D3_NORM_SQR:: PUSH RBP MOV RBP,RSP MOV RDX,U64 SF_ARG1[RBP] FLD U64 [RDX] FMUL ST0,ST0 FLD U64 8[RDX] FMUL ST0,ST0 FADDP ST1,ST0 FLD U64 16[RDX] FMUL ST0,ST0 FADDP ST1,ST0 FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _D3_DIST:: PUSH RBP MOV RBP,RSP MOV RDX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] FLD U64 [RDX] FSUB ST0,U64 [RBX] FMUL ST0,ST0 FLD U64 8[RDX] FSUB ST0,U64 8[RBX] FMUL ST0,ST0 FADDP ST1,ST0 FLD U64 16[RDX] FSUB ST0,U64 16[RBX] FMUL ST0,ST0 FADDP ST1,ST0 FSQRT FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 16 //************************************ _D3_DIST_SQR:: PUSH RBP MOV RBP,RSP MOV RDX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] FLD U64 [RDX] FSUB ST0,U64 [RBX] FMUL ST0,ST0 FLD U64 8[RDX] FSUB ST0,U64 8[RBX] FMUL ST0,ST0 FADDP ST1,ST0 FLD U64 16[RDX] FSUB ST0,U64 16[RBX] FMUL ST0,ST0 FADDP ST1,ST0 FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 16 //************************************ _D3_CROSS:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RDX,U64 SF_ARG2[RBP] MOV RBX,U64 SF_ARG3[RBP] FLD U64 8[RDX] FMUL ST0,U64 16[RBX] FLD U64 16[RDX] FMUL ST0,U64 8[RBX] FSUBP ST1,ST0 FSTP U64 [RAX] FLD U64 [RDX] FMUL ST0,U64 16[RBX] FLD U64 16[RDX] FMUL ST0,U64 [RBX] FSUBRP ST1,ST0 FSTP U64 8[RAX] FLD U64 [RDX] FMUL ST0,U64 8[RBX] FLD U64 8[RDX] FMUL ST0,U64 [RBX] FSUBP ST1,ST0 FSTP U64 16[RAX] POP RBP RET1 24 //************************************ _D3_DOT:: PUSH RBP MOV RBP,RSP MOV RDX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] FLD U64 [RDX] FMUL ST0,U64 [RBX] FLD U64 8[RDX] FMUL ST0,U64 8[RBX] FADDP ST1,ST0 FLD U64 16[RDX] FMUL ST0,U64 16[RBX] FADDP ST1,ST0 FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 16 //************************************ _D3_ADD:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RDX,U64 SF_ARG2[RBP] MOV RBX,U64 SF_ARG3[RBP] FLD U64 [RDX] FADD ST0,U64 [RBX] FSTP U64 [RAX] FLD U64 8[RDX] FADD ST0,U64 8[RBX] FSTP U64 8[RAX] FLD U64 16[RDX] FADD ST0,U64 16[RBX] FSTP U64 16[RAX] POP RBP RET1 24 //************************************ _D3_SUB:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RDX,U64 SF_ARG2[RBP] MOV RBX,U64 SF_ARG3[RBP] FLD U64 [RDX] FSUB ST0,U64 [RBX] FSTP U64 [RAX] FLD U64 8[RDX] FSUB ST0,U64 8[RBX] FSTP U64 8[RAX] FLD U64 16[RDX] FSUB ST0,U64 16[RBX] FSTP U64 16[RAX] POP RBP RET1 24 //************************************ _D3_MUL:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG3[RBP] FLD U64 SF_ARG2[RBP] FLD ST0 FMUL ST0,U64 [RBX] FSTP U64 [RAX] FLD ST0 FMUL ST0,U64 8[RBX] FSTP U64 8[RAX] FMUL ST0,U64 16[RBX] FSTP U64 16[RAX] POP RBP RET1 24 //************************************ _D3_DIV:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] FLD U64 SF_ARG3[RBP] FLD ST0 FDIVR ST0,U64 [RBX] FSTP U64 [RAX] FLD ST0 FDIVR ST0,U64 8[RBX] FSTP U64 8[RAX] FDIVR ST0,U64 16[RBX] FSTP U64 16[RAX] POP RBP RET1 24 //************************************ _D3_ZERO:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] XOR RDX,RDX MOV U64 [RAX],RDX MOV U64 8[RAX],RDX MOV U64 16[RAX],RDX POP RBP RET1 8 //************************************ _D3_COPY:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] MOV RDX,U64 [RBX] MOV U64 [RAX],RDX MOV RDX,U64 8[RBX] MOV U64 8[RAX],RDX MOV RDX,U64 16[RBX] MOV U64 16[RAX],RDX POP RBP RET1 16 //************************************ _D3_EQU:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RDX,U64 SF_ARG2[RBP] MOV U64 [RAX],RDX MOV RDX,U64 SF_ARG3[RBP] MOV U64 8[RAX],RDX MOV RDX,U64 SF_ARG4[RBP] MOV U64 16[RAX],RDX POP RBP RET1 32 //************************************ _D3_ADD_EQU:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] FLD U64 [RAX] FADD ST0,U64 [RBX] FSTP U64 [RAX] FLD U64 8[RAX] FADD ST0,U64 8[RBX] FSTP U64 8[RAX] FLD U64 16[RAX] FADD ST0,U64 16[RBX] FSTP U64 16[RAX] POP RBP RET1 16 //************************************ _D3_SUB_EQU:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] MOV RBX,U64 SF_ARG2[RBP] FLD U64 [RAX] FSUB ST0,U64 [RBX] FSTP U64 [RAX] FLD U64 8[RAX] FSUB ST0,U64 8[RBX] FSTP U64 8[RAX] FLD U64 16[RAX] FSUB ST0,U64 16[RBX] FSTP U64 16[RAX] POP RBP RET1 16 //************************************ _D3_MUL_EQU:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] FLD U64 SF_ARG2[RBP] FLD ST0 FMUL ST0,U64 [RAX] FSTP U64 [RAX] FLD ST0 FMUL ST0,U64 8[RAX] FSTP U64 8[RAX] FMUL ST0,U64 16[RAX] FSTP U64 16[RAX] POP RBP RET1 16 //************************************ _D3_DIV_EQU:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] FLD U64 SF_ARG2[RBP] FLD ST0 FDIVR ST0,U64 [RAX] FSTP U64 [RAX] FLD ST0 FDIVR ST0,U64 8[RAX] FSTP U64 8[RAX] FDIVR ST0,U64 16[RAX] FSTP U64 16[RAX] POP RBP RET1 16 //************************************ _D3_UNIT:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG1[RBP] FLD U64 [RAX] FMUL ST0,ST0 FLD U64 8[RAX] FMUL ST0,ST0 FADDP ST1,ST0 FLD U64 16[RAX] FMUL ST0,ST0 FADDP ST1,ST0 FSQRT FST U64 SF_ARG1[RBP] MOV RBX,SF_ARG1[RBP] TEST RBX,RBX JZ @@05 FLD ST0 FDIVR ST0,U64 [RAX] FSTP U64 [RAX] FLD ST0 FDIVR ST0,U64 8[RAX] FSTP U64 8[RAX] FDIVR ST0,U64 16[RAX] FSTP U64 16[RAX] POP RBP RET1 8 @@05: FFREE ST0 FINCSTP POP RBP RET1 8 //************************************ _SQR:: PUSH RBP MOV RBP,RSP FLD U64 SF_ARG1[RBP] FMUL ST0,ST0 FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _SIGN:: PUSH RBP MOV RBP,RSP FLD U64 SF_ARG1[RBP] FTST FSTSW FFREE ST0 FINCSTP MOV RDX,RAX XOR RAX,RAX BT RDX,14 JC @@05 MOV RAX,1.0 BT RDX,8 JNC @@05 MOV RAX,-1.0 @@05: POP RBP RET1 8 //************************************ _ARG:: PUSH RBP MOV RBP,RSP FLD U64 SF_ARG2[RBP] FLD U64 SF_ARG1[RBP] @@05: FPATAN FSTSW TEST AX,0x400 JNZ @@05 FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 16 //************************************ _ROUND:: PUSH RBP MOV RBP,RSP SUB RSP,8 FSTCW U16 -8[RBP] MOV AX,U16 -8[RBP] MOV U16 -6[RBP],AX AND AX,~0x0C00 MOV U16 -8[RBP],AX FLDCW U16 -8[RBP] FLD U64 SF_ARG1[RBP] FRNDINT FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] FLDCW U16 -6[RBP] LEAVE RET1 8 //************************************ _TRUNC:: PUSH RBP MOV RBP,RSP SUB RSP,8 FSTCW U16 -8[RBP] MOV AX,U16 -8[RBP] MOV U16 -6[RBP],AX OR AX,0x0C00 MOV U16 -8[RBP],AX FLDCW U16 -8[RBP] FLD U64 SF_ARG1[RBP] FRNDINT FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] FLDCW U16 -6[RBP] LEAVE RET1 8 //************************************ _FLOOR:: PUSH RBP MOV RBP,RSP SUB RSP,8 FSTCW U16 -8[RBP] MOV AX,U16 -8[RBP] MOV U16 -6[RBP],AX AND AX,~0x0C00 OR AX,0x0400 MOV U16 -8[RBP],AX FLDCW U16 -8[RBP] FLD U64 SF_ARG1[RBP] FRNDINT FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] FLDCW U16 -6[RBP] LEAVE RET1 8 //************************************ _CEIL:: PUSH RBP MOV RBP,RSP SUB RSP,8 FSTCW U16 -8[RBP] MOV AX,U16 -8[RBP] MOV U16 -6[RBP],AX AND AX,~0x0C00 OR AX,0x0800 MOV U16 -8[RBP],AX FLDCW U16 -8[RBP] FLD U64 SF_ARG1[RBP] FRNDINT FSTP U64 SF_ARG1[RBP] MOV RAX,SF_ARG1[RBP] FLDCW U16 -6[RBP] LEAVE RET1 8 //************************************ SYS_POW:: // RAX=RDX`RAX PUSH RBP MOV RBP,RSP SUB RSP,24 TEST RAX,RAX //To power of zero? JNZ @@05 MOV RAX,1.0 JMP @@20 @@05: TEST RDX,RDX //zero to a power? JNZ @@10 XOR RAX,RAX JMP @@20 @@10: MOV RCX,RAX //RCX=pow MOV U64 -8[RBP],RDX MOV U64 -16[RBP],RAX FSTCW U16 -24[RBP] MOV AX,U16 -24[RBP] MOV U16 -22[RBP],AX OR AX,0x0C00 MOV U16 -24[RBP],AX FLDCW U16 -24[RBP] FLD U64 -16[RBP] FLD U64 -8[RBP] FABS //base should be pos FYL2X // y*log2(x) FST U64 -8[RBP] FRNDINT FLD U64 -8[RBP] FSUBRP ST1,ST0 F2XM1 FLD1 FADDP ST1,ST0 FSTP U64 -16[RBP] FLD U64 -8[RBP] FLD U64 -16[RBP] FSCALE // ST0<<ST1 TEST RDX,RDX //was base neg? JGE @@15 MOV U64 -16[RBP],RCX FLD U64 -16[RBP] FISTTP U64 -16[RBP] TEST U64 -16[RBP],1 JZ @@15 //was pow odd? FCHS @@15: FSTP U64 -8[RBP] FFREE ST0 FINCSTP FLDCW U16 -22[RBP] MOV RAX,U64 -8[RBP] @@20: LEAVE RET //************************************ _POW:: PUSH RBP MOV RBP,RSP MOV RAX,U64 SF_ARG2[RBP] MOV RDX,U64 SF_ARG1[RBP] CALL SYS_POW POP RBP RET1 16 //************************************ _POW10:: PUSH RBP MOV RBP,RSP SUB RSP,16 FSTCW U16 -8[RBP] MOV AX,U16 -8[RBP] MOV U16 -6[RBP],AX OR AX,0x0C00 MOV U16 -8[RBP],AX FLDCW U16 -8[RBP] FLDL2T FLD U64 SF_ARG1[RBP] FMULP ST1,ST0 FST U64 SF_ARG1[RBP] FRNDINT FLD U64 SF_ARG1[RBP] FSUBRP ST1,ST0 F2XM1 FLD1 FADDP ST1,ST0 FSTP U64 -16[RBP] FLD U64 SF_ARG1[RBP] FLD U64 -16[RBP] FSCALE // ST0<<ST1 FSTP U64 -16[RBP] FFREE ST0 FINCSTP FLDCW U16 -6[RBP] MOV RAX,U64 -16[RBP] LEAVE RET1 8 //************************************ _EXP:: PUSH RBP MOV RBP,RSP SUB RSP,16 FSTCW U16 -8[RBP] MOV AX,U16 -8[RBP] MOV U16 -6[RBP],AX OR AX,0x0C00 MOV U16 -8[RBP],AX FLDCW U16 -8[RBP] FLDL2E FLD U64 SF_ARG1[RBP] FMULP ST1,ST0 FST U64 SF_ARG1[RBP] FRNDINT FLD U64 SF_ARG1[RBP] FSUBRP ST1,ST0 F2XM1 FLD1 FADDP ST1,ST0 FSTP U64 -16[RBP] FLD U64 SF_ARG1[RBP] FLD U64 -16[RBP] FSCALE // ST0<<ST1 FSTP U64 -16[RBP] FFREE ST0 FINCSTP FLDCW U16 -6[RBP] MOV RAX,U64 -16[RBP] LEAVE RET1 8 //************************************ _LOG10:: PUSH RBP MOV RBP,RSP FLDLG2 FLD U64 SF_ARG1[RBP] FYL2X // y*log2(x) FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _LOG2:: PUSH RBP MOV RBP,RSP FLD1 FLD U64 SF_ARG1[RBP] FYL2X // y*log2(x) FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _LN:: PUSH RBP MOV RBP,RSP FLDLN2 FLD U64 SF_ARG1[RBP] FYL2X // y*log2(x) FSTP U64 SF_ARG1[RBP] MOV RAX,U64 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _FLDCW:: PUSH RBP MOV RBP,RSP FLDCW U16 SF_ARG1[RBP] POP RBP RET1 8 //************************************ _FSTCW:: PUSH RBP MOV RBP,RSP SUB RSP,8 FSTCW U16 -8[RBP] MOVZX RAX,U16 -8[RBP] LEAVE RET //************************************ _FSTSW:: XOR RAX,RAX FSTSW RET //************************************ _FCLEX:: FCLEX RET }
2599b76a4f89599b5024d7a96fce1a44a61becc1
59cb0e5cd9da12a6cab1a80f8dfdbbb25f2674ff
/Queue/Queue.cpp
003eee1eae233e4939cdf990211805f17edbb3fc
[]
no_license
jupmorenor/CppAlgorithmsStructures
73a75be3d1314c8aec1761007f8054494fdd8f7a
a98855b65668bfa38ac2dfa25b168f5f6d12c25d
refs/heads/master
2022-11-23T10:19:14.814327
2020-07-01T02:02:42
2020-07-01T02:02:42
276,252,787
0
0
null
null
null
null
UTF-8
C++
false
false
2,546
cpp
Queue.cpp
/* * Queue.cpp * * Created on: 29/09/2014 * Author: Juan Pablo Moreno Rico - 20111020059 */ #include <stddef.h> #include "Queue.h" template <typename T> Queue<T>::Queue() { cabeza = NULL; tam = 0; } template <typename T> Queue<T>::~Queue() { Nodo<T> *Aux; if (!esta_vacia()) { for(Aux=cabeza->siguiente; Aux->siguiente!=Aux; Aux=Aux->siguiente) { Aux->anterior = cabeza->anterior; (Aux->anterior)->siguiente = Aux; delete cabeza; cabeza = Aux; tam--; } delete Aux; delete cabeza; } } template <typename T> bool Queue<T>::insertar_inicio(T elm) { if (esta_vacia()) { cabeza = crear_nodo(elm); cabeza->siguiente = cabeza; cabeza->anterior = cabeza; } else { Nodo<T> *Aux = cabeza; cabeza = crear_nodo(elm); cabeza->siguiente = Aux; cabeza->anterior = Aux->anterior; Aux->anterior = cabeza; (cabeza->anterior)->siguiente = cabeza; } tam++; return true; } template <typename T> bool Queue<T>::insertar_final(T elm) { if(esta_vacia()) { cabeza = crear_nodo(elm); cabeza->siguiente = cabeza; cabeza->anterior = cabeza; } else { Nodo<T> *Aux = crear_nodo(elm); Aux->siguiente = cabeza; Aux->anterior = cabeza->anterior; cabeza->anterior = Aux; (Aux->anterior)->siguiente = Aux; } tam++; return true; } template <typename T> bool Queue<T>::eliminar_inicio() { Nodo<T> *Aux = cabeza; if (esta_vacia()) { return false; } else if (tam == 1) { delete cabeza; } else { (Aux->siguiente)->anterior = Aux->anterior; (Aux->anterior)->siguiente = Aux->siguiente; cabeza = Aux->siguiente; delete Aux; } tam--; return true; } template <typename T> bool Queue<T>::eliminar_final() { Nodo<T> *Aux = cabeza->anterior; if (esta_vacia()) { return false; } else if (tam == 1) { delete cabeza; } else { (Aux->siguiente)->anterior = Aux->anterior; (Aux->anterior)->siguiente = Aux->siguiente; delete Aux; } tam--; return true; } template <typename T> T Queue<T>::buscar(int pos) { Nodo<T> *Aux = cabeza; while (pos > tam) { pos-=tam; } if (!esta_vacia()) { if (pos == 0) { return primero(); }else if (pos == tam-1) { return ultimo(); } else { for(int i=0; i<pos; i++) { Aux = Aux->siguiente; } return Aux->dato; } } } template <typename T> T Queue<T>::primero() { return cabeza->dato; } template <typename T> T Queue<T>::ultimo() { return (cabeza->anterior)->dato; } template <typename T> int Queue<T>::long_lista() { return tam; } template <typename T> bool Queue<T>::esta_vacia() { return (tam == 0); }
f0f5f7a99d51184ef5b4e72b7eff973fd1476d9e
3a6018a0c82dc39c4e513da40dcd8cf5b1d23089
/emperorlu/2593/3192058_WA.cc
6dbfd9325aaa4456125e96b670280c31c23c9b7e
[ "BSD-3-Clause" ]
permissive
lulyon/poj-archive
2ff04082ff70e0afc997c7a49d23d3d31ce3ddbe
7ba5569d1780f8619621bc8b1adc0501b0d7ec51
refs/heads/master
2020-06-01T23:29:51.532319
2013-09-14T08:14:08
2013-09-14T08:14:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
860
cc
3192058_WA.cc
#include<iostream> #include<math.h> using namespace std; int a[100010],Left[100010],Right[100010]; int main() { int n,sum,max,tmp; while(1) { scanf("%d",&n); if(!n)break; for(int i=0;i<n;++i) scanf("%d",a+i); sum=0; max=-10000000; for(int i=0;i<n;++i) { if(sum>=0)sum+=a[i]; else sum=a[i]; if(max<sum)max=sum; Left[i]=max; } sum=0; max=-10000000; for(int i=n-1;i>=0;--i) { if(sum>=0)sum+=a[i]; else sum=a[i]; if(max<sum)max=sum; Right[i]=max; } /* for(int i=0;i<n;++i) printf("%d ",Left[i]); cout<<endl; for(int i=0;i<n;++i) printf("%d ",Right[i]); cout<<endl; system("pause"); max=-10000000; */ for(int i=0;i<n-1;++i) { tmp=Left[i]+Right[i+1]; if(max<tmp)max=tmp; } printf("%d\n",max); } return 0; }
2871c4e4e30a65f205597e7542120216e0ecb472
7bbf59e87c2cc7f42581d0e6506672b0e1b7a040
/SoulCollectorDxLib/TypeCardBase.cpp
565e9a84fd5990ec5d52e69b574d90fd7f85e864
[]
no_license
ProjectVapen/SoulCpllectorDxLibNext
d1aa30574829111d967a2cbc4f3a2d36919e8efb
554bcc8bd38863655785e89a7c4c7e33f4699409
refs/heads/master
2016-09-10T18:49:17.645666
2015-06-27T19:17:37
2015-06-27T19:17:37
38,081,295
0
0
null
null
null
null
UTF-8
C++
false
false
97
cpp
TypeCardBase.cpp
#include "TypeCardBase.h" TypeCardBase::TypeCardBase() { } TypeCardBase::~TypeCardBase() { }
3c63e71d96a851e626c8065c1ba395f149650910
b99885f604995812c172054510554b3486784f45
/VolumeFile/Inode.h
bb7ab653077e52a5fdf01d45cfc4326954613773
[]
no_license
zzc-tongji/volume-file
a7867c91966266672ed73d8a3ededea79ee9086f
e415cd1d7c63fbe83e64ff5300949d878c690b6b
refs/heads/master
2021-10-10T17:29:39.626107
2018-08-02T09:39:36
2018-08-02T09:39:36
104,196,412
1
0
null
null
null
null
GB18030
C++
false
false
17,100
h
Inode.h
#pragma once #include "Image_SuperBlock.h" #include "Image_BitMap.h" #include "Image_UserData.h" /* Inode */ class Inode { public: //一个Inode节点所占据的空间大小:64(务必确保!) static const unsigned int INODE_SIZE = 64; //初始化时设置标志位 static const unsigned short MODE_INIT = 0x0000; //占用时设置标志位(110 110 110 1 1 000 0 1) static const unsigned short MODE_OCC = 0xDB61; //UID设定值 static const unsigned short UID_INIT = 1; //GID设定值 static const unsigned short GID_INIT = 1; //一个索引盘块可容纳的索引的最大数量:128 static const unsigned int MAX_INDEX_NUM = Image_SuperBlock::BLOCK_CAP / sizeof(unsigned int); //小型文件最大大小(块):6 static const unsigned int SMALL_MAX_SIZE_BLOCK = 6; //大型文件最大大小(块):262 static const unsigned int LARGE_MAX_SIZE_BLOCK = 6 + 2 * MAX_INDEX_NUM; //(巨型)文件最大大小(块):33030 static const unsigned int MAX_SIZE_BLOCK = 6 + 2 * MAX_INDEX_NUM + 2 * MAX_INDEX_NUM * MAX_INDEX_NUM; //(巨型)文件最大大小(字节):16911360 Bit(16515 KiB,约16.12 MiB) static const unsigned int MAX_SIZE_BYTE = MAX_SIZE_BLOCK * Image_SuperBlock::BLOCK_CAP; /* 状态标志位:[15]~[0] [15][14][13]: 文件所有者对文件的访问权(rwx,有权限-1) [12][11][10]: 文件所有者的同组其他用户对文件的访问权(rwx,有权限-1) [9][8][7]: 其他用户对文件的访问权(rwx,有权限-1) [6]: uid表示文件所有者的用户标识数 [5]: gid表示文件所有者所在的用户组标识数 [4][3][2]: 空文件:000,小型文件:001,大型文件:011,巨型文件:111 [1]: 普通文件-0,目录文件-1 [0]: 节点未分配-0,节点已分配-1 ps:这里将顺序倒过来是为了提高搜索效率,因为后面的SetMode()、GetMode()都是从低位端开始选择的。 */ unsigned short mode; unsigned short uid; //文件所有者的用户标识数 unsigned short gid; //文件所有者的组标识数 unsigned short padding; //(占位) unsigned int size_byte; //文件大小(字节) unsigned int size_block; //文件大小(块,不足一块算一块) unsigned int atime; //最后访问时间 unsigned int addr[10]; //用于文件逻辑块号和物理块号转换的基本索引表 Image_SuperBlock *super_block; //指向文件系统超级块(这个值每次运行都会更新) //构造函数 Inode() { Release(); for (unsigned int i = 0; i < 10; i++) { addr[i] = -1; } super_block = nullptr; } //析构函数 ~Inode() { } //设定:是否为文件夹 void SetModeDirectory(bool d) { if (d) { SetMode(1, true); } else { SetMode(1, false); } } //读取:是否为文件夹 bool GetModeDirectory() { if (GetMode(1) == true) { return true; } else { return false; } } //计算size_block void CalculateSizeBlock() { size_block = (unsigned int)(ceil(double(size_byte) / double(Image_SuperBlock::BLOCK_CAP))); } //更新最后访问时间 void UpdateAtime() { atime = (unsigned int)time(NULL); //这里在90年之后会出现BUG(2014年8月11日) } /* 占用节点的顺序:占用节点 -> 分配存放文件索引表的空间 -> 分配存放文件内容的空间 放弃节点的顺序:释放存放文件内容的空间 -> 释放存放文件索引表的空间 -> 放弃节点 切记!!顺序一定不能错!! */ //占用节点 void Occupy() { mode = MODE_OCC; uid = UID_INIT; gid = GID_INIT; padding = 0; size_byte = 0; CalculateSizeBlock(); UpdateAtime(); } //释放节点 void Release() { mode = MODE_INIT; uid = 0; gid = 0; padding = 0; size_byte = 0; CalculateSizeBlock(); atime = 0; } /* 重新分配文件盘块 参数: s - 重新分配后的文件大小(字节,范围:0~16911360) 返回: 1 - 成功 0xFFFFFFFF - “磁盘”已满,无法分配“物理盘块”,失败 注意: 如果这是个目录文件,那么s为6,输入无效! */ unsigned int RedistributeBlock(unsigned int s) { //释放盘块 if (GetMode(2) == true) { ReleaseDataBlock(); } if (GetMode(2) == true) { ReleaseIndexBlock05(); } if (GetMode(3) == true) { ReleaseIndexBlock67(); } if (GetMode(4) == true) { ReleaseIndexBlock89(); } //调整文件大小 if (GetModeDirectory()) { size_byte = 3072; } else { size_byte = s; } CalculateSizeBlock(); //修改相应标志位 if (size_block == 0) { SetMode(2, false); SetMode(3, false); SetMode(4, false); } else if (size_block >= 1 && size_block <= SMALL_MAX_SIZE_BLOCK) { SetMode(2, true); SetMode(3, false); SetMode(4, false); } else if (size_block >= 7 && size_block <= LARGE_MAX_SIZE_BLOCK) { SetMode(2, true); SetMode(3, true); SetMode(4, false); } else if (size_block >= 263 && size_block <= MAX_SIZE_BLOCK) { SetMode(2, true); SetMode(3, true); SetMode(4, true); } //分配盘块 if (GetMode(2) == true) { if (AllocateIndexBlock05() == 0xFFFFFFFF) { return 0xFFFFFFFF; } } if (GetMode(3) == true) { if (AllocateIndexBlock67() == 0xFFFFFFFF) { return 0xFFFFFFFF; } } if (GetMode(4) == true) { if (AllocateIndexBlock89() == 0xFFFFFFFF) { return 0xFFFFFFFF; } } if (GetMode(2) == true) { if (AllocateDataBlock() == 0xFFFFFFFF) { return 0xFFFFFFFF; } } return 1; } /* 分配addr[0]~addr[5]的文件索引表盘块 返回: 1 - 成功 0xFFFFFFFF - “磁盘”已满,无法分配“物理盘块”,失败 注意: 不包含更改状态标志位的操作! 分配的是存放文件索引表的盘块,而不是存放文件内容的盘块! */ unsigned int AllocateIndexBlock05() { for (unsigned int i = 0; i <= 5; i++) { addr[i] = 0xFFFFFFFF; } return 1; } /* 分配addr[6]~addr[7]的文件索引表盘块 返回: 1 - 成功 0xFFFFFFFF - “磁盘”已满,无法分配“物理盘块”,失败 注意: 不包含更改状态标志位的操作! 分配的是存放文件索引表的盘块,而不是存放文件内容的盘块! */ unsigned int AllocateIndexBlock67() { unsigned int temp = 0; unsigned int *addr_sub = nullptr; for (unsigned int i = 6; i <= 7; i++) { //addr[i] temp = super_block->bit_map->SearchEmptyBlock(false); if (temp == 0xFFFFFFFF) { return 0xFFFFFFFF; } super_block->bit_map->AllocateBlock(temp); addr[i] = temp; //addr[i]:一级 addr_sub = (unsigned int *)(super_block->user_data->ToAddress(addr[i])); for (unsigned int j = 0; j <= MAX_INDEX_NUM - 1; j++) { addr_sub[j] = 0xFFFFFFFF; } } return 1; } /* 分配addr[8]~addr[9]的文件索引表盘块 返回: 1 - 成功 0xFFFFFFFF - “磁盘”已满,无法分配“物理盘块”,失败 注意: 不包含更改状态标志位的操作! 分配的是存放文件索引表的盘块,而不是存放文件内容的盘块! */ unsigned int AllocateIndexBlock89() { unsigned int temp = 0; unsigned int *addr_sub = nullptr; unsigned int *addr_sub_sub = nullptr; for (unsigned int i = 8; i <= 9; i++) { //addr[i] temp = super_block->bit_map->SearchEmptyBlock(false); if (temp == 0xFFFFFFFF) { return 0xFFFFFFFF; } super_block->bit_map->AllocateBlock(temp); addr[i] = temp; //addr[i]:一级 addr_sub = (unsigned int *)(super_block->user_data->ToAddress(addr[i])); for (unsigned int j = 0; j <= MAX_INDEX_NUM - 1; j++) { temp = super_block->bit_map->SearchEmptyBlock(false); if (temp == 0xFFFFFFFF) { return 0xFFFFFFFF; } super_block->bit_map->AllocateBlock(temp); addr_sub[j] = temp; //addr[8]:二级 addr_sub_sub = (unsigned int *)(super_block->user_data->ToAddress(addr_sub[j])); for (unsigned int k = 0; k <= MAX_INDEX_NUM - 1; k++) { addr_sub_sub[k] = 0xFFFFFFFF; } } } return 1; } /* 申请存放文件数据的盘块 返回: 1 - 成功 0xFFFFFFFF - “磁盘”已满,无法分配“物理盘块”,失败 注意: 不包含更改状态标志位的操作! 不包含申请索引表盘块的操作!文件索引表盘块必须在执行本函数之前申请好,否则会出现严重错误! */ unsigned int AllocateDataBlock() { unsigned int temp_v; unsigned int temp_v2; unsigned int *temp_p; bool dir; dir = GetModeDirectory(); if (dir) { temp_v2 = super_block->bit_map->SearchEmptyBlock(true); } if (size_block != 0) { for (unsigned int i = 0; i <= size_block - 1; i++) { temp_v = Bmap(i, temp_p); if (dir) { super_block->bit_map->AllocateBlock(temp_v2 + i); *temp_p = temp_v2 + i; } else { temp_v = super_block->bit_map->SearchEmptyBlock(false); if (temp_v == 0xFFFFFFFF) { return 0xFFFFFFFF; } super_block->bit_map->AllocateBlock(temp_v); *temp_p = temp_v; } } } return 1; } /* 释放存放文件数据的盘块 注意: 不包含更改状态标志位的操作! 在执行本函数之后,才能释放文件索引表盘块,否则将造成存储空间泄露! */ void ReleaseDataBlock() { if (size_block != 0) { unsigned int temp_v = 0; unsigned int *temp_p = nullptr; for (unsigned int i = 0; i <= size_block - 1; i++) { temp_v = Bmap(i, temp_p); super_block->bit_map->ReleaseBlock(temp_v); *temp_p = -1; } } } /* 释放addr[0]~addr[5]的文件索引表盘块 注意: 不包含更改状态标志位的操作! 释放的是存放文件索引表的盘块,而不是存放文件内容的盘块! */ void ReleaseIndexBlock05() { for (unsigned int i = 0; i <= 5; i++) { addr[i] = -1; } } /* 释放addr[6]~addr[7]的文件索引表盘块 注意: 不包含更改状态标志位的操作! 释放的是存放文件索引表的盘块,而不是存放文件内容的盘块! */ void ReleaseIndexBlock67() { for (unsigned int i = 6; i <= 7; i++) { super_block->bit_map->ReleaseBlock(addr[i]); addr[i] = -1; } } /* 释放addr[8]~addr[9]的文件索引表盘块 注意: 不包含更改状态标志位的操作! 释放的是存放文件索引表的盘块,而不是存放文件内容的盘块! */ void ReleaseIndexBlock89() { unsigned int temp_v = -1; unsigned int *temp_p = nullptr; for (unsigned int i = 8; i <= 9; i++) { temp_p = (unsigned int *)(super_block->user_data->ToAddress(addr[i])); for (unsigned int j = 1; j <= MAX_INDEX_NUM - 1; j++) { super_block->bit_map->ReleaseBlock(temp_p[j]); } super_block->bit_map->ReleaseBlock(addr[i]); addr[i] = -1; } } /* 将逻辑盘块号转化为物理盘块号 参数: lbn - 逻辑盘块号 p - 存放物理盘块号的无符号整数的地址(输出) 返回: 2048 ~ 1097151 - 物理盘块号; 此时,pointer为存放物理盘块号的无符号整数的地址。 0xFFFFFFFF - 这个逻辑盘块号暂未对应物理盘块号(在申请文件内容盘块是会出现这一情况); 此时,pointer为存放物理盘块号的无符号整数的地址。 强制退出: 如果计算结果不对应存放用户数据的“物理盘块”,那么输出错误信息并且强制退出。 */ unsigned int Bmap(unsigned int lbn, unsigned int *(&pointer)) { unsigned int r0, r1, r2; pointer = nullptr; //小型文件 if (lbn < 6) { BmapFunc0(lbn, r0); pointer = addr + r0; } //大型文件 else if (lbn < 6 + 2 * MAX_INDEX_NUM) { BmapFunc1(lbn, r0, r1); pointer = addr + r0; pointer = (unsigned int*)(super_block->user_data->ToAddress(*pointer)); pointer += r1; } //巨型文件 else { BmapFunc2(lbn, r0, r1, r2); pointer = addr + r0; pointer = (unsigned int*)(super_block->user_data->ToAddress(*pointer)); pointer += r1; pointer = (unsigned int*)(super_block->user_data->ToAddress(*pointer)); pointer += r2; } //如果计算结果不对应存放用户数据的“物理盘块”,那么输出错误信息并且强制退出。 if (*pointer < Image_SuperBlock::USER_BLOCK_START || *pointer >= Image_SuperBlock::ALL_BLOCK_NUM) { if (*pointer != 0xFFFFFFFF) { cout << "错误!" << endl; cout << "Bmap算法不正确。" << endl; cout << endl; cout << "程序退出..." << endl; system("pause"); exit(-1); } } return *pointer; } //Bmap:直接索引辅助函数 void BmapFunc0(unsigned int l, unsigned int &r0) { r0 = l; } //Bmap:一级索引辅助函数 void BmapFunc1(unsigned int l, unsigned int &r0, unsigned int &r1) { if (l < 6 + MAX_INDEX_NUM) { r0 = 6; } else { r0 = 7; } r1 = l - (6 + (r0 - 6) * MAX_INDEX_NUM); } //Bmap:二级索引辅助函数 void BmapFunc2(unsigned int l, unsigned int &r0, unsigned int &r1, unsigned int &r2) { if (l < 6 + 2 * MAX_INDEX_NUM + MAX_INDEX_NUM * MAX_INDEX_NUM) { r0 = 8; } else { r0 = 9; } r1 = (l - (6 + 2 * MAX_INDEX_NUM + (r0 - 8) * MAX_INDEX_NUM * MAX_INDEX_NUM)) / MAX_INDEX_NUM; r2 = l - (6 + 2 * MAX_INDEX_NUM + (r0 - 8) * MAX_INDEX_NUM * MAX_INDEX_NUM) - r1 * MAX_INDEX_NUM; } /* 对mode进行按位读取 参数: bit - 需要输出的位 返回: true - 1 false - 0 TIPS: 如果输入的bit大于15,那么一律返回false 状态标志位:[15]~[0] [15][14][13]: 文件所有者对文件的访问权(rwx,有权限-1) [12][11][10]: 文件所有者的同组其他用户对文件的访问权(rwx,有权限-1) [9][8][7]: 其他用户对文件的访问权(rwx,有权限-1) [6]: uid表示文件所有者的用户标识数 [5]: gid表示文件所有者所在的用户组标识数 [4][3][2]: 空文件:000,小型文件:001,大型文件:011,巨型文件:111 [1]: 普通文件-0,目录文件-1 [0]: 节点未分配-0,节点已分配-1 执行Occupy()后的取值情况为(左高右低):110 110 110 1 1 000 0 1 */ bool GetMode(unsigned int bit) { if (bit < 0 || bit > 15) { return 0; } unsigned short temp = 0x0001; for (unsigned int i = 1; i <= bit; i++) { temp = temp << 1; } if ((mode & temp) == 0) { return 0; } else { return 1; } } /* 对mode进行按位写入 参数: bit - 需要操作的位 set - true:置1,false:置0 TIPS: 如果输入的bit大于15,那么设定无效 状态标志位:[15]~[0] [15][14][13]: 文件所有者对文件的访问权(rwx,有权限-1) [12][11][10]: 文件所有者的同组其他用户对文件的访问权(rwx,有权限-1) [9][8][7]: 其他用户对文件的访问权(rwx,有权限-1) [6]: uid表示文件所有者的用户标识数 [5]: gid表示文件所有者所在的用户组标识数 [4][3][2]: 空文件:000,小型文件:001,大型文件:011,巨型文件:111 [1]: 普通文件-0,目录文件-1 [0]: 节点未分配-0,节点已分配-1 执行Occupy()后的取值情况为(左高右低):110 110 110 1 1 000 0 1 */ void SetMode(unsigned int bit, bool set) { if (bit < 0 || bit > 15) { return; } else { unsigned short temp = 0x0001; for (unsigned int i = 1; i <= bit; i++) { temp = temp << 1; } if (set) { mode = mode | temp; } else { mode = mode & (0xFFFF - temp); } } } };
e62088e93a27b71e895e1627ac5397c2784624ac
e842372699fbba5e42708fc18de4cc775377e5d0
/fs_mgr/liblp/test_partition_opener.h
b90fee759b4e65c5fb31ce95abfb8ea07ec85e85
[ "MIT" ]
permissive
aosp-mirror/platform_system_core
cd1921c7e87396ef99ff46332aa34512977c58a4
18560efc308f9c345915dd4d5fa1a2939fcf5ebc
refs/heads/master
2023-08-28T05:09:18.711274
2023-08-25T17:07:42
2023-08-25T17:07:42
65,923
610
877
NOASSERTION
2023-05-13T20:56:01
2008-10-21T18:21:04
C++
UTF-8
C++
false
false
1,386
h
test_partition_opener.h
/* * Copyright (C) 2018 The Android Open Source Project * * 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. */ #pragma once #include <map> #include <string> #include <android-base/unique_fd.h> #include <liblp/partition_opener.h> namespace android { namespace fs_mgr { class TestPartitionOpener : public PartitionOpener { public: explicit TestPartitionOpener(const std::map<std::string, int>& partition_map, const std::map<std::string, BlockDeviceInfo>& partition_info = {}); android::base::unique_fd Open(const std::string& partition_name, int flags) const override; bool GetInfo(const std::string& partition_name, BlockDeviceInfo* info) const override; private: std::map<std::string, int> partition_map_; std::map<std::string, BlockDeviceInfo> partition_info_; }; } // namespace fs_mgr } // namespace android
a5fb801d31211d52fba49c398928777faa470bf9
86dcea4619590879ad9b1938d80ffe0a035cd041
/NeuroStudio/impl/Win32/AbstractNNWnd.h
5d14e2be4480f7dcfbefa0b22813cc5f5ba9743f
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "BSD-2-Clause" ]
permissive
smmzhang/NeuroStudio
aaa4826ef732963e4f748a46625a468a1ae810d3
f505065d694a8614587e7cc243ede72c141bd80b
refs/heads/master
2022-01-08T23:37:52.361831
2019-01-07T11:29:45
2019-01-07T11:29:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,141
h
AbstractNNWnd.h
#pragma once #include "gui/win32/MappingWnd.h" #include "gui/Win32/GraphicUtil.h" #include "network/NetworkMatrix.h" #include "network/NNMatrixModify.h" using namespace np; using namespace np::network; using namespace np::gui::win32; class AbstractNNWnd : public CMappingWnd { public: AbstractNNWnd(const network::NetworkMatrix& network_matrix, const std::vector<_CLIPBOARDFORMAT_INFO>& cf_vector = {}); virtual ~AbstractNNWnd(); void ClearSelect(); const NetworkMatrix& GetNetworkMatrix() const { return m_network_matrix; } void SelectLayer(AbstractLayer* layer); void EnsureVisible(const AbstractLayer& layer); protected: NP_SIZE GetScrollTotalViewSize() const override; neuro_u32 GetScrollMoving(bool is_horz) const override; virtual void Draw(CDC& dc, CRect rcClient) override; virtual void MouseLClickEvent(bool bMouseDown, NP_POINT pt) override; virtual void MouseRClickEvent(bool bMouseDown, NP_POINT pt) override; virtual void MouseMoveEvent(NP_POINT point) override; virtual void ContextMenuEvent(NP_POINT point) override; protected: virtual _POS_INFO_IN_LAYER SelectNeuroUnit(NP_POINT point); virtual void AfterNetworkSelected(NP_POINT point) {} virtual void AfterNetworkMouseMove(NP_POINT point) {} const _LINK_INFO* LinkHitTest(const NP_POINT& pt) const; virtual void OnLClickedUnit(bool bMouseDown, NP_POINT point) {} virtual void OnRClickedUnit(bool bMouseDown, NP_POINT point) {} virtual bool OnContextMenu(NP_POINT point, const _POS_INFO_IN_LAYER& pos_info) { return false; } protected: virtual void BeginDragLayer(NP_POINT pt, const MATRIX_POINT& matrix_pt){} protected: const NetworkMatrix& m_network_matrix; bool m_bMouseLButtonDown; AbstractLayer* m_mouseoverLayer; const _LINK_INFO* m_mouseoverLink; struct _SELECTED_UNIT { _SELECTED_UNIT() { Initialize(); } void Initialize() { link = NULL; layer = NULL; } bool IsValid() const { return link != NULL || layer != NULL; } const _LINK_INFO* link; AbstractLayer* layer; }; _SELECTED_UNIT m_selected_unit; MATRIX_SCOPE m_selected_scope; virtual void SelectMultiLayers(const NP_2DSHAPE& rc); };
df2a47747e3341f5cfdf8f90155106806c3b7a95
1ed1f5c2d12dcd3c11ae405c7e84d90e82bef8e0
/Phase II/basicsP2/AlphaShapeManipulation.cpp
762c9097b3e9bd80b5c04da922bcee7075b5d86d
[]
no_license
akbari59/cs5237-geo
6805f67e12e08b1994974f0d7e467af32196353e
f928a999fec3130684f16fd0321f5a1e95251dff
refs/heads/master
2020-04-15T15:32:52.693194
2012-11-13T12:39:28
2012-11-13T12:39:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
186
cpp
AlphaShapeManipulation.cpp
#include "trist.h" void Trist::setVoronoiVertex(OrTri tri, const LongInt& x, const LongInt& y, const LongInt& denominator) { triangles[tri>>3].setVoronoiVertex(x, y, denominator); }
7c7a2f17f2e6254a984e6cdfa68d6e5326ca0123
af0ecafb5428bd556d49575da2a72f6f80d3d14b
/CodeJamCrawler/dataset/13_33_30.cpp
ff1e293fcdf3e7a92b3d59e4dfd7d27d43e14401
[]
no_license
gbrlas/AVSP
0a2a08be5661c1b4a2238e875b6cdc88b4ee0997
e259090bf282694676b2568023745f9ffb6d73fd
refs/heads/master
2021-06-16T22:25:41.585830
2017-06-09T06:32:01
2017-06-09T06:32:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,305
cpp
13_33_30.cpp
#include <iostream> using namespace std; int verificar(char mat[4][4]) { int respuesta=0; int x=5,y=5; int lasx=0,lasy=0; bool haypunto=false; for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { if (mat[i][j]=='T') {x=i;y=j;} if (mat[i][j]=='.') haypunto=true; } } if (x!=5 && y!=5) { for (int i=0;i<4;i++) { if (mat[x][i]=='X') lasx++; if (mat[x][i]=='O') lasy++; } if(lasx==3 || lasx==4) respuesta=1; if(lasy==3 || lasy==4) respuesta=2; else {lasx=0;lasy=0;} for (int i=0;i<4;i++) { if (mat[i][y]=='X') lasx++; if (mat[i][y]=='O') lasy++; } if(lasx==3) respuesta=1; if(lasy==3) respuesta=2; else {lasx=0;lasy=0;} mat[x][y]='X'; if ((mat[0][0]==mat[1][1])&&(mat[1][1]==mat[2][2])&&(mat[2][2]==mat[3][3])&&(mat[3][3]=='X')) respuesta=1; if ((mat[0][3]==mat[1][2])&&(mat[1][2]==mat[2][1])&&(mat[2][1]==mat[3][0])&&(mat[3][0]=='X')) respuesta=1; mat[x][y]='O'; if ((mat[0][0]==mat[1][1])&&(mat[1][1]==mat[2][2])&&(mat[2][2]==mat[3][3])&&(mat[3][3]=='O')) respuesta=2; if ((mat[0][3]==mat[1][2])&&(mat[1][2]==mat[2][1])&&(mat[2][1]==mat[3][0])&&(mat[3][0]=='O')) respuesta=2; mat[x][y]='T'; } lasx=0;lasy=0; for (int i=0;i<4;i++) { for(int j=0;j<4;j++) { if (mat[i][j]=='X') lasx++; if (mat[i][j]=='O') lasy++; } if(lasx==4) {respuesta=1;i=5;} if(lasy==4) {respuesta=2;i=5;} else {lasx=0;lasy=0;} } for (int i=0;i<4;i++) { for(int j=0;j<4;j++) { if (mat[j][i]=='X') lasx++; if (mat[j][i]=='O') lasy++; } if(lasx==4) {respuesta=1;i=5;} if(lasy==4) {respuesta=2;i=5;} else {lasx=0;lasy=0;} } if ((mat[0][0]==mat[1][1])&&(mat[1][1]==mat[2][2])&&(mat[2][2]==mat[3][3])&&(mat[3][3]=='X')) respuesta=1; if ((mat[0][3]==mat[1][2])&&(mat[1][2]==mat[2][1])&&(mat[2][1]==mat[3][0])&&(mat[3][0]=='X')) respuesta=1; if ((mat[0][0]==mat[1][1])&&(mat[1][1]==mat[2][2])&&(mat[2][2]==mat[3][3])&&(mat[3][3]=='O')) respuesta=2; if ((mat[0][3]==mat[1][2])&&(mat[1][2]==mat[2][1])&&(mat[2][1]==mat[3][0])&&(mat[3][0]=='O')) respuesta=2; if (respuesta==0 && (haypunto==false)) respuesta=3; if (respuesta==0 && haypunto) respuesta=4; return respuesta; } int main() { int t; char k; char mat[4][4]; cin>>t; for(int c=0;c<t;c++) { for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { cin>>k; mat[i][j]=k; } } cout<<"Case #"<<c+1<<": "; int respuesta=verificar(mat); if (respuesta==1) cout<<"X won"; if (respuesta==2) cout<<"O won"; if (respuesta==3) cout<<"Draw"; if (respuesta==4) cout<<"Game has not completed"; cout<<endl; } }
5a6b44bde1becb02c86c88bb2739719cda0a9689
23f6ef9ef92bc43e86822363b08c957c074250e4
/src/attribute.cpp
1ac0bd00e92330131647830482b5c0c916435ec5
[ "MIT" ]
permissive
szszss/CharmingTremblePlus
51e2a64984227dd59225a6d53fb116a0cb987154
1f14a100963b4bc846324f0bd7bfbc0751f7e1bd
refs/heads/master
2020-05-21T01:05:53.212814
2014-10-29T08:06:28
2014-10-29T08:06:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,053
cpp
attribute.cpp
#include "attribute.h" #include "entity.h" #include "memory.h" //#include "collection.h" int InitAttributes() { LoggerInfo("Attributes initialized"); return 0; } BOOL AttributeMossySlow::OnUpdate(World &world, Entity *entity) { EntityPlayer* player = (EntityPlayer*)entity; if (player->landed && ((lastLife) < (GetDefaultLife() - 5))) return FALSE; if (player->posY<-14.0f) return FALSE; player->speedFactorX *= 0.5f; return TRUE; } int AttributeMossySlow::GetDefaultLife() { return 300; } BOOL AttributePowerUpSpeed::OnUpdate(World &world, Entity *entity) { EntityPlayer* player = (EntityPlayer*)entity; player->speedFactorX *= 2.0f; return TRUE; } int AttributePowerUpSpeed::GetDefaultLife() { return 300; } BOOL AttributePowerUpJump::OnUpdate(World &world, Entity *entity) { EntityPlayer* player = (EntityPlayer*)entity; player->jumpFactor *= 1.5f; return TRUE; } int AttributePowerUpJump::GetDefaultLife() { return 300; } int AttributeDestroyCallback(void *attributeInstance) { delete(attributeInstance); return 0; }
7e3201fdb893ffa27ddfea2d4c6b004b6ae84989
c558cf8bf8f74696925e190a327fcdd3f912eb33
/encoder_information.h
747167022c006e8384252de59421f148abc0e198
[]
no_license
sdusky/encoder_device
4aeb4d3efe0c197cc92b5d6ea11e807cffbdaace
4695e5933e577f750542c573e42ea0b3788f585a
refs/heads/master
2021-01-10T20:57:37.616635
2015-02-26T02:47:14
2015-02-26T02:47:14
28,015,952
1
1
null
null
null
null
UTF-8
C++
false
false
1,430
h
encoder_information.h
#ifndef ENCODER_INFORMATION_H #define ENCODER_INFORMATION_H #include <QObject> #include "encoder_package.h" /** * @brief 信息打包类,生成结构化视频信息包 * 邢大天 2014-12-07 * 邢大天 2015-02-06 * */ class encoder_information : public QObject { Q_OBJECT public: /** * @brief * * @param parent */ explicit encoder_information(QObject *parent = 0); signals: /** * @brief 信号 * * @param data 需要udp发送的信息 */ void send_data_to_udp(QByteArray data); private: QByteArray data_send; /**< 需要发送的信息 */ QByteArray data_sensor; /**< 传感器信息 */ int num_of_sensor; /**< 传感器数量 */ public slots: /** * @brief 槽函数,接收编码后视频信息 融合传感器信息形成结构化信息 * 格式: * 6字节包长度+1个字节传感器数量+6字节视频长度+视频信息+4字节传感器信息长度+传感器信息 * * @param encoded_picture_information h.264编码结构体 */ void get_video_from_encoder(encoded_picture_information); /** * @brief 槽函数,接收传感器信息 * * @param sensor_data 传感器信息 * @param sensor_num 已采集传感器数量 */ void get_infor_from_sensor(QByteArray sensor_data,int sensor_num); }; #endif // ENCODER_INFORMATION_H
c7d31eb0d9855f46298d1994adc493b11079f6cc
da7dff2101a6af25d2a6070e8e1944ae069a8a69
/game/state/rules/city/ufogrowth.h
5adf75fe60d7a979ad5a51b62c412d1f60bd1b83
[ "GPL-3.0-only" ]
permissive
idshibanov/OpenApoc
2983c72bd07ac1e964fc7a0ba16375834c0ed673
50bffd4d7fcfc58bb27f9983d0a9cdcdf43e09f3
refs/heads/master
2021-05-20T17:15:18.505076
2021-02-20T13:02:06
2021-02-20T13:02:06
61,973,803
2
0
MIT
2020-07-22T13:39:57
2016-06-26T04:35:55
C++
UTF-8
C++
false
false
278
h
ufogrowth.h
#pragma once #include "game/state/stateobject.h" #include "library/strings.h" #include <vector> namespace OpenApoc { class UFOGrowth : public StateObject<UFOGrowth> { public: int week = 0; std::vector<std::pair<UString, int>> vehicleTypeList; }; }; // namespace OpenApoc
2552acad9b35e689a8ae0de8a1b9338ed6fb78a6
90f2191bb8a5c9f82c33a23e34f58d7a2b8e6c96
/Binary Trees/Lab/BinaryTreeDeleteTest.cpp
b110c8be4bed0e77190929a52356fd24ff7a20a4
[]
no_license
Pierce1396/Data-Structures-Algorithms
0e34443eadcff66bc4e17770e5033a736279bbec
86b3b35b192ccc67efb0eef68161e422f0e9ef0e
refs/heads/main
2023-02-02T03:40:19.685273
2020-12-23T18:36:36
2020-12-23T18:36:36
323,976,344
0
0
null
null
null
null
UTF-8
C++
false
false
2,902
cpp
BinaryTreeDeleteTest.cpp
#include <iostream> #include <string> #include <memory> #include "BTree.h" using namespace std; bool checkTest(string testName, bool condition); bool checkTest(string testName, int whatItShouldBe, int whatItIs); void testFindMethod( BTree<int>); void testRightMostNodeSearch(BTree<int>); void deleteTest(BTree<int>); BTree<int> populateTree(); int main() { BTree<int> myTree = populateTree(); testFindMethod(myTree); testRightMostNodeSearch(myTree); deleteTest(myTree); return 0; } BTree <int> populateTree(){ BTree<int> myTree; int values[] = {37, 32, 73, 95, 42, 12, 0, 49, 98, 7, 27, 17, 47, 87, 77, 97, 67, 85, 15, 5, 35, 55, 65, 75, 25, 45, 3, 93, 83, 53, 63, 23, 13, 43, 33}; int size = (sizeof(values)/sizeof(*values)); for(int i = 0; i < size; i++){ myTree.insert(values[i]); } myTree.inOrder(); cout << endl; return myTree; } void testFindMethod( BTree<int> myTree){ auto ptr = myTree.find(49); checkTest("Test 1: Find(49)", 49, ptr->data); ptr = myTree.find(200); checkTest("Test 2: Find(200)", ptr == nullptr); } void testRightMostNodeSearch(BTree<int> myTree){ auto ptr = myTree.find(49); auto ptrchild = myTree.findRightMostNode(ptr); checkTest("Test 3: RightNodeTest(49)", 67, ptrchild->data); } void deleteTest(BTree<int> myTree){ myTree.remove(35); auto ptr = myTree.find(35); if(!checkTest("Test 4: Delete Leaf: 13", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(67); ptr = myTree.find(67); if(!checkTest("Test 5: Delete Node with Left Child: 67", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(42); ptr = myTree.find(42); if(!checkTest("Test 6: Delete Node with Right Child: 42", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(73); ptr = myTree.find(73); if(!checkTest("Test 7: Delete Node with two children: 42", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(37); ptr = myTree.find(37); if(!checkTest("Test 8: Delete root: 37", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } } //Helps with Testing bool checkTest(string testName, int whatItShouldBe, int whatItIs) { if (whatItShouldBe == whatItIs) { cout << "Passed " << testName << endl; return true; } else { cout << "***Failed test " << testName << " *** " << endl << " Output was " << whatItIs << endl << " Output should have been " << whatItShouldBe << endl; return false; } } //Helps with Testing bool checkTest(string testName, bool condition) { if (condition) { cout << "Passed " << testName << endl; return true; } else { cout << "***Failed test " << testName << " *** " << endl; return false; } }
c0bc3caf3c004b9a6223d896ade03599b6df233c
870208ac28f0c2523e1a0d939e771dc9fcb10b99
/p0.5 Display Array.cpp
b7145d1180fd26ab7af0dc81134827272cc70e9a
[]
no_license
Greco452/Cplusplus-code-examples
47ac3381cd63253394e3ee40ad3f4b6bddab51de
df60b59f95ad79c8c7a988dba89026beb1b00216
refs/heads/master
2021-07-03T21:39:46.445461
2017-09-18T15:44:36
2017-09-18T15:44:36
103,957,456
0
0
null
null
null
null
UTF-8
C++
false
false
1,017
cpp
p0.5 Display Array.cpp
// Course: CS2400-60 Computer Science 2 // Name: Greco, Michael // Assignment: P0.5 // Date assigned: 1/19/17 // Date due: 1/25/17 // Date handed in: 1/31/17 // Remark: This is a program consisting of main and display_array functions. //The main function then calls the display_array function to display the contents of the array. #include <iostream> using namespace std; void display_array(int a[]);//Function prototype //Precondition: An initialized array must be declared to be displayed //Postcondition: The contents of the array are displayed const int arraySize = 10; int main() { int a[arraySize] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // initalize array with values 1-10 display_array(a);//function call system("pause"); return 0; } void display_array(int a[]) // function header { for (int n = 0; n < arraySize; n++) //Loop to display values in each array spot { cout << "Array value " << n + 1 << " is: " << a[n] << endl; //output array value n } cout << endl; }
d43c2261150492ff974e521c7ab5824f306d4dca
04f15913aca8a702efe47962bf82b60eedad73d9
/Lib/DbUi/DbBackupThread.h
f7abf56ac27e02c47d8fc2208e7cbd6955e71834
[]
no_license
DevilCCCP/Code
eae9b7f5a2fede346deefe603a817027a87ef753
9cc1a06e5010bb585876056a727abad48bca3915
refs/heads/master
2021-10-07T17:04:27.728918
2021-09-28T06:49:50
2021-09-28T06:49:50
166,522,458
0
1
null
null
null
null
UTF-8
C++
false
false
1,114
h
DbBackupThread.h
#pragma once #include <QThread> #include <QSet> #include <Lib/Db/Db.h> #include <Lib/Db/DbBackup.h> DefineClassS(DbBackupThread); DefineClassS(DbBackupTc); DefineClassS(FormDbBackup); DefineClassS(DbBackup); class DbBackupTc: public DbBackupController { FormDbBackup* mHost; public: /*override */virtual bool QueryContinue() override; /*override */virtual void OnPercent(int perc) override; /*override */virtual void OnTable(int index) override; /*override */virtual void OnInfo(const QString& text) override; /*override */virtual void OnError(const QString& text) override; public: DbBackupTc(FormDbBackup* _Host); ~DbBackupTc(); }; class DbBackupThread: public QThread { FormDbBackup* mHost; QStringList mTableOrder; bool mBackup; QSet<QString> mTableSet; QString mFile; public: /*override */virtual void run() override; public: void Start(const QString& file, const QSet<QString>& tableSet, bool backup); public: DbBackupThread(FormDbBackup* _Host, QStringList _TableOrder); ~DbBackupThread(); };
3e77ba6e57abc06d864bdba7f0a007f32bd493bc
7b34793f270945fb20c03d6bd3e2ced13b59f079
/Xcode Build/that game engine/that_game_engine/Math.hpp
3c6012443fc917780f1194b763fb42ddc3b41d71
[ "MIT" ]
permissive
thatgamesguy/that_game_engine
3a1c8fa57d5582ec19bcef111552f12eb669be94
90c80ebb4e890b9e4684ec87841b4bf4e446a3d1
refs/heads/master
2021-12-31T07:11:15.765836
2021-12-10T10:24:26
2021-12-10T10:24:26
120,003,746
88
34
MIT
2021-04-01T16:23:40
2018-02-02T16:21:06
C++
UTF-8
C++
false
false
416
hpp
Math.hpp
#ifndef Math_hpp #define Math_hpp class Mathf { public: static inline sf::Vector2f Normalise(const sf::Vector2f& v) { float l = Magnitude(v); if (l != 0) { return v / l; } return v; } static inline float Magnitude(const sf::Vector2f& v) { return sqrt((v.x * v.x) + (v.y * v.y)); } }; #endif /* Math_hpp */
cb1f0ba2ff87a8ddcbb4b7e0d0ce3d1aa672f6f6
9f561d4ce1646b0818b69087b06813a26bb290a5
/Codeforces/C++/A/653A.cpp
708f170224babc7a598347117d1f4bc226ae47c9
[]
no_license
ahmedfci93/Problem-Solving
b5c34601b59075d5b62aead10b8073b6c00f797c
148e9e29bd4fd3cf6fe9f93a7d90983abb83cd38
refs/heads/master
2018-12-22T15:43:55.405718
2018-10-06T16:28:23
2018-10-06T16:28:23
112,637,571
0
0
null
null
null
null
UTF-8
C++
false
false
428
cpp
653A.cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int i,n,f=0,num; vector<int> t; cin>>n; for(i=0;i<n;i++) { cin>>num; t.push_back(num); } sort(t.begin(),t.end()); t.erase(unique(t.begin(), t.end()),t.end()); int sz=t.size(); for(i=0;i<sz-2;i++) { if(t[i]+1==t[i+1] && t[i+1]+1==t[i+2] ) { f=1; break; } } if(f)cout<<"YES"; else cout<<"NO"; return 0; }
124dc2c1c1889bac80a3c494901eae7aa3667911
4cbd85de1b149a0bb35a90e09160bbcbc935b042
/NOI/sols/E/IP/contest.cpp
5d4f0d4237401cee312e6bffad04c35b97595a02
[]
no_license
Alex-Tsvetanov/Testing-Scripts
cacaaea1642b18f6ea261faa0e19d0cc26a5b6d2
c201f3bf02662a8fb3e862211cbf6f74725dfac3
refs/heads/master
2021-05-13T23:46:17.206320
2018-01-07T00:18:13
2018-01-07T00:18:13
116,525,044
0
0
null
null
null
null
UTF-8
C++
false
false
227
cpp
contest.cpp
#include <iostream> using namespace std; int main (){ long long nBrZ; long long tCasa; long long fz; long long xVr; long long vreme; cin>>n>>t>>fz>>x; vreme=1; for(fz=vreme;tCasa>vreme;nBrZ=xVr*nBrZ) return 0; }
2a339fa3fa7c3eb4b61b7ebe9a8b373e19d01446
ef035816f2fd3f6c5ab32b835b8a6dcbbf097bf6
/src/prototype/simulation/Rate.h
3e7a5e58f4fafa0a769915422682b2dd9815cd0c
[]
no_license
sdellang/ispn-cpp-client-prototype
a71a8e0e01bba43e418773bfae4e19966e430eb9
d8b30456f7c8fe3d9ee888f780bb63ef4b07b522
refs/heads/master
2021-01-19T07:53:42.462635
2013-10-23T16:30:55
2013-10-23T16:30:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
501
h
Rate.h
#ifndef PROTOTYPE_SIMULATION_RATE_H #define PROTOTYPE_SIMULATION_RATE_H #include "prototype/simulation/RateInterval.h" #include "prototype/simulation/RateIter.h" #include <vector> namespace prototype { namespace simulation { class Rate { public: Rate& add(const RateInterval& rate); RateIter begin(); RateIter end(); private: std::vector<RateInterval> rateIntervals; }; }} // namespace prototype::simulation #endif /* PROTOTYPE_SIMULATION_RATE_H */
88081a6df498e7ed9821cf460e01e5080476809d
7e1b9bc535ec774dca11b716dbcd037f9c2acf77
/include/gallery/rsearch_gallery.h
5505ff36a0b7e4e1f314dea112c6386fee8019bd
[]
no_license
ZhengZhuorui/rsearch
5b2424f8f89bd3549f14d5edf339f85606e447c2
1996c762474f2aef22b62eb0463240f5fa2073a4
refs/heads/master
2021-03-12T04:40:03.064320
2020-07-31T15:26:32
2020-07-31T15:26:32
246,590,332
0
1
null
null
null
null
UTF-8
C++
false
false
880
h
rsearch_gallery.h
#pragma once #include "rsearch_def.h" #include "utils/utils.h" namespace rsearch{ template<typename T> class gallery{ public: gallery(){} virtual ~gallery(){} virtual int init() = 0; typedef typename TMap<T>::type Tout; virtual int add(const T* const x, const int n) = 0; virtual int add_with_uids(const T* const x, const idx_t * const uids, const int n) = 0; virtual int change_by_uids(const T* const x, const idx_t * const uids, const int n) = 0; virtual int remove_by_uids(const idx_t * const uids, const int n) = 0; virtual int query_by_uids(const idx_t* const uid, const int n, T * x) = 0; virtual int reset() = 0; virtual int store_data(std::string file_name) = 0; virtual int load_data(std::string file_name) = 0; virtual int train(const float* const x, int n) = 0; }; }
44355690f494236e6cd865b386041c01b1091700
c19fbae37e0361d44cbc4ef93df055b336467709
/C++/talkWithMe/mainwindow.cpp
74f3072c55f3b8dc3fb9b47190a8dbc7f9e34b60
[]
no_license
cuidx/codememo
6894bd4668b63c8981ee7a35bd98496b404add13
3bad4d3039a60c1369d74c77962d3b33a14cdbe1
refs/heads/master
2021-09-04T03:00:18.695532
2021-08-13T01:04:35
2021-08-13T01:04:35
104,612,147
0
0
null
null
null
null
UTF-8
C++
false
false
1,700
cpp
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include "objectview.h" #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ObjectView *view = new ObjectView(this); view->setGeometry(rect()); view->SetResource(QString(":/res/Hello.bmp"), QString(""),//QString("/home/cuidx/talkWithMe/sample.wav"), // QString::fromUtf8("<emphasis level=\'strong\'>爸</emphasis><emphasis level=\'reduce\'>爸</emphasis>")); //QString::fromUtf8("爸<break time=\'300ms\'/>爸")); QString::fromUtf8("<phoneme>ba4</phoneme><phoneme>ba</phoneme>")); m_playList = new PlayList(); m_playList->LoadPlayList(std::string("./playList.xml")); if (m_playList->GetCount() == 0) { for (int iPos = 0; iPos < 10; iPos++) { ObjectInfo obj; obj.m_title = "TestObject"; obj.m_title.push_back('0' + iPos); obj.m_picPath = ":/res/Hello.bmp"; obj.m_soundPath = "/home/cuidx/talkWithMe/sample.wav"; m_playList->AddObject(obj); } m_playList->SavePlayList(); } else { qDebug() << "playlist count : " <<m_playList->GetCount(); PlayList::PlayListIterator iter = m_playList->begin(); for (; iter != m_playList->end(); iter++) { qDebug()<<QString::fromStdString(iter->m_title)<< " \t" <<QString::fromStdString(iter->m_picPath)<<" \t" <<QString::fromStdString(iter->m_soundPath); } } } MainWindow::~MainWindow() { delete ui; }
fa9d14e291dec7453717304617575d9fba919d1b
d2f67d6c5933f96b816a3195401aabd56a4f7f05
/Day_04/ex00/Victim.hpp
3d501d70418d202155b29e8c57305d03c46ba6c9
[]
no_license
florianne1212/CPP_piscine_42
2ce473fdd4cdac4ee100159b80a28ac91426843f
c151616103e606ab05f2f6ac66d5a93b2900591b
refs/heads/master
2023-03-25T03:43:53.828656
2021-03-24T11:15:04
2021-03-24T11:15:04
316,215,698
0
0
null
null
null
null
UTF-8
C++
false
false
446
hpp
Victim.hpp
#ifndef VICTIM_H # define VICTIM_H #include <string> #include <iostream> class Victim { protected: Victim(); std::string _name; public: Victim(std::string name); Victim(Victim const & copy); virtual ~Victim(); Victim & operator=(Victim const & ope); virtual void getPolymorphed() const; const std::string& getName(void) const; }; std::ostream &operator<<(std::ostream &stream, Victim const &victi); #endif
645ba4d1b98f900fb43a4de9343a8f14ffb65a6a
b42b0be53a4b0a6d0333dc231c0c613dfaa7b321
/Plugins/VRCharacterPlugin/Source/VRCharacterPlugin/Public/VRCharacterBase.h
64370338bd5676201b98b4ce600f29379dde3fba
[]
no_license
saiedbaran/VRCharacter_UE4
8e1fda2138bf18481b3acd5c19c3b328d160168a
34fabe3c3fa1161d1027030a4c141f2a6cd46319
refs/heads/main
2023-03-29T23:08:06.448065
2021-04-06T16:32:29
2021-04-06T16:32:29
326,738,132
1
0
null
null
null
null
UTF-8
C++
false
false
5,089
h
VRCharacterBase.h
// Pawn Class for VR applications in Unreal Engine // Game Lab Graz, Jan 2021 #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "VRCharacterBase.generated.h" class USphereComponent; class UVRHandMotionController; class UCameraComponent; constexpr float GripOpen = 0.0f; constexpr float GripClose = 1.0f; constexpr int DefaultTypeOfGrab = 0; struct FPredictProjectilePathResult; struct FPredictProjectilePathParams; UCLASS() class VRCHARACTERPLUGIN_API AVRCharacterBase : public ACharacter { GENERATED_BODY() // Methods public: AVRCharacterBase(); virtual void Tick(float DeltaTime) override; virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; virtual void PostRegisterAllComponents() override; // Grab interaction void OnGrabRight(); void OnGrabLeft(); void OnReleaseRight(); void OnReleaseLeft(); static AActor* GetNearestOverlappingPickup(USphereComponent* SphereComponent); // Hand Pose void UpdateGripStatRight(const float AxisValue); void UpdateGripStatLeft(const float AxisValue); // Teleportation void OnPressTeleportRight(); void OnReleaseTeleportRight(); void OnPressTeleportLeft(); void OnReleaseTeleportLeft(); void UpdateDestinationMarker(); bool UpdateProjectilePath(FPredictProjectilePathParams& PathParams, FPredictProjectilePathResult& PathResult, FVector StartPos, FVector LaunchVelocityVector) const; void UpdateProjectileSpline(TArray<FVector> PathPoints) const; void ClearProjectilePool(); void UpdateProjectileMesh(TArray<FVector> PathPoints); void BeginTeleport() const; USkeletalMeshComponent* GetHandSkeletalMesh(USceneComponent* AttachTo) const; protected: virtual void BeginPlay() override; UFUNCTION() void RightHandBeginOverlapped(UPrimitiveComponent* OverlappedComp, AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); void LeftHandBeginOverlapped(UPrimitiveComponent* OverlappedComp, AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); private: // Members public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "[Feature] components") USceneComponent* VROffset; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "[Feature] components") UStaticMeshComponent* TeleportIndicator; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "[Feature] components") UCameraComponent* VRCamera; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "[Feature] components") UVRHandMotionController* RightHand; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "[Feature] components") UVRHandMotionController* LeftHand; protected: UPROPERTY(EditAnywhere, Category = "[Feature] Debug") bool bDebugGrabSphere = false; UPROPERTY(EditAnywhere, Category = "[Feature] Debug") bool bDebugGrabAction = false; UPROPERTY(EditAnywhere, Category = "[Feature] Debug") bool bDebugHandPose = false; UPROPERTY(EditAnywhere, Category = "[Feature]: Debug") bool bIsShowProjectionDebug = true; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float MaxTeleportDistance = 1000.0f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float TeleportBeginOffset = 20.0f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float TeleportFadeDelay = 1.0f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float ProjectileDuration = 10.0f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float TeleportLaunchVelocity = 900.0f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float ProjectilePathRadius = 5.0f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") bool bIsTraceComplex = true; UPROPERTY(EditDefaultsOnly, Category = "[Feature]: Teleportation") UStaticMesh* TeleportProjectileMesh; UPROPERTY(EditDefaultsOnly, Category = "[Feature]: Teleportation") UMaterialInterface* TeleportProjectileMaterial; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") TArray<AActor*> ActorsToIgnore; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") FVector ProjectNavigationExtend = FVector(500.0f, 500.0f, 500.0f); UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") UHapticFeedbackEffect_Base* TeleportationHaptic; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") float TeleportHapticIntensity = 0.3f; UPROPERTY(EditAnywhere, Category = "[Feature]: Teleportation") FColor CameraFadeColor = FColor::Black; UPROPERTY(VisibleAnywhere, Category = "[Feature]: Teleportation") TArray<class USplineMeshComponent*> ProjectileMeshPool; private: bool bIsHitTeleportTarget = false; bool bIsUpdatingTeleportDestination = false; bool bIsDestinationFound = false; bool bIsRightHandDoTeleportation = true; };
5037e3a05daae610299eb0ca34d1daa6902da781
e9d06e6a15a71faca95835d5bedfe1eac290cc63
/libcamera/ExynosCameraActivitySpecialCapture.h
d94723a7f53bc2f11cd34de8bab281e051b1885e
[ "Apache-2.0" ]
permissive
randomstuffpaul/android_hardware_samsung_slsi-cm_exynos5420
3a2a5d1232e823f8a6f9525d3ba5f48cdaa30b3d
d49b27252de467ff93448332585e2ada74395643
refs/heads/cm-13.0
2021-01-15T18:45:59.045047
2016-09-14T02:12:46
2016-09-14T02:12:46
68,110,096
2
0
null
2016-09-13T13:19:23
2016-09-13T13:19:23
null
UTF-8
C++
false
false
3,373
h
ExynosCameraActivitySpecialCapture.h
/* * Copyright 2012, Samsung Electronics Co. LTD * * 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 toggle 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. */ /*! * \file ExynosCameraActivitySpecialCapture.h * \brief hearder file for CAMERA HAL MODULE * \author Pilsun Jang(pilsun.jang@samsung.com) * \date 2012/12/19 * */ #ifndef EXYNOS_CAMERA_ACTIVITY_SPECIAL_CAPTURE_H__ #define EXYNOS_CAMERA_ACTIVITY_SPECIAL_CAPTURE_H__ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <signal.h> #include <sys/mman.h> #include <sys/time.h> #include <sys/ioctl.h> #include <sys/poll.h> #include <sys/stat.h> #include <sys/types.h> #include <utils/threads.h> #include <videodev2.h> #include <videodev2_exynos_camera.h> #include <linux/vt.h> #include <utils/RefBase.h> #include <utils/String8.h> #include <utils/List.h> #include "cutils/properties.h" #include "exynos_format.h" #include "ExynosBuffer.h" #include "ExynosRect.h" #include "ExynosJpegEncoderForCamera.h" #include "ExynosExif.h" #include "exynos_v4l2.h" #include "fimc-is-metadata.h" #include "ExynosCameraActivityBase.h" #define CAPTURE_SKIP_COUNT (1) #define BAYER_LOCK (2) namespace android { class ExynosCameraActivitySpecialCapture : public ExynosCameraActivityBase { public: enum SCAPTURE_DUMMY { SCAPTURE_DUMMY, SCAPTURE_DUMMY1 }; enum SCAPTURE_MODE { SCAPTURE_MODE_NONE, SCAPTURE_MODE_LLL, SCAPTURE_MODE_END }; enum SCAPTURE_STEP { SCAPTURE_STEP_OFF, SCAPTURE_STEP_START, SCAPTURE_STEP_MINUS_SET, SCAPTURE_STEP_ZERO_DELAY_SET, SCAPTURE_STEP_ZERO_SET, SCAPTURE_STEP_PLUS_SET, SCAPTURE_STEP_RESTORE, SCAPTURE_STEP_WAIT_CAPTURE_DELAY, SCAPTURE_STEP_WAIT_CAPTURE, SCAPTURE_STEP_END }; public: ExynosCameraActivitySpecialCapture(); virtual ~ExynosCameraActivitySpecialCapture(); protected: int t_funcNull(void *args); int t_funcSensorBefore(void *args); int t_funcSensorAfter(void *args); int t_func3ABefore(void *args); int t_func3AAfter(void *args); int t_funcISPBefore(void *args); int t_funcISPAfter(void *args); int t_funcSCPBefore(void *args); int t_funcSCPAfter(void *args); int t_funcSCCBefore(void *args); int t_funcSCCAfter(void *args); public: int setCaptureMode(enum SCAPTURE_MODE sCaptureModeVal); int setCaptureStep(enum SCAPTURE_STEP sCaptureStepVal); private: enum SCAPTURE_MODE m_specialCaptureMode; enum SCAPTURE_STEP m_specialCaptureStep; unsigned int m_currentInputFcount; int m_backupAeExpCompensation; enum aa_scene_mode m_backupSceneMode; enum aa_mode m_backupAaMode; int m_delay; bool m_check; ExynosBuffer m_reqBuf; }; } #endif /* EXYNOS_CAMERA_ACTIVITY_SPECIAL_CAPTURE_H__ */
98a4603d3fe35545b562aeaeb488887a0bc1feb1
0ba59fda936961754036920538a7d7a02446b642
/debug.h
6527b6126aff0db239105bc95ba22d9ac0cfca02
[]
no_license
okdshin/SavageOld
c00d53c504bb79df07f496f3f04d43b1912e8910
7c07f3d9b13226da79211404422390497b719315
refs/heads/master
2023-06-10T08:26:59.964985
2014-04-17T13:43:29
2014-04-17T13:43:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
355
h
debug.h
#ifndef SAVAGE_DEBUG_H #define SAVAGE_DEBUG_H //20140326 #include <iostream> #define SAVAGE_DEBUG_PRINT(Message) \ std::cout << "DEBUG: " << Message << std::endl; #define SAVAGE_DEBUG_DEFAULT_IMPLEMENTATION_USED_NOTATION \ std::cout << "DEBUG: " << __FILE__ << ":" << __LINE__ << ": default implementation used" << std::endl; #endif //SAVAGE_DEBUG_H
af273662e8e04bf97261aa4072647b879275cacb
051c01825ff71f40b177796cb4a5a5f597ce41dc
/SETools/SEToolsCommon/SECollada/SEColladaAnimationChannel.h
fe823ade0e048faa47ceece3febf36b2b9789a21
[]
no_license
jazzboysc/SwingEngine1
896d1df24d7012308ad67bf4e86bf46383492c87
48f229ce2f1750756010a9db5e340e819b28b7ef
refs/heads/master
2020-06-02T16:09:24.663829
2015-07-31T05:19:29
2015-07-31T05:19:29
39,988,059
0
1
null
null
null
null
UTF-8
C++
false
false
2,511
h
SEColladaAnimationChannel.h
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library 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 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #ifndef Swing_ColladaAnimationChannel_H #define Swing_ColladaAnimationChannel_H #include "SEToolsCommonLIB.h" #include "SEToolsUtility.h" #include "SEObject.h" #include "SEColladaAnimationSource.h" #include "SEColladaAnimationSampler.h" namespace Swing { class SEColladaKeySet; //---------------------------------------------------------------------------- // Description: // Author:Sun Che // Date:20090917 //---------------------------------------------------------------------------- class SE_TOOLS_COMMON_API SEColladaAnimationChannel : public SEObject { SE_DECLARE_RTTI; SE_DECLARE_NAME_ID; public: SEColladaAnimationChannel(void); ~SEColladaAnimationChannel(void); enum AnimationTarget { AT_TARGET_X, AT_TARGET_Y, AT_TARGET_Z, AT_TARGET_XYZ, AT_TARGET_ANGLE, AT_TARGET_UNKNOWN, AT_S_X_AXIS, AT_S_Y_AXIS, AT_S_Z_AXIS, AT_S, AT_R_X_AXIS, AT_R_Y_AXIS, AT_R_Z_AXIS, AT_R, AT_T_X_AXIS, AT_T_Y_AXIS, AT_T_Z_AXIS, AT_T, AT_SOURCE, AT_MATRIX }; SEColladaAnimationSamplerPtr Sampler; std::string TargetID; std::string TargetSID; std::string TargetMember; AnimationTarget TargetType; SEColladaAnimationSourcePtr InputSource; SEColladaAnimationSourcePtr OutputSource; enum { MAX_KEY_SETS = 10 }; SEColladaKeySet* Keys[MAX_KEY_SETS]; int NumElementTargets; }; typedef SESmartPointer<SEColladaAnimationChannel> SEColladaAnimationChannelPtr; } #endif
dac833d22254c9d7e60aa5ee6f6eaa5d486cc41f
337d83b40f9795f909c1a9355fe074c51053fca9
/leetcode/find_first_and_last_position_of_element_in_sorted_array.cpp
c6a1627654601a54d8998a0ddda9b97067bdedd3
[ "MIT" ]
permissive
alexandru-dinu/competitive-programming
022d61f1901d91c75e9424f5ce04f4119e5692ac
4515d221a649b3ab8bc012d01f38b9e4659e2e76
refs/heads/main
2023-08-21T20:36:08.146902
2021-11-04T16:05:31
2021-11-04T16:05:31
328,739,204
0
0
null
null
null
null
UTF-8
C++
false
false
1,206
cpp
find_first_and_last_position_of_element_in_sorted_array.cpp
// https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array class Solution { public: int bs(const vector<int> &nums, int target) { int l = 0, r = nums.size() - 1; int mid; /* * default value = array size * intuitively, if x >= target is not found in nums * then it is "after" the end of the array */ int pos = nums.size(); while (l <= r) { mid = l + (r - l) / 2; if (nums[mid] >= target) { pos = mid; r = mid - 1; } else l = mid + 1; } return pos; } vector<int> searchRange(vector<int> &nums, int target) { // idea: use b.s. to find index of // (>= target, >= target+1) int lo = bs(nums, target); int hi = bs(nums, target + 1) - 1; // because want <= target /* * if some x >= target is not found, * it is clear that no x >= target + 1 will be found as well * so, in this case, lo = hi - 1, returning {-1, -1} */ if (lo > hi) lo = hi = -1; return { lo, hi }; } };
dbc0e5c6cb06e15e4334764cade3ad2c80c17dc2
e6f8c63578c8617cf13794c921aff29ff6c56230
/io/printf.hpp
d198f71b4b51db5d0fb4934648a7fa7d20cf9f4a
[]
no_license
simonask/grace-base
8b76c60c9b3d1eae0b32d9dd3432d6d2ccb669ea
ab5a0fd4fc7583c3f3b59f2c18770f5fe0a9abc5
refs/heads/master
2021-03-13T00:01:01.765633
2013-10-03T14:46:40
2013-10-03T14:46:40
12,755,495
2
0
null
null
null
null
UTF-8
C++
false
false
1,887
hpp
printf.hpp
#pragma once #ifndef GRACE_PRINTF_HPP_INCLUDED #define GRACE_PRINTF_HPP_INCLUDED #include "io/formatted_stream.hpp" #include "base/string.hpp" #include "base/parse.hpp" #include "base/regex.hpp" #include "memory/static_allocator.hpp" #include <array> namespace grace { struct IWriteToFormattedStream { virtual void write(FormattedStream&) = 0; }; template <typename T> struct WriteToFormattedStream : IWriteToFormattedStream { T& object; WriteToFormattedStream(T& x) : object(x) {} void write(FormattedStream& os) final { os << object; } }; template <typename T> WriteToFormattedStream<T> make_write_to_formatted_stream(T& x) { return WriteToFormattedStream<T>{x}; } template <typename ArgsWriterTuple, size_t... I> void formatted_stream_printf_impl(FormattedStream& os, StringRef format, ArgsWriterTuple& tuple, Indices<I...>) { std::array<IWriteToFormattedStream*, sizeof...(I)> arg_writers = {{ static_cast<IWriteToFormattedStream*>(&std::get<I>(tuple))... }}; StringRef haystack = format; static const Regex interpolation("{(\\d+)}", static_allocator()); replace_with_through(haystack, interpolation, os, [&](FormattedStream& s, ArrayRef<StringRef> groups) { if (groups.size() != 2) { s << groups[0]; } else { Maybe<int> idx = parse<int>(groups[1]); if (idx && *idx < arg_writers.size()) { arg_writers[*idx]->write(s); } else { s << groups[0]; } } }); } template <typename... Args> FormattedStream& FormattedStream::printf(StringRef format, Args&&... args_pack) { // Instantiate a number of specialized classes that can turn the arguments into strings: auto arg_writers = std::make_tuple(make_write_to_formatted_stream(args_pack)...); using Indices = typename MakeIndices<sizeof...(Args)>::Type; formatted_stream_printf_impl(*this, format, arg_writers, Indices()); return *this; } } #endif
6da5a808aba0d6a16f3a53c576be6980744932b8
23ec7aa0c7f56175529b342673be9d2a956804d9
/include/RealSenseID/UserFaceprints.h
4b1910661340394a533fb2e98b8152af78631629
[ "Apache-2.0" ]
permissive
NoahRosa/RealSenseID
4bef4d3e0408062140ad0ccd49444720848d9fbe
8710465c534b0825cc0ec90eaccb4c83d8862928
refs/heads/master
2023-07-18T16:48:22.408538
2021-08-30T10:14:30
2021-08-30T10:14:30
385,933,413
0
0
Apache-2.0
2021-08-30T14:19:28
2021-07-14T12:32:06
C++
UTF-8
C++
false
false
652
h
UserFaceprints.h
/******************************************************************************* INTEL CORPORATION PROPRIETARY INFORMATION This software is supplied under the terms of a license agreement or nondisclosure agreement with Intel Corporation and may not be copied or disclosed except in accordance with the terms of that agreement Copyright(c) 2011-2020 Intel Corporation. All Rights Reserved. *******************************************************************************/ #pragma once #include "Faceprints.h" #include <string> namespace RealSenseID { struct UserFaceprints { std::string user_id; Faceprints faceprints; }; }
8f305400d71d24f6863ffa80c92e8f50aab83b1a
425548609102bd655c4eff66b066321fef6bb3de
/enterdialog.cpp
e8a11ec0efd6260335830240200f61bc17927e05
[]
no_license
anhcx0209/GraphIO
4fad545b033bcf3a4092633dab53ce21a05179f1
fea7d56153ce0c3ad3d2b0895020dd6d5baecbc1
refs/heads/master
2021-01-20T13:42:13.828593
2017-05-18T10:42:02
2017-05-18T10:42:02
90,514,673
0
0
null
null
null
null
UTF-8
C++
false
false
2,301
cpp
enterdialog.cpp
#include "enterdialog.h" EnterDialog::EnterDialog(QString name) { name_ = name; data_ = 0; number_edges_spinbox_ = new QSpinBox; number_vertexs_spinbox_ = new QSpinBox; table_view_ = new QTableView(); QHBoxLayout *tableLayout = new QHBoxLayout; tableLayout->addWidget(table_view_); QLabel *edgesLabel = new QLabel(tr("Количество ребер")); QLabel *vertexsLabel = new QLabel(tr("Количество вершин")); QHBoxLayout *edgesLayout = new QHBoxLayout; edgesLayout->addWidget(edgesLabel); edgesLayout->addWidget(number_edges_spinbox_); QHBoxLayout *vertexsLayout = new QHBoxLayout; vertexsLayout->addWidget(vertexsLabel); vertexsLayout->addWidget(number_vertexs_spinbox_); QPushButton *acceptButton = new QPushButton(tr("Вводить")); connect(acceptButton, SIGNAL(clicked()), this, SLOT(enterData())); QHBoxLayout *changeTableLayout = new QHBoxLayout; changeTableLayout->addWidget(acceptButton); QPushButton *finishButton = new QPushButton(tr("Завершать")); connect(finishButton, SIGNAL(clicked()), this, SLOT(sendData())); QPushButton *closeButton = new QPushButton(tr("Отмена")); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addWidget(finishButton); buttonLayout->addWidget(closeButton); QGroupBox *logGroup = new QGroupBox("Сообщение"); log_label_ = new QLabel; QHBoxLayout *logLayout = new QHBoxLayout; logLayout->addWidget(log_label_); logGroup->setLayout(logLayout); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(edgesLayout); mainLayout->addLayout(vertexsLayout); mainLayout->addLayout(changeTableLayout); mainLayout->addLayout(tableLayout); mainLayout->addLayout(buttonLayout); mainLayout->addWidget(logGroup); setLayout(mainLayout); setWindowTitle(name_); setGeometry(200, 200, 500, 500); } void EnterDialog::sendData() { if (data_ != 0 && data_->validate()) { emit finishEnterData(data_); close(); } else { log_label_->setText("Ошибка."); } } void EnterDialog::notice(QString mess) { log_label_->setText(mess); }
1e1101d14f85948cef48634e81ce1ea0da428181
c950ab1606311abbe3c4de455077bf8d54e9596e
/main.cpp
b370389d6e9c6122246cde0a464588ad339e1880
[]
no_license
Pwera/Executors
ae7fa9f4ab8ec597ebe43dc76ffb9e5bdabdbdb3
276998f5d318e119a342c9a4cce1b469b76ef656
refs/heads/master
2020-12-31T07:19:47.797177
2017-08-04T07:51:45
2017-08-04T07:51:45
56,632,301
1
1
null
2018-10-20T18:52:08
2016-04-19T21:10:43
C++
UTF-8
C++
false
false
841
cpp
main.cpp
#include "headers.h" #include <atomic> #include <functional> #include <future> #include <set> #include <thread> #include <utility> #include <vector> #include <thread> #include <chrono> int main(){ //just for terminal clearance std::this_thread::sleep_for(std::chrono::milliseconds(3000)); // system_executor system_executor &system_executor = system_executor::get_executor(); // system_executor.spawn(std::move(YetAnotherTimeWastedWork())); // system_executor.spawn(std::move(YetAnotherTimeWastedWork())); // system_executor.spawn(std::move(YetAnotherTimeWastedWork())); // system_executor.spawn(std::move(YetAnotherTimeWastedWork())); // system_executor.spawn(std::move(YetAnotherTimeWastedWork())); std::this_thread::sleep_for(std::chrono::milliseconds(500)); return 0; }
cdef66d37dfe11e0d674cc33ec0c1dd8997c390c
2fcee87709417717620d2ca4131f96e29c0bc320
/Codeforces/vjude_B.cpp
39df2e20bac557f5e105c0e32476d6e3d1391117
[]
no_license
Jaminur-Rashid/Problem-Solving
7b502b03c5eea180282adcaad1b74ab526c92f12
c651c9e810dba6a8f4b1ece6a3c27554d4a49ac0
refs/heads/master
2023-07-27T15:22:14.744541
2021-09-09T12:13:13
2021-09-09T12:13:13
404,700,331
1
0
null
null
null
null
UTF-8
C++
false
false
961
cpp
vjude_B.cpp
#include<bits/stdc++.h> #include<utility> #include<algorithm> #include<map> #include<vector> #include<cmath> using namespace std; typedef long long ll; #define pb push_back #define PI acos(-1.0) #define MAX 10000007 //1e7+7 #define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X)) //#define rrep(X,Y) #define rrep(X,Y) for(int (X) = (Y)-1;(X) >=0;--(X)) #define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) int main(){ __FastIO; string st,str; ll i,j; while(cin>>st>>str){ ll cnt=0; ll len=st.length(); for(i=0;i<len;i++){ if(st[i]!=st[i]){ cnt++; } } if(cnt%2!=0){ cout<<"impossible"<<endl; } else{ for(i=0;i<len;i++){ if(st[i]!=str[i]&&cnt>0){ if(st[i]=='0'){ cout<<"1"; cnt--; } else{ cout<<"0"; cnt--; } } else{ cout<<st[i]; } } } cout<<endl; } return 0; }
1859d1308b3dc07d895784a80a45388c4faf9eae
51ad6a4afb352752fb79ccc130b6ee2ab16a7b17
/LLParsing/parser-generator.cc
1a56f2fe5d1d79b9b8e76af8f1928d132e11b89b
[]
no_license
hechangqing/ParsingTechniques
2b969b1d7cf9876c03ce8f722b8e70a980459be0
9dce0889d8e6b1c1eb4000ff607e9872e2b66530
refs/heads/master
2021-05-26T16:06:12.533575
2020-07-19T05:55:20
2020-07-19T05:55:20
254,130,773
0
0
null
null
null
null
UTF-8
C++
false
false
32
cc
parser-generator.cc
#include "parser-generator.h"
a3874553e3f82238c37a3dbfff591b04c16f51dc
1b78473394bc01af38ccc6161375ab5ffc016c02
/libctrpf/source/CTRPluginFrameworkImpl/Graphics/Renderer_Sysfont.cpp
456c136a6fdb8d95607663ff2e30fa2dbabbbe8c
[ "MIT" ]
permissive
RedShyGuy/Vapecord-ACNL-Plugin
70080dd2ea8e4921bebf24a42b70451a27a143e2
e57d1e56c3a36276f78eee98e003272ae9624a08
refs/heads/master
2023-08-21T12:51:26.345266
2023-08-14T00:30:09
2023-08-14T00:30:09
203,736,413
90
16
MIT
2023-07-13T03:57:20
2019-08-22T07:15:13
C++
UTF-8
C++
false
false
20,124
cpp
Renderer_Sysfont.cpp
#include "types.h" #include "CTRPluginFramework/Graphics/Render.hpp" #include "CTRPluginFrameworkImpl/Graphics.hpp" #include "CTRPluginFrameworkImpl/Graphics/Font.hpp" #include "CTRPluginFrameworkImpl/Preferences.hpp" #include <algorithm> namespace CTRPluginFramework { extern "C" CFNT_s* g_sharedFont; extern "C" int g_charPerSheet; inline u32 GetFramebufferOffset(int posX, int posY, int bpp, int rowsize) { return ((rowsize - 1 - posY + posX * rowsize) * bpp); } void Renderer::FontCalcGlyphPos(fontGlyphPos_s *out, charWidthInfo_s **cwout, int glyphIndex, float scaleX, float scaleY) { FINF_s* finf = &g_sharedFont->finf; TGLP_s* tglp = finf->tglp; charWidthInfo_s *cwi = fontGetCharWidthInfo(nullptr, glyphIndex); *cwout = cwi; int sheetId = glyphIndex / g_charPerSheet; int glInSheet = glyphIndex % g_charPerSheet; out->sheetIndex = sheetId; out->xOffset = scaleX * cwi->left; out->xAdvance = scaleX * cwi->charWidth; out->width = scaleX * cwi->glyphWidth; int lineId = glInSheet / tglp->nRows; int rowId = glInSheet % tglp->nRows; float tp = (float)(rowId*(tglp->cellWidth+1)+1); float tx = (float)(tp / tglp->sheetWidth) ; float ty = 1.0f - (float)((lineId+1)*(tglp->cellHeight+1)+1) / tglp->sheetHeight; float tw = (float)cwi->glyphWidth / tglp->sheetWidth; float th = (float)tglp->cellHeight / tglp->sheetHeight; out->texcoord.left = tx; out->texcoord.top = ty; out->texcoord.right = tx+tw; out->texcoord.bottom = ty + th; } float Renderer::GetTextSize(const char *text) { if (!text) return (0.0f); float w = 0.f; u8 *c = (u8 *)text; // Skip UTF8 sig if (c[0] == 0xEF && c[1] == 0xBB && c[2] == 0xBF) c += 3; while (*c == '\n') c++; do { if (!*c) break; if (*c == '\r' || *c == '\n') { c++; continue; } if (*c == 0x18) { c++; continue; } if (*c == 0x1B) { c += 4; continue; } if (*c == 0x11) { c++; u16 control = *(u16*)c; c += 2; if (control & 0x8000) { u16 skipToX = control & 0x1FF; if (skipToX > w) w = skipToX; } continue; } Glyph *glyph = Font::GetGlyph(c); if (glyph == nullptr) break; w += glyph->Width(); } while (true); return (w); } int Renderer::GetLineCount(const char *text, float maxWidth) { if (!text) return (0.0f); int lineCount = 1; float w = 0.0f; u8 *c = (u8 *)text; // Skip UTF8 sig if (c[0] == 0xEF && c[1] == 0xBB && c[2] == 0xBF) c += 3; while (*c) { if (*c == '\r') { c++; continue; } if (*c == '\n') { lineCount++; w = 0.f; c++; continue; } if (*c == 0x18) { c++; continue; } if (*c == 0x1B) { c += 4; continue; } if (*c == 0x11) { c++; u16 control = *(u16*)c; c += 2; if (control & 0x8000) { u16 skipToX = control & 0x1FF; if (skipToX > w && skipToX < maxWidth) w = skipToX; } continue; } Glyph *glyph = Font::GetGlyph(c); if (glyph == nullptr) break; float gSize = glyph->Width(); if (w + gSize > maxWidth) { lineCount++; w = gSize; } else w += gSize; } return (lineCount); } void Renderer::GetTextInfos(const char *text, int &lineCount, float &lineMaxWidth, float maxWidth) { lineCount = 0; lineMaxWidth = 0.f; if (!text || !*text) return; lineCount = 1; float w = 0.0f; u8 *c = (u8 *)text; // Skip UTF8 sig if (c[0] == 0xEF && c[1] == 0xBB && c[2] == 0xBF) c += 3; while (*c) { if (*c == '\n') { lineCount++; if (w > lineMaxWidth) lineMaxWidth = w; w = 0.f; c++; continue; } if (*c == 0x18) { c++; continue; } if (*c == 0x1B) { c += 4; continue; } if (*c == 0x11) { c++; u16 control = *(u16*)c; c += 2; if (control & 0x8000) { u16 skipToX = control & 0x1FF; if (skipToX > w && skipToX < maxWidth) w = skipToX; } continue; } Glyph *glyph = Font::GetGlyph(c); if (glyph == nullptr) break; float gSize = glyph->Width(); if (w + gSize > maxWidth) { lineCount++; if (w > lineMaxWidth) lineMaxWidth = w; w = gSize; } else w += gSize; } if (w > lineMaxWidth) lineMaxWidth = w; } void Renderer::DrawSysCheckBox(const char *str, int posX, int &posY, int xLimits, Color color, bool isChecked, float offset) { Icon::DrawCheckBox(posX, posY, isChecked); posX += 20; DrawSysString(str, posX, posY, xLimits, color, offset); posY += 1; } void Renderer::DrawSysFolder(const char *str, int posX, int &posY, int xLimits, Color color, float offset) { Icon::DrawFolder(posX, posY); posX += 20; DrawSysString(str, posX, posY, xLimits, color, offset); posY += 1; } int Renderer::DrawGlyph(Glyph *glyph, int posX, int posY, Color color, u32 flags) { return DrawGlyph(GetContext()->screen, glyph, posX, posY, color, flags); } int Renderer::DrawGlyph(ScreenImpl *screen, Glyph *glyph, int posX, int posY, Color color, u32 flags) { if (!screen || !glyph) return posY; posX += glyph->xOffset; u32 stride = screen->_stride; u32 bpp = screen->_bytesPerPixel; u8 *data = glyph->glyph; u8 *left = static_cast<u8 *>(screen->GetLeftFrameBuffer(posX, posY)); u8 *fb = left; u8 italicOffset = (flags & Render::FontDrawMode::ITALIC) ? 3 : 0; u32 lineCount = 0; for (int i = 0; i < 208; i++) { if (i != 0 && i % 13 == 0) { if ((lineCount % 4) == 0 && flags &Render::FontDrawMode::ITALIC) italicOffset--; lineCount++; left -= bpp; fb = left; } u32 alpha = data[i]; // Don't waste time on pixels which are only 5% visible for (int j = 0; (alpha > 12) && j < ((flags & Render::FontDrawMode::BOLD) ? 2 : 1); j++) { color.a = alpha; Color &&l = PrivColor::FromFramebuffer(fb + stride * j + italicOffset * stride); Color &&c = l.Blend(color, Color::BlendMode::Alpha); PrivColor::ToFramebuffer(fb + stride * j + italicOffset * stride, c); } fb += stride; } return (posX + glyph->xAdvance); } int Renderer::DrawGlyph(ScreenImpl *screen, Glyph *glyph, int posX, int posY, float &offset, Color color, u32 flags) { if (!screen || !glyph) return posY; posX += glyph->xOffset; u32 stride = screen->_stride; u32 bpp = screen->_bytesPerPixel; u8 *data = glyph->glyph; u8 *left = static_cast<u8 *>(screen->GetLeftFrameBuffer(posX, posY)); u8 *fb = left; u8 italicOffset = (flags & Render::FontDrawMode::ITALIC) ? 3 : 0; u32 lineCount = 0; for (int i = static_cast<int>(offset); i < 208; i++) { if (i != 0 && i % 13 == 0) { if (offset) i += offset; if ((lineCount % 4) == 0 && flags & Render::FontDrawMode::ITALIC) italicOffset--; lineCount++; left -= bpp; fb = left; } u32 alpha = data[i]; // Don't waste time on pixels which are only 5% visible for (int j = 0; (alpha > 12) && j < ((flags & Render::FontDrawMode::BOLD) ? 2 : 1); j++) { color.a = alpha; Color &&l = PrivColor::FromFramebuffer(fb + stride * j + italicOffset * stride); Color &&c = l.Blend(color, Color::BlendMode::Alpha); PrivColor::ToFramebuffer(fb + stride * j + italicOffset * stride, c); } fb += stride; } if (offset > 0.f) { posX -= offset; offset = 0; } return (posX + glyph->xAdvance); } int Renderer::DrawSysStringReturn(const unsigned char *stri, int posX, int& posY, int xLimits, Color color, int maxY, u32 flags) { // Check for a valid pointer if (!(stri && *stri)) return (posX); int lineCount = 1; u8 *str = const_cast<u8 *>(stri); int x = posX; int underLineStart = -1, strikeLineStart = -1; ScreenImpl *screen = GetContext()->screen; void (*lineDrawer)(int posX, int posY, int width, const Color &color, int height) = Renderer::DrawLine; if (!screen) return posY; xLimits = std::min(xLimits, (GetContext()->target == TOP ? 400 : 320)); // Skip UTF8 sig if (str[0] == 0xEF && str[1] == 0xBB && str[2] == 0xBF) str += 3; do { if (posY >= maxY) break; u8 c = *str; if (c == '\r') str++; if (c == '\n') { if (flags & Render::FontDrawMode::UNDERLINE) { if (underLineStart != x) lineDrawer(underLineStart, posY + 15, x - underLineStart, color, 1); underLineStart = posX; } if (flags & Render::FontDrawMode::STRIKETHROUGH) { if (strikeLineStart != x) lineDrawer(strikeLineStart, posY + 9, x - strikeLineStart, color, 1); strikeLineStart = posX; } x = posX; lineCount++; posY += 16; str++; continue; } if (c == 0x18) { color = Preferences::Settings.MainTextColor; str++; continue; } if (c == 0x1B) { str++; color.r = *str++; color.g = *str++; color.b = *str++; continue; } if (c == 0x11) { str++; u16 control = *(u16*)str; str += 2; if (control & 0x8000) { u16 skipToX = control & 0x1FF; if (skipToX > x && skipToX < xLimits) { if (underLineStart == posX && x == posX) // Fix for aligned text after newline underLineStart = skipToX; if (strikeLineStart == posX && x == posX) // Fix for aligned text after newline strikeLineStart = skipToX; x = skipToX; } } else if (control & 0x4000) { u32 prevFlags = flags; flags ^= (control & 0x7F); if (flags & Render::LINEDOTTED) lineDrawer = DrawStippledLine; else lineDrawer = DrawLine; if ((prevFlags & Render::FontDrawMode::UNDERLINE) != (flags & Render::FontDrawMode::UNDERLINE)) { bool startLine = flags & Render::FontDrawMode::UNDERLINE; if (startLine) underLineStart = x; else { if (underLineStart != x) lineDrawer(underLineStart, posY + 15, x - underLineStart, color, 1); underLineStart = -1; } } if ((prevFlags & Render::FontDrawMode::STRIKETHROUGH) != (flags & Render::FontDrawMode::STRIKETHROUGH)) { bool startLine = flags & Render::FontDrawMode::STRIKETHROUGH; if (startLine) strikeLineStart = x; else { if (strikeLineStart != x) lineDrawer(strikeLineStart, posY + 9, x - strikeLineStart, color, 1); strikeLineStart = -1; } } } continue; } Glyph *glyph = Font::GetGlyph(str); if (glyph == nullptr) break; if (x + glyph->Width() >= xLimits) { if (flags & Render::FontDrawMode::UNDERLINE) { if (underLineStart != x) lineDrawer(underLineStart, posY + 15, x - underLineStart, color, 1); underLineStart = posX; } if (flags & Render::FontDrawMode::STRIKETHROUGH) { if (strikeLineStart != x) lineDrawer(strikeLineStart, posY + 9, x - strikeLineStart, color, 1); strikeLineStart = posX; } x = posX; lineCount++; posY += 16; } x = DrawGlyph(screen, glyph, x, posY, color, flags); } while (*str); if (posY < maxY && flags & Render::FontDrawMode::UNDERLINE) { if (underLineStart != x) lineDrawer(underLineStart, posY + 15, x - underLineStart, color, 1); } if (posY < maxY && flags & Render::FontDrawMode::STRIKETHROUGH) { if (strikeLineStart != x) lineDrawer(strikeLineStart, posY + 9, x - strikeLineStart, color, 1); } posY += 16; return (x); } namespace RendererPriv { Color g_customColor; } int Renderer::DrawSysString(const char *stri, int posX, int &posY, int xLimits, Color color, float offset, const char *end, u32 flags) { Glyph *glyph; int x = posX; //u8 *str = (u8 *)stri.c_str(); u8 *str = (u8 *)stri; int underLineStart = -1, strikeLineStart = -1; void (*lineDrawer)(int posX, int posY, int width, const Color &color, int height) = DrawLine; ScreenImpl *screen = GetContext()->screen; if (!(str && *str) || !screen) return (x); xLimits = std::min(xLimits, (GetContext()->target == TOP ? 400 : 320)); // Skip UTF8 sig if (str[0] == 0xEF && str[1] == 0xBB && str[2] == 0xBF) str += 3; do { u8 c = *str; if (x >= xLimits || str == (u8 *)end) { break; } if (c == '\n' || c == '\r') { str++; continue; } if (c == 0x18) { RendererPriv::g_customColor = color = Preferences::Settings.MainTextColor; str++; continue; } if (c == 0x1B) { str++; color.r = *str++; color.g = *str++; color.b = *str++; RendererPriv::g_customColor = color; continue; } if (c == 0x11) { str++; u16 control = *(u16*)str; str += 2; if (control & 0x8000) { u16 skipToX = control & 0x1FF; if (skipToX > x && skipToX < xLimits) x = skipToX; } else if (control & 0x4000) { u32 prevFlags = flags; flags ^= (control & 0x7F); if (flags & Render::LINEDOTTED) lineDrawer = DrawStippledLine; else lineDrawer = DrawLine; if ((prevFlags & Render::FontDrawMode::UNDERLINE) != (flags & Render::FontDrawMode::UNDERLINE)) { bool startLine = flags & Render::FontDrawMode::UNDERLINE; if (startLine) underLineStart = x; else { if (underLineStart != x) lineDrawer(underLineStart, posY + 15, x - underLineStart, color, 1); underLineStart = -1; } } if ((prevFlags & Render::FontDrawMode::STRIKETHROUGH) != (flags & Render::FontDrawMode::STRIKETHROUGH)) { bool startLine = flags & Render::FontDrawMode::STRIKETHROUGH; if (startLine) strikeLineStart = x; else { if (strikeLineStart != x) lineDrawer(strikeLineStart, posY + 9, x - strikeLineStart, color, 1); strikeLineStart = -1; } } } continue; } if (posY >= 240) break; glyph = Font::GetGlyph(str); if (glyph == nullptr) break; float gWidth = glyph->Width(); if (x + gWidth > xLimits) { break; } if (offset >= gWidth) { offset -= (gWidth); continue; } x = DrawGlyph(screen, glyph, x, posY, offset, color, flags); } while (*str); if (flags & Render::FontDrawMode::UNDERLINE) { if (underLineStart != x) lineDrawer(underLineStart, posY + 15, x - underLineStart, color, 1); } if (flags & Render::FontDrawMode::STRIKETHROUGH) { if (strikeLineStart != x) lineDrawer(strikeLineStart, posY + 9, x - strikeLineStart, color, 1); } posY += 16; return (x); } }
7bb78caaacfb2e7372f9e4e8a62cfea163a3c9d4
a2e4e437e39f6280a889d31fa58fd5d52563ec10
/HelloWorldVCpp/CommonLibrary/CommonLibrary.Android/CommonLibrary.Android.cpp
cae4d23d2ca2feb9361970da595c24b14cf5156d
[ "MIT" ]
permissive
bobbyz-dk/cross-cpp-hello
e632c22fa83765dcce0b71fcdbba7565073ed20f
75525b0119877cb0b37f304093b2146419b5ec7c
refs/heads/master
2020-12-24T14:54:11.454495
2015-06-14T18:27:05
2015-06-14T18:27:05
31,918,951
0
0
null
null
null
null
UTF-8
C++
false
false
385
cpp
CommonLibrary.Android.cpp
#include "CommonLibrary.h" #include "CommonLibrary.Android.h" CommonLibraryAndroid::CommonLibraryAndroid() { lib = new CommonLibrary(); } CommonLibraryAndroid::~CommonLibraryAndroid() { } char * CommonLibraryAndroid::getTemplateInfo() { return CommonLibrary::getTemplateInfo(); } std::string CommonLibraryAndroid::helloWorld(std::string world) { return lib->helloWorld(world); }
2cb8c23aa9a90c781ed45b24a65c3da7daf7c8d6
40fc6cfdadbc09d0d0f69aaceeb6c9400e9f29d8
/tests/main.cpp
a9c4b89c92bef6b30d465e000907af143f1ab127
[]
no_license
Kevincav/Data_Trends
611d6b30f9c6d19f6fa65af035e3a893103ae789
a049a9591dc104c52f9a70cebce6d19e177da83f
refs/heads/master
2016-09-05T17:08:49.982246
2014-03-19T22:57:30
2014-03-19T22:57:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
271
cpp
main.cpp
#include <iostream> #include <random> #include <vector> #include "../src/Graphs.hpp" #include "../src/Parser.hpp" int main(int argc, char *argv[]) { Parser p(argv[1]); Graphs g(p.getMatrix()); std::cout << g.calcSalery(95) << std::endl; return 0; }
b2ee0022d92473a8ed4da597a5bfa2727991bc83
a9d89247d9c49ce51e2b74a8fd8cded95123cd5d
/icebox/sync_host_context.h
c36e4e49f427f2bbc6c9dbd35ffb856182f805c8
[]
no_license
lubing521/librhino
e021062a3fa4b947487cd62bec6a09cf122128c3
08983a744fe01dc4446168d46cdee4f532b974cd
refs/heads/master
2022-01-16T03:12:02.189216
2014-11-21T01:28:32
2014-11-21T01:28:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,389
h
sync_host_context.h
#ifndef RHINO_ICEBOX_SYNC_HOST_CONTEXT_H_ #define RHINO_ICEBOX_SYNC_HOST_CONTEXT_H_ #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" namespace net { class URLRequestContextGetter; } // namespace net namespace remoting { class AutoThreadTaskRunner; } namespace Synclib { // A class that manages threads and running context for the chromoting host // process. This class is virtual only for testing purposes (see below). class SyncHostContext { public: ~SyncHostContext(); // Create threads and URLRequestContextGetter for use by a host. // During shutdown the caller should tear-down the ChromotingHostContext and // then continue to run until |ui_task_runner| is no longer referenced. // NULL is returned if any threads fail to start. static scoped_ptr<SyncHostContext> Create( scoped_refptr<remoting::AutoThreadTaskRunner> ui_task_runner); // Task runner for the thread that is used for blocking file // IO. This thread is used by the URLRequestContext to read proxy // configuration and by NatConfig to read policy configs. scoped_refptr<remoting::AutoThreadTaskRunner> file_task_runner(); // Task runner for the thread used for network IO. This thread runs // a libjingle message loop, and is the only thread on which // libjingle code may be run. scoped_refptr<remoting::AutoThreadTaskRunner> network_task_runner(); // Task runner for the thread that is used for the UI. In the NPAPI // plugin this corresponds to the main plugin thread. scoped_refptr<remoting::AutoThreadTaskRunner> ui_task_runner(); scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(); private: SyncHostContext(remoting::AutoThreadTaskRunner* ui_task_runner); // Thread for I/O operations. scoped_refptr<remoting::AutoThreadTaskRunner> file_task_runner_; // Thread for network operations. scoped_refptr<remoting::AutoThreadTaskRunner> network_task_runner_; // Caller-supplied UI thread. This is usually the application main thread. scoped_refptr<remoting::AutoThreadTaskRunner> ui_task_runner_; // Serves URLRequestContexts that use the network and UI task runners. scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; DISALLOW_COPY_AND_ASSIGN(SyncHostContext); }; } // namespace synclib #endif // RHINO_ICEBOXSYNC_HOST_CONTEXT_H_
daf85046ce52d813261ad019620e4f926171ff81
fded81a37e53d5fc31cacb9a0be86377825757b3
/additionally/rpod_v.cpp
3f12af1aa96de4e712e232013627d5ad4821ad54
[]
no_license
iceblinux/iceBw_GTK
7bf28cba9d994e95bab0f5040fea1a54a477b953
a4f76e1fee29baa7dce79e8a4a309ae98ba504c2
refs/heads/main
2023-04-02T21:45:49.500587
2021-04-12T03:51:53
2021-04-12T03:51:53
356,744,886
0
0
null
null
null
null
UTF-8
C++
false
false
10,892
cpp
rpod_v.cpp
/*$Id: rpod_v.c,v 1.15 2013/08/13 06:10:25 sasa Exp $*/ /*12.01.2006 29.04.2004 Белых А.И. rpod_v.c Ввод и корректировка сальдо по счетам */ #include <stdlib.h> #include <ctype.h> #include <unistd.h> #include <time.h> #include "i_rest.h" #include "rpod.h" gboolean rpod_v_key_press(GtkWidget *widget,GdkEventKey *event,class rpod_data *data); void rpod_v_knopka(GtkWidget *widget,class rpod_data *data); void rpod_v_vvod(GtkWidget *widget,class rpod_data *data); int rpod_pk(const char *god,GtkWidget*); int rpod_zap(class rpod_data *data); void rpod_kkvt(const char *kods,const char *kodn,GtkWidget *wpredok); extern uid_t kod_operatora; void rpod_v(class rpod_data *data) { char strsql[300]; //printf("l_rpod_v\n"); if(data->vwindow != NULL) return; data->kl_shift=0; data->vvod.clear_zero(); if(data->metkazapisi == 1) { data->vvod.kod.new_plus(data->kodv.ravno()); data->vvod.naim.new_plus(data->naimv.ravno()); } else { sprintf(strsql,"%d",iceb_get_new_kod("Restpod",0,data->window)); data->vvod.kod.new_plus(strsql); } data->vwindow=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position( GTK_WINDOW(data->vwindow),ICEB_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(data->vwindow),TRUE); if(data->metkazapisi == 0) sprintf(strsql,"%s %s",name_system,gettext("Ввод новой записи")); if(data->metkazapisi == 1) sprintf(strsql,"%s %s",name_system,gettext("Корректировка записи")); gtk_window_set_title(GTK_WINDOW(data->vwindow),strsql); g_signal_connect(data->vwindow,"destroy",G_CALLBACK(gtk_widget_destroyed),&data->vwindow); g_signal_connect_after(data->vwindow,"key_press_event",G_CALLBACK(rpod_v_key_press),data); //Удерживать окно над породившем его окном всегда gtk_window_set_transient_for(GTK_WINDOW(data->vwindow),GTK_WINDOW(data->window)); //Закрыть окно если окно предок удалено gtk_window_set_destroy_with_parent(GTK_WINDOW(data->vwindow),TRUE); GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous (GTK_BOX(vbox),FALSE); //Устанваливает одинакоый ли размер будут иметь упакованные виджеты-TRUE-одинаковые FALSE-нет GtkWidget *hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous (GTK_BOX(hbox1),FALSE); //Устанваливает одинакоый ли размер будут иметь упакованные виджеты-TRUE-одинаковые FALSE-нет GtkWidget *hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous (GTK_BOX(hbox2),FALSE); //Устанваливает одинакоый ли размер будут иметь упакованные виджеты-TRUE-одинаковые FALSE-нет GtkWidget *hboxknop = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous (GTK_BOX(hboxknop),FALSE); //Устанваливает одинакоый ли размер будут иметь упакованные виджеты-TRUE-одинаковые FALSE-нет gtk_container_add (GTK_CONTAINER (data->vwindow), vbox); gtk_container_add (GTK_CONTAINER (vbox), hbox1); gtk_container_add (GTK_CONTAINER (vbox), hbox2); gtk_container_add (GTK_CONTAINER (vbox), hboxknop); GtkWidget *label=gtk_label_new(gettext("Код подразделения")); data->entry[E_KOD] = gtk_entry_new (); gtk_entry_set_max_length(GTK_ENTRY(data->entry[E_KOD]),10); gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox1), data->entry[E_KOD], TRUE, TRUE, 0); g_signal_connect(data->entry[E_KOD], "activate",G_CALLBACK(rpod_v_vvod),data); gtk_entry_set_text(GTK_ENTRY(data->entry[E_KOD]),data->vvod.kod.ravno()); gtk_widget_set_name(data->entry[E_KOD],iceb_u_inttochar(E_KOD)); label=gtk_label_new(gettext("Наименование подразделения")); data->entry[E_NAIM] = gtk_entry_new (); gtk_entry_set_max_length(GTK_ENTRY(data->entry[E_NAIM]),80); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox2), data->entry[E_NAIM], TRUE, TRUE, 0); g_signal_connect(data->entry[E_NAIM], "activate",G_CALLBACK(rpod_v_vvod),data); gtk_entry_set_text(GTK_ENTRY(data->entry[E_NAIM]),data->vvod.naim.ravno()); gtk_widget_set_name(data->entry[E_NAIM],iceb_u_inttochar(E_NAIM)); sprintf(strsql,"F2 %s",gettext("Запись")); data->knopka_pv[PFK2]=gtk_button_new_with_label(strsql); gtk_widget_set_tooltip_text(data->knopka_pv[PFK2],gettext("Запись введеной в меню информации")); g_signal_connect(data->knopka_pv[PFK2],"clicked",G_CALLBACK(rpod_v_knopka),data); gtk_widget_set_name(data->knopka_pv[PFK2],iceb_u_inttochar(PFK2)); sprintf(strsql,"F10 %s",gettext("Выход")); data->knopka_pv[PFK10]=gtk_button_new_with_label(strsql); gtk_widget_set_tooltip_text(data->knopka_pv[PFK10],gettext("Завершение работы с меню без записи введенной информации")); g_signal_connect(data->knopka_pv[PFK10],"clicked",G_CALLBACK(rpod_v_knopka),data); gtk_widget_set_name(data->knopka_pv[PFK10],iceb_u_inttochar(PFK10)); gtk_box_pack_start(GTK_BOX(hboxknop), data->knopka_pv[PFK2], TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hboxknop), data->knopka_pv[PFK10], TRUE, TRUE, 0); if(data->metkazapisi == 1) gtk_widget_grab_focus(data->entry[0]); else gtk_widget_grab_focus(data->entry[1]); gtk_widget_show_all (data->vwindow); } /*********************************/ /*Обработка нажатия клавиш */ /*********************************/ gboolean rpod_v_key_press(GtkWidget *widget,GdkEventKey *event,class rpod_data *data) { //char bros[300]; //printf("rpod_v_key_press\n"); switch(event->keyval) { case GDK_KEY_F2: g_signal_emit_by_name(data->knopka_pv[PFK2],"clicked"); return(TRUE); case GDK_KEY_Escape: case GDK_KEY_F10: g_signal_emit_by_name(data->knopka_pv[PFK10],"clicked"); return(FALSE); case ICEB_REG_L: case ICEB_REG_R: // printf("Нажата клавиша Shift\n"); data->kl_shift=1; return(TRUE); } return(TRUE); } /*****************************/ /*Обработчик нажатия кнопок */ /*****************************/ void rpod_v_knopka(GtkWidget *widget,class rpod_data *data) { //char bros[300]; int knop=atoi(gtk_widget_get_name(widget)); switch ((gint)knop) { case PFK2: if(rpod_zap(data) == 0) { gtk_widget_destroy(data->vwindow); data->vwindow=NULL; } return; case PFK10: gtk_widget_destroy(data->vwindow); data->vwindow=NULL; return; } } /********************************/ /*Перевод чтение текста и перевод фокуса на следующюю строку ввода*/ /******************************************/ void rpod_v_vvod(GtkWidget *widget,class rpod_data *data) { int enter=atoi(gtk_widget_get_name(widget)); //g_print("rpod_v_vvod enter=%d\n",enter); switch (enter) { case E_KOD: data->vvod.kod.new_plus(gtk_entry_get_text(GTK_ENTRY(widget))); break; case E_NAIM: data->vvod.naim.new_plus(gtk_entry_get_text(GTK_ENTRY(widget))); break; } enter+=1; if(enter >= KOLENTER) enter=0; gtk_widget_grab_focus(data->entry[enter]); } /****************************/ /*Запись */ /****************************/ int rpod_zap(class rpod_data *data) { char strsql[1000]; //SQL_str row; time_t vrem; time(&vrem); printf("rpod_v_zap\n"); for(int i=0; i < KOLENTER; i++) g_signal_emit_by_name(data->entry[i],"activate"); if(data->vvod.kod.ravno()[0] == '\0') { iceb_u_str sp; sp.plus(gettext("Не введен код !")); iceb_menu_soob(&sp,data->vwindow); return(1); } if(isdigit(data->vvod.kod.ravno()[0]) == 0) { iceb_u_str sp; sp.plus(gettext("Код должен быть цифровым !")); iceb_menu_soob(&sp,data->vwindow); return(1); } if(data->vvod.naim.ravno()[0] == '\0') { iceb_u_str sp; sp.plus(gettext("Не введено наименование !")); iceb_menu_soob(&sp,data->vwindow); return(1); } short metkakor=0; if(data->metkazapisi == 0) { if(rpod_pk(data->vvod.kod.ravno(),data->vwindow) != 0) return(1); sprintf(strsql,"insert into Restpod \ values (%d,'%s',%d,%ld)", atoi(data->vvod.kod.ravno()), data->vvod.naim.ravno_filtr(), kod_operatora,vrem); } else { printf("metkazapisi=%d\n",data->metkazapisi); if(iceb_u_SRAV(data->kodv.ravno(),data->vvod.kod.ravno(),0) != 0) { if(rpod_pk(data->vvod.kod.ravno(),data->vwindow) != 0) return(1); iceb_u_str repl; repl.plus(gettext("Корректировать код ? Вы уверены ?")); if(iceb_menu_danet(&repl,2,data->vwindow) == 2) return(1); metkakor=1; } memset(strsql,'\0',sizeof(strsql)); sprintf(strsql,"update Restpod \ set \ kod=%d,\ naik='%s',\ ktoi=%d,\ vrem=%ld \ where kod=%d", atoi(data->vvod.kod.ravno()), data->vvod.naim.ravno_filtr(), kod_operatora,vrem, atoi(data->kodv.ravno())); } //printf("kontr_zap-strsql=%s\n",strsql); if(iceb_sql_zapis(strsql,0,0,data->vwindow) != 0) return(1); gtk_widget_hide(data->vwindow); if(metkakor == 1) rpod_kkvt(data->kodv.ravno(),data->vvod.kod.ravno(),data->vwindow); rpod_create_list(data); return(0); } /*******************************/ /*Проверка на уже введенную запись*/ /**********************************/ int rpod_pk(const char *kod,GtkWidget *wpredok) { char strsql[300]; sprintf(strsql,"select kod from Restpod where kod=%d",atoi(kod)); //printf("rpod_pk-%s\n",strsql); if(sql_readkey(&bd,strsql) > 0) { iceb_u_str repl; repl.plus(gettext("Такая запись уже есть !")); iceb_menu_soob(&repl,wpredok); return(1); } return(0); } /*****************************/ /*Корректировка кода в таблицах*/ /********************************/ void rpod_kkvt(const char *kods,const char *kodn,GtkWidget *wpredok) { char strsql[300]; sprintf(strsql,"update Restdok set podr=%s where podr=%s",kodn,kods); if(sql_zap(&bd,strsql) != 0) { if(sql_nerror(&bd) == ER_DBACCESS_DENIED_ERROR) //Только чтение { iceb_u_str SOOB; SOOB.plus(gettext("У вас нет полномочий для выполнения этой операции !")); iceb_menu_soob(&SOOB,wpredok); return; } else iceb_msql_error(&bd,gettext("Ошибка корректировки записи !"),strsql,wpredok); } sprintf(strsql,"update Restdok1 set podr=%s where podr=%s",kodn,kods); if(sql_zap(&bd,strsql) != 0) iceb_msql_error(&bd,gettext("Ошибка корректировки записи !"),strsql,wpredok); }
7e724b5506550478986db04ca84349d888ff7e4d
f1bd4d38d8a279163f472784c1ead12920b70be2
/xrLC/Occlusion/_vector3d.h
d6af4e7f0220c10b6b9a0b041a0b7730af1dca68
[]
no_license
YURSHAT/stk_2005
49613f4e4a9488ae5e3fd99d2b60fd9c6aca2c83
b68bbf136688d57740fd9779423459ef5cbfbdbb
refs/heads/master
2023-04-05T16:08:44.658227
2021-04-18T09:08:18
2021-04-18T18:35:59
361,129,668
1
0
null
null
null
null
UTF-8
C++
false
false
5,209
h
_vector3d.h
#ifndef __V3D__ #define __V3D__ typedef struct _vector { public: union { struct{ float x,y,z; }; float m[3]; }; __forceinline D3DVECTOR *d3d(void) { return (D3DVECTOR *)this; }; __forceinline void set(float _x, float _y, float _z) { x = _x; y = _y; z = _z; }; __forceinline void set(_vector &v) { x = v.x; y = v.y; z = v.z; }; __forceinline void set(float* p) { x = p[0]; y = p[1]; z = p[2]; }; __forceinline void get(float* p) { p[0] = x; p[1] = y; p[2] = z; }; __forceinline void add(_vector &v) { x+=v.x; y+=v.y; z+=v.z; }; __forceinline void add(float s) { x+=s; y+=s; z+=s; }; __forceinline void add(_vector &a, _vector &v) { x=a.x+v.x;y=a.y+v.y; z=a.z+v.z; }; __forceinline void add(_vector &a, float s) { x=a.x+s; y=a.y+s; z=a.z+s; }; __forceinline void sub(_vector &v) { x-=v.x; y-=v.y; z-=v.z; }; __forceinline void sub(float s) { x-=s; y-=s; z-=s; }; __forceinline void sub(_vector &a, _vector &v) { x=a.x-v.x;y=a.y-v.y; z=a.z-v.z; }; __forceinline void sub(_vector &a, float s) { x=a.x-s; y=a.y-s; z=a.z-s; }; __forceinline void mul(_vector &v) { x*=v.x; y*=v.y; z*=v.z; }; __forceinline void mul(float s) { x*=s; y*=s; z*=s; }; __forceinline void mul(_vector &a, _vector &v) { x=a.x*v.x;y=a.y*v.y; z=a.z*v.z; }; __forceinline void mul(_vector &a, float s) { x=a.x*s; y=a.y*s; z=a.z*s; }; __forceinline void div(_vector &v) { x/=v.x; y/=v.y; z/=v.z; }; __forceinline void div(float s) { x/=s; y/=s; z/=s; }; __forceinline void div(_vector &a, _vector &v) { x=a.x/v.x;y=a.y/v.y; z=a.z/v.z; }; __forceinline void div(_vector &a, float s) { x=a.x/s; y=a.y/s; z=a.z/s; }; __forceinline bool cmp(_vector &v) { return x==v.x && y==v.y && z == v.z; }; // Align vector by axis (!y) __forceinline void align() { y = 0; if (fabsf(z)>=fabsf(x)) { z /= fabsf(z?z:1); x = 0; } else { x /= fabsf(x); z = 0; } } // Clamp vector __forceinline void clamp(_vector &min, _vector max) { if (x<min.x) x = min.x; else if (x>max.x) x = max.x; if (y<min.y) y = min.y; else if (y>max.y) y = max.y; if (z<min.z) z = min.z; else if (z>max.z) z = max.z; } __forceinline void clamp(_vector &_v) { Fvector v; v.x = fabsf(_v.x); v.y = fabsf(_v.y); v.z = fabsf(_v.z); if (x<-v.x) x = -v.x; else if (x>v.x) x = v.x; if (y<-v.y) y = -v.y; else if (y>v.y) x = v.y; if (z<-v.z) z = -v.z; else if (z>v.z) z = v.z; } // Interpolate vectors (inertion) __forceinline void inertion(_vector &p, float v) { x = v*x + (1.f-v)*p.x; y = v*y + (1.f-v)*p.y; z = v*z + (1.f-v)*p.z; } // Direct vector from point P by dir D with length M __forceinline void direct(_vector &p, _vector &d, float m) { x = p.x + d.x*m; y = p.y + d.y*m; z = p.z + d.z*m; } // magnitude __forceinline float magnitude(void) { return sqrtf(x*x + y*y + z*z); } // SQ magnitude __forceinline float square_magnitude(void) { return x*x + y*y + z*z; } // Normalize _E(__forceinline void normalize(void)) VERIFY((x*x+y*y+z*z)>0.00000001f); float mag=sqrtf(1.0f/(x*x + y*y + z*z)); x *= mag; y *= mag; z *= mag; _end; // Safe-Normalize __forceinline void normalize_safe(void) { float magnitude=x*x + y*y + z*z; if (magnitude>0.000001f) { magnitude=sqrtf(1/magnitude); x *= magnitude; y *= magnitude; z *= magnitude; } } // Normalize _E(__forceinline void normalize(_vector &v)) VERIFY((v.x*v.x+v.y*v.y+v.z*v.z)>0.00000001f); float mag=sqrtf(1.0f/(v.x*v.x + v.y*v.y + v.z*v.z)); x = v.x*mag; y = v.y*mag; z = v.z*mag; _end; // Safe-Normalize __forceinline void normalize_safe(_vector &v) { float magnitude=v.x*v.x + v.y*v.y + v.z*v.z; if (magnitude>0.000001f) { magnitude=sqrtf(1/magnitude); x = v.x*magnitude; y = v.y*magnitude; z = v.z*magnitude; } } // DotProduct __forceinline float dotproduct(const _vector &v) // v1*v2 { return x*v.x + y*v.y + z*v.z; } // CrossProduct __forceinline void crossproduct(const _vector &v1, const _vector &v2) // (v1,v2) -> this { x = v1.y * v2.z - v1.z * v2.y ; y = v1.z * v2.x - v1.x * v2.z ; z = v1.x * v2.y - v1.y * v2.x ; } // Distance calculation __forceinline float distance_to_xz(const _vector &v) { return sqrtf( (x-v.x)*(x-v.x) + (z-v.z)*(z-v.z) ); } // Distance calculation __forceinline float distance_to(const _vector &v) { return sqrtf( (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) + (z-v.z)*(z-v.z) ); } // Distance calculation __forceinline float distance_to_sqr(const _vector &v) { return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) + (z-v.z)*(z-v.z); } __forceinline void position_of_camera (const _matrix &m); __forceinline void transform_tiny (const _matrix &mat); __forceinline void transform (const _matrix &mat); __forceinline void transform_dir (const _matrix &mat); __forceinline void transform_tiny (const _vector &v, const _matrix &mat); // preferred to use __forceinline void transform (const _vector &v, const _matrix &mat); // preferred to use __forceinline void transform_dir (const _vector &v, const _matrix &mat); // preferred to use } Fvector; #endif
f91fb2ad3d27207fe2393e655568df1f2bcb23a1
9918520b3e6fee65fef2ac82d7de7ba65cef8d65
/libs/geometry/OBB.h
12eae5f2161ed76e571b88908141b6d2de087b58
[]
no_license
jijinlong/shaobohou-cppcodes
e93e430130216a992471c989764a9e41cc850856
bb1357f4a7513919f74fcd1c36089aa376fd0e6d
refs/heads/master
2021-01-10T09:51:59.535408
2012-03-04T16:39:04
2012-03-04T16:39:04
48,173,421
0
1
null
null
null
null
UTF-8
C++
false
false
1,268
h
OBB.h
#ifndef OBB_H #define OBB_H #include "Vector3D.h" #include "Quaternion.h" #include "ConvexHull.h" class OBB { public: OBB(); OBB(const Quaternion &orientationOffset, const Vector3D &centreOffset, const Vector3D &extents); OBB(const Vector3D &position, const Quaternion &orientation, const Quaternion &orientationOffset, const Vector3D &centreOffset, const Vector3D &extents); OBB(const ConvexHull3D &hull, double scaling); virtual ~OBB(); void setExtents(const Vector3D &extents); const Quaternion& getOrientation() const; const Vector3D& getCentre() const; const Vector3D& getExtents() const; const Vector3D& getCentreOffset() const; const Vector3D& getAxis(unsigned int axis) const; //0 = X, 1 = Y, 2 = Z void sync(const Vector3D &position, const Quaternion &orientation); static bool testIntersection(const OBB &obb1, const OBB &obb2); private: Quaternion orientation, orientationOffset; Vector3D centre, centreOffset; Vector3D extents; Vector3D axes[3]; //axes, left, up and forward, calculate from orientation void updateAxes(const Quaternion &orientation); }; #endif
827f65cb70d26ede70a7831522eda84fcfd7badd
b6c61fe159f9ac42a693c6372c243565aad2edec
/comp345game/IPlayerType.h
701a4e3fb3e96f3bf904217944133b2566923377
[]
no_license
anthroe/KingOfNewYorkGame
9b874f18292e90953ba2a4fe6f042e95c6d59b61
02f15c5b9cd7227303d0e4db9be03ea2b0eba056
refs/heads/master
2020-03-28T14:55:27.083722
2018-12-03T04:44:33
2018-12-03T04:44:33
148,536,445
0
1
null
null
null
null
UTF-8
C++
false
false
730
h
IPlayerType.h
#pragma once #include "player.h" #include "deck.h" class player; class IPlayerType { public: virtual void rollDice(player*); virtual void resolveDice(player*); virtual void move(player*); virtual void chooseStartingRegion(player*); virtual void buyCards(player*); }; class aggressiveBot : public IPlayerType { public: virtual void rollDice(player*); virtual void move(player*); }; class moderateBot : public IPlayerType { public: virtual void rollDice(player*); virtual void move(player*); }; class client : public IPlayerType { public: virtual void rollDice(player*); virtual void resolveDice(player*); virtual void move(player*); virtual void chooseStartingRegion(player*); virtual void buyCards(player*); };
c6bc8f59191a47c29f0b8444438e44177822b8cb
41fd2e43649ccc2c9cdd6bbcddf159babdf36dba
/compass/regressions/C++/References 5/test.cpp
ba0b57af3b1ddd12301bff6fa1f2994f730767a0
[]
no_license
fredfeng/compass
84d37183c11692da77b3c8cf7666c15a5b524390
3063df1a86e9473bbd62d52e9002743fd7e90c3b
refs/heads/master
2020-04-10T11:57:17.616921
2015-03-10T16:54:21
2015-03-10T16:54:21
31,969,036
0
1
null
null
null
null
UTF-8
C++
false
false
202
cpp
test.cpp
#include <stdlib.h> class Foo { int x; public: Foo(){x = 5;}; virtual int get_x() {return x;}; }; void test_reference() { Foo x; Foo & y = x; static_assert(y.get_x() == 6); //should fail }
bfcf09e64cc221188708b535fd3f922e5d1de4ce
668fa4c7a0d0595dd114f5f36d89146e35bac4d4
/src/viz/ReadCSV.h
647d9d9bd0e6ef3664f91b0bab5f377fd2804c29
[]
no_license
sippeangelo/dota2viz
b537b678a578166b0b192379b0218534893674a2
1d2941f8d6adc2c6b96f8c67a2356d3526610183
refs/heads/master
2020-05-23T14:50:30.346631
2015-03-18T22:37:53
2015-03-18T22:37:53
32,207,234
0
0
null
null
null
null
UTF-8
C++
false
false
246
h
ReadCSV.h
#include <iostream> #include <string> #include <tuple> #include <vector> #include <boost/filesystem.hpp> struct Data { double x; double y; double team; double time; }; class ReadCSV { public: std::vector<Data> read(std::string path); };
1ce978a56bd3046d499242803fdc1b1e30229205
b902f7edd4dd21bbd5644be7bfb8a0bca7f065cd
/shader_stuff.h
af8d3dc43c20cd513ab077fc54f5aaf4dc932aa2
[]
no_license
kubzoey95/OpenGLProjekt
b2037ccb2e05744f774e3b11c12692420a418900
20a59f13afc7d792d62be25f33635277823db152
refs/heads/master
2023-01-04T12:50:31.499978
2020-11-03T20:24:15
2020-11-03T20:24:15
309,771,556
1
0
null
null
null
null
UTF-8
C++
false
false
40,859
h
shader_stuff.h
#ifndef __SHADER_STUFF #define __SHADER_STUFF #define M_PI 3.14159265358979323846 // References: // https://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/loading.php #include <fstream> #include <string> #include <stdio.h> #include <iostream> #include <vector> #include "texture_loader.hpp" #include <stdio.h> #include <GL/glew.h> #include <GL/freeglut.h> #include <glm/gtc/type_ptr.hpp> #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #include <glm/gtx/string_cast.hpp> #include <glm/gtx/norm.hpp> #include <glm/gtx/quaternion.hpp> #include <glm/gtc/quaternion.hpp> #include "obj_loader.hpp" #include <GL/glew.h> #include <GL/freeglut.h> #include <GL/SOIL.h> #include <windows.h> #include <mmsystem.h> #include <cstdlib> #include <ctime> using namespace std; // --------------------------------------------- // Variables for control the view GLfloat _scene_rotate_x = 0.0f; GLfloat _scene_rotate_y = 0.0f; GLfloat _scene_translate_x = 0.0f; GLfloat _scene_translate_y = 0.0f; GLfloat _scene_translate_z = 0.0f; GLuint coordBuffer; GLuint vertexArray; GLuint vIndexBuffer; GLuint vNormalBuffer; GLuint vBufferUV; GLuint lightsBuffer; GLuint specLightsBuffer; GLuint vInstances; int _mouse_buttonState = GLUT_UP; int right_btn_state = GLUT_UP; int _mouse_buttonX, _mouse_buttonY; GLuint currentProgram; GLuint viewMatrixLocation; GLuint modelMatrixLocation; GLuint projMatrixLocation; int lightsPointer = 0; float lights[12]; int specLightsPointer = 0; float specLights[16]; GLuint TextureID; GLuint Texture1ID; float gunShot = 0.f; bool gunShotBool = false; int magazine = 17; int ammo = 17 * 4; float reload = 0.f; bool reloadBool = false; // -------------------------------------------------------------- void SpecialKeysUp( int key, int x, int y ) { switch( key ) { case GLUT_KEY_LEFT: _scene_translate_x = 0.f; break; case GLUT_KEY_RIGHT: _scene_translate_x = 0.f; break; case GLUT_KEY_DOWN: _scene_translate_y = 0.f; break; case GLUT_KEY_UP: _scene_translate_y = 0.f; break; } // glutPostRedisplay(); } void SpecialKeys( int key, int x, int y ) { switch( key ) { case GLUT_KEY_LEFT: _scene_translate_x = -0.1f; break; case GLUT_KEY_RIGHT: _scene_translate_x = 0.1f; break; case GLUT_KEY_DOWN: _scene_translate_y = -0.1f; break; case GLUT_KEY_UP: _scene_translate_y = 0.1f; break; } // glutPostRedisplay(); } // -------------------------------------------------------------- void Keyboard( unsigned char key, int x, int y ) { switch(key) { case 27: // ESC key exit(0); break; } } // -------------------------------------------------------------- void MouseButton( int button, int state, int x, int y ) { if( button == GLUT_LEFT_BUTTON ) { _mouse_buttonState = state; if( state == GLUT_DOWN ) { // SoundEngine->play2D("C:/Users/jakub/projects/helloworld/gunshot.wav", false); // mciSendString(TEXT("play C:/Users/jakub/projects/helloworld/gunshot.wav"), NULL, 0, NULL); if (magazine > 0 && !reloadBool){ mciSendString(TEXT("seek gun to start"),NULL,100,NULL); mciSendString(TEXT("play gun"),NULL,0,NULL); // PlaySound(TEXT("C:/Users/jakub/projects/helloworld/gunshot.wav"), NULL, SND_FILENAME | SND_ASYNC); gunShot = 1.f; gunShotBool = true; magazine--; } else{ if (!reloadBool){ mciSendString(TEXT("seek noammo to start"),NULL,100,NULL); mciSendString(TEXT("play noammo"),NULL,0,NULL); } } _mouse_buttonX = x; _mouse_buttonY = y; } else { _scene_rotate_y = 0.f; _scene_rotate_x = 0.f; } } if (button == GLUT_RIGHT_BUTTON){ if (magazine < 17 && ammo > 0){ reload = 1.f; reloadBool = true; mciSendString(TEXT("seek reload to start"),NULL,100,NULL); mciSendString(TEXT("play reload"),NULL,0,NULL); if (ammo < 17 - magazine) { magazine += ammo; ammo = 0; } else{ ammo -= 17 - magazine; magazine = 17; } } } } // -------------------------------------------------------------- void MouseMotion( int x, int y ) { if( _mouse_buttonState == GLUT_DOWN ) { _scene_rotate_y = 2.f*(float)(x - _mouse_buttonX)/(float)glutGet( GLUT_WINDOW_WIDTH ); _mouse_buttonX = glutGet(GLUT_WINDOW_HEIGHT) / 2; _scene_rotate_x = -2.f*(float)(_mouse_buttonY - y)/(float)glutGet( GLUT_WINDOW_HEIGHT ); _mouse_buttonY = glutGet(GLUT_WINDOW_WIDTH) / 2; glutWarpPointer(glutGet(GLUT_WINDOW_HEIGHT) / 2, glutGet(GLUT_WINDOW_WIDTH) / 2); } if (right_btn_state == GLUT_DOWN){ _scene_translate_z = 2*(_mouse_buttonY - y)/(float)glutGet( GLUT_WINDOW_HEIGHT ); _mouse_buttonY = y; } else { _scene_translate_z = 0.f; } // glutPostRedisplay(); } // int winHeight = glutGet(GLUT_WINDOW_HEIGHT); // int winWidth = glutGet(GLUT_WINDOW_HEIGHT); void PassiveMotion(int x, int y){ _scene_rotate_y = 2.f*(float)(x - _mouse_buttonX)/(float)glutGet( GLUT_WINDOW_WIDTH ); _mouse_buttonX = glutGet(GLUT_WINDOW_HEIGHT) / 2; _scene_rotate_x = -2.f*(float)(_mouse_buttonY - y)/(float)glutGet( GLUT_WINDOW_HEIGHT ); _mouse_buttonY = glutGet(GLUT_WINDOW_WIDTH) / 2; glutWarpPointer(glutGet(GLUT_WINDOW_HEIGHT) / 2, glutGet(GLUT_WINDOW_WIDTH) / 2); } // -------------------------------------------------------------- void MouseWheel(int button, int dir, int x, int y) { } unsigned long getFileLength(std::ifstream& file) { if(!file.good()) return 0; unsigned long pos=file.tellg(); file.seekg(0,std::ios::end); unsigned long len = file.tellg(); file.seekg(std::ios::beg); return len; } // --------------------------------------------- GLchar * LoadShaderFile(const char* filename) { std::ifstream file; file.open(filename, std::ios::in); // opens as ASCII! if(!file) { printf("Can't open file %s !\n", filename); exit(1); } unsigned long len = getFileLength(file); if (len==0) { printf("File %s is empty!\n", filename); exit(1); }; // Error: Empty File GLchar *ShaderSource = new GLchar[len+1]; if (ShaderSource == NULL) { printf("Can't reserve memory %d \n", len+1); exit(1); } // can't reserve memory // len isn't always strlen cause some characters are stripped in ascii read... // it is important to 0-terminate the real length later, len is just max possible value... ShaderSource[len] = 0; unsigned int i=0; while (file.good()) { ShaderSource[i] = file.get(); if (!file.eof()) i++; } ShaderSource[i] = 0; file.close(); return ShaderSource; } // --------------------------------------- void CheckForErrors_Shader(GLuint shader) { GLint status; glGetShaderiv( shader, GL_COMPILE_STATUS, &status ); if( status != GL_TRUE ) { printf("Blad!\n"); GLint logLength; glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &logLength ); char *log = new char[logLength]; glGetShaderInfoLog( shader, logLength, NULL, log ); printf("LOG: %s\n", log); delete[] log; exit(1); } } // --------------------------------------- void CheckForErrors_Program(GLuint program, GLenum mode) { GLint status; glGetProgramiv( program, mode, &status ); if( status != GL_TRUE ) { switch (mode) { case GL_LINK_STATUS: printf("Blad konsolidacji programu!\n"); break; case GL_VALIDATE_STATUS: printf("Blad walidacji programu!\n"); break; default: printf("Inny blad programu!\n"); } GLint logLength; glGetProgramiv( program, GL_INFO_LOG_LENGTH, &logLength ); char *log = new char[logLength]; glGetProgramInfoLog( program, logLength, NULL, log ); printf("LOG: %s\n", log); delete[] log; exit(1); } } // --------------------------------------- GLuint LoadShader( GLuint MODE, const char *filename ) { // utworzenie obiektu shadera GLuint shader = glCreateShader( MODE ); // Wczytanie kodu shadera z pliku GLchar *code = LoadShaderFile(filename); glShaderSource( shader, 1, &code, NULL ); glCompileShader( shader ); CheckForErrors_Shader(shader); delete[] code; return shader; } GLuint LoadShader(GLuint MODE, char shader_stream_start[], char shader_stream_end[]) { GLuint shader = glCreateShader( MODE ); size_t size = (shader_stream_end - shader_stream_start) / sizeof(char); GLchar * code = new GLchar[size + 1]; code[size] = 0; int iter=0; for (char* p = shader_stream_start; p != shader_stream_end; p++) { code[iter] = *p; iter++; } code[iter] = 0; cout << "=============================================================" << endl; if (MODE == GL_VERTEX_SHADER){ cout << "Loaded vertex shader:" << endl; } if (MODE == GL_FRAGMENT_SHADER){ cout << "Loaded fragment shader:" << endl; } cout << "=============================================================" << endl << endl; cout << code << endl; glShaderSource( shader, 1, &code, NULL ); glCompileShader( shader ); CheckForErrors_Shader(shader); delete[] code; return shader; } void clear(){ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); specLightsPointer = 0; lightsPointer = 0; GLuint bindingPoint; GLuint blockID; // spec lights // glBufferData(GL_UNIFORM_BUFFER, specLights.size()*sizeof(float), NULL, GL_DYNAMIC_DRAW); blockID = glGetUniformBlockIndex(currentProgram, "specLights"); bindingPoint = 1; glUniformBlockBinding(currentProgram, blockID, bindingPoint); glBindBufferBase(GL_UNIFORM_BUFFER, bindingPoint, specLightsBuffer); glBindBuffer(GL_UNIFORM_BUFFER, specLightsBuffer); // glBufferSubData(GL_UNIFORM_BUFFER, 0, specLights.size()*sizeof(float), &specLights[0]); glBufferData(GL_UNIFORM_BUFFER, sizeof(float), specLights, GL_DYNAMIC_DRAW); // just lights // glBufferData(GL_UNIFORM_BUFFER, lights.size()*sizeof(float), NULL, GL_DYNAMIC_DRAW); blockID = glGetUniformBlockIndex(currentProgram, "lights"); bindingPoint = 2; glUniformBlockBinding(currentProgram, blockID, bindingPoint); glBindBufferBase(GL_UNIFORM_BUFFER, bindingPoint, lightsBuffer); glBindBuffer(GL_UNIFORM_BUFFER, lightsBuffer); // glBufferSubData(GL_UNIFORM_BUFFER, 0, lights.size()*sizeof(float), &lights[0]); glBufferData(GL_UNIFORM_BUFFER, sizeof(lights), lights, GL_DYNAMIC_DRAW); } void InitializeBuffers(){ glGenVertexArrays(1, &vertexArray); glBindVertexArray(vertexArray); glGenBuffers( 1, &coordBuffer ); glBindBuffer( GL_ARRAY_BUFFER, coordBuffer ); glGenBuffers( 1, &vNormalBuffer ); glBindBuffer( GL_ARRAY_BUFFER, vNormalBuffer ); glGenBuffers( 1, &vNormalBuffer ); glBindBuffer( GL_ARRAY_BUFFER, vNormalBuffer ); glGenBuffers( 1, &vBufferUV ); glBindBuffer( GL_ARRAY_BUFFER, vBufferUV ); glGenBuffers(1, &lightsBuffer); glBindBuffer(GL_UNIFORM_BUFFER, lightsBuffer); glGenBuffers(1, &specLightsBuffer); glBindBuffer(GL_UNIFORM_BUFFER, specLightsBuffer); glGenBuffers(1, &vInstances); glBindBuffer(GL_ARRAY_BUFFER, vInstances); glGenTextures(1, &TextureID); } // --------------------------------------- void LinkAndValidateProgram(GLuint program) { // Konsolidacja programu glLinkProgram( program ); CheckForErrors_Program(program, GL_LINK_STATUS); // Walidacja programu glValidateProgram( program ); CheckForErrors_Program(program, GL_VALIDATE_STATUS); } glm::vec3 extractCameraPos(const glm::mat4 & a_modelView) { glm::mat4 modelViewT = transpose(a_modelView); glm::vec3 n1(modelViewT[0]); glm::vec3 n2(modelViewT[1]); glm::vec3 n3(modelViewT[2]); float d1(modelViewT[0].w); float d2(modelViewT[1].w); float d3(modelViewT[2].w); glm::vec3 n2n3 = cross(n2, n3); glm::vec3 n3n1 = cross(n3, n1); glm::vec3 n1n2 = cross(n1, n2); glm::vec3 top = (n2n3 * d1) + (n3n1 * d2) + (n1n2 * d3); float denom = dot(n1, n2n3); return top / -denom; } glm::quat rotationBetweenVectors(glm::vec3 start, glm::vec3 dest){ start = glm::normalize(start); dest = glm::normalize(dest); float cosTheta = glm::dot(start, dest); glm::vec3 rotationAxis; if (cosTheta < -1 + 0.001f){ rotationAxis = glm::cross(glm::vec3(0.0f, 0.0f, 1.0f), start); if (length2(rotationAxis) < 0.01 ) { rotationAxis = glm::cross(glm::vec3(1.0f, 0.0f, 0.0f), start); } rotationAxis = normalize(rotationAxis); return angleAxis(glm::radians(180.0f), rotationAxis); } rotationAxis = glm::cross(start, dest); float s = glm::sqrt( (1+cosTheta)*2 ); float invs = 1 / s; return glm::quat( s * 0.5f, rotationAxis.x * invs, rotationAxis.y * invs, rotationAxis.z * invs ); } glm::mat3x3 rodriguesMatrix(const double degrees, const glm::vec3& axis) { glm::mat3x3 v = glm::mat3x3( axis.x*axis.x, axis.x*axis.y, axis.x*axis.z, axis.x*axis.y, axis.y*axis.y, axis.y*axis.z, axis.x*axis.z, axis.y*axis.z, axis.z*axis.z ); glm::mat3x3 v2 = glm::mat3x3( 0, -axis.z, axis.y, axis.z, 0, -axis.x, -axis.y, axis.x, 0 ); glm::mat3x3 rotation = cosf(degrees * M_PI/180.f) * glm::mat3x3(1.0f) + (1.f-cosf(degrees * M_PI/180.f)) * v + sinf(degrees * M_PI/180.f) * v2; return rotation; } class CTriangle { public: // wspolrzedne punktow trojkata // uwaga! os pionowa w tym wypadku to z glm::vec3 p[3]; // rownanie plaszczyzny Ax + By + Cz + D = 0 float A,B,C,D; CTriangle() { } CTriangle(const glm::vec3 &p1, const glm::vec3 &p2, const glm::vec3 &p3) { p[0] = p1; p[1] = p2; p[2] = p3; calculateEquation(); } // obliczanie wspolczynnikow rownania void calculateEquation(void) { glm::vec3 v1, v2; v1 = p[1] - p[0]; v2 = p[2] - p[0]; A = v1.y * v2.z - v1.z * v2.y; // A B = v1.z * v2.x - v1.x * v2.z; // B C = v1.x * v2.y - v1.y * v2.x; // C D = - (A*p[0].x + B*p[0].y + C*p[0].z); // D if (C == 0) { printf("Uwaga! Trojkat pionowy.\n"); } } // czy punkt p1 jest po lewej stronie odcinka p2-p3 inline float sign (glm::vec2 p1, glm::vec3 p2, glm::vec3 p3) { return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y); } // czy punkt jest wewnatrz trojkata rzutowanego na plaszczyzne xy inline bool isInside (glm::vec2 point) { float s1, s2, s3; bool has_neg, has_pos; s1 = sign(point, p[0], p[1]); s2 = sign(point, p[1], p[2]); s3 = sign(point, p[2], p[0]); has_neg = (s1 < 0) || (s2 < 0) || (s3 < 0); has_pos = (s1 > 0) || (s2 > 0) || (s3 > 0); return !(has_neg && has_pos); } glm::vec3 getNormal(){ return glm::vec3(this->A,this->B,this->C); } // obliczamy wysokosc punktu w trojkacie inline float altitude(glm::vec2 point) { if (C) return -(A*point.x + B*point.y + D)/C; else { return 99999; } } }; class GameObject{ protected: glm::vec3 position = glm::vec3(0.f); glm::vec3 scaling = glm::vec3(1.f, 1.f, 1.f); glm::vec3 rotation = glm::vec3(0.f); public: glm::vec3 getScaling(){ return this->scaling; } glm::vec3 getPosition(){ return this->position; } glm::vec3 getUp(){ return glm::vec3(this->getMatrix()[1]); } glm::vec3 getFront(){ return glm::vec3(this->getMatrix()[2]); } void setScaling(float x, float y, float z){ this->scaling = glm::vec3(x,y,z); } void setPosition(float x, float y, float z){ this->position = glm::vec3(x,y,z); } void setRotation(float x, float y, float z){ this->rotation = glm::vec3(x,y,z); } void setPosition(glm::vec3 pos){ this->position = pos; } void translate(float x, float y, float z){ this->position += glm::vec3(x,y,z); } void rotate(float x, float y, float z){ this->rotation += glm::vec3(x,y,z); } void scale(float x, float y, float z){ this->scaling += glm::vec3(x,y,z); } glm::vec3 getRight(){ return glm::vec3(this->getMatrix()[0]); } void moveInLocalCoor(float amount, glm::vec3 direction){ this->position += glm::normalize( direction.x * glm::normalize(this->getRight()) + direction.y * glm::normalize(this->getUp()) + direction.z * glm::normalize(this->getFront()) ) * amount; } void moveForward(float amount){ this->moveInLocalCoor(amount, glm::vec3(0.f,0.f,1.f)); } void moveUp(float amount){ this->moveInLocalCoor(amount, glm::vec3(0.f,1.f,0.f)); }void moveRight(float amount){ this->moveInLocalCoor(amount, glm::vec3(1.f,0.f,0.f)); } glm::mat4x4 getMatrix(){ glm::mat4x4 mat = glm::mat4x4(1.f); mat = glm::translate(mat, this->position); mat = mat * glm::mat4_cast(glm::quat(this->rotation)); mat = glm::scale(mat, this->scaling); return mat; } void display(){ } }; class Light : public GameObject { protected: glm::vec3 ambient = glm::vec3(0.2f, 0.2f, 0.2f); glm::vec3 diffuse = glm::vec3(0.8f, 0.8f, 0.8f); glm::vec3 position = glm::vec3(0.f,0.f,0.f); public: Light(){ } Light(glm::vec3 ambient, glm::vec3 diffuse, glm::vec3 position){ this->ambient = ambient; this->diffuse = diffuse; this->position = position; } void pushAttribs(float * list, int & pointer){ list[pointer] = this->ambient.x; list[pointer + 1] = this->ambient.y; list[pointer + 2] = this->ambient.z; list[pointer + 3] = 1.f; pointer += 4; list[pointer] = this->diffuse.x; list[pointer + 1] = this->diffuse.y; list[pointer + 2] = this->diffuse.z; list[pointer + 3] = 1.f; pointer += 4; list[pointer] = this->position.x; list[pointer + 1] = this->position.y; list[pointer + 2] = this->position.z; list[pointer + 3] = 1.f; pointer += 4; } void display(){ this->pushAttribs(lights, lightsPointer); } }; class SpecularLight : public Light{ private: glm::vec3 specular = glm::vec3(1.0f, 1.0f, 1.0f); public: SpecularLight(){} SpecularLight(glm::vec3 ambient, glm::vec3 diffuse, glm::vec3 position, glm::vec3 specular){ this->ambient = ambient; this->diffuse = diffuse; this->position = position; this->specular = specular; } void pushAttribs(float * list, int & pointer){ Light::pushAttribs(list, pointer); list[pointer] = this->specular.x; list[pointer + 1] = this->specular.y; list[pointer + 2] = this->specular.z; list[pointer + 3] = 1.f; pointer += 4; } void display(){ this->pushAttribs(specLights, specLightsPointer); } }; class CompositeGameObject : public GameObject { private: vector<GameObject> objects; public: CompositeGameObject(vector<GameObject> objects): objects(objects){} void addObject(GameObject object){ objects.push_back(object); } void display(){ // for (auto &object : this->objects){ // object->display(); // } } }; class Viewport : public GameObject { public: Viewport(glm::vec2 position, glm::vec2 size){ this->position = glm::vec3(position, 0.f); this->scaling = glm::vec3(size, 0.f); } glm::mat4x4 getProjMatrix(){ return glm::perspectiveFov(glm::radians(60.0f), (float)this->scaling.x, (float)this->scaling.y, 0.1f, 100.f ); } void display(){ glViewport((float)glutGet(GLUT_WINDOW_WIDTH) * this->position.x, (float)glutGet(GLUT_WINDOW_HEIGHT) * this->position.y, this->scaling.x, this->scaling.y ); glUniformMatrix4fv( projMatrixLocation, 1, GL_FALSE, glm::value_ptr(this->getProjMatrix()) ); } }; class Camera : public GameObject { private: glm::vec3 front = glm::vec3(0.f, 0.f, -1.f); glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); public: Camera(){ this->front = glm::vec3(0.f,0.f,1.f); } Camera(glm::vec3 cameraPos, glm::vec3 cameraFront, glm::vec3 cameraUp){ this->position = cameraPos; this->front = cameraFront; this->up = cameraUp; } void rotateCoor(float amount, glm::vec3 axis){ if (abs(amount) > 0.1f){ glm::mat3x3 rotation = rodriguesMatrix(amount, axis); this->front = glm::vec3(rotation * this->front); } } void moveInLocalCoor(float amount, glm::vec3 direction){ this->position += glm::normalize( direction.x * glm::normalize(this->getRight()) + direction.y * glm::normalize(this->getUp()) + direction.z * glm::normalize(this->getFront()) ) * amount; } void moveForward(float amount){ this->moveInLocalCoor(amount, glm::vec3(0.f,0.f,1.f)); } void moveUp(float amount){ this->moveInLocalCoor(amount, glm::vec3(0.f,1.f,0.f)); }void moveRight(float amount){ this->moveInLocalCoor(amount, glm::vec3(1.f,0.f,0.f)); } void rotateAroundUp(float amount){ this->rotateCoor(amount, this->getUp()); } void rotateAroundRight(float amount){ this->rotateCoor(amount, this->getRight()); } void rotateAroundFront(float amount){ this->rotateCoor(amount, this->getFront()); } void lookAt(float x, float y, float z){ this->front = glm::vec3(x,y,z) - this->position; } glm::vec3 getRight(){ return glm::cross(this->getFront(), this->getUp()); } glm::vec3 getUp(){ return this->up; } void setUp(glm::vec3 up){ this->up = up; } void setFront(glm::vec3 front){ this->front = front; } glm::mat4x4 getMatrix(){ return glm::lookAt(this->position, this->position - this->front, this->up); } glm::vec3 getPosition(){ glm::vec3 returnVect = this->position; return returnVect; } glm::vec3 getFront(){ return -this->front; } void display(){ glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, glm::value_ptr(this->getMatrix())); } }; class Program { private: GLuint program; public: Program(const char *vShaderFilename, const char *fShaderFilename){ this->program = glCreateProgram(); glAttachShader(this->program, LoadShader(GL_VERTEX_SHADER, vShaderFilename)); glAttachShader(this->program, LoadShader(GL_FRAGMENT_SHADER, fShaderFilename)); LinkAndValidateProgram(this->program); } Program(){ this->program = glCreateProgram(); } GLuint getProgram(){ return this->program; } void useThis(){ currentProgram = this->program; glUseProgram(currentProgram); viewMatrixLocation = glGetUniformLocation( currentProgram, "viewMatrix" ); modelMatrixLocation = glGetUniformLocation( currentProgram, "modelMatrix" ); projMatrixLocation = glGetUniformLocation( currentProgram, "projMatrix" ); } ~Program(){ glDeleteProgram(this->program); } void setUniformMatrix(const char *name, glm::mat4x4 matrix){ glUniformMatrix4fv(glGetUniformLocation(this->program, name), 1, GL_FALSE, glm::value_ptr(matrix)); } }; class Object : public GameObject { public: Object(){} void alignLocalVectorWith(glm::vec3 vectorToAlign, glm::vec3 vectorToAlignWith){ glm::vec3 toAlign = this->getRight() * vectorToAlign.x + this->getUp() * vectorToAlign.y + this->getFront() * vectorToAlign.z; glm::quat rotation = rotationBetweenVectors(toAlign, vectorToAlignWith); this->rotation = glm::eulerAngles(rotation * glm::quat(this->rotation)); } void alignFrontWith(glm::vec3 vectorToAlignWith){ this->alignLocalVectorWith(glm::vec3(0.f,0.f,1.f), vectorToAlignWith); } void alignRightWith(glm::vec3 vectorToAlignWith){ this->alignLocalVectorWith(glm::vec3(1.f,0.f,0.f), vectorToAlignWith); } void drawFunc(){} void prepareBuffers(){} void prepareShader(){} void initialize(){} void display(){} }; class ObjectFromArray: public Object { protected: std::vector<glm::vec3> array; glm::vec3 boundingBoxOrigin = glm::vec3(0.f); glm::vec3 boundingBoxWidth = glm::vec3(0.f); glm::vec3 boundingBoxHeight = glm::vec3(0.f); glm::vec3 boundingBoxDepth = glm::vec3(0.f); glm::vec3 centerOfGravity = glm::vec3(0.f); float radius = 0.f; public: ObjectFromArray(){} ObjectFromArray(std::vector<glm::vec3> array){ this->array = array; } ObjectFromArray(const char * path){ std::vector<glm::vec3> out_vertices; std::vector<glm::vec2> out_uvs; std::vector<glm::vec3> out_normals; loadOBJ(path, out_vertices, out_uvs, out_normals); this->array = out_vertices; this->boundingBoxOrigin = this->array.front(); this->boundingBoxWidth = glm::vec3(0,0,0); this->boundingBoxHeight = glm::vec3(0,0,0); this->boundingBoxDepth = glm::vec3(0,0,0); this->centerOfGravity = this->array[0]; for( int i=1;i < this->array.size(); i++){ this->centerOfGravity += this->array[i]; if(this->array[i].x < this->boundingBoxOrigin.x){ this->boundingBoxOrigin.x = this->array[i].x; } if(this->array[i].y < this->boundingBoxOrigin.y){ this->boundingBoxOrigin.y = this->array[i].y; } if(this->array[i].z < this->boundingBoxOrigin.z){ this->boundingBoxOrigin.z = this->array[i].z; } } this->centerOfGravity /= this->array.size(); float width = 0; float height = 0; float depth = 0; for(int i=1;i < this->array.size(); i++){ if (glm::length(this->centerOfGravity - this->array[i]) > this->radius){ this->radius = glm::length(this->centerOfGravity - this->array[i]); } if (this->array[i].x - this->boundingBoxOrigin.x > width){ width = this->array[i].x - this->boundingBoxOrigin.x; } if (this->array[i].y - this->boundingBoxOrigin.y > height){ height = this->array[i].y - this->boundingBoxOrigin.y; } if (this->array[i].z - this->boundingBoxOrigin.z > width){ depth = this->array[i].z - this->boundingBoxOrigin.z; } } this->boundingBoxWidth.x = width; this->boundingBoxHeight.y = height; this->boundingBoxDepth.z = depth; } glm::vec3 getBoundingBoxOrigin(){ glm::vec4 origin = glm::vec4(this->boundingBoxOrigin, 1.f); return glm::vec3(this->getMatrix() * origin); } glm::vec3 getBoundingBoxWidth(){ glm::vec4 width = glm::vec4(this->boundingBoxWidth, 0.f); return glm::vec3(this->getMatrix() * width); } glm::vec3 getBoundingBoxHeight(){ glm::vec4 height = glm::vec4(this->boundingBoxHeight, 0.f); return glm::vec3(this->getMatrix() * height); } glm::vec3 getBoundingBoxDepth(){ glm::vec4 depth = glm::vec4(this->boundingBoxDepth, 0.f); return glm::vec3(this->getMatrix() * depth); } glm::vec3 getCenterOfGravity(){ glm::vec4 center = glm::vec4(this->centerOfGravity, 1.f); return glm::vec3(this->getMatrix() * center); } float getRadius(){ return this->radius; } bool collidesWith(ObjectFromArray *other){ if (glm::length(other->getCenterOfGravity() - this->getCenterOfGravity()) < this->radius){ return true; // glm::vec4 firstPlane = glm::vec4(other->getBoundingBoxWidth(), -(other->getBoundingBoxWidth().x * other->getBoundingBoxOrigin().x + other->getBoundingBoxWidth().y * other->getBoundingBoxOrigin().y + other->getBoundingBoxWidth().z * other->getBoundingBoxOrigin().z)); } return false; } void prepareBuffers(){ glBindBuffer( GL_ARRAY_BUFFER, coordBuffer ); glBufferData( GL_ARRAY_BUFFER, this->array.size() * sizeof(glm::vec3), &this->array[0], GL_STATIC_DRAW ); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL ); glEnableVertexAttribArray(0); } void drawFunc(){ glDrawArrays(GL_TRIANGLES, 0, this->array.size()); } void display(){ glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, glm::value_ptr(this->getMatrix())); this->prepareBuffers(); this->drawFunc(); // glutPostRedisplay(); } }; class ObjectFromArrayWithNormals: public ObjectFromArray { protected: std::vector<glm::vec3> normals; public: ObjectFromArrayWithNormals(){} ObjectFromArrayWithNormals(std::vector<glm::vec3> array,std::vector<glm::vec3> normals){ this->array = array; this->normals = normals; } ObjectFromArrayWithNormals(const char * path){ std::vector<glm::vec3> out_vertices; std::vector<glm::vec2> out_uvs; std::vector<glm::vec3> out_normals; loadOBJ(path, out_vertices, out_uvs, out_normals); this->array = out_vertices; this->normals = out_normals; } void prepareBuffers(){ ObjectFromArray::prepareBuffers(); glBindBuffer( GL_ARRAY_BUFFER, vNormalBuffer ); glBufferData( GL_ARRAY_BUFFER, this->normals.size() * sizeof(glm::vec3), &this->normals[0], GL_STATIC_DRAW ); glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, NULL ); glEnableVertexAttribArray( 1 ); } void display(){ glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, glm::value_ptr(this->getMatrix()) ); this->prepareBuffers(); this->drawFunc(); // glutPostRedisplay(); } }; class ObjectFromArrayWithNormalsAndTexture: public ObjectFromArray { protected: std::vector<glm::vec3> normals; std::vector<glm::vec2> uvs; unsigned char *tex_data; int tex_width; int tex_height; GLuint textureID; glm::vec3 ambient = glm::vec3(0.8f, 0.8f, 0.2f); glm::vec3 diffuse = glm::vec3(1.0f, 1.0f, 1.0f); glm::vec3 specular = glm::vec3(0.7f, 0.7f, 0.7f); float shininess = 32.0f; glm::vec3 radPoint = glm::vec3(0.f); public: ObjectFromArrayWithNormalsAndTexture(){} ObjectFromArrayWithNormalsAndTexture(std::vector<glm::vec3> array,std::vector<glm::vec3> normals){ this->array = array; this->normals = normals; this->setBoundingCircle(); } ObjectFromArrayWithNormalsAndTexture(const char * objPath, const char * texPath, glm::vec3 ambient, glm::vec3 diffuse, glm::vec3 specular, float shine){ std::vector<glm::vec3> out_vertices; std::vector<glm::vec2> out_uvs; std::vector<glm::vec3> out_normals; loadOBJ(objPath, out_vertices, out_uvs, out_normals); this->array = out_vertices; this->normals = out_normals; this->uvs = out_uvs; this->tex_data = SOIL_load_image(texPath, &this->tex_width, &this->tex_height, 0, SOIL_LOAD_RGBA); glGenTextures(1, &this->textureID); glBindTexture(GL_TEXTURE_2D, this->textureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->tex_width, this->tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->tex_data); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); this->ambient = ambient; this->diffuse = diffuse; this->specular = specular; this->shininess = shine; this->setBoundingCircle(); } ObjectFromArrayWithNormalsAndTexture(const char * objPath, const char * texPath){ std::vector<glm::vec3> out_vertices; std::vector<glm::vec2> out_uvs; std::vector<glm::vec3> out_normals; loadOBJ(objPath, out_vertices, out_uvs, out_normals); this->array = out_vertices; this->normals = out_normals; this->uvs = out_uvs; this->tex_data = SOIL_load_image(texPath, &this->tex_width, &this->tex_height, 0, SOIL_LOAD_RGBA); glGenTextures(1, &this->textureID); glBindTexture(GL_TEXTURE_2D, this->textureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->tex_width, this->tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->tex_data); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); this->setBoundingCircle(); } void loadTexture(){ glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, this->textureID); glUniform1i(glGetUniformLocation(currentProgram, "texture"), 0); } void prepareBuffers(){ ObjectFromArray::prepareBuffers(); glBindBuffer( GL_ARRAY_BUFFER, vNormalBuffer ); glBufferData( GL_ARRAY_BUFFER, this->normals.size() * sizeof(glm::vec3), &this->normals[0], GL_STATIC_DRAW ); glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, NULL ); glEnableVertexAttribArray( 1 ); glBindBuffer( GL_ARRAY_BUFFER, vBufferUV ); glBufferData( GL_ARRAY_BUFFER, this->uvs.size() * sizeof(glm::vec2), &this->uvs[0], GL_STATIC_DRAW ); glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, 0, NULL ); glEnableVertexAttribArray( 2 ); } void setBoundingCircle(){ this->centerOfGravity = glm::vec3(0.f); for (int i=0;i < this->array.size();i++){ this->centerOfGravity += this->array[i]; } this->centerOfGravity /= (float)this->array.size(); float radius = 0.f; for (int i=0;i < this->array.size();i++){ glm::vec3 thisPoint = this->array[i]; float lng = glm::length(this->centerOfGravity - thisPoint); if (lng > radius){ radius = lng; this->radPoint = thisPoint; } } } glm::vec3 getCircleCenter(){ return glm::vec3(this->getMatrix() * glm::vec4(this->centerOfGravity,1.f)); } glm::vec3 getCircleRad(){ return glm::vec3(this->getMatrix() * glm::vec4(this->radPoint,1.f)); } void display(){ glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, glm::value_ptr(this->getMatrix())); glUniform3fv(glGetUniformLocation(currentProgram, "materialAmbient"), 1, &this->ambient[0]); glUniform3fv(glGetUniformLocation(currentProgram, "materialDiffuse"), 1, &this->diffuse[0]); glUniform3fv(glGetUniformLocation(currentProgram, "materialSpecular"), 1, &this->specular[0]); glUniform1f(glGetUniformLocation(currentProgram, "materialShine"), this->shininess); this->prepareBuffers(); this->loadTexture(); this->drawFunc(); } }; class HUD : public ObjectFromArray { private: std::vector<glm::vec2> uvs; unsigned char *tex_data; int tex_width; int tex_height; GLuint textureID; int width = 1024; int height = 768; public: HUD(const char * texPath){ this->tex_data = SOIL_load_image(texPath, &this->tex_width, &this->tex_height, 0, SOIL_LOAD_RGBA); glGenTextures(1, &this->textureID); glBindTexture(GL_TEXTURE_2D, this->textureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->tex_width, this->tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->tex_data); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); this->array.push_back(glm::vec3(0.f,1.f * (float)this->height,0.3)); this->array.push_back(glm::vec3(1.f* (float)this->width, 1.f* (float)this->height, 0.3)); this->array.push_back(glm::vec3(0.f, 0.f, 0.3)); this->array.push_back(glm::vec3(1.f* (float)this->width, 0.f, 0.3)); this->uvs.push_back(glm::vec2(1.f,0.f)); this->uvs.push_back(glm::vec2(0.f,1.f)); this->uvs.push_back(glm::vec2(0.f,0.f)); this->uvs.push_back(glm::vec2(1.f,1.f)); } void prepareBuffers(){ ObjectFromArray::prepareBuffers(); glBindBuffer( GL_ARRAY_BUFFER, vBufferUV ); glBufferData( GL_ARRAY_BUFFER, this->uvs.size() * sizeof(glm::vec2), &this->uvs[0], GL_STATIC_DRAW ); glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, 0, NULL ); glEnableVertexAttribArray( 2 ); } void loadTexture(){ glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, this->textureID); glUniform1i(glGetUniformLocation(currentProgram, "texture"), 0); } void display(){ glm::mat4x4 orthProj = glm::ortho(0,this->width / 2, 0, this->height / 2, -1,1); glUniformMatrix4fv( projMatrixLocation, 1, GL_FALSE, glm::value_ptr(orthProj)); glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, glm::value_ptr(glm::mat4x4(1.f))); glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, glm::value_ptr(glm::mat4x4(1.f))); this->prepareBuffers(); this->loadTexture(); this->drawFunc(); } }; // class AlignedWithCam: public ObjectFromArrayWithNormalsAndTexture{ // Camera cam; // AlignedWithCam(){ // } // } class CGround: public ObjectFromArrayWithNormalsAndTexture { public: int Number_of_triangles = 0; std::vector<CTriangle> triangles; CGround(const char * objPath, const char * texPath): ObjectFromArrayWithNormalsAndTexture(objPath, texPath){ glm::vec3 p1,p2,p3; std::vector<glm::vec3>::iterator it = this->array.begin(); while (it != this->array.end()) { p1 = *it++; p2 = *it++; p3 = *it++; // uwaga ! zamiana wspolrzednych, tak aby z byl wysokoscia triangles.push_back(CTriangle(glm::vec3(p1.x,p1.z,p1.y), glm::vec3(p2.x,p2.z,p2.y), glm::vec3(p3.x,p3.z,p3.y))); } Number_of_triangles = triangles.size(); printf("Created CGround of %d triangles.\n", Number_of_triangles); } // obliczenie wysokosci glm::vec3 getNormal(glm::vec2 point){ CTriangle *collTriangle = NULL; std::vector<CTriangle>::iterator it; for (it = triangles.begin(); it != triangles.end(); it++) { if ((*it).isInside(point)) { collTriangle = &(*it); return glm::normalize(collTriangle->getNormal()); } } return glm::vec3(0,1.f,0); } float getAltitute(glm::vec2 point) { // obliczenie listy trojkatow nad ktorymi jestesmy CTriangle *collTriangle = NULL; std::vector<CTriangle>::iterator it; for (it = triangles.begin(); it != triangles.end(); it++) { if ((*it).isInside(point)) { collTriangle = &(*it); break; } } // jesli zostal znaleziony if (collTriangle) { return collTriangle->altitude(point); } else { return 0.0; } } }; class ObjectFromArrayWithNormalsAndTextureInstanced: public ObjectFromArrayWithNormalsAndTexture{ protected: std::vector<glm::vec3> instanceMatrices; public: ObjectFromArrayWithNormalsAndTextureInstanced(const char * objPath, const char * texPath, std::vector<glm::vec3> instanceMatrices):ObjectFromArrayWithNormalsAndTexture(objPath, texPath){ this->instanceMatrices.assign(instanceMatrices.begin(), instanceMatrices.end()); } void assignNew(std::vector<glm::vec3> instanceMatrices){ this->instanceMatrices.assign(instanceMatrices.begin(), instanceMatrices.end()); } void drawFunc(){ glDrawArraysInstanced(GL_TRIANGLES, 0, this->array.size(), this->instanceMatrices.size()); } void prepareBuffers(){ ObjectFromArrayWithNormalsAndTexture::prepareBuffers(); glBindBuffer(GL_ARRAY_BUFFER, vInstances); glBufferData(GL_ARRAY_BUFFER, this->instanceMatrices.size() * sizeof(glm::vec3), &this->instanceMatrices[0], GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray(3); glBindBuffer(GL_ARRAY_BUFFER, vInstances); glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), (void*)0); glBindBuffer(GL_ARRAY_BUFFER, 0); glVertexAttribDivisor(3, 1); } void display(){ glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, glm::value_ptr(this->getMatrix())); // glUniform3fv(glGetUniformLocation(currentProgram, "materialAmbient"), 1, &this->ambient[0]); // glUniform3fv(glGetUniformLocation(currentProgram, "materialDiffuse"), 1, &this->diffuse[0]); // glUniform3fv(glGetUniformLocation(currentProgram, "materialSpecular"), 1, &this->specular[0]); // glUniform1f(glGetUniformLocation(currentProgram, "materialShine"), this->shininess); this->prepareBuffers(); this->loadTexture(); this->drawFunc(); } }; class Oponent{ protected: GameObject renderer; glm::vec2 position; int life = 4; public: Oponent(GameObject& renderer){ this->renderer = renderer; } void display(){ this->renderer.setPosition(this->position.x, this->renderer.getPosition().y, this->position.y); this->renderer.display(); } void moveRandomly(float amount){ srand(time(NULL)); float rand1 = (((float)rand() / (float)RAND_MAX) - 0.5) * 2.f; srand(time(NULL)); float rand2 = (((float)rand() / (float)RAND_MAX) - 0.5) * 2.f; this->position += glm::vec2(rand1, rand2)*amount; } void moveTowards(glm::vec2 point, float amount){ this->position += glm::normalize(point - this->position) * amount; } GameObject getRenderer(){ return this->renderer; } void setPosition(float x, float z){ this->position = glm::vec2(x, z); } glm::vec2 getPosition(){ return this->position; } bool alive(){ return this->life > 0; } int getLife(){ return this->life; } bool hit(){ this->life--; return this->life > 0; } }; class ObjectFromIndexArray: public ObjectFromArray { protected: std::vector<int> indexArray; public: ObjectFromIndexArray(){} ObjectFromIndexArray(std::vector<glm::vec3> array, std::vector<int> indexArray){ this->array = array; this->indexArray = indexArray; } void drawFunc(){ glDrawElements( GL_TRIANGLES, indexArray.size(), GL_UNSIGNED_INT, NULL ); } void prepareBuffers(){ ObjectFromArray::prepareBuffers(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vIndexBuffer ); glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->indexArray.size() * sizeof(int), &this->indexArray[0], GL_STATIC_DRAW ); } }; #endif
cc770c99182ee774d70070660a893f14c773a9ca
8b3186e126ac2d19675dc19dd473785de97068d2
/bmt_prod/util/bezier.h
b4073d982237223238b6f5e3a7c840edecdb47aa
[]
no_license
leavittx/revenge
e1fd7d6cd1f4a1fb1f7a98de5d16817a0c93da47
3389148f82e6434f0619df47c076c60c8647ed86
refs/heads/master
2021-01-01T17:28:26.539974
2011-08-25T20:25:14
2011-08-25T20:25:14
618,159
2
0
null
null
null
null
UTF-8
C++
false
false
468
h
bezier.h
#pragma once #include "../globals.h" class BezierCurve : public Curve { public: BezierCurve(); ~BezierCurve(); void destroy(); //point = piste, tangent = suunta (sisältää jo pisteen paikan) void startCreation(); void addPoint(Vector3 &point, Vector3 &tangent); void endCreation(); Vector3 getValue(float t); Vector3 *points; Vector3 *tangents; private: std::vector<Vector3> insertedPoints; std::vector<Vector3> insertedTangents; int pcount; };
a1187c4507107eb2a2896f601f3adeb71d11ed59
e1522f45a46820f6ddbfcc699379821e7eb660af
/codeforces.com/Codeforces Ladder 1500-1599/0275B.cpp
5c6960722fe70ab769d53293c9654e21fd9c3ad1
[]
no_license
dmkz/competitive-programming
1b8afa76eefbdfd9d5766d5347e99b1bfc50761b
8d02a5db78301cf34f5fdffd3fdf399c062961cb
refs/heads/master
2023-08-21T00:09:21.754596
2023-08-13T13:21:48
2023-08-13T13:21:48
130,999,150
21
12
null
2023-02-16T17:43:53
2018-04-25T11:54:48
C++
UTF-8
C++
false
false
2,465
cpp
0275B.cpp
/* Problem: 275B. Convex Shape Solution: dynamic programming, brute force */ #include <iostream> #include <algorithm> #include <string> #include <vector> #include <cassert> int main() { int nRows, nCols; scanf("%d %d", &nRows, &nCols); std::vector<std::vector<bool>> arr(nRows, std::vector<bool>(nCols)); for (int r = 0; r < nRows; ++r) { for (int c = 0; c < nCols; ++c) { char ch; scanf(" %c", &ch); arr[r][c] = (ch == 'B'); } } std::vector<std::vector<int>> mxD(nRows, std::vector<int>(nCols)); auto mxR = mxD, mxL = mxD, mxU = mxD; for (int r = nRows - 1; r >= 0; --r) { for (int c = 0; c < nCols; ++c) { mxD[r][c] = arr[r][c] ? (r+1 < nRows ? mxD[r+1][c] + 1 : 1) : 0; } } for (int r = 0; r < nRows; ++r) { for (int c = 0; c < nCols; ++c) { mxU[r][c] = arr[r][c] ? (r-1 >= 0 ? mxU[r-1][c] + 1 : 1) : 0; } } for (int r = 0; r < nRows; ++r) { for (int c = 0; c < nCols; ++c) { mxL[r][c] = arr[r][c] ? (c-1 >= 0 ? mxL[r][c-1] + 1 : 1) : 0; } } for (int r = 0; r < nRows; ++r) { for (int c = nCols-1; c >= 0; --c) { mxR[r][c] = arr[r][c] ? (c+1 < nCols ? mxR[r][c+1] + 1 : 1) : 0; } } for (int r1 = 0; r1 < nRows; ++r1) { for (int c1 = 0; c1 < nCols; ++c1) { if (!arr[r1][c1]) continue; for (int r2 = r1; r2 < nRows; ++r2) { for (int c2 = 0; c2 <= c1; ++c2) { if (!arr[r2][c2]) continue; int rlen = r2-r1+1; int clen = c1-c2+1; bool flag = (mxD[r1][c1] >= rlen && mxR[r2][c2] >= clen)||(mxL[r1][c1] >= clen && mxU[r2][c2] >= rlen); if (!flag) { printf("NO"); return 0; } } for (int c2 = c1; c2 < nCols; ++c2) { if (!arr[r2][c2]) continue; int rlen = r2-r1+1; int clen = c2-c1+1; bool flag = (mxD[r1][c1] >= rlen && mxL[r2][c2] >= clen)||(mxR[r1][c1] >= clen && mxU[r2][c2] >= rlen); if (!flag) { printf("NO"); return 0; } } } } } printf("YES"); return 0; }
4c555577f527fe90e7701088bf68be7bc04d4260
c3782a52da4479a5ca3d0131cbacd3ff23cea572
/Codeforces/contest/554/a/14710701.cpp
6a0ec8370901417851a525314ccdb0bb285e93e2
[]
no_license
misclicked/Codes
5def6d488bfd028d415f3dc6f18ff6d904226e6f
1aa53cf585abf0eed1a47e0a95d894d34942e3b1
refs/heads/master
2021-07-16T00:28:05.717259
2020-05-25T06:20:37
2020-05-25T06:20:37
142,436,632
6
0
null
null
null
null
UTF-8
C++
false
false
158
cpp
14710701.cpp
#include<bits/stdc++.h> using namespace std; typedef long long LL; int main(){ string input; cin>>input; cout<<input.size()*25+26<<endl; }
c6fe66fc102be505bd7cb6eb0b40dd1b4181a395
041688683f349dd00d0c47e4444e8178184a813c
/Bombillo_con_aplausos_recomendado.ino
daf12b1ed9a48a275dc8654ea6b3314a9050579b
[]
no_license
EstebanCP2003/EstebanCP2003
64f46474656ca32ac518bb1b8aff90f7657caca7
2a62c3ca439ef8763e48b6d7e910280f4db4f53f
refs/heads/main
2023-06-29T22:36:47.771045
2021-08-06T17:52:42
2021-08-06T17:52:42
392,820,055
0
0
null
null
null
null
UTF-8
C++
false
false
175
ino
Bombillo_con_aplausos_recomendado.ino
void setup() { pinMode(2, OUTPUT); pinMode(A0, INPUT); } void loop() { if(analogRead(A0) > 600) { digitalWrite(2, !digitalRead(2)); delay(1000); } }
d934dc232fec94ddb47dab63abeaccc924a30ef2
eb827d7993b146cf507b57a45e420fffdf641eef
/tinkoff/2020/data_structures1/e2.cpp
a949ce4cd956362e1c37ace7c73b609d6ac43345
[]
no_license
khbminus/code2020
dfdbcae71d61d03d4457aad47ff7d4136e6fcc1e
a0d2230b0905df79ba78cb98353f4ba03f16e8b0
refs/heads/master
2023-07-16T16:08:20.629283
2021-08-29T20:35:14
2021-08-29T20:35:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,818
cpp
e2.cpp
#include <iostream> #include <vector> #include <stdio.h> #include <algorithm> #include <set> #include <limits.h> using namespace std; #define int long long int maxn, logn; struct e { int a = -1, b = -1, c = -1; }; int n, d; vector<vector<int>> t; vector<e> lst; void rel(vector<int> &cur, int x) { vector<int> per(d, -1); int a = lst[x].a, b = lst[x].b, c = lst[x].c; if (a == -1) return; for (int i = 0; i < d; i++) { if (cur[i] == -1 && i != 0) continue; per[(i + a) % d] = max(per[(i + a) % d], max((int) 0, cur[i]) + a); per[(i + b) % d] = max(per[(i + b) % d], max((int) 0, cur[i]) + b); per[(i + c) % d] = max(per[(i + c) % d], max((int) 0, cur[i]) + c); } for (int i = 0; i < d; i++) { cur[i] = per[i]; } } int sl(vector<int> &cur, vector<int> &add) { int ans = -1; int bl = 0; for (int i = 0; i < d; i++) { if (add[i] != -1) bl = 1; } if (!bl) return cur[0]; bl = 0; for (int i = 0; i < d; i++) { if (cur[i] != -1) bl = 1; } if (!bl) return add[0]; // if (cur[0] == -1 || add[0] == -1) ans = -1; for (int i = 0; i < d; i++) { if (cur[i] == -1 || add[(d - i) % d] == -1) continue; ans = max(ans, cur[i] + add[(d - i) % d]); } return ans; } int sz = 0; vector<int> res; struct q { int ind, l, r, lvl; }; vector<q> ans; void build() { // int cnt = logn; // for (e tt :lst) cerr << tt.a << " " << tt.b << " " << tt.c << '\n'; for (int lvl = 0; lvl < logn; ++lvl) { cerr << '\n'; for (int block = 0; block < ((int)1 << lvl); ++block) { int l = block << (logn - lvl); int r = min(maxn, (block + 1) << (logn - lvl)); int m = (l + r) / 2; // cerr << l << " " << m << " " << r << '\n'; vector<int> cur(d, -1); if (m < r) { rel(cur, m); t[m] = cur; for (int i = m + 1; i < r; i++) { rel(cur, i); t[i] = cur; } } cur.assign(d, -1); if (m - 1 < l) continue; rel(cur, m - 1); t[m - 1] = cur; for (int i = m - 2; i >= l; i--) { rel(cur, i); t[i] = cur; } } while (sz < ans.size() && ans[sz].lvl == lvl) { vector<int> aa = t[ans[sz].l]; if (ans[sz].l == ans[sz].r) { res[ans[sz].ind] = aa[0]; } else { res[ans[sz].ind] = sl(aa, t[ans[sz].r]); } sz++; } } } void get(int l, int r) { r--; if (l == r) { ans.push_back({(int) ans.size(), l, r, logn - 1}); return; } int diff = __builtin_clzll((unsigned int)(l ^ r)) ^ 63; int lvl = logn - 1 - diff; // vector<int> res = t[lvl][l]; // cerr << lvl << '\n'; // for (int i:t[lvl][r]) cerr << i << ' '; // cerr << '\n'; // cerr << l << ' '<< r <<" "<< lvl <<'\n'; ans.push_back({(int) ans.size(), l, r, lvl}); // return sl(res, t[lvl][r]); } signed main() { cin >> n >> d; for (int i = 0; i < n; i++) { e x; cin >> x.a >> x.b >> x.c; lst.push_back(x); } maxn = 1, logn = 0; for (; maxn <= lst.size(); maxn *= 2, ++logn) {} e nl; nl.a = -1; lst.resize(maxn, nl); t.resize(maxn, vector<int>(d, -1)); int m; cin >> m; res.assign(m, 0); for (int q = 0; q < m; q++) { int l, r; cin >> l >> r; l--; get(l, r); } sort(ans.begin(), ans.end(), [](const q &a, const q &b) { return a.lvl < b.lvl; }); build(); for (int i = 0; i < m; i++) { cout << res[i] << "\n"; } return 0; }
50fe0dc1a0a352d8d701c9ce70d10e3f6f5a12b5
e51d009c6c6a1633c2c11ea4e89f289ea294ec7e
/xr2-dsgn/sources/xray/editor/base/api.h
5463deca05bfb949cf9aaac36378def289ff7138
[]
no_license
avmal0-Cor/xr2-dsgn
a0c726a4d54a2ac8147a36549bc79620fead0090
14e9203ee26be7a3cb5ca5da7056ecb53c558c72
refs/heads/master
2023-07-03T02:05:00.566892
2021-08-06T03:10:53
2021-08-06T03:10:53
389,939,196
3
2
null
null
null
null
UTF-8
C++
false
false
584
h
api.h
//////////////////////////////////////////////////////////////////////////// // Created : 14.07.2010 // Author : Sergey Pryshchepa // Copyright (C) GSC Game World - 2010 //////////////////////////////////////////////////////////////////////////// #ifndef XRAY_EDITOR_BASE_API_H_INCLUDED #define XRAY_EDITOR_BASE_API_H_INCLUDED #include "options_page.h" #define XRAY_EDITOR_BASE_API namespace xray { namespace editor_base { typedef memory::doug_lea_allocator_type allocator_type; } // namespace editor_base } // namespace xray #endif // #ifndef XRAY_EDITOR_BASE_API_H_INCLUDED
81ebc0db7d91dc1e878c977bd76634475a979eab
c5bde0e881594d1208f397f0317c2e02fd33d164
/main.cpp
986789e1e77027c2cd6c88099b56bb8e25dbadb9
[ "MIT" ]
permissive
FascodeNet/lightdm-greeter-dbus-server
df75ac9cc7b6279152118d2d743ac3952b736a59
b62a709a24f662e895208da4fe18beeb199ab14e
refs/heads/master
2023-03-03T21:05:29.194304
2021-02-11T03:50:40
2021-02-11T03:50:40
337,392,507
0
0
null
null
null
null
UTF-8
C++
false
false
1,354
cpp
main.cpp
#include <QCoreApplication> #include "lightdmobject.h" #include "dbus_lightdm_server.h" #include "greeter_subprocess_runner.h" #include "settings_manager.h" #include <QCommandLineParser> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QString pathBase = "net.fascode.lightdm.greeter_dbus."; QString objBase = "/net/fascode/lightdm/greeter_dbus/"; QString senderName = "sender"; QString receiverName = "recevier"; QCoreApplication::setApplicationName("Lightdm dbus server"); QCoreApplication::setApplicationVersion("1.0"); QCommandLineParser parser; parser.setApplicationDescription("LightDM Greeter DBUS Server"); parser.addHelpOption(); QCommandLineOption setting_option({"c","config"},"Greeter Config","json file","/etc/lightdm/lightdm-dbus-greeter-server.json"); parser.addOption(setting_option); parser.process(a.arguments()); Settings_manager settingm; if(QFile::exists(parser.value(setting_option))){ settingm.load(parser.value(setting_option)); } std::cout << settingm.client_path.toStdString() << std::endl; DBUS_Lightdm_Server serverkun(pathBase,objBase,receiverName,senderName); greeter_subprocess_runner runner(settingm.client_path,new QObject()); QTimer::singleShot(0,&runner,&greeter_subprocess_runner::run); return a.exec(); }
0b9e7b2ed04d28d5aee9dd91876881ea26da13f6
9a72c6c2754e86f0de7014e824ffc42917c63a7a
/original_backup/rank_based_selection.cxx
e8a1ac7fa7d8bb720f075653617f8f8aa8828a30
[]
no_license
sentinel88/IDP
305461f689af12c22e23b978d00933a1f24f370c
01d2a9e446cd797d69ee8c7b4ce79dc5108e3392
refs/heads/master
2016-09-10T01:03:04.908517
2015-10-12T19:03:27
2015-10-12T19:03:27
34,963,959
0
0
null
null
null
null
UTF-8
C++
false
false
10,926
cxx
rank_based_selection.cxx
#include <defs.h> #include <data.h> #include <funcs.h> #ifdef RANK_BASED_SELECTION int assign_selection_rb_prob(candidate *ga_cand, int size) { int i; int fitness = size; int total_fitness = (size * (size+1))/ 2; for (i=0; i<size; i++) { ga_cand[i].selection_prob = (float)(fitness)/(float)total_fitness; fitness--; } return 0; } int select_candidate_rb(candidate *ga_cand, int size) { int i; int count = 3; float sum = 0.0; double rand_elem = (double)rand()/(double)RAND_MAX; for (i=0; i<size; i++) { sum += ga_cand[i].selection_prob; if (sum >= rand_elem) return i; } return -1; } int rank_based_selection(candidate *ga_cand, candidate *gen_children, network_data netinfo, int size) { unsigned int i = 0; int index = -1; candidate *pool = (candidate *)malloc((size) * sizeof(candidate)); memset(pool, 0, size * sizeof(candidate)); //Elitism: Best candidate from current population goes to the next generation automatically as we do not touch the 0th index in population. // Fill the mating pool with chromosomes from the parent population to be used for crossover operation printf("\nSelected candidates for crossover operations are as below\n"); while (i < size ) { index = select_candidate_rb(ga_cand, size); memcpy(&pool[i], &ga_cand[index], sizeof(candidate)); print_candidate(&pool[i]); i++; } genetic_rb_crossover(ga_cand, pool, gen_children, netinfo, size); genetic_mutation(gen_children, netinfo, size); free(pool); memcpy(&ga_cand[1], gen_children, (size-1) * sizeof(candidate)); return 0; } #endif int genetic_rb_crossover(candidate* ga_cand, candidate *pool, candidate *gen_children, network_data netinfo, int size) { int i, j, k=0, l, i1, i2, m, rand_elem, bits; int intervals, tempval, srand, value; #ifdef TWO_POINT_CROSSOVER int value2; int crossover[2]; #endif int index[2] = {-1, -1}; int best_fit_index = -1; int retry=0; double rand_val; candidate temp, temp1; candidate *temp_gen; int dup_parent_gen = 0; int dup_child_gen = 0; int dup_temp_gen = 0; int retry_attempts = 0; int error_flag = 0; bool switch_order = false; printf("\nEntering crossover function\n"); //bits = ceil(log2((double)NL)); //intervals = (round((log2((double)RAND_MAX)))) / bits; if (NL) { intervals = (round((log2((double)RAND_MAX)))) / NL; tempval = pow(2, NL) - 1; } //tempval = !(1<<(NL-1)) + 1; //srand(time(NULL)); i = rand_elem = rand(); //i = rand_elem; l = intervals; rand_val = (double)rand() / (double)RAND_MAX; while(1) { if (error_flag) { retry = 0; retry_attempts = 0; rand_val = (double)rand() / (double)RAND_MAX; error_flag = 0; } if (k >= (size - 1)) break; if (rand_val > cross_prob) { rand_val = (double)rand() / (double)RAND_MAX; continue; } /*if (l==0) { rand_elem = rand(); l = intervals; } value = rand_elem & tempval; l--; rand_elem = rand_elem >> NL; if (value == 0) continue;*/ printf("\n"); value = get_random(NL, false); #ifdef TWO_POINT_CROSSOVER do { value2 = get_random(NL, false); }while(value2 == value); if (value < value2) { crossover[0] = value; crossover[1] = value2; } else { crossover[0] = value2; crossover[1] = value; } #endif printf("\n"); printf("\nCrossover point is %d\n", value); #ifdef TWO_POINT_CROSSOVER printf("\nSecond crossover point is %d\n", value2); #endif if (!retry_attempts) { i1 = get_random(size, true); i2 = get_random(size, true); printf("\n"); if (i1 == i2) continue; best_fit_index = i1; if (pool[i2].fitness_value < pool[i1].fitness_value) best_fit_index = i2; if (!memcmp(pool[i1].binary_enc, pool[i2].binary_enc, NL * sizeof(unsigned char)) ) { printf("\nThe parent chromosomes at these indexes are the same\n"); memset(&gen_children[k], 0, sizeof(candidate)); if (retry == MAX_CROSSOVER_ATTEMPTS) { printf("\nEnough attempts have been made to do a crossover operation but the parent chromosome pairs are always same.\n"); /*rand_val = (double)rand() / (double)RAND_MAX; retry_attempts = 0; retry = 0;*/ memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[best_fit_index].binary_enc, NL * sizeof(unsigned char)); k++; error_flag = 1; continue; } //retry_attempts++; retry++; continue; } } /* Following memory copy operations do not reference the binary_enc member inside structure candidate for every gen_children because it is just a shortcut since the first member in the candidate data structure is binary_enc and the memcpy will work correctly without specfiying the binary_enc */ // memcpy(&gen_children[k], &(ga->population[j].binary_enc), i); if (switch_order) { i1 = i1 + i2; i2 = i1 - i2; i1 = i1 - i2; //switch_order = false; } #ifdef TWO_POINT_CROSSOVER memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[i1].binary_enc, crossover[0]); memcpy((char *)&gen_children[k].binary_enc + crossover[0], (char *)&pool[i2].binary_enc + crossover[0], crossover[1] - crossover[0]); memcpy((char *)&gen_children[k].binary_enc + crossover[1], (char *)&pool[i1].binary_enc + crossover[0], NL - crossover[1]); //memcpy((char *)&gen_children[k].binary_enc + crossover[0], (char *)&pool[i2].binary_enc + crossover[0], crossover[1] - crossover[0]); #else memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[i1].binary_enc, value); // memcpy((char *)(&gen_children[k]) + i, (char *)(&ga->population[j+1]) + i, sizeof(temp) - i); memcpy((char *)&gen_children[k].binary_enc + value, (char *)&pool[i2].binary_enc + value, sizeof(temp) - value); #endif //Commented the below section to avoid crossover in the other direction to make the implementation easier and consider the other order only in case we need to switch the order. /*if (compare(gen_children[k])) { memcpy((char *)&gen_children[k], &pool[i2].binary_enc, value); memcpy((char *)&gen_children[k] + value, (char *)&pool[i1].binary_enc + value, NL - value); } //else { //switch_order == true ? false: true; //switch_order = true; //} */ // memcpy((char *)&gen_children[k+1].binary_enc, (char *)&pool[i2].binary_enc, value); // memcpy((char *)&gen_children[k+1].binary_enc + value, (char *)&pool[i1].binary_enc + value, sizeof(temp) - value); // Still need to handle the scenarios where we need to decide what to do after retry attempts are equal to 5. Need to do this for all conditions below if (compare(gen_children[k])) { //switch_order = false; if (retry == 5) { printf("\nMade 5 attempts to avoid generating a zero child but now we will not perform any more crossover attempts for this pair \ of candidates\n"); /*retry = 0; retry_attempts = 0; rand_val = (double)rand() / (double)RAND_MAX;*/ memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[best_fit_index].binary_enc, NL * sizeof(unsigned char)); k++; error_flag = 1; continue; } switch_order = false; retry++; continue; } if (feasibility(gen_children[k], netinfo)) { //Possibly consider to also increment retry here to avoid infinite attempts printf("\nChild from crossover not feasible\n"); memset(&gen_children[k], 0, sizeof(candidate)); if (retry_attempts == MAX_CROSSOVER_ATTEMPTS) { printf("\nEnough attempts have been made to do a crossover operation for this pair but all crossovers have resulted in infeasible \ children\n"); /*rand_val = (double)rand() / (double)RAND_MAX; retry_attempts = 0; retry = 0;*/ memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[best_fit_index].binary_enc, NL * sizeof(unsigned char)); k++; error_flag = 1; continue; } switch_order = false; retry_attempts++; continue; } dup_parent_gen = check_duplicate(&gen_children[k], ga_cand, GA_POPULATION_SIZE); if (dup_parent_gen) { if (retry_attempts == MAX_CROSSOVER_ATTEMPTS) { //printf("\nAlready tried enough attempts at generating a unique child from crossover but now we will consider this even though \ its a duplicate\n"); printf("\nAlready tried enough attempts at generating a unique child from crossover. Reached max. limit for crossover attempts.\n"); //memset(&gen_children[k], 0, sizeof(candidate)); memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[best_fit_index].binary_enc, NL * sizeof(unsigned char)); k++; /*rand_val = (double)rand() / (double)RAND_MAX; retry_attempts = 0; retry = 0;*/ error_flag = 1; continue; } else { printf("\nThis crossover operation has generated a child that is a duplicate of one of the candidates in the parent population. hence \ we need to repeat this crossover operation for this pair of candidates with a different crossover point.\n"); memset(&gen_children[k], 0, sizeof(candidate)); switch_order = false; retry_attempts++; continue; } } if (k) { dup_child_gen = check_duplicate(&gen_children[k], gen_children, k); } if (k && dup_child_gen) { printf("\nThis child generated from a crossover operation is already present in this population of children. We do not consider it \ and continue with no more attempts\n"); if (retry_attempts == MAX_CROSSOVER_ATTEMPTS) { memcpy((char *)&gen_children[k].binary_enc, (char *)&pool[best_fit_index].binary_enc, NL * sizeof(unsigned char)); k++; /* rand_val = (double)rand() / (double)RAND_MAX; retry = 0; retry_attempts = 0; */ error_flag = 1; continue; } else { memset(&gen_children[k], 0, sizeof(candidate)); switch_order = false; retry_attempts++; continue; } } retry = 0; retry_attempts = 0; k++; error_flag = 0; rand_val = (double)rand() / (double)RAND_MAX; if (k >= (size - 1)) break; if (!switch_order) { retry_attempts = 1; switch_order = true; } else { switch_order = false; } } //memcpy(&gen_children[0], &temp_gen[0], sizeof(candidate) * GA_POPULATION_SIZE); //free(temp_gen); printf("\nExiting crossover function\n"); return 0; }
fed23291254f67ec5a72892c33238d1802f145ac
e055052d3aaaad2da20f0cc2ffabd06e8b134861
/Direct3D_11/Sunrin_Engine_D3D11/Engine/SR_Input.cpp
8f531707866be78ecc091509ead894e72cc0ae64
[ "MIT" ]
permissive
shh1473/Sunrin_Engine_2019
e911d7e34717445ee4455fa1642bf32e8560df8d
182f7c9bae5bdd2d0e8bda792d672138abb4f9b4
refs/heads/master
2023-07-08T17:06:52.687553
2023-06-27T09:13:39
2023-06-27T09:13:39
160,938,238
0
0
null
null
null
null
UTF-8
C++
false
false
2,203
cpp
SR_Input.cpp
#include "SR_PCH.h" #include "SR_Input.h" #include "SR_App.h" namespace SunrinEngine { SR_Input::SR_Input() noexcept : m_oldKeyState {}, m_nowKeyState {}, m_oldMouseState {}, m_nowMouseState {}, m_directInput { nullptr }, m_keyboardInput { nullptr }, m_mouseInput { nullptr } { } bool SR_Input::Initialize() { static HRESULT result{}; SR_LOG_RF_HR_AUTO(DirectInput8Create(SR_App::GetInstance()->GetWindowInstanceHandle(), DIRECTINPUT_VERSION, IID_IDirectInput8W, reinterpret_cast<void**>(&m_directInput), NULL)); SR_LOG_RF_HR_AUTO(m_directInput->CreateDevice(GUID_SysKeyboard, &m_keyboardInput, NULL)); SR_LOG_RF_HR_AUTO(m_keyboardInput->SetDataFormat(&c_dfDIKeyboard)); SR_LOG_RF_HR_AUTO(m_keyboardInput->SetCooperativeLevel(SR_App::GetInstance()->GetWindowHandle(), DISCL_FOREGROUND | DISCL_EXCLUSIVE)); result = m_keyboardInput->Acquire(); SR_LOG_RF_HR_AUTO(result != DIERR_INVALIDPARAM && result != DIERR_NOTINITIALIZED); SR_LOG_RF_HR_AUTO(m_directInput->CreateDevice(GUID_SysMouse, &m_mouseInput, NULL)); SR_LOG_RF_HR_AUTO(m_mouseInput->SetDataFormat(&c_dfDIMouse));; SR_LOG_RF_HR_AUTO(m_mouseInput->SetCooperativeLevel(SR_App::GetInstance()->GetWindowHandle(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)); result = m_mouseInput->Acquire(); SR_LOG_RF_HR_AUTO(result != DIERR_INVALIDPARAM && result != DIERR_NOTINITIALIZED); return true; } bool SR_Input::UpdateKeyboardInput() { static HRESULT result{}; CopyMemory(m_oldKeyState, m_nowKeyState, sizeof(m_nowKeyState)); if (FAILED(m_keyboardInput->GetDeviceState(sizeof(m_nowKeyState), reinterpret_cast<void*>(&m_nowKeyState)))) { result = m_keyboardInput->Acquire(); SR_LOG_RF_HR_AUTO(result != DIERR_INVALIDPARAM && result != DIERR_NOTINITIALIZED); } return true; } bool SR_Input::UpdateMouseInput() { static HRESULT result{}; CopyMemory(&m_oldMouseState, &m_nowMouseState, sizeof(m_nowMouseState)); if (FAILED(m_mouseInput->GetDeviceState(sizeof(m_nowMouseState), reinterpret_cast<void*>(&m_nowMouseState)))) { result = m_mouseInput->Acquire(); SR_LOG_RF_HR_AUTO(result != DIERR_INVALIDPARAM && result != DIERR_NOTINITIALIZED); } return true; } }
bd86ef4e6e5449fcc99320e5c5d1f08eef4b8339
f583498f66102429f6dd5b38ed79df546b665a91
/KonkurensTCPSzerver/SysThread.h
773ea3adf2bf6621cd55c74af1aaedcafd22991c
[]
no_license
bartaliskrisztian/chat-server
4e4197d89c0e34a6d9481d2d676669e9b4d5718c
7138ae8d05583caa8b81c2042fa69937dd29008f
refs/heads/master
2023-06-02T23:48:52.661414
2021-06-19T11:56:42
2021-06-19T11:56:42
327,062,083
0
0
null
null
null
null
ISO-8859-2
C++
false
false
691
h
SysThread.h
#pragma once #include <windows.h> class SysThread { public: SysThread(void); virtual ~SysThread(); virtual bool start(void); virtual bool stop(unsigned int timeout = 0); inline volatile bool& isRunning(void) { return m_bRunning; } inline volatile bool& isExited(void) { return m_bExited; } protected: virtual void run(void); //Ezt a metodust a származtatott //osztályban felül kell írni.Ide kell beírni az utasítás szekvenciát //amit a szálunk végre kell hajtson private: friend DWORD WINAPI runStub(LPVOID mthread); public: static const unsigned int INFINIT_WAIT; private: volatile bool m_bRunning; volatile bool m_bExited; HANDLE m_thread; };
d9580881da7b2006d22a857dbd1557cd7da569df
fe58581d25467deb5ca2e87cfdd93894b643f5ca
/dll断链/Source/AirLib_Match/AirLibRunOneInstance.cpp
7aa8089f5fd257af6844015a9060880e26671f68
[]
no_license
radtek/dll-
2de55cabb7989a72aeba7aa2ecf02d36e0d18624
523b43dcb4c4e5b35d89ecb68a996fcb43a3f8d7
refs/heads/master
2020-06-14T09:59:37.419795
2015-07-31T08:45:36
2015-07-31T08:45:36
null
0
0
null
null
null
null
GB18030
C++
false
false
775
cpp
AirLibRunOneInstance.cpp
#include <Windows.h> #include "AirLibRunOneInstance.h" #include "logfile/LoLHelperLocalLog.h" //本dll只运行一个实例检测 static const char* strSemOnlyRunOnce = "AirLibDLLstrSemOnlyRunOnce"; static HANDLE hOnlyRunOnce = 0; BOOL AirLibOnlyRunOnceInit() //有一个AirLib在运行,如果是的话,返回FALSE { hOnlyRunOnce = OpenSemaphoreA(SEMAPHORE_ALL_ACCESS, FALSE, strSemOnlyRunOnce); if (hOnlyRunOnce == NULL) { hOnlyRunOnce = CreateSemaphoreA(NULL, 1, 1, strSemOnlyRunOnce); //fail return NULL if (hOnlyRunOnce == NULL) { LoLLocalLogErr("OnlyRunOnceInit call CreateSemaphoreA fail"); return TRUE; } return TRUE; } return FALSE; } void AirLibOnlyRunOnceExit() { if (hOnlyRunOnce){ CloseHandle(hOnlyRunOnce); hOnlyRunOnce = 0; } }
943fd9f880f0a1de268a4a033ebddbc17b6c981c
28e2d2e153fe265988b232c46f694b03e339c030
/src/control/utils.h
41bc086c0ed221d620947c60176f9d87ba0d9225
[]
no_license
NhielECE/Lunabotics_ROS
4bde0cdf6c457446032d774912ef3ae1ac11a1fe
7a3f3adb437792b552f18eb9d864cfaebcc711c3
refs/heads/master
2020-05-20T10:08:35.877953
2013-07-11T03:55:44
2013-07-11T03:55:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
179
h
utils.h
#ifndef _UTILS_H_ #define _UTILS_H_ #include <vector> namespace lunabotics { std::vector<double> lowpassFilter(std::vector<double> values, float dt, float smoothing); } #endif
fa9e969a3686ee20070e3f9693f1b76fd3135f96
781682cc989137a8f5b6a396032142bfc6856379
/Теория графов/Определения/adj_matrix->vert_list/main.cpp
b16e5311ae6a11baa9f6c305efa813bb1860bcdd
[]
no_license
agafonovartem/Competitive_programming
ff3a1d5b6156fc21e4b4023d7f595ba23d663d68
eb131c8abf1bc6a3a671670b262d084935fa4d90
refs/heads/master
2022-12-03T05:57:03.048767
2020-08-23T17:43:33
2020-08-23T17:43:33
288,933,632
0
0
null
null
null
null
UTF-8
C++
false
false
654
cpp
main.cpp
#include <iostream> #include <vector> #include <set> using namespace std; int main(int argc, const char * argv[]) { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<int, int>> vert_list; for (int i = 1; i <= n; i++){ string s; cin >> s; for (int j = i; j <= n; j++){ int v = (int)(s[j - 1] - '0'); if (v == 1){ vert_list.push_back({i, j}); } } } cout << vert_list.size() << endl; for (const auto& item : vert_list){ cout << item.first << " " << item.second << endl; } return 0; }
5dbe97841cbcdb586757fae72e376932e8aeabe9
6dc788234a360c41864930ccf27d3af33b774492
/memory_block.h
0f91a60bde0e50fc2ddb9b5b05e461ed5412d14f
[]
no_license
nidhibelur95/Memory-Management-System
48153714d48d0f5124bedbd94bbca3bd0c2d61f2
252b082ec093c7f4fbc1cf1dc46562414c72f6ef
refs/heads/master
2021-08-22T09:50:38.588776
2017-11-29T22:39:11
2017-11-29T22:39:11
112,507,505
0
0
null
null
null
null
UTF-8
C++
false
false
1,031
h
memory_block.h
// Created by nbelur on 11/16/17. /* Creating an interface to work with memory blocks. These blocks are added into the dynamically allocated mms space with their address and size defined for easier access. */ #ifndef MMS_MEMORY_BLOCK_H #define MMS_MEMORY_BLOCK_H #include <string> namespace mms { using namespace std; class memory_block { private: char* pointer_address; int block_size; int allocated_memory; int thread_id; public: char *get_pointer_address() { return this->pointer_address; } int get_block_size() { return this->block_size; } int get_requested_memory() { return this->allocated_memory; } void set_pointer_address(char* address) { pointer_address = address; } int set_block_size(int blk_size) { block_size = blk_size; } int set_requested_memory(int requested_memory) { allocated_memory = requested_memory; } int get_thread_id(){ return this->thread_id; } int set_thread_id(int id){ this->thread_id = id; } }; } #endif //MMS_MEMORY_BLOCK_H
8ddb9f01b1a2382170624ba65721a059d1344353
836239167d8ef7542b680d527866dff76fe7902a
/Poisson.cpp
d972fa5c4caebe1e271e368f2d11b6a87f9e31f3
[]
no_license
apsgk9/final-save1
c6f958173674338e07614f8dfc5c6a0301e86981
c9a38f91cb3009bb63df1a76b8302f7c87cfa4da
refs/heads/master
2022-07-14T07:00:14.353100
2020-05-10T03:41:02
2020-05-10T03:41:02
261,906,258
0
0
null
null
null
null
UTF-8
C++
false
false
4,366
cpp
Poisson.cpp
#include "Poisson.h" Poisson::Poisson(const string input_file, const string output_file, double forcing_function) : file_input(input_file), file_output(output_file), image(retrieve(file_input)), A(createPoissonAMatrix(image)), compact_A(A), b(createBvector(forcing_function,A.rows())) {} vector<double> Poisson::createBvector(double input_ff,int size) { vector<double> b_temp(size); for (int i = 0; i < size; i++) { b_temp[i] = input_ff; } return b_temp; } matrix<double> Poisson::createPoissonAMatrix(matrix<bool> givenMatrix) { int rows = givenMatrix.rows(); int cols = givenMatrix.cols(); int size = rows * cols; double adjacentValue = -0.25; double iValue = 1.0; matrix<double> mat(size, size); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) //check diag { if (j == i) { mat(i, j) = iValue; } else { mat(i, j) = 0.0; } } } //updownleftright int ydir[4] = { 1,-1,0, 0 }; int xdir[4] = { 0, 0,-1,1 }; auto canplace = [=](int&& x, int&& y) { //isnotoutofBounds bool result = (x < 0 || x > cols - 1 || y<0 || y>rows - 1) ? false : true; if (result) { bool hasnoKnownValue = (givenMatrix(y, x) != 0) ? true : false; //if has known value put it to bool return hasnoKnownValue; } //cout << "\nResult: " << x << "|" << y << "|" << result; return result; }; int matrow = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) //check diag { //up if (canplace(xdir[0] + j, ydir[0] + i)) { mat(matrow, matrow + (cols)) = adjacentValue; } //down if (canplace(xdir[1] + j, ydir[1] + i)) { mat(matrow, matrow - (cols)) = adjacentValue; } //left if (canplace(xdir[2] + j, ydir[2] + i)) { mat(matrow, matrow - 1) = adjacentValue; } //right if (canplace(xdir[3] + j, ydir[3] + i)) { mat(matrow, matrow + 1) = adjacentValue; } matrow++; } } return mat; } void Poisson::solve(solverInterface<double>& s) { answer = s(A, b); printtofile(file_output); cout << "Outputting File: " << file_output; } void Poisson::fastsolve(solverInterface<double>& s) { answer = s(compact_A, b); printtofile(file_output); cout << "Outputting File: " << file_output; } void Poisson::printtofile(string file) { if (answer.empty()) { throw std::invalid_argument("Answer has not been found yet"); } //string fileHeatMap = "heat.csv"; string fileHeatMap = file; std::ofstream fout(fileHeatMap); //int rows = 100; //int cols = 100; int rows = image.rows(); int cols = image.cols(); //int n = std::sqrt(rows * cols); for (int i = 0; i < rows * cols; i++) { if (i % cols == 0 && i != 0) { fout << "\n"; } fout << answer[i]; if (i != ((rows * cols) - 1)) { fout << ","; } } } matrix<bool> Poisson::retrieve(string textfile) { std::ifstream finput(textfile); string temp_input; int numlines = 0; std::getline(finput, temp_input); //run until non empty line has been found. while (temp_input.length() == 0) { std::getline(finput, temp_input); } vector<string> temp_vector; //Get coloumn of string std::istringstream tokenStream(temp_input); std::istream_iterator<char> eos; // end-of-stream iterator std::istream_iterator<char> iit(tokenStream); // stdin iterator int input_coloumn = 0; while (iit != eos) { input_coloumn++; ++iit; } //----------------- while (temp_input.length() != 0) { numlines++; temp_vector.resize(numlines); temp_vector[numlines - 1] = temp_input; std::getline(finput, temp_input); } matrix <bool> new_m(numlines, input_coloumn); for (int i = 0; i < numlines; i++) { tokenStream = std::istringstream(temp_vector[i]);//reset stream iit = std::istream_iterator<char>(tokenStream); for (int j = 0; j < input_coloumn; j++) { if (*iit == 'B') { new_m(i, j) = true; } else { new_m(i, j) = false; } ++iit; } } finput.close(); return new_m; }
978cc642e133ff4c53e86c7202559539d0ac582f
253b2cb5d2acdcee2dedef39d0e18c5e9355c951
/src/mlpack/methods/ann/init_rules/zero_init.hpp
b4538b76a58a5fc906de458b8293ef1507cb6a30
[ "BSD-3-Clause" ]
permissive
varunnagpaal/mlpack
f49d3db4d65153c0d705309464bb3e4458dcb781
cd5986e141b41781fdc13a9c89443f9be33b56bd
refs/heads/master
2021-01-17T21:13:08.956324
2015-12-15T01:16:32
2015-12-15T01:16:32
48,117,626
2
0
null
2015-12-16T15:13:09
2015-12-16T15:13:09
null
UTF-8
C++
false
false
1,489
hpp
zero_init.hpp
/** * @file zero_init.hpp * @author Marcus Edel * * Intialization rule for the neural networks. This simple initialization is * performed by assigning a zero matrix to the weight matrix. */ #ifndef __MLPACK_METHODS_ANN_INIT_RULES_ZERO_INIT_HPP #define __MLPACK_METHODS_ANN_INIT_RULES_ZERO_INIT_HPP #include <mlpack/core.hpp> namespace mlpack { namespace ann /** Artificial Neural Network. */ { /** * This class is used to initialize randomly the weight matrix. */ class ZeroInitialization { public: /** * Create the ZeroInitialization object. */ ZeroInitialization() { /* Nothing to do here */ } /** * Initialize the elements of the specified weight matrix. * * @param W Weight matrix to initialize. * @param rows Number of rows. * @param cols Number of columns. */ template<typename eT> void Initialize(arma::Mat<eT>& W, const size_t rows, const size_t cols) { W = arma::zeros<arma::Mat<eT> >(rows, cols); } /** * Initialize the elements of the specified weight (3rd order tensor). * * @param W Weight matrix to initialize. * @param rows Number of rows. * @param cols Number of columns. */ template<typename eT> void Initialize(arma::Cube<eT>& W, const size_t rows, const size_t cols, const size_t slices) { W = arma::zeros<arma::Cube<eT> >(rows, cols, slices); } }; // class ZeroInitialization } // namespace ann } // namespace mlpack #endif
863e6450d6f23cc944c89adda6fc28e317c1ab06
678f05bcf766f085e24dacbdffadca587fd74c05
/modules/gin_dsp/dsp/gin_oscillators.cpp
5ab2672dbfc9e38cc1e57dd01610f5acd4ced287
[ "BSD-3-Clause" ]
permissive
FigBug/Gin
7771a68a4830638dc91cf1de450479a258061b29
d85397a3a16cd987b1c3d2d558ac8b0fd68618bb
refs/heads/master
2023-09-04T08:16:57.144381
2023-09-03T20:18:43
2023-09-03T20:18:43
117,844,713
176
30
BSD-3-Clause
2022-12-20T23:25:21
2018-01-17T14:06:47
C++
UTF-8
C++
false
false
3,836
cpp
gin_oscillators.cpp
/* ============================================================================== This file is part of the GIN library. Copyright (c) 2019 - Roland Rabien. ============================================================================== */ //============================================================================== void StereoOscillator::noteOn (float p) { p >= 0 ? phaseL = p : juce::Random::getSystemRandom().nextFloat(); phaseR = phaseL; } void StereoOscillator::process (float note, const Params& params, juce::AudioSampleBuffer& buffer) { float freq = float (std::min (sampleRate / 2.0, 440.0 * std::pow (2.0, (note - 69.0) / 12.0))); float delta = 1.0f / (float ((1.0f / freq) * sampleRate)); int samps = buffer.getNumSamples(); auto l = buffer.getWritePointer (0); auto r = buffer.getWritePointer (1); for (int i = 0; i < samps; i++) { auto s = bllt.process (params.wave, note, phaseL, params.pw); *l++ = s * params.leftGain; *r++ = s * params.rightGain; phaseL += delta; while (phaseL >= 1.0f) phaseL -= 1.0f; } phaseR = phaseL; } void StereoOscillator::process (float noteL, float noteR, const Params& params, juce::AudioSampleBuffer& buffer) { float freqL = float (std::min (sampleRate / 2.0, 440.0 * std::pow (2.0, (noteL - 69.0) / 12.0))); float freqR = float (std::min (sampleRate / 2.0, 440.0 * std::pow (2.0, (noteR - 69.0) / 12.0))); float deltaL = 1.0f / (float ((1.0f / freqL) * sampleRate)); float deltaR = 1.0f / (float ((1.0f / freqR) * sampleRate)); int samps = buffer.getNumSamples(); auto l = buffer.getWritePointer (0); auto r = buffer.getWritePointer (1); for (int i = 0; i < samps; i++) { auto sL = bllt.process (params.wave, noteL, phaseL, params.pw); auto sR = bllt.process (params.wave, noteR, phaseL, params.pw); *l++ = sL * params.leftGain; *r++ = sR * params.rightGain; phaseL += deltaL; phaseR += deltaR; while (phaseL >= 1.0f) phaseL -= 1.0f; while (phaseR >= 1.0f) phaseR -= 1.0f; } } void StereoOscillator::processAdding (float note, const Params& params, juce::AudioSampleBuffer& buffer) { float freq = float (std::min (sampleRate / 2.0, 440.0 * std::pow (2.0, (note - 69.0) / 12.0))); float delta = 1.0f / (float ((1.0f / freq) * sampleRate)); int samps = buffer.getNumSamples(); auto l = buffer.getWritePointer (0); auto r = buffer.getWritePointer (1); for (int i = 0; i < samps; i++) { auto s = bllt.process (params.wave, note, phaseL, params.pw); *l++ += s * params.leftGain; *r++ += s * params.rightGain; phaseL += delta; while (phaseL >= 1.0f) phaseL -= 1.0f; } phaseR = phaseL; } void StereoOscillator::processAdding (float noteL, float noteR, const Params& params, juce::AudioSampleBuffer& buffer) { float freqL = float (std::min (sampleRate / 2.0, 440.0 * std::pow (2.0, (noteL - 69.0) / 12.0))); float freqR = float (std::min (sampleRate / 2.0, 440.0 * std::pow (2.0, (noteR - 69.0) / 12.0))); float deltaL = 1.0f / (float ((1.0f / freqL) * sampleRate)); float deltaR = 1.0f / (float ((1.0f / freqR) * sampleRate)); int samps = buffer.getNumSamples(); auto l = buffer.getWritePointer (0); auto r = buffer.getWritePointer (1); for (int i = 0; i < samps; i++) { auto sL = bllt.process (params.wave, noteL, phaseL, params.pw); auto sR = bllt.process (params.wave, noteR, phaseR, params.pw); *l++ += sL * params.leftGain; *r++ += sR * params.rightGain; phaseL += deltaL; phaseR += deltaR; while (phaseL >= 1.0f) phaseL -= 1.0f; while (phaseR >= 1.0f) phaseR -= 1.0f; } }
b989137e4244fc2797d5337cbee33db6b143a21c
c9eb7d56b539faf0c820751a697663a1b4d3f7e0
/NNKit/CommonTools/interface/TreeData.h
044ee547d0e7a67093c0cb35afafa89b74ba622e
[ "Apache-2.0" ]
permissive
ashrafkasem/cmg-cmssw
450638fe7fd31283604b21cde8f9e4d5bb95a2f3
e29f0e064eefc0306c71c3e984d5733eed6a0e1e
refs/heads/heppy_94X_dev
2022-12-31T13:22:16.833971
2019-02-27T11:27:53
2019-02-27T11:27:53
109,702,769
0
0
null
2019-02-27T12:18:16
2017-11-06T14:03:15
C++
UTF-8
C++
false
false
5,712
h
TreeData.h
/* * TreeData.h * * Created on: May 23, 2017 * Author: hqu */ #ifndef NTUPLECOMMONS_INTERFACE_TREEDATA_H_ #define NTUPLECOMMONS_INTERFACE_TREEDATA_H_ #include <string> #include <vector> #include <memory> #include <map> #include <cassert> #include <typeinfo> #include <typeindex> #include <stdexcept> #include "FWCore/Utilities/interface/Exception.h" namespace deepntuples { class AbstractTreeVar { public: AbstractTreeVar(std::string name_) : name(name_) {} virtual ~AbstractTreeVar() {} virtual void reset() = 0; const std::string name; }; template<typename Type> class TreeVar : public AbstractTreeVar { public: TreeVar(std::string name_, const Type defaultValue_) : AbstractTreeVar(name_), defaultValue(defaultValue_), value(defaultValue_) { } // void fill() { value = defaultValue; } void fill(const Type var) { value = var; } void set(const Type var) { fill(var); } Type get() { return value; } void reset() { value = defaultValue; } protected: const Type defaultValue; Type value; }; template<typename Type> class TreeMultiVar : public AbstractTreeVar { public: TreeMultiVar(std::string name_) : AbstractTreeVar(name_) { } // void fill() {} void fill(const Type var) { value.push_back(var); } void set(const std::vector<Type>& vars) { value = vars; } void reset() { value.clear(); } const std::vector<Type>& get() { return value; } protected: std::vector<Type> value; }; class TreeData { using TypeMap = std::map<std::type_index, std::string>; public: TreeData(std::string prefix = "") : prefix(prefix){} virtual ~TreeData() { } template<typename Type> void add(std::string name, const Type defaultValue){ assert(!isBooked); auto fullname = fullName(name); if (data.find(fullname) != data.end()){ throw cms::Exception("InvalidArgument") << "[TreeData::add] Variable w/ the same name has already been added: " << fullname; } try{ data[fullname] = std::make_unique<TreeVar<Type>>(fullname, defaultValue); } catch (const std::out_of_range& e){ throw cms::Exception("InvalidArgument") << std::string(typeid(Type).name()) + " is not a valid type for TTree!"; } } template<typename Type> void addMulti(std::string name){ assert(!isBooked); auto fullname = fullName(name); if (data.find(fullname) != data.end()){ throw cms::Exception("InvalidArgument") << "[TreeData::addMulti] Variable w/ the same name has already been added: " << fullname; } data[fullname] = std::make_unique<TreeMultiVar<Type>>(fullname); } template<typename Type, typename FillType> void fill(std::string name, const FillType var){ auto fullname = fullName(name); try { auto *tv=dynamic_cast<TreeVar<Type>*>(data.at(fullname).get()); if (!tv) throw cms::Exception("InvalidArgument") << "[TreeData::fill] Filling a different type than registered: " << fullname; tv->fill(var); } catch (const std::out_of_range& e){ throw cms::Exception("InvalidArgument") << "[TreeData::fill] Variable " << fullname << " is not registered!"; } } template<typename Type, typename FillType> void fillMulti(std::string name, const FillType var){ auto fullname = fullName(name); try { auto *tv=dynamic_cast<TreeMultiVar<Type>*>(data.at(fullname).get()); if (!tv) throw cms::Exception("InvalidArgument") << "[TreeData::fillMulti] Filling a different type than registered: " << fullname; tv->fill(var); } catch (const std::out_of_range& e){ throw cms::Exception("InvalidArgument") << "[TreeData::fillMulti] Variable " << name << " is not booked!"; } } template<typename Type> void set(std::string name, const Type var) { fill<Type, Type>(name, var); } template<typename Type> void setMulti(std::string name, const std::vector<Type> &vec){ auto fullname = fullName(name); try { auto *tv=dynamic_cast<TreeMultiVar<Type>*>(data.at(fullname).get()); if (!tv) throw cms::Exception("InvalidArgument") << "[TreeData::setMulti] Filling a different type than registered: " << fullname; tv->set(vec); } catch (const std::out_of_range& e){ throw cms::Exception("InvalidArgument") << "[TreeData::setMulti] Variable " << name << " is not booked!"; } } template<typename Type> Type get(std::string name) const { auto fullname = fullName(name); try { auto *tv=dynamic_cast<TreeVar<Type>*>(data.at(fullname).get()); if (!tv) throw cms::Exception("InvalidArgument") << "[TreeData::get] Wrong type: " << fullname; return tv->get(); } catch (const std::out_of_range& e){ throw cms::Exception("InvalidArgument") << "[TreeData::get] Variable " << fullname << " does not exist!"; } } template<typename Type> const std::vector<Type>& getMulti(std::string name) const { auto fullname = fullName(name); try { auto *tv=dynamic_cast<TreeMultiVar<Type>*>(data.at(fullname).get()); if (!tv) throw cms::Exception("InvalidArgument") << "[TreeData::getMulti] Wrong type: " << fullname; return tv->get(); } catch (const std::out_of_range& e){ throw cms::Exception("InvalidArgument") << "[TreeData::getMulti] Variable " << name << " does not exist!"; } } void book(){ isBooked = true; } void reset(){ for(const auto &d : data) d.second->reset(); } protected: std::string fullName(std::string name) const { return prefix == "" ? name : (prefix + "_" + name); } bool isBooked = false; std::string prefix; std::map<std::string, std::unique_ptr<AbstractTreeVar>> data; }; } /* namespace deepntuples */ #endif /* NTUPLECOMMONS_INTERFACE_TREEDATA_H_ */
746341bf624d77c6c4871ae0087050198d016fb3
7846e98b2a8c5ed349f52c8bbb4e956425f4e9cc
/src/ManagementLayer/TrafficManager.h
e92d071b896d41b7389aeebc6042aa3dc7a3b53b
[]
no_license
SwirlGit/sniffer
3121fa0d95fa8b677cd91280e425d3b5b26c0b62
b5be7a51b62efe6dfe9bb63522588447358e69e0
refs/heads/master
2020-04-24T09:53:10.406999
2019-02-27T11:06:03
2019-02-27T11:06:03
171,876,013
0
0
null
2019-02-27T11:06:03
2019-02-21T13:23:32
C++
UTF-8
C++
false
false
1,058
h
TrafficManager.h
#ifndef TRAFFICMANAGER_H #define TRAFFICMANAGER_H #include "AbstractViewManager.h" #include "DataLayer/NetworkPackage.h" #include <memory> namespace ViewLayer { class TrafficView; } namespace ManagementLayer { /** * @brief Менеджер трафика */ class TrafficManager : public AbstractViewManager { Q_OBJECT public: explicit TrafficManager(QObject* parent = nullptr); ~TrafficManager(); /** * @brief Получить представление, которым управляем */ QWidget* view() const override final; /** * @brief Отобразить полученный пакет */ void showPackage(const DataLayer::NetworkPackage& package); private: /** * @brief Представление трафика */ std::unique_ptr<ViewLayer::TrafficView> m_view; /** * @brief Суммарный размер полученных пакетов */ long long int m_summaryPackageSize = 0; }; } // namespace ManagementLayer #endif // TRAFFICMANAGER_H
98ed1e34d9eeb299d650eff505cd52c0e3c7f186
ac7d7823a48bb465072353b167136c03d8c79d28
/hw4/Mem.h
2cd37e601f88b97a14615fce6fd29b00b9c2e0fc
[]
no_license
gengyu89/Computer-Architecture
42013a75a90916328a80f53264be74494bc30677
d5def1d1882a54a265785c15609928460f11bf97
refs/heads/master
2021-06-19T14:18:29.829089
2017-07-18T07:32:30
2017-07-18T07:32:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
221
h
Mem.h
#ifndef MEM_H #define MEM_H #define MEMsize 256 class Mem { private: int mem[MEMsize][4]; public: Mem (); int* getfromMem(const int); void writetoMem(const int, int*); void printMem(); }; #endif
526fe0bb436f9f0faf1bb2f15549dab183db44ca
72a0d15bbc90b292cba8e02e8bc6d37c1ed2b7a9
/Chapter_16/ex_16_62/ex_16_62.cxx
eb3c47049786711d8282c9457b849e4aba199b7f
[]
no_license
GuanqunGe/Cpp-Primer_Exercise
9414f053c0d343fd3521d63d3f873a9f165764a4
295ab9272c83e9dc3a627fb647e7977c01ef88ad
refs/heads/main
2023-03-24T11:22:15.913814
2021-03-23T13:03:33
2021-03-23T13:03:33
319,142,953
0
0
null
null
null
null
UTF-8
C++
false
false
473
cxx
ex_16_62.cxx
#include <iostream> #include <unordered_set> #include "Sales_data.h" int main(){ std::unordered_multiset<Sales_data> set1; set1.insert(Sales_data()); set1.insert(Sales_data("AAAAA")); set1.insert(Sales_data("AAAAA", 5, 30)); set1.insert(Sales_data("BBBBB", 9, 10.4)); set1.insert(Sales_data("AAAAA", 5, 30)); //print out the set for(auto iter = set1.begin(); iter != set1.end(); ++iter) std::cout << *iter << std::endl; return 0; }
77417004ae3eaa3bd748a724765a6abbdf5f8243
4768468efa6b23f66f3a776674e1adf733a3f699
/cpp/test.cpp
ff23ab16ae177169b9c6d60b522b0b553eb11f5e
[]
no_license
tongust/notebook
6c1e74dae6e8426e34c1d7d7e0b464ca5cf88e99
98c04ce3a8793247cbca128a6aed74ff25e8afe7
refs/heads/master
2021-01-23T05:10:19.835700
2018-06-07T10:55:19
2018-06-07T10:55:19
102,461,713
0
0
null
null
null
null
UTF-8
C++
false
false
2,214
cpp
test.cpp
#include <algorithm> #include <cmath> #include <iostream> #include <iterator> #include <list> #include <math.h> /* log2 */ #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #ifndef MMIN #define MMIN(x,y) ((x) > (y) ? (y) : (x)) #endif #ifndef MMAX #define MMAX(x,y) ((x) < (y) ? (y) : (x)) #endif #ifndef PRINT1D #define PRINT1D(v,d) do {for (auto it_print : v) cout << it_print << d; cout << endl;}while(0) #endif #ifdef PRINT1D #ifndef PRINT2D #define PRINT2D(v,d) \ do { \ cout << endl; \ for (auto &it_print2d : v) { \ for (auto &it_print1d : it_print2d) { \ cout << it_print1d << d; \ } cout << endl; \ } \ } while(0) #endif #endif #ifndef MDebugLog #define MDebugLog(msg) std::cout << __FILE__ << ":" << __LINE__ << ": " << msg #endif /* Usings */ using std::cin; using std::cout; using std::endl; using std::list; using std::multiset; using std::pair; using std::set; using std::sqrt; using std::string; using std::unordered_map; using std::unordered_set; using std::vector; /* Typedef */ typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<vvint> vvvint; typedef vector<vvvint> vvvvint; class A { public: A(int d = 1): data(d) {} A(const A& rhs) { copy(rhs); cout << " copy " << rhs.data << endl; } A& operator=(const A& rhs) { data = rhs.data; cout << " = " << endl; return *this; } ~A() = default; void copy(const A& rhs) { data = rhs.data; cout << "data copied: " << rhs.data << endl; return; } private: int data; }; class B { public: B() = default; void foo(const B& rhs); private: int data; }; void B::foo(const B& rhs) { data = rhs.data; return; } int main() { A a; A b = a; b.copy(a); return 0; }
b959b08408254db14ecbb78313cdd946faa53617
640a23b3d5270f64e42fee279da4d3c66dec1bf5
/cpp/base/virtual_test1.cpp
33e5697dd76f980e40495aed999a416e2c11d06b
[]
no_license
f20500909/study_note
82bc7f3d80e5c0684e4659fa5d4ac08a903b3757
09181332565479016aa9067c68769d3bcd40a6ab
refs/heads/master
2022-07-31T22:28:28.897562
2020-05-11T10:41:41
2020-05-11T10:41:41
228,950,706
0
0
null
null
null
null
UTF-8
C++
false
false
1,854
cpp
virtual_test1.cpp
#include <iostream> using namespace std; class Parent { public: int iparent; Parent() : iparent(10) {} virtual void f() { cout << "Parent::f()" << endl; } virtual void g() { cout << "Parent::g()" << endl; } virtual void h() { cout << "Parent::g()" << endl; } }; class Child : public Parent { public: int ichild; Child() : ichild(100) {} virtual void f() { cout << "Child::f()" << endl; } virtual void g_child() { cout << "Child::g_child()" << endl; } virtual void h_child() { cout << "Child::h_child()" << endl; } }; class GrandChild : public Child { public: int igrandchild; GrandChild() : igrandchild(1000) {}; virtual void f() { cout << "GrandChild::f()" << endl; } virtual void g_child() { cout << "GrandChild::g_child()" << endl; } virtual void h_gradnchild() { cout << "GrandChild::h_grandchild()" << endl; } }; int main(int argc, char **argv) { GrandChild gc; typedef void(*Fun)(void); Fun pf; cout << "[0] GrandChild::vfptr->" << endl; cout << " [0]"; pf = (Fun) *(int *) *(int *) &gc; pf(); cout << " [1]"; pf = (Fun) *((int *) *(int *) &gc + 1); pf(); cout << " [2]"; pf = (Fun) *((int *) *(int *) &gc + 2); pf(); cout << " [3]"; pf = (Fun) *((int *) *(int *) &gc + 3); pf(); cout << " [4]"; pf = (Fun) *((int *) *(int *) &gc + 4); pf(); cout << " [5]"; pf = (Fun) *((int *) *(int *) &gc + 5); pf(); cout << "[1] Parent.iparent = " << (int) (*((int *) &gc + 1)) << endl; cout << "[2] Child.ichild = " << (int) (*((int *) &gc + 2)) << endl; cout << "[3] GrandChild.igrandchild = " << (int) (*((int *) &gc + 3)) << endl; return 0; }
8f71164ffdc819c594f25973514417c7e9a205c7
b93ae4e1ced2079bb0d8bc4be779ee5694df423c
/IMCPlusPlusForMacProj/IMCPlusPlusForMacProj/Headers/NatworkEngine/UPacketProcessor.h
26bfca7359f42db137afc12f91c5d3c5125762e9
[]
no_license
lynnlinyong/IMDemoTest
382d5a99787a7416c7603a02a8925e83b2302fe0
2ccda999029942b066977e803a38afc199525842
refs/heads/master
2019-01-19T13:38:36.136980
2012-12-28T19:29:34
2012-12-28T19:29:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
992
h
UPacketProcessor.h
/* * File: UPacketProcessor.h * Author: easydigital-001 * * Created on 2012年11月28日, 下午5:07 */ #ifndef UPACKETPROCESSOR_H #define UPACKETPROCESSOR_H #include <map> #include <pthread.h> #include "debug.h" #include "errorNumber.h" using namespace std; class UPacketProcessor { public: virtual ~UPacketProcessor(); public: interface__ static UPacketProcessor *getInstance(); interface__ REG_CALLBACK_RESULT registCallback(unsigned char, func_pointer); interface__ FREE_REG_RESULT freeCallback(unsigned char); interface__ void processPacketLoop(); interface__ void setUpdateVoice(bool); interface__ void stopPacketLoop(); private: forbid__ UPacketProcessor(); forbid__ UPacketProcessor(const UPacketProcessor& orig); private: static UPacketProcessor instance; std::map <int, func_pointer> callbackContainer; pthread_mutex_t mutex; bool updateVoice; bool needStop; }; #endif /* UPACKETPROCESSOR_H */
6d352059c5f18a35a045fc8e9d55ed19ded0ede1
66a0e5c3959683c12a61c2e97b0f361dc042a3e4
/CodeForces/CF#742/C.cpp
b44af8f4e827b4f7cdb99fb961c980944737491a
[]
no_license
theteleton/ACM
3f5fb98a20599443b5ead010e477c3338fbb07e0
161b6daea32a6b0fd122c6858749f54269089b45
refs/heads/master
2023-07-14T15:09:38.779805
2021-08-26T18:00:55
2021-08-26T18:00:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
C.cpp
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define f first #define s second using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); return 0; }
1a47768f0c3341173c76d93814b885973386cddc
a1809f8abdb7d0d5bbf847b076df207400e7b08a
/Simpsons Hit&Run/game/libs/radcore/tools/flamer/src/Main.cpp
8d65c3c2d10e7046daf367c37678f7210ae1a09c
[]
no_license
RolphWoggom/shr.tar
556cca3ff89fff3ff46a77b32a16bebca85acabf
147796d55e69f490fb001f8cbdb9bf7de9e556ad
refs/heads/master
2023-07-03T19:15:13.649803
2021-08-27T22:24:13
2021-08-27T22:24:13
400,380,551
8
0
null
null
null
null
UTF-8
C++
false
false
19,611
cpp
Main.cpp
/* * Program to burn Saturn, PSX, and Windows CD's using * a Yamaha CDR100 and the SEGCDW software * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <direct.h> #include <ctype.h> #include <time.h> #include <assert.h> #include "global.h" #include "dir.h" #include "cnstrnt.h" #include "system.h" #include "script.h" #include "iso.h" #include "fileio.h" #include "win.h" #include "windows.h" #define FLAMER_VERSION "4.1" struct dir_tree *tree=NULL; int target_system; //int copy_files=FALSE; /* copy files with NCOPY if TRUE */ //int debug=FALSE; /* prints out directory tree at end */ int test=FALSE; /* passes -t option to SEGACDW if TRUE */ int really_burn=TRUE; /* call SEGACDW if TRUE */ int flat_files=FALSE; /* all files in root if TRUE */ int validate=FALSE; /* check to see if image file can be read */ int special=TRUE; /* do special processing of str files and so on */ int end_pad=FALSE; /* put 27,648,000 of nothing at the end. */ int sort_files=TRUE; /* Sort Files the TRUE */ int use_ps2_license = FALSE; /* Use old psx liscense */ int script=FALSE; /* use old vcdbuild method */ int psxlimits=TRUE; /* limit psx to 30 files 45 directories */ int override_limit = FALSE; /* TRUE if OK to over-ride disk image size */ int override_collisions = FALSE; /* TRUE if we allow name collisions */ int override_maxfiles = FALSE; /* TRUE if we allow file limit to be exceeded */ int override_namelen = FALSE; /* TRUE is we allow filename lengths to be exceeded */ int use_dao = FALSE; /* TRUE if we are using the Goldenhawk DAO CD burn software */ int speed=4; int scsiid=2; int hostadapter=0; char psx_license_code = 'A'; char dest_dir[_MAX_PATH]; char config_dir[_MAX_PATH]; char image_dir[_MAX_PATH]; char ps2Executable[ 50 ]; char disc_name[33]; char SystemIdentifier[33]; char VolumeIdentifier[33]; char VolumeSetID[129]; char PublisherID[129]; char DataPreparerID[129]; char ApplicationID[129]; char CopyrightFileID[38]; char AbstractFileID[38]; char BiblioFileID[38]; char ApplicationUse[513]; char TagFile[_MAX_PATH]= {0}; // Tag this file with a Burn ID char TagString[256] = {0}; // Tag the file with this string void usage(void); void version(void); void loadConfig(void); void print_current_options(); void main( int argc, char * argv[] ) { int i; version(); if (argc < 2) { usage(); exit(1); } disc_name[0] = 0; loadConfig(); if (_stricmp(argv[1],"saturn")==0) { target_system = SATURN; flat_files = TRUE; printf("Burning a SEGA Saturn CD.\n\n"); } else if (_stricmp(argv[1],"psx")==0) { target_system = PSX; printf("Burning a Sony Playstation CD.\n\n"); } else if (_stricmp(argv[1],"ps2")==0) { target_system = PSX; printf("Burning a Sony Playstation2 CD.\n\n"); use_ps2_license = TRUE; } else if (_stricmp(argv[1],"windows")==0) { target_system = WINDOWS; printf("Burning a Windows CD.\n\n"); printf("WARNING! Then platform type WINDOWS is obsolete. PLEASE use WIN95 instead!\n"); } else if (_stricmp(argv[1],"win95")==0) { target_system = WINDOWS; printf("Burning a Windows CD.\n\n"); } else if(_stricmp(argv[1],"purge")==0) { char scratch[_MAX_PATH]; strcpy(config_dir,argv[0]); // char* ptr; GetModuleFileName( NULL, config_dir, sizeof( config_dir ) ); // GetFullPathName( config_dir, _MAX_PATH, config_dir, &ptr ); for(i=strlen(config_dir)-1;i>=0;i--) if(config_dir[i]=='\\') { config_dir[i] = 0; break; } strcpy(image_dir,config_dir); strcat(image_dir,"\\IMAGE"); sprintf(scratch,"DELTREE /Y %s",image_dir); syscall(scratch); exit(1); } else { usage(); exit(1); } for(i=2;i<argc;i++) { if (argc>2) { // if(_stricmp(argv[i],"copy")==0) { // copy_files = TRUE; // } else if(_stricmp(argv[i],"/nocopy")==0) { // copy_files = FALSE; // } else if(_stricmp(argv[i],"/debug")==0) { // debug = TRUE; // } else if(_stricmp(argv[i],"/nodebug")==0) { // debug = FALSE; /* } else*/ if(_stricmp(argv[i],"/test")==0) { test = TRUE; } else if(_stricmp(argv[i],"/notest")==0) { test = FALSE; } else if(_stricmp(argv[i],"/burn")==0) { really_burn = TRUE; } else if(_stricmp(argv[i],"/noburn")==0) { really_burn = FALSE; } else if(_stricmp(argv[i],"/flat")==0) { flat_files = TRUE; } else if(_stricmp(argv[i],"/noflat")==0) { flat_files = FALSE; } else if(_stricmp(argv[i],"/validate")==0) { validate = TRUE; } else if(_stricmp(argv[i],"/novalidate")==0) { validate = FALSE; } else if(_stricmp(argv[i],"/special")==0) { special = TRUE; } else if(_stricmp(argv[i],"/nospecial")==0) { special = FALSE; } else if(_stricmp(argv[i],"/script")==0) { script = TRUE; } else if(_stricmp(argv[i],"/noscript")==0) { script = FALSE; } else if(_stricmp(argv[i],"/endpad")==0) { end_pad = TRUE; } else if(_stricmp(argv[i],"/noendpad")==0) { end_pad = FALSE; } else if(_stricmp(argv[i], "/sort") == 0) { sort_files = TRUE; } else if(_stricmp(argv[i], "/nosort") == 0 ) { sort_files = FALSE; } else if(_stricmp(argv[i],"/limits")==0) { if(target_system!=PSX) { printf("the /LIMITS option is only valid when burning Playstation CD's\n"); exit(1); } psxlimits = TRUE; } else if(_stricmp(argv[i],"/nolimits")==0) { if(target_system!=PSX) { printf("the /NOLIMITS option is only valid when burning Playstation CD's\n"); exit(1); } psxlimits = FALSE; } else if(_stricmp(argv[i],"/ID")==0) { i++; if(i==argc) { printf("Sorry, but /ID requires a number\n"); exit(1); } scsiid = atoi(argv[i]); if(scsiid<1) { printf( "Sorry, but %s is not a valid ID value\n" "Try a non-negative integer number please\n",argv[i]); exit(1); } } else if(_stricmp(argv[i],"/HA")==0) { i++; if(i==argc) { printf("Sorry, but /HA requires a number\n"); exit(1); } hostadapter = atoi(argv[i]); if(hostadapter<1) { printf( "Sorry, but %s is not a valid host adapter value\n" "Try a non-negative integer number please\n",argv[i]); exit(1); } } else if(_stricmp(argv[i],"/SPEED")==0) { i++; if(i==argc) { printf("Sorry, but /SPEED requires a number\n"); exit(1); } speed = atoi(argv[i]); if(speed<1 || speed > 16) { printf( "Sorry, but %s is not a valid speed value\n" "Try a non-negative integer number please\n",argv[i]); exit(1); } } else if(_stricmp(argv[i],"/COUNTRY")==0) { i++; if(i==argc) { printf("Sorry, but /COUNTRY requires a letter\n"); exit(1); } psx_license_code = *argv[i]; if(target_system!=PSX) { printf("Sorry, but the /COUNTRY option is only valid for PSX CD's\n"); exit(1); } } else if(_stricmp(argv[i],"/TAG") == 0) { // Tag the file with i++; if(i==argc) { printf("Sorry, but /TAG requires a filename\n"); exit(1); } _fullpath( TagFile, argv[i], _MAX_PATH ); _strupr( TagFile ); } else if( _stricmp( argv[i], "/NOTAG" ) == 0 ) { memset( TagFile, 0, sizeof TagFile ); memset( TagString, 0, sizeof TagString ); } else if( _stricmp( argv[i], "/OVERSIZE" ) == 0 ) { override_limit = TRUE; } else if( _stricmp( argv[i], "/NOOVERSIZE" ) == 0 ) { override_limit = FALSE; } else if( _stricmp( argv[i], "/COLLISION" ) == 0 ) { if(target_system == WINDOWS) { printf("Sorry, the /COLLISION option is invalid when burning Windows CD's\n"); exit(1); } override_collisions = TRUE; } else if( _stricmp( argv[i], "/NOCOLLISION" ) == 0 ) { if(target_system == WINDOWS) { printf("Sorry, the /NOCOLLISION option is invalid when burning Windows CD's\n"); exit(1); } override_collisions = FALSE; } else if( _stricmp( argv[i], "/MAXFILES" ) == 0 ) { if(target_system == WINDOWS) { printf("Sorry, the /MAXFILES option is invalid when burning Windows CD's\n"); exit(1); } override_maxfiles = FALSE; } else if( _stricmp( argv[i], "/NOMAXFILES" ) == 0 ) { if(target_system == WINDOWS) { printf("Sorry, the /NOMAXFILES option is invalid when burning Windows CD's\n"); exit(1); } override_maxfiles = TRUE; } else if( _stricmp( argv[i], "/NAMELEN" ) == 0 ) { if(target_system == WINDOWS) { printf("Sorry, the /NAMELEN option is invalid when burning Windows CD's\n"); exit(1); } override_namelen = FALSE; } else if( _stricmp( argv[i], "/NONAMELEN" ) == 0 ) { if(target_system == WINDOWS) { printf("Sorry, the /NONAMELEN option is invalid when burning Windows CD's\n"); exit(1); } override_namelen = TRUE; } else { usage(); exit(1); } } } print_current_options(); // if (copy_files) { // printf("Files will be copied to local drive.\n\n"); // } else { // printf("Files will remain on network drive.\n\n"); // } // // Here we determine which CD burning tool to use. If we detect the DAO executable // in the search path, then we will use it. Otherwise we will use the old // sega burner. // char pathbuffer[_MAX_PATH]; _searchenv( "DAO.EXE", "PATH", pathbuffer ); if( *pathbuffer != '\0' ) { // // Non null string indicates that the DAO executable was found. // use_dao = TRUE; } strcpy(config_dir,argv[0]); // char* ptr; GetModuleFileName( NULL, config_dir, sizeof( config_dir ) ); // GetFullPathName( config_dir, _MAX_PATH, config_dir, &ptr ); for(i=strlen(config_dir)-1;i>=0;i--) { if(config_dir[i]=='\\') { config_dir[i] = 0; break; } } strcpy(image_dir,config_dir); char scratch[_MAX_PATH]; if(_getcwd(scratch,_MAX_PATH)==NULL) { perror( "_getcwd error" ); exit(1); } strcat(image_dir,"\\IMAGE"); strcpy(dest_dir,image_dir); scratch[1] = 0; strcat(dest_dir,"\\"); strcat(dest_dir,scratch); strcat(dest_dir,&(scratch[2])); if(dest_dir[strlen(dest_dir)-1]=='\\') dest_dir[strlen(dest_dir)-1] = 0; printf("Config dir: '%s'\n",config_dir); printf(" Image dir: '%s'\n",image_dir); printf(" Dest dir: '%s'\n",dest_dir); unsigned u; for(u=3;u<strlen(dest_dir);u++) { if(dest_dir[u]=='\\') { strcpy(scratch,dest_dir); scratch[u] = 0; _mkdir(scratch); } } _mkdir(dest_dir); // // On the PS2, the liscense files we use were generated assuming the elf // was named SLSP123.45. If the user has a different elf name, we must alter it // behind the scenes. // if(use_ps2_license ) { // // Open the system config file. // char filespec[ 256 ]; _getcwd( filespec, _MAX_PATH ); if( filespec[ strlen( filespec ) - 1 ] != '\\' ) { strcat( filespec, "\\"); } strcat( filespec, "system.cnf"); // // Get size of file. // WIN32_FIND_DATA FindData; HANDLE dirHandle = FindFirstFile( filespec, &FindData ); if( dirHandle != INVALID_HANDLE_VALUE ) { FindClose( dirHandle ); FIOP fh = fio_open(filespec,"rb"); char buffer[ 2048 ]; int io_result = fio_read(buffer,FindData.nFileSizeLow, fh); assert( io_result == 1 ); fio_close( fh ); // // Currently all we extract is the filename of the executable. // We assume version is 1.00 and NTSC for japan and america, PAL for europe. // char* pstr = strstr( buffer, "cdrom0:\\" ); assert(pstr != NULL ); pstr += strlen( "cdrom0:\\" ); char* dst = ps2Executable; while( *pstr != ';' ) { *dst++ = *pstr++; } *dst = '\0'; } } printf("Loading directory structure.\n"); { time_t tNow; char szTimeStamp[256]; time( &tNow ); strftime( szTimeStamp, 256, "%Y/%m/%d %H:%M:%S", localtime( &tNow ) ); sprintf( TagString, "$$RADICAL %s $$", szTimeStamp ); if( TagFile[0] ) printf( "FLAMER Tagging file %s with %s\n", TagFile, TagString ); } tree = load_dirs(); printf("Checking constraints.\n"); constraints(tree); //prep(); if(script) { make_script(tree); post(); } else { make_iso(tree); burn(); } // if(debug) // print_tree(tree); } void version(void) { printf("\nFLAMER version " FLAMER_VERSION "\n\n"); } void usage(void) { printf( "Usage: FLAMER [PSX | PS2 | SATURN | WIN95 | PURGE] <OPTIONS>\n\n"); print_current_options(); printf( "/SPEED x Burn at 1, 2, 4, 8, or 16 speed. x = 1 | 2 | 4 | 8 | 16\n" "/SPECIAL do special things to .DA and .STR files\n" "/TEST enable test mode of CD writer\n" "/BURN after creating the image, burn it to CD\n" "/FLAT collapse directory structure\n" "/VALIDATE check hard disk for bad sectors before burning\n" "/ENDPAD put a 30MB of black data at the end of the data track\n" "/LIMITS enable 30 file, 15 directory check for PSX\n" "/COUNTRY x choose license file for PSX. x = A | J | E\n" "/TAG file Tag this file with a Burn ID\n" "/ID x choose SCSI ID of CD writer\n" "/HA x choose SCSI Host Adpater\n" "/SORT Sort files and directories\n" "/OVERSIZE Override disk image limits\n" "/COLLISION Override filename collision detection\n" "/NOMAXFILES Override number of files limit\n" "/NONAMELEN Override maximum filename length detection\n" ); printf("\nFor further customization, use a FLAMER.CFG file.\n"); printf("An example can be found in L:\\RTOOLS\\FLAMER\\FLAMER.CFG\n"); } void loadConfig(void) { SystemIdentifier[0] = SystemIdentifier[32] = 0; VolumeIdentifier[0] = VolumeIdentifier[32] = 0; VolumeSetID[0] = VolumeSetID[128] = 0; PublisherID[0] = PublisherID[128] = 0; DataPreparerID[0] = DataPreparerID[128] = 0; ApplicationID[0] = ApplicationID[128] = 0; CopyrightFileID[0] = CopyrightFileID[37] = 0; AbstractFileID[0] = AbstractFileID[37] = 0; BiblioFileID[0] = BiblioFileID[37] = 0; ApplicationUse[0] = ApplicationUse[512] = 0; FILE *fh = fopen("FLAMER.CFG","rt"); if(fh!=NULL) { char buffer[1024]; buffer[1023] = 0; fgets(buffer,1023,fh); while(!feof(fh)) { char *token = strtok(buffer," \t"); if(*token == ';') { // it is a comment } else if(_stricmp(token,"SystemIdentifier:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>32) printf("FLAMER.CFG WARNING: SystemIdentifier is too long\n"); strncpy(SystemIdentifier,(token+i),32); } else if(_stricmp(token,"VolumeIdentifier:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>32) printf("FLAMER.CFG WARNING: VolumeIdentifier is too long\n"); strncpy(VolumeIdentifier,(token+i),32); } else if(_stricmp(token,"VolumeSetID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>128) printf("FLAMER.CFG WARNING: VolumeSetID is too long\n"); strncpy(VolumeSetID,(token+i),128); } else if(_stricmp(token,"PublisherID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>128) printf("FLAMER.CFG WARNING: PublisherID is too long\n"); strncpy(PublisherID,(token+i),128); } else if(_stricmp(token,"DataPreparerID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>128) printf("FLAMER.CFG WARNING: DataPreparerID is too long\n"); strncpy(DataPreparerID,(token+i),128); } else if(_stricmp(token,"ApplicationID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>128) printf("FLAMER.CFG WARNING: ApplicationID is too long\n"); strncpy(ApplicationID,(token+i),128); } else if(_stricmp(token,"CopyrightFileID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>37) printf("FLAMER.CFG WARNING: CopyrightFileID is too long\n"); strncpy(CopyrightFileID,(token+i),37); } else if(_stricmp(token,"AbstractFileID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>37) printf("FLAMER.CFG WARNING: AbstractFileID is too long\n"); strncpy(AbstractFileID,(token+i),37); } else if(_stricmp(token,"BiblioFileID:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>37) printf("FLAMER.CFG WARNING: BiblioFileID is too long\n"); strncpy(BiblioFileID,(token+i),37); } else if(_stricmp(token,"ApplicationUse:")==0) { token = strtok(NULL,"\n"); for(unsigned i=0;i<strlen(token);i++) if(!isspace(*(token+i))) break; if(strlen(token+i)>512) printf("FLAMER.CFG WARNING: ApplicationUse is too long\n"); strncpy(ApplicationUse,(token+i),512); } fgets(buffer,1023,fh); } } } void print_current_options(void) { printf("Current Options: "); // if(copy_files) printf("/COPY "); else printf("/NOCOPY "); // if(debug) printf("/DEBUG "); else printf("/NODEBUG "); if(test) printf("/TEST "); else printf("/NOTEST "); if(really_burn) printf("/BURN "); else printf("/NOBURN "); if(flat_files) printf("/FLAT "); else printf("/NOFLAT "); if(validate) printf("/VALIDATE "); else printf("/NOVALIDATE "); if(script) printf("/SCRIPT "); else printf("/NOSCRIPT "); if(special) printf("/SPECIAL "); else printf("/NOSPECIAL "); if(end_pad) printf("/ENDPAD "); else printf("/NOENDPAD "); if(sort_files) printf("/SORT "); else printf("/NOSORT "); if(target_system==PSX) { if(psxlimits) printf("/LIMITS "); else printf("/NOLIMITS "); } if(target_system==PSX) printf("/COUNTRY %c ",psx_license_code); if( TagFile[0] == 0 ) printf("/NOTAG "); else printf( "/TAG %s ", TagFile ); if( override_limit ) printf("/OVERSIZE "); else printf( "/NOOVERSIZE " ); if(target_system != WINDOWS ) { if( override_collisions ) printf("/COLLISION "); else printf( "/NOCOLLISION " ); } if(target_system != WINDOWS ) { if( override_maxfiles ) printf("/NOMAXFILES "); else printf( "/MAXFILES " ); } if(target_system != WINDOWS ) { if( override_namelen ) printf("/NONAMELEN "); else printf( "/NAMELEN " ); } printf("/HA %d /ID %d /SPEED %d\n\n",hostadapter, scsiid,speed); }
db08af95b2d73098f5eee2f50df81e4facbb2d95
c8ac03f5c9ce8019451b212db1ca069b9074df78
/2021春招/20210320滴滴两道做了1.63道/didi1A了第一道.cpp
2400403a8b1e5d727c5a7b17abb2e92a2600232e
[]
no_license
HANXU2018/HBU2019programingtext
88099b842a1165bfbd1bfe9521e905b1eccac194
4e64de1170646a090a6d6ac05a44bebe04db1388
refs/heads/master
2021-06-16T16:13:28.877457
2021-04-24T12:24:51
2021-04-24T12:24:51
195,534,579
5
1
null
2020-05-11T13:34:09
2019-07-06T11:59:44
C++
UTF-8
C++
false
false
741
cpp
didi1A了第一道.cpp
#include<iostream> using namespace std; int num[300]; int main(){ string s; cin>>s; for(int i= s.size()-1;i>=0;i--){ if(num[s[i]]==0)num[s[i]]=i; } // for(int i='a';i<='z';i++){ // cout<<num[i]<<" "<<i<<endl; // } int flag=0; for(int i=0;i<s.size();i++){ if(flag==1){ break; } if(s[i]=='a')continue; else{ for(int j='a';j<s[i];j++){ if(num[j]>i){ //cout<<num[j]<<": "<<i<<endl; flag=1; s[num[j]]=s[i]; s[i]=j; cout<<s<<endl; return 0; } } } } cout<<s; return 0; }
42c1c4c693321447dbc7599a0d75b9e6e43a4a7a
49ce19efa25bf27f03e25edb7fe3a5c3582c33b5
/src/Camera.cpp
d634830e063bafc3ea69da95f6ca71212d9e9063
[ "Unlicense" ]
permissive
jpunzel/jray
1a506a38d9b2ced487aa14e708b83320db2da031
a78792356f8ffafdb41fd958f24b4bcebc165507
refs/heads/master
2023-03-21T04:50:57.854087
2021-03-15T19:22:47
2021-03-15T19:22:47
348,055,076
0
0
null
null
null
null
UTF-8
C++
false
false
2,230
cpp
Camera.cpp
#include <random> #include "Camera.h" #include "math.h" Matrix Camera::view_transform(const Point &from, const Point &to, const Vector &up) { Vector forward = normalize(to - from); Vector upn = normalize(up); Vector left = cross(forward, upn); Vector true_up = cross(left, forward); Matrix orientation(4,4, { left.x(), left.y(), left.z(), 0, true_up.x(), true_up.y(), true_up.z(), 0, -forward.x(), -forward.y(), -forward.z(), 0, 0, 0, 0, 1 }); return orientation * Matrix::translation(-from.x(), -from.y(), -from.z()); } void Camera::setTransform(const Point &from, const Point &to, const Vector &up) { Matrix T = Camera::view_transform(from, to, up); transform = T; inverse_transform = T.inverse(); } void Camera::setTransform(const Matrix &m) { transform = m; inverse_transform = m.inverse(); } Ray Camera::ray_for_pixel(const size_t px, const size_t py, double px_offset, double py_offset) const { // offset from edge of canvas to specified pixel offset // (default to 0.5 for pixel center when supersampling is not used) double xoffset = (px + px_offset) * pixel_size; double yoffset = (py + py_offset) * pixel_size; double world_x = half_width - xoffset; double world_y = half_height - yoffset; // Transform the canvas point and the aperture/origin (our "eye"), // then compute the ray's direction vector. // (canvas is focal_length away at z=-focal_length) Point pixel = inverse_transform * Point(world_x, world_y, -focal_length); Point origin; if (aperture_radius > 0) { // implement focal blur std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<> dis(-aperture_radius, aperture_radius); double aperture_x_offset = dis(gen); double aperture_y_offset = dis(gen); origin = inverse_transform * Point(aperture_x_offset, aperture_y_offset, 0); } else { origin = inverse_transform * Point(0,0,0); } Vector direction = normalize(pixel - origin); return Ray(origin, direction); }
8035e6d4a0cee63269ea1d4d407bcde6d68d20da
c14bfb9cef1d89d4d0588f5cc46b66611426c2b8
/Code/spectrum_mod/spectrum_mod.ino
313a21d6e627f4d7982d6cb67e1f077fcacaa6fb
[]
no_license
jmaccarl/Build-18-2016-Emotional_Flower
ee83fef844ae3c3f6146cd8a8a76092ab78f5c18
6df9d3c22a591dcdf786928e163ccf5c93c729a9
refs/heads/master
2021-01-10T09:50:48.670484
2016-01-18T22:10:37
2016-01-18T22:11:03
49,619,154
2
0
null
null
null
null
UTF-8
C++
false
false
9,694
ino
spectrum_mod.ino
// Audio Spectrum Display // Copyright 2013 Tony DiCola (tony@tonydicola.com) // This code is part of the guide at http://learn.adafruit.com/fft-fun-with-fourier-transforms/ #define ARM_MATH_CM4 #include <arm_math.h> #include <Adafruit_NeoPixel.h> //////////////////////////////////////////////////////////////////////////////// // CONIFIGURATION // These values can be changed to alter the behavior of the spectrum display. //////////////////////////////////////////////////////////////////////////////// int SAMPLE_RATE_HZ = 9000; // Sample rate of the audio in hertz. float SPECTRUM_MIN_DB = 30.0; // Audio intensity (in decibels) that maps to low LED brightness. float SPECTRUM_MAX_DB = 60.0; // Audio intensity (in decibels) that maps to high LED brightness. const int FFT_SIZE = 256; // Size of the FFT. Realistically can only be at most 256 // without running out of memory for buffers and other state. const int AUDIO_INPUT_PIN = 0; // Input ADC pin for audio data. const int ANALOG_READ_RESOLUTION = 10; // Bits of resolution for the ADC. const int ANALOG_READ_AVERAGING = 16; // Number of samples to average with each ADC reading. const int POWER_LED_PIN = 13; // Output pin for power LED (pin 13 to use Teensy 3.0's onboard LED). const int ARDUINO_SIGNAL_PIN = 10; const int THRESHOLD_VOICE_NORMAL = 1000000000; const int THRESHOLD_VOICE_HAPPY = 1500000000; const int THRESHOLD_VOICE_IMPASSIONED = 2000000000; const int WINDOW_US = 1000000; int LEDS_ENABLED = 1; const int NEO_PIXEL_PIN = 3; const int NEO_PIXEL_COUNT = 5; //////////////////////////////////////////////////////////////////////////////// // INTERNAL STATE // These shouldn't be modified unless you know what you're doing. //////////////////////////////////////////////////////////////////////////////// IntervalTimer samplingTimer; IntervalTimer moodTimer; float samples[FFT_SIZE*2]; float magnitudes[FFT_SIZE]; int sampleCounter = 0; IntervalTimer colorChangeTimer; volatile int currR=0; volatile int currG=255; volatile int currB=0; volatile int nextR=0; volatile int nextG=255; volatile int nextB=0; const int pin_low = 11; const int pin_hi = 12; #define SAD 0 #define NEUTRAL 1 #define HAPPY 2 #define IMPASSIONED 3 volatile int mood_nxt = SAD; int mood[4][2] = {{LOW, LOW}, {LOW, HIGH}, {HIGH, LOW}, {HIGH, HIGH}}; float hues[NEO_PIXEL_COUNT]; Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NEO_PIXEL_COUNT, NEO_PIXEL_PIN, NEO_GRB + NEO_KHZ800); int ignore_nxt = 0; //set to 1 if the last input from the arduino was that we should not change output state yet; this ensures no motor sounds will affect the flower's operation //////////////////////////////////////////////////////////////////////////////// // MAIN SKETCH FUNCTIONS //////////////////////////////////////////////////////////////////////////////// void setup() { // Set up serial port. Serial.begin(38400); // Set up ADC and audio input. pinMode(AUDIO_INPUT_PIN, INPUT); analogReadResolution(ANALOG_READ_RESOLUTION); analogReadAveraging(ANALOG_READ_AVERAGING); // Turn on the power indicator LED. pinMode(POWER_LED_PIN, OUTPUT); digitalWrite(POWER_LED_PIN, HIGH); //Set up input pin from Arduino that tells us when we need to wait before changing output pinMode(ARDUINO_SIGNAL_PIN, INPUT_PULLUP); //set to INPUT_PULLUP so it'll still work even when not connected to arduino. should be safe since we're going through a level-shifting transistor anyway between the two devices. may need to tweak polarity accordingly, or may even be able to remove this entirely depending on that transistor structure (since it'll probably just be a NOT gate with a 3.3V Vdd and 0-5V Vgs. //Set up the two interrupts colorChangeTimer.priority(3); samplingTimer.priority(2); moodTimer.priority(1); pinMode(pin_low, OUTPUT); pinMode(pin_hi, OUTPUT); digitalWrite(pin_low, mood[mood_nxt][0]); digitalWrite(pin_hi, mood[mood_nxt][1]); // Begin sampling audio samplingBegin(); //Start mood timer moodBegin(); //Initialize neo pixels pixels.begin(); pixels.show(); } void loop() { // Calculate FFT if a full sample is available. if (samplingIsDone()) { // Run FFT on sample data. arm_cfft_radix4_instance_f32 fft_inst; arm_cfft_radix4_init_f32(&fft_inst, FFT_SIZE, 0, 1); arm_cfft_radix4_f32(&fft_inst, samples); // Calculate magnitude of complex numbers output by the FFT. arm_cmplx_mag_f32(samples, magnitudes, FFT_SIZE); int mymood=mood_nxt; Serial.println(stdBin()); //Compute mood_nxt calcMood(); //Update neopixel //pixels.setPixelColor(0,255,0,0); //pixels.show(); // Restart audio sampling. samplingBegin(); } } //////////////////////////////////////////////////////////////////////////////// // UTILITY FUNCTIONS //////////////////////////////////////////////////////////////////////////////// // Compute the average magnitude of a target frequency window vs. all other frequencies. void windowMean(float* magnitudes, int lowBin, int highBin, float* windowMean, float* otherMean) { *windowMean = 0; *otherMean = 0; // Notice the first magnitude bin is skipped because it represents the // average power of the signal. for (int i = 1; i < FFT_SIZE/2; ++i) { if (i >= lowBin && i <= highBin) { *windowMean += magnitudes[i]; } else { *otherMean += magnitudes[i]; } } *windowMean /= (highBin - lowBin) + 1; *otherMean /= (FFT_SIZE / 2 - (highBin - lowBin)); } // Convert a frequency to the appropriate FFT bin it will fall within. int frequencyToBin(float frequency) { float binFrequency = float(SAMPLE_RATE_HZ) / float(FFT_SIZE); return int(frequency / binFrequency); } //////////////////////////////////////////////////////////////////////////////// // SAMPLING FUNCTIONS //////////////////////////////////////////////////////////////////////////////// void samplingCallback() { // Read from the ADC and store the sample data samples[sampleCounter] = (float32_t)analogRead(AUDIO_INPUT_PIN); // Complex FFT functions require a coefficient for the imaginary part of the input. // Since we only have real data, set this coefficient to zero. samples[sampleCounter+1] = 0.0; // Update sample buffer position and stop after the buffer is filled sampleCounter += 2; if (sampleCounter >= FFT_SIZE*2) { samplingTimer.end(); } } void samplingBegin() { // Reset sample buffer position and start callback at necessary rate. sampleCounter = 0; samplingTimer.begin(samplingCallback, 1000000/SAMPLE_RATE_HZ); } boolean samplingIsDone() { return sampleCounter >= FFT_SIZE*2; } void moodCallback() { //first check input pin from Arduino to see if this should even execute if (digitalRead(ARDUINO_SIGNAL_PIN) && !ignore_nxt) { //pin should be high when arduino disconnected or when color change is active, low when we don't want any state change digitalWrite(pin_low, mood[mood_nxt][0]); digitalWrite(pin_hi, mood[mood_nxt][1]); setNextMoodColor(mood_nxt); colorChangeTimer.begin(colorChangeCallback, 1500); //one step per 1.5ms, this means the color fade *should* never exceed the measurement period. may want to fine-tune for visual effect. mood_nxt = SAD; } else if (ignore_nxt) ignore_nxt = 0; else ignore_nxt = 1; } void colorChangeCallback() { if (currR==nextR && currG==nextG && currB==nextB) { colorChangeTimer.end(); return; } else { if (currR != nextR) { if (currR > nextR) currR--; else currR++; } if (currG != nextG) { if (currG > nextG) currG--; else currG++; } if (currB != nextB) { if (currB > nextB) currB--; else currB++; } for (int i=0; i<NEO_PIXEL_COUNT; i++) { pixels.setPixelColor(i, currR, currG, currB); } pixels.show(); } } void setNextMoodColor(int mood) { switch (mood) { case SAD: nextR=0; nextG=255; nextB=0; break; case NEUTRAL: nextR=255; nextG=255; nextB=0; break; case HAPPY: nextR=255; nextG=127; nextB=0; break; case IMPASSIONED: nextR=255; nextG=0; nextB=0; break; } } void moodBegin() { moodTimer.begin(moodCallback, WINDOW_US); //once per second } //////////////////////////////////////////////////////////////////////////////// // Frequency table functions //////////////////////////////////////////////////////////////////////////////// //Get fundamental frequency f0 by finding the mode frequency bin int fundamental(){ int i = 1; float currMax = magnitudes[1]; int currMaxIdx = 0; for(i=2;i<128;i++){ if(magnitudes[i] > currMax){ currMaxIdx = i; currMax = magnitudes[i]; } } return currMaxIdx; } //Get mean frequency bin int meanBin(){ int sum=0; int count=0; for (int i=1; i<256; i++) { sum+=i*magnitudes[i]; count+=magnitudes[i]; } return sum/count; } //Get standard deviation float stdBin(){ float variance=0; int mean=meanBin(); for (int i=1; i<256; i++) { if (i==mean) continue; else { variance+=magnitudes[i]*(i-mean)*(i-mean); } } return variance; } void calcMood() { float std = stdBin(); if (mood_nxt==IMPASSIONED || std > THRESHOLD_VOICE_IMPASSIONED) { mood_nxt = IMPASSIONED; return; } else if (mood_nxt==HAPPY || std > THRESHOLD_VOICE_HAPPY) { mood_nxt=HAPPY; return; } else if (mood_nxt==NEUTRAL || std > THRESHOLD_VOICE_NORMAL) { mood_nxt=NEUTRAL; return; } else mood_nxt=SAD; return; }
ee94d67f227e5774331efc6ab260463d49e88415
e5223c63a2f43c699345c733098d3b680b38bffe
/BTreeLib/BTree.h
38e15f9edd1c8785bcaa80eee2a5e6741fe7c645
[]
no_license
vakho10/BTree-Implementation
819fbad8ed0d74e180c8c1eacf3c0fcac8fcf88e
9d346799a0161c6939e3d4facdc94f02f504fd7b
refs/heads/master
2021-01-20T02:54:42.555077
2017-05-02T13:12:34
2017-05-02T13:12:34
83,823,619
1
0
null
null
null
null
UTF-8
C++
false
false
849
h
BTree.h
#pragma once #include <string> #include <functional> #include "BTreeNode.h" namespace BTreeLib { template<typename T, typename Compare = std::less<T> > class BTree { BTreeNode<T, Compare> *root; // Pointer to root node int t; // Minimum degree Compare cmp; // Custom comparator public: // Constructor (Initializes tree as empty) BTree(int _t, Compare& _cmp = Compare()) { root = NULL; t = _t; cmp = _cmp; } // function to traverse the tree void traverse() { if (root != NULL) root->traverse(); } // function to search a key in this tree BTreeNode<T, Compare>* search(T k) { return (root == NULL) ? NULL : root->search(k); } // The main function that inserts a new key in this B-Tree void insert(T k); // The main function that removes a new key in thie B-Tree void remove(T k); }; }
3f9211d2c6eb56f734a7e7126ee7a5de3c93846b
f437d77e62ad87d3328968bf6f432f1f0d403dc1
/maxQuene.cpp
2007412d923829362a5e4155857e65ac49e678de
[]
no_license
ericivan/alg_sign
8b0924ba8b6ff194d347a5ec0b154c4ef87b1948
7027fdaf9a1f3cb208d5de2da400a123c113acf6
refs/heads/main
2023-03-29T15:42:46.408051
2021-04-06T08:03:12
2021-04-06T08:03:12
349,018,828
0
0
null
null
null
null
UTF-8
C++
false
false
614
cpp
maxQuene.cpp
#include "QueueMax.h" //队列的最大值https://leetcode-cn.com/problems/dui-lie-de-zui-da-zhi-lcof/ int QueueMax::max_value() { if (d.empty()) { return -1; } return d.front(); } /** * 往队列插入数据 * @param value */ void QueueMax::push_back(int value) { q.push(value); while (!d.empty() && d.back() < value) { d.pop_back(); } d.push_back(value); } int QueueMax::pop_front() { if (q.empty()) { return -1; } int qFront = q.front(); if (qFront == d.front()) { d.pop_front(); } q.pop(); return qFront; }
b312a680d8c1b09525814e463f8f477e55fa8ae0
59f6d4d1ecb6c67dc0acc1a69855bd3ebd9d9103
/lib/Helper.cxx
902b1363e51206201b1938fd33cd6c769d39b0e8
[ "MIT" ]
permissive
ufz-vislab/EnvimetReader
52670e62a81dce5c31b53118508700715cfdeb23
f183e9896ec4e87217d2c5c2cca53ca7888bb4ca
refs/heads/master
2021-01-17T12:20:41.280273
2019-04-17T13:01:25
2019-04-17T13:01:25
32,026,593
2
0
null
2015-10-28T09:55:39
2015-03-11T15:53:36
C++
UTF-8
C++
false
false
540
cxx
Helper.cxx
// // Created by Lars Bilke on 26.10.15. // #include "Helper.h" #include <iostream> #include <sys/stat.h> int Helper::CanReadFile(const char *name, const char *extension) { // Check if file exists struct stat fs; if (stat(name, &fs) != 0) { std::cout << "The file " << name << " does not exist." << std::endl; return 0; } if(std::string(name).rfind(extension) == std::string::npos) { std::cout << "The file " <<name << " has the wrong extension. Expected: " << extension << std::endl; return 0; } else return 1; }
390476df7bc35f39aaee5e9bb520d29c2d7e4101
566e45d21ca67d4b930b7971125b434d9536a8c2
/src/utility/timers.cpp
f964bdeb5e2e5c21c8f9736fe2d10ddc422a095b
[]
no_license
TheNotChosenOne/Sorrow
bae1e852eb00c30c639e2ccc3be543277ca8a814
cc7e7af7d6815fa3104be5d4193bba2bb75804c0
refs/heads/master
2021-06-07T08:13:42.302570
2020-05-10T20:16:50
2020-05-10T20:16:50
133,557,612
2
0
null
2018-09-17T03:35:14
2018-05-15T18:33:55
C++
UTF-8
C++
false
false
1,690
cpp
timers.cpp
#include "utility/timers.h" DurationTimer::DurationTimer() : timingIndex(0) { } void DurationTimer::tick(const std::chrono::duration< double > seconds) { if (timings.size() < 256) { timings.push_back(seconds.count()); return; } timings[timingIndex++ % 256] = seconds.count(); } double DurationTimer::average() const { double total = 0.0; for (const auto x : timings) { total += x; } return total / std::max(size_t(1), timings.size()); } double DurationTimer::perSecond() const { return 1.0 / average(); } ActionTimer::ActionTimer(double seconds) : timeLeft(0.0) , duration(seconds) , scale(1.0) { } bool ActionTimer::tick(const std::chrono::duration< double > seconds) { timeLeft += scale * seconds; if (timeLeft.count() >= duration) { timeLeft -= std::chrono::duration< double >(duration); return true; } return false; } double ActionTimer::estimate() const { return (std::chrono::duration< double >(duration) - timeLeft).count() / scale; } void ActionTimer::setTimeScale(double ts) { scale = ts; } AccumulateTimer::AccumulateTimer() : accum(0.0) { } void AccumulateTimer::add(const std::chrono::duration< double > seconds) { accum += seconds; } std::chrono::duration< double > AccumulateTimer::add(const std::function< void() > &work) { const auto start = std::chrono::high_resolution_clock::now(); work(); const auto stop = std::chrono::high_resolution_clock::now(); const auto time = stop - start; accum += time; return time; } double AccumulateTimer::empty() { const double a = accum.count(); accum = std::chrono::duration< double >(0); return a; }
a104ab826cfd0ecb6d077bd084668cb7bef49523
6932c21a775e4a180b0d48efb2bd33eb506d70ff
/source/CrazeCore/SystemInfo/SystemInfo.h
ba1844ee277727c35d99a7597e4b8976368379be
[]
no_license
lindend/lighting-thesis
8e42d4cc75212b06a5c7aa17314be9c69088a0d5
d37f9e2a1409ba716899487f91cb9c474176df5f
refs/heads/master
2021-01-19T13:52:48.240078
2013-01-23T20:45:55
2013-01-23T20:45:55
35,110,146
0
0
null
null
null
null
UTF-8
C++
false
false
189
h
SystemInfo.h
#pragma once #include <string> namespace Craze { namespace SystemInfo { bool Initialize(); unsigned int GetNumProcessors(); const std::string& GetCurrentDir(); }; }
253bd6bd65280efb748bc2a96a1c8b702a2dc154
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5766201229705216_0/C++/TooHard/full_binary_tree.cpp
1f7f4328c60c06dedee8df7fbff81a6f390e4754
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
2,659
cpp
full_binary_tree.cpp
// // full_binary_tree.cpp // // Siwakorn Srisakaokul - ping128 // Written on Friday, 25 April 2014. // #include <cstdio> #include <iostream> #include <sstream> #include <cstdlib> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <list> #include <cmath> #include <algorithm> #include <map> #include <ctype.h> #include <string.h> #include <assert.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<PII, int> PII2; #define MAXN 1005 int N; vector<int> adj[MAXN]; vector<int> children[MAXN]; int num_node[MAXN]; void dfs(int at, int parent) { num_node[at] = 1; children[at].clear(); int sz = adj[at].size(); for (int i = 0; i < sz; i++) { int v = adj[at][i]; if (v != parent) { dfs(v, at); children[at].push_back(v); num_node[at] += num_node[v]; } } } int temp[MAXN]; int mem[MAXN]; int dfs2(int at, int parent) { int sz = children[at].size(); if (sz == 0) { return mem[at] = 0; } if (sz == 1) { return mem[at] = num_node[children[at][0]]; } if (sz == 2) { return mem[at] = dfs2(children[at][0], at) + dfs2(children[at][1], at); } int sum = 0; for (int i = 0; i < sz; i++) { int v = children[at][i]; dfs2(v, at); } for (int i = 0; i < sz; i++) { int v = children[at][i]; temp[i] = mem[v] - num_node[v]; sum += num_node[v]; } int minn1 = 0; int minn2 = 1; if (temp[minn1] > temp[minn2]) swap(minn1, minn2); for (int i = 2; i < sz; i++) { if (temp[i] <= temp[minn1]) { minn2 = minn1; minn1 = i; } else if (temp[i] <= temp[minn2]) { minn2 = i; } } return mem[at] = sum + temp[minn1] + temp[minn2]; } int compute(int root) { int ans; dfs(root, -1); ans = dfs2(root, -1); return ans; } int temp2[MAXN][2]; void solve() { scanf("%d", &N); for (int i = 0; i < MAXN; i++) { num_node[i] = 0; children[i].clear(); adj[i].clear(); temp[i] = 0; } int u, v; for (int i = 0; i < N - 1; i++) { scanf("%d %d", &u, &v); temp2[i][0] = u; temp2[i][1] = v; adj[u].push_back(v); adj[v].push_back(u); } int minn = 1000000; for (int i = 1; i <= N; i++) { minn = min(minn, compute(i)); } printf("%d\n", minn); } int main() { int test; scanf("%d", &test); for (int i = 0; i < test; i++) { printf("Case #%d: ", i + 1); solve(); } return 0; }
04dd8ec657a2a426c488ee0423876cfce71e763c
d8f0d15bff3b8bf1d73a9616709048a605d7dc46
/Foundation/library/source/TTThread.cpp
debff8420d0fa1d2025be1cf73163b9d2522ec3f
[ "BSD-3-Clause" ]
permissive
i-score-old/JamomaCore
bcdf458d2b7dc870d55e9d9ac310e62ef775a018
73632decfa2da9227638961f888f972053b4df3d
refs/heads/master
2021-01-17T16:48:39.097122
2014-12-08T12:36:38
2014-12-08T12:36:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,557
cpp
TTThread.cpp
/* * TTBlue Class for working with threads * Copyright © 2008, Timothy Place * * License: This code is licensed under the terms of the "New BSD License" * http://creativecommons.org/licenses/BSD/ */ #include "TTThread.h" /****************************************************************************************************/ // C-based callback for the thread to execute our method static void* TTThreadCallback(void *ttTheadInstance) { TTThread* thisThread = (TTThread*)ttTheadInstance; return thisThread->doCallbackMethod(); } /****************************************************************************************************/ TTThread::TTThread(TTThreadCallbackType aCallback, void* anArgument) { #ifdef TT_PLATFORM_WIN // FIXME: Implement! #else int err = 0; pthread_attr_t attr; callback = aCallback; argument = anArgument; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); err = pthread_create(&thread, &attr, TTThreadCallback, this); pthread_attr_destroy(&attr); #endif } TTThread::~TTThread() { #ifdef TT_PLATFORM_WIN // FIXME: Implement! #else pthread_cancel(thread); #endif } void TTThread::sleep(TTUInt32 millisecondsToSleep) { #ifdef TT_PLATFORM_WIN SleepEx(millisecondsToSleep,TRUE); #else usleep(millisecondsToSleep * 1000); #endif } void TTThread::wait() { #ifdef TT_PLATFORM_WIN // FIXME: Implement! #else pthread_join(thread, &status); #endif } void* TTThread::doCallbackMethod() { if (callback) return callback(argument); else return (void*)-1; }
ed542cfebedc6472a701e9df13e49c142858e0b1
2ad0f289d045cbb147ce7410a80f7fa50e23e3ff
/openframeworks/src/Creature/Tangles.cpp
7d69882de515386e4e7e4fa326f075700c598591
[]
no_license
imclab/socialsqncr
291216cad20053835cab8efe3011641c1efc97e0
7c145e43e83894927a3f5d9337c45442ee8352b1
refs/heads/master
2020-05-29T11:43:20.121233
2011-04-22T00:08:20
2011-04-22T00:08:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,936
cpp
Tangles.cpp
/* * Tangles.cpp * openFrameworks * * Created by Nick Hardeman on 3/25/10. * Copyright 2010 __MyCompanyName__. All rights reserved. * */ #include "Tangles.h" void Tangles::initiate(int $numPts, int $numSegmentPts, float $maxRadius, float $spineLength, float $extremetySpacing, float $tentacleDivLength) { Creature::initiate($numPts, $numSegmentPts, $maxRadius, $spineLength, $extremetySpacing, $tentacleDivLength); type = CREATURE_TYPE_RECTANGLES; segmentHighColor.r = 255; segmentHighColor.g = 50; segmentHighColor.b = 100; segmentHighColor.a = 200; segmentBaseColor.r = 255; segmentBaseColor.g = 255; segmentBaseColor.b = 255; segmentBaseColor.a = 50; extremetyHighColor.r = 200; extremetyHighColor.g = 255; extremetyHighColor.b = 50; extremetyHighColor.a = 200; extremetyBaseColor.r = 255; extremetyBaseColor.g = 255; extremetyBaseColor.b = 255; extremetyBaseColor.a = 150; //extremetyHighColor.r = 255; extremetyHighColor.g = 50; extremetyHighColor.b = 100; extremetyHighColor.a = 200; //extremetyBaseColor.r = 255; extremetyBaseColor.g = 255; extremetyBaseColor.b = 255; extremetyBaseColor.a = 50; for(int i = 0; i < totalPlaneNormals * 4; i++) { ofxVec3f pt(0, 0, 0); extrusionPts.push_back( pt ); } } void Tangles::update() { Creature::update(); //////////////////////////////////////////////////////////////////////////////// ofxVec3f planeCenter, planeNormal, topRail; ofxVec3f pt1, pt2, pt3, pt4; ofxVec3f pt1Diff, pt2Diff, pt3Diff, pt4Diff; ofxVec3f bumpItVec; int planeNormalIndex = 0; int extrusionPtIndex = 0; float diffScale = 0.f; for (int i = 0; i < numBodyPts; i++) { if (i < numBodyPts - 1) { for(int j = 0; j < spine[i].numPts; j++) { if (movementPts[i].bodyPts[j].radius > 3) { planeNormalIndex = (j * numMovementPts + i); extrusionPtIndex = planeNormalIndex * 4; //planeNormals[planeNormalIndex]->set(v2.x, v2.y, v2.z); planeNormal.set( planeNormals[planeNormalIndex]->x, planeNormals[planeNormalIndex]->y, planeNormals[planeNormalIndex]->z ); planeCenter.set( planeCenters[planeNormalIndex]->x, planeCenters[planeNormalIndex]->y, planeCenters[planeNormalIndex]->z ); planeNormal *= movementPts[i].bodyPts[j].radius * deathPct; if (spine[i].segColorPosPct < 3) { bumpItVec.set(planeNormal.x, planeNormal.y, planeNormal.z); bumpItVec.normalize(); bumpItVec *= (3 - spine[i].segColorPosPct) * (planeNormal.length() * .4); planeNormal += bumpItVec; } pt1 = spine[i+1].bodyPts[j]; pt2 = spine[i].bodyPts[j]; pt3 = spine[i+1].bodyPts[j+1]; pt4 = spine[i].bodyPts[j+1]; if (j == spine[i].numPts - 1) { pt3 = spine[i+1].bodyPts[0]; pt4 = spine[i].bodyPts[0]; } topRail = pt2 - pt1; //float distBtw = topRail.length() pt1.set( (topRail.x * .45) + pt1.x, (topRail.y * .45) + pt1.y, (topRail.z * .45) + pt1.z); topRail = pt1 - pt2; pt2.set( (topRail.x * .45) + pt2.x, (topRail.y * .45) + pt2.y, (topRail.z * .45) + pt2.z); topRail = pt4 - pt3; pt3.set( (topRail.x * .45) + pt3.x, (topRail.y * .45) + pt3.y, (topRail.z * .45) + pt3.z); topRail = pt3 - pt4; pt4.set( (topRail.x * .45) + pt4.x, (topRail.y * .45) + pt4.y, (topRail.z * .45) + pt4.z); topRail = pt3 - pt1; pt1.set( (topRail.x * .25) + pt1.x, (topRail.y * .25) + pt1.y, (topRail.z * .25) + pt1.z); topRail = pt1 - pt3; pt3.set( (topRail.x * .25) + pt3.x, (topRail.y * .25) + pt3.y, (topRail.z * .25) + pt3.z); topRail = pt4 - pt2; pt2.set( (topRail.x * .25) + pt2.x, (topRail.y * .25) + pt2.y, (topRail.z * .25) + pt2.z); topRail = pt2 - pt4; pt4.set( (topRail.x * .25) + pt4.x, (topRail.y * .25) + pt4.y, (topRail.z * .25) + pt4.z); //float diffScale = movementPts[i].bodyPts[j].radius * .07; diffScale = movementPts[i].bodyPts[j].radius * .16; diffScale = diffScale > 15.f ? 15.f : diffScale; //float diffScale = .08f; // is there not a better way to do this? // pt1Diff = pt1 - planeCenter; pt1Diff.normalize(); pt1Diff *= diffScale; pt2Diff = pt2 - planeCenter; pt2Diff.normalize(); pt2Diff *= diffScale; pt3Diff = pt3 - planeCenter; pt3Diff.normalize(); pt3Diff *= diffScale; pt4Diff = pt4 - planeCenter; pt4Diff.normalize(); pt4Diff *= diffScale; extrusionPts[extrusionPtIndex ].set( planeNormal.x + pt1.x + pt1Diff.x, planeNormal.y + pt1.y + pt1Diff.y, planeNormal.z + pt1.z + pt1Diff.z ); extrusionPts[extrusionPtIndex + 1].set( planeNormal.x + pt2.x + pt2Diff.x, planeNormal.y + pt2.y + pt2Diff.y, planeNormal.z + pt2.z + pt2Diff.z ); extrusionPts[extrusionPtIndex + 2].set( planeNormal.x + pt3.x + pt3Diff.x, planeNormal.y + pt3.y + pt3Diff.y, planeNormal.z + pt3.z + pt3Diff.z ); extrusionPts[extrusionPtIndex + 3].set( planeNormal.x + pt4.x + pt4Diff.x, planeNormal.y + pt4.y + pt4Diff.y, planeNormal.z + pt4.z + pt4Diff.z ); } } } } } void Tangles::draw() { Creature::draw(); //ofxVec3f planeCenter, planeNormal, topRail; ofxVec3f pt1, pt2, pt3, pt4; //ofxVec3f pt1Diff, pt2Diff, pt3Diff, pt4Diff; int noteIndex; ofColor activeColor, inActiveColor; float colorPct, oneOverColorPct; int extrusionPtIndex = 0; //ofEnableAlphaBlending(); float segNotesBodyPtsRatio = (float)CREATURE_NUM_NOTES_PER_SEGMENT / (float)CREATURE_NUM_BODY_PTS_PER_SEGMENT; // mostly .5 // for (int i = 0; i < numBodyPts; i++) { if (i < numBodyPts - 1) { colorPct = spine[i].segColorPct; oneOverColorPct = 1 - colorPct; activeColor.r = (colorPct * extremetyHighColor.r) + (oneOverColorPct * extremetyBaseColor.r); activeColor.g = (colorPct * extremetyHighColor.g) + (oneOverColorPct * extremetyBaseColor.g); activeColor.b = (colorPct * extremetyHighColor.b) + (oneOverColorPct * extremetyBaseColor.b); activeColor.a = (colorPct * extremetyHighColor.a) + (oneOverColorPct * extremetyBaseColor.a); /* // Highlights all of the extremeties equally // inActiveColor.r = (colorPct * segmentHighColor.r) + (oneOverColorPct * segmentBaseColor.r); inActiveColor.g = (colorPct * segmentHighColor.g) + (oneOverColorPct * segmentBaseColor.g); inActiveColor.b = (colorPct * segmentHighColor.b) + (oneOverColorPct * segmentBaseColor.b); inActiveColor.a = (colorPct * segmentHighColor.a) + (oneOverColorPct * segmentBaseColor.a); */ // NO highlight of inactive extremeties // /* inActiveColor.r = extremetyBaseColor.r; inActiveColor.g = extremetyBaseColor.g; inActiveColor.b = extremetyBaseColor.b; inActiveColor.a = extremetyBaseColor.a; */ // highlights the inActive colors less than the active colors // colorPct = colorPct * .5; oneOverColorPct = 1 - colorPct; inActiveColor.r = (colorPct * segmentHighColor.r) + (oneOverColorPct * segmentBaseColor.r); inActiveColor.g = (colorPct * segmentHighColor.g) + (oneOverColorPct * segmentBaseColor.g); inActiveColor.b = (colorPct * segmentHighColor.b) + (oneOverColorPct * segmentBaseColor.b); inActiveColor.a = (colorPct * segmentHighColor.a) + (oneOverColorPct * segmentBaseColor.a); ////////////////////////////////////////////////////////////// if (bRenderWireFrame) { if (i == segmentIndex) { //ofSetColor(segmentHighColor.r, segmentHighColor.g, segmentHighColor.b, segmentHighColor.a); activeColor.r = extremetyHighColor.r; activeColor.g = extremetyHighColor.g; activeColor.b = extremetyHighColor.b; activeColor.a = extremetyHighColor.a; } else if (i < segmentIndex) { //ofSetColor(segmentBaseColor.r, segmentBaseColor.g, segmentBaseColor.b, segmentBaseColor.a); activeColor.r = extremetyBaseColor.r; activeColor.g = extremetyBaseColor.g; activeColor.b = extremetyBaseColor.b; activeColor.a = extremetyBaseColor.a; } else { ofColor deadColor = ColorPalette::getInactiveCreatureColor(); //ofSetColor(deadColor.r, deadColor.g, deadColor.b, deadColor.a); inActiveColor.r = deadColor.r; inActiveColor.g = deadColor.g; inActiveColor.b = deadColor.b; inActiveColor.a = deadColor.a; } } for(int j = 0; j < spine[i].numPts; j++) { if (movementPts[i].bodyPts[j].radius > 3) { noteIndex = ceil((float)j * segNotesBodyPtsRatio); //cout << "j: " << j << ", noteIndex: " << noteIndex << ", [bool]: " << movementPts[i].notes[noteIndex] << endl; // set the colors based on if note is active // if (movementPts[i].notes[noteIndex] == true) { ofSetColor(activeColor.r, activeColor.g, activeColor.b, activeColor.a); } else { ofSetColor(inActiveColor.r, inActiveColor.g, inActiveColor.b, inActiveColor.a); } extrusionPtIndex = (j * numMovementPts + i) * 4; pt1 = spine[i+1].bodyPts[j]; pt2 = spine[i].bodyPts[j]; pt3 = spine[i+1].bodyPts[j+1]; pt4 = spine[i].bodyPts[j+1]; if (j == spine[i].numPts - 1) { pt3 = spine[i+1].bodyPts[0]; pt4 = spine[i].bodyPts[0]; } /* ofxVec3f pt1Norm = (planeNormal+pt1+pt1Diff) - pt1; ofxVec3f pt2Norm = (planeNormal+pt2+pt2Diff) - pt2; ofxVec3f pt3Norm = (planeNormal+pt3+pt3Diff) - pt3; ofxVec3f pt4Norm = (planeNormal+pt4+pt4Diff) - pt4; //if (i == 4) { //ofSetColor(255, 255, 255, 150); int numDivisions = planeNormal.length() / spine[i].extremetySpacing; // 1 for good luck // //cout << "This is the num of divs " << numDivisions << endl; float spacing = planeNormal.length() / (float) numDivisions; for (int k = 0; k < numDivisions; k++) { glBegin(GL_QUAD_STRIP); float currDist = (float)k * spacing + .2; //cout << currDist << endl; pt1Norm.normalize(); pt1Norm *= currDist; //cout << "1. pt1Norm.length " << pt1Norm.length() << endl; glVertex3f(pt1.x + pt1Norm.x, pt1.y + pt1Norm.y, pt1.z + pt1Norm.z); pt1Norm.normalize(); pt1Norm *= (currDist + spacing); //cout << "2. pt1Norm.length " << pt1Norm.length() << endl; glVertex3f(pt1.x + pt1Norm.x, pt1.y + pt1Norm.y, pt1.z + pt1Norm.z); //glVertex3f(0, 0, 0); pt2Norm.normalize(); pt2Norm *= currDist; glVertex3f(pt2.x + pt2Norm.x, pt2.y + pt2Norm.y, pt2.z + pt2Norm.z); pt2Norm.normalize(); pt2Norm *= (currDist + spacing); glVertex3f(pt2.x + pt2Norm.x, pt2.y + pt2Norm.y, pt2.z + pt2Norm.z); pt4Norm.normalize(); pt4Norm *= currDist; glVertex3f(pt4.x + pt4Norm.x, pt4.y + pt4Norm.y, pt4.z + pt4Norm.z); pt4Norm.normalize(); pt4Norm *= (currDist + spacing); glVertex3f(pt4.x + pt4Norm.x, pt4.y + pt4Norm.y, pt4.z + pt4Norm.z); pt3Norm.normalize(); pt3Norm *= currDist; glVertex3f(pt3.x + pt3Norm.x, pt3.y + pt3Norm.y, pt3.z + pt3Norm.z); pt3Norm.normalize(); pt3Norm *= (currDist + spacing); glVertex3f(pt3.x + pt3Norm.x, pt3.y + pt3Norm.y, pt3.z + pt3Norm.z); pt1Norm.normalize(); pt1Norm *= currDist; glVertex3f(pt1.x + pt1Norm.x, pt1.y + pt1Norm.y, pt1.z + pt1Norm.z); pt1Norm.normalize(); pt1Norm *= (currDist + spacing); glVertex3f(pt1.x + pt1Norm.x, pt1.y + pt1Norm.y, pt1.z + pt1Norm.z); glEnd(); } ofxQuad(planeNormal.x + pt1.x + pt1Diff.x, planeNormal.y + pt1.y + pt1Diff.y, planeNormal.z + pt1.z + pt1Diff.z, planeNormal.x + pt2.x + pt2Diff.x, planeNormal.y + pt2.y + pt2Diff.y, planeNormal.z + pt2.z + pt2Diff.z, planeNormal.x + pt4.x + pt4Diff.x, planeNormal.y + pt4.y + pt4Diff.y, planeNormal.z + pt4.z + pt4Diff.z, planeNormal.x + pt3.x + pt3Diff.x, planeNormal.y + pt3.y + pt3Diff.y, planeNormal.z + pt3.z + pt3Diff.z ); */ glBegin(GL_QUADS); glVertex3f(pt1.x, pt1.y, pt1.z); glVertex3f(extrusionPts[extrusionPtIndex ].x, extrusionPts[extrusionPtIndex ].y, extrusionPts[extrusionPtIndex ].z); glVertex3f(extrusionPts[extrusionPtIndex + 1].x, extrusionPts[extrusionPtIndex + 1].y, extrusionPts[extrusionPtIndex + 1].z); glVertex3f(pt2.x, pt2.y, pt2.z); // top // glVertex3f(extrusionPts[extrusionPtIndex ].x, extrusionPts[extrusionPtIndex ].y, extrusionPts[extrusionPtIndex ].z); glVertex3f(extrusionPts[extrusionPtIndex + 1].x, extrusionPts[extrusionPtIndex + 1].y, extrusionPts[extrusionPtIndex + 1].z); glVertex3f(extrusionPts[extrusionPtIndex + 3].x, extrusionPts[extrusionPtIndex + 3].y, extrusionPts[extrusionPtIndex + 3].z); glVertex3f(extrusionPts[extrusionPtIndex + 2].x, extrusionPts[extrusionPtIndex + 2].y, extrusionPts[extrusionPtIndex + 2].z); ///////// glVertex3f(pt3.x, pt3.y, pt3.z); glVertex3f(extrusionPts[extrusionPtIndex + 2].x, extrusionPts[extrusionPtIndex + 2].y, extrusionPts[extrusionPtIndex + 2].z); glVertex3f(extrusionPts[extrusionPtIndex + 3].x, extrusionPts[extrusionPtIndex + 3].y, extrusionPts[extrusionPtIndex + 3].z); glVertex3f(pt4.x, pt4.y, pt4.z); glVertex3f(pt1.x, pt1.y, pt1.z); glVertex3f(extrusionPts[extrusionPtIndex ].x, extrusionPts[extrusionPtIndex ].y, extrusionPts[extrusionPtIndex ].z); glVertex3f(extrusionPts[extrusionPtIndex + 2].x, extrusionPts[extrusionPtIndex + 2].y, extrusionPts[extrusionPtIndex + 2].z); glVertex3f(pt3.x, pt3.y, pt3.z); glVertex3f(pt2.x, pt2.y, pt2.z); glVertex3f(extrusionPts[extrusionPtIndex + 1].x, extrusionPts[extrusionPtIndex + 1].y, extrusionPts[extrusionPtIndex + 1].z); glVertex3f(extrusionPts[extrusionPtIndex + 3].x, extrusionPts[extrusionPtIndex + 3].y, extrusionPts[extrusionPtIndex + 3].z); glVertex3f(pt4.x, pt4.y, pt4.z); glEnd(); //ofSetColor(255, 0, 0); //ofSetColor(0, 0, 255); /* glBegin(GL_LINES); glVertex3f(pt1.x, pt1.y, pt1.z); glVertex3f(planeNormal.x + pt1.x + pt1Diff.x, planeNormal.y + pt1.y + pt1Diff.y, planeNormal.z + pt1.z + pt1Diff.z); glVertex3f(planeNormal.x + pt1.x + pt1Diff.x, planeNormal.y + pt1.y + pt1Diff.y, planeNormal.z + pt1.z + pt1Diff.z); glVertex3f(planeNormal.x + pt2.x + pt2Diff.x, planeNormal.y + pt2.y + pt2Diff.y, planeNormal.z + pt2.z + pt2Diff.z); glVertex3f(pt2.x, pt2.y, pt2.z); glVertex3f(planeNormal.x + pt2.x + pt2Diff.x, planeNormal.y + pt2.y + pt2Diff.y, planeNormal.z + pt2.z + pt2Diff.z); glVertex3f(planeNormal.x + pt2.x + pt2Diff.x, planeNormal.y + pt2.y + pt2Diff.y, planeNormal.z + pt2.z + pt2Diff.z); glVertex3f(planeNormal.x + pt4.x + pt4Diff.x, planeNormal.y + pt4.y + pt4Diff.y, planeNormal.z + pt4.z + pt4Diff.z); glVertex3f(pt3.x, pt3.y, pt3.z); glVertex3f(planeNormal.x + pt3.x + pt3Diff.x, planeNormal.y + pt3.y + pt3Diff.y, planeNormal.z + pt3.z + pt3Diff.z); glVertex3f(planeNormal.x + pt3.x + pt3Diff.x, planeNormal.y + pt3.y + pt3Diff.y, planeNormal.z + pt3.z + pt3Diff.z); glVertex3f(planeNormal.x + pt4.x + pt4Diff.x, planeNormal.y + pt4.y + pt4Diff.y, planeNormal.z + pt4.z + pt4Diff.z); glVertex3f(pt4.x, pt4.y, pt4.z); glVertex3f(planeNormal.x + pt4.x + pt4Diff.x, planeNormal.y + pt4.y + pt4Diff.y, planeNormal.z + pt4.z + pt4Diff.z); glVertex3f(planeNormal.x + pt1.x + pt1Diff.x, planeNormal.y + pt1.y + pt1Diff.y, planeNormal.z + pt1.z + pt1Diff.z); glVertex3f(planeNormal.x + pt3.x + pt3Diff.x, planeNormal.y + pt3.y + pt3Diff.y, planeNormal.z + pt3.z + pt3Diff.z); glEnd(); */ //glLineWidth (1.f); } } } } //ofDisableAlphaBlending(); }
e242a7cb5f3956b56d73fb8084d28aa6a036bd27
8ed61980185397f8a11ad5851e3ffff09682c501
/thirdparty/GeometricTools/WildMagic5/SampleMathematics/NonlocalBlowup/GpuPyramid2.cpp
2d7258822b690eecb085b42b603373c47e7cf418
[ "BSD-2-Clause-Views" ]
permissive
SoMa-Project/vision
8975a2b368f69538a05bd57b0c3eda553b783b55
ea8199d98edc363b2be79baa7c691da3a5a6cc86
refs/heads/melodic
2023-04-12T22:49:13.125788
2021-01-11T15:28:30
2021-01-11T15:28:30
80,823,825
1
0
NOASSERTION
2021-04-20T21:27:03
2017-02-03T11:36:44
C++
UTF-8
C++
false
false
11,596
cpp
GpuPyramid2.cpp
// Geometric Tools, LLC // Copyright (c) 1998-2014 // 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.3.0 (2010/09/07) #include "GpuPyramid2.h" #include "Wm5BitHacks.h" using namespace Wm5; const float GpuPyramid2::msSquare[4][2] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f } }; const GLchar* GpuPyramid2::msVertexText = "attribute vec2 modelPosition;\n" "varying vec2 tcoord;\n" "void main ()\n" "{\n" " tcoord = modelPosition;\n" " gl_Position = vec4(2.0*modelPosition - 1.0, 0.0, 1.0);\n" "}\n"; const GLchar* GpuPyramid2::msFragmentDeclareText = "varying vec2 tcoord;\n" "uniform vec4 delta;\n" "uniform vec2 multiplier;\n" "uniform vec2 offset;\n" "uniform sampler2D rSampler;\n"; const GLchar* GpuPyramid2::msFragmentSamplerText = "void main ()\n" "{\n" " vec2 prevTCoord = multiplier*tcoord - offset;\n" " float f00 = texture2D(rSampler, prevTCoord).r;\n" " float f10 = texture2D(rSampler, prevTCoord + delta.xy).r;\n" " float f01 = texture2D(rSampler, prevTCoord + delta.zw).r;\n" " float f11 = texture2D(rSampler, prevTCoord + delta.xy + delta.zw).r;\n"; const GLchar* GpuPyramid2::msFragmentResultText = " gl_FragColor.r = result;\n" " gl_FragColor.gba = vec3(0.0, 0.0, 0.0);\n" "}\n"; //---------------------------------------------------------------------------- GpuPyramid2::GpuPyramid2 (const GLchar* declarations, const GLchar* equation, int dimension0, int dimension1, const Image2<float>& initial, bool& success) : mNumTexels(0), mNumLevels(0), mVertexBuffer(0), mVertexShader(0), mFragmentShader(0), mProgram(0), mModelPositionAttribute(0), mRSamplerLocation(-1), mDeltaLocation(-1), mMultiplierLocation(-1), mOffsetLocation(-1), mOwner(true) { // Default initialization of the remaining class members that are arrays. for (int i = 0; i < 2; ++i) { mDimension[i] = 0; mTexture[i] = 0; mFrameBuffer[i] = 0; mDelta[i] = 0.0f; mMultiplier[i] = 0.0f; mSize[i] = 0; } // Start the construction that might have failures along the way. success = false; if (dimension0 <= 0 || !IsPowerOfTwo(dimension0) || dimension1 <= 0 || !IsPowerOfTwo(dimension1)) { return; } mDimension[0] = dimension0; mDimension[1] = dimension1; mNumTexels = dimension0*dimension1; int logDim0 = Log2OfPowerOfTwo(dimension0); int logDim1 = Log2OfPowerOfTwo(dimension1); mNumLevels = (logDim0 >= logDim1 ? logDim0 + 1 : logDim1 + 1); if (!CreateGraphicsObjects(declarations, equation)) { return; } SetInitialValues(initial); success = true; } //---------------------------------------------------------------------------- GpuPyramid2::GpuPyramid2 (const GLchar* declarations, const GLchar* equation, int dimension0, int dimension1, GLuint texture0, GLuint texture1, GLuint frameBuffer0, GLuint frameBuffer1, bool& success) : mNumTexels(0), mNumLevels(0), mFragmentShader(0), mProgram(0), mModelPositionAttribute(0), mRSamplerLocation(-1), mDeltaLocation(-1), mMultiplierLocation(-1), mOffsetLocation(-1), mOwner(false) { // Default initialization of the remaining class members that are arrays. mTexture[0] = texture0; mTexture[1] = texture1; mFrameBuffer[0] = frameBuffer0; mFrameBuffer[1] = frameBuffer1; for (int i = 0; i < 2; ++i) { mDimension[i] = 0; mDelta[i] = 0.0f; mMultiplier[i] = 0.0f; mSize[i] = 0; } // Start the construction that might have failures along the way. success = false; if (dimension0 <= 0 || !IsPowerOfTwo(dimension0) || dimension1 <= 0 || !IsPowerOfTwo(dimension1)) { return; } mDimension[0] = dimension0; mDimension[1] = dimension1; mNumTexels = dimension0*dimension1; int logDim0 = Log2OfPowerOfTwo(dimension0); int logDim1 = Log2OfPowerOfTwo(dimension1); mNumLevels = (logDim0 >= logDim1 ? logDim0 + 1 : logDim1 + 1); if (!CreateGraphicsObjects(declarations, equation)) { return; } success = true; } //---------------------------------------------------------------------------- GpuPyramid2::~GpuPyramid2 () { OpenGL::DestroyProgram(mProgram); if (mOwner) { for (int i = 0; i < 2; ++i) { OpenGL::DestroyFrameBuffer(mFrameBuffer[i]); OpenGL::DestroyTexture(mTexture[i]); } } OpenGL::DestroyShader(mFragmentShader); OpenGL::DestroyShader(mVertexShader); OpenGL::DestroyBuffer(mVertexBuffer); } //---------------------------------------------------------------------------- bool GpuPyramid2::Execute () { int j; for (j = 0; j < 2; ++j) { mDelta[j] = 0.5f/(float)mDimension[j]; mSize[j] = mDimension[j]; mMultiplier[j] = 2.0f; } // Base class enables mProgram. if (!OnPreIteration()) { return false; } for (int level = 1, active = 0; level < mNumLevels; ++level) { for (j = 0; j < 2; ++j) { if (mSize[j] > 1) { mSize[j] /= 2; mMultiplier[j] *= 0.5f; } } if (!OnPreDraw(level, active, 1-active)) { return false; } // Enable the vertex buffer. glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); glEnableVertexAttribArray(mModelPositionAttribute); glVertexAttribPointer(mModelPositionAttribute, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), 0); // Update the multipliers. glUniform2f(mMultiplierLocation, mMultiplier[0], mMultiplier[1]); // Enable the input texture. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mTexture[active]); // Enable the output framebuffer. glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFrameBuffer[1-active]); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); // Execute the program. glPushAttrib(GL_VIEWPORT_BIT); glViewport(0, 0, mSize[0], mSize[1]); glDrawArrays(GL_QUADS, 0, 4); glPopAttrib(); // Disable the output framebuffer. glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glDrawBuffer(GL_BACK); // Disable the input texture; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); // Disable the vertex buffer. glDisableVertexAttribArray(mModelPositionAttribute); glBindBuffer(GL_ARRAY_BUFFER, 0); if (!OnPostDraw(level, active, 1-active)) { return false; } for (j = 0; j < 2; ++j) { if (mSize[j] == 1 && mDelta[j] > 0.0f) { mDelta[j] = 0.0f; glUniform4f(mDeltaLocation, mDelta[0], 0.0f, 0.0f, mDelta[1]); } } active = 1 - active; } // Base class disables mProgram. if (!OnPostIteration()) { return false; } return true; } //---------------------------------------------------------------------------- bool GpuPyramid2::Use (GLuint texture0, GLuint texture1, GLuint frameBuffer0, GLuint frameBuffer1) { if (!mOwner) { mTexture[0] = texture0; mTexture[1] = texture1; mFrameBuffer[0] = frameBuffer0; mFrameBuffer[1] = frameBuffer1; return true; } return false; } //---------------------------------------------------------------------------- bool GpuPyramid2::CreateGraphicsObjects (const GLchar* declarations, const GLchar* equation) { mVertexBuffer = OpenGL::CreateVertexBuffer(4, 2*sizeof(float), GL_STATIC_DRAW, &msSquare[0][0]); if (!mVertexBuffer) { return false; } mVertexShader = OpenGL::CreateVertexShader(msVertexText); if (!mVertexShader) { OpenGL::DestroyBuffer(mVertexBuffer); return false; } std::string fragmentText = std::string(msFragmentDeclareText) + std::string(declarations) + std::string("\n") + std::string(msFragmentSamplerText) + std::string(equation) + std::string("\n") + std::string(msFragmentResultText); mFragmentShader = OpenGL::CreateFragmentShader(fragmentText.c_str()); if (!mFragmentShader) { OpenGL::DestroyShader(mVertexShader); OpenGL::DestroyBuffer(mVertexBuffer); return false; } mProgram = OpenGL::CreateProgram(mVertexShader, mFragmentShader); if (!mProgram) { OpenGL::DestroyShader(mFragmentShader); OpenGL::DestroyShader(mVertexShader); OpenGL::DestroyBuffer(mVertexBuffer); return false; } // Bind the model position to index mModelPosition. glBindAttribLocation(mProgram, mModelPositionAttribute, "modelPosition"); // Get the uniform locations. mRSamplerLocation = glGetUniformLocation(mProgram, "rSampler"); mDeltaLocation = glGetUniformLocation(mProgram, "delta"); mMultiplierLocation = glGetUniformLocation(mProgram, "multiplier"); mOffsetLocation = glGetUniformLocation(mProgram, "offset"); return true; } //---------------------------------------------------------------------------- void GpuPyramid2::SetInitialValues (const Image2<float>& initial) { mTexture[0] = OpenGL::CreateTexture2D(mDimension[0], mDimension[1], GL_RED, GL_R32F, GL_FLOAT, initial.GetPixels1D()); mTexture[1] = OpenGL::CreateTexture2D(mDimension[0], mDimension[1], GL_RED, GL_R32F, GL_FLOAT, 0); mFrameBuffer[0] = OpenGL::CreateFrameBuffer(mTexture[0]); mFrameBuffer[1] = OpenGL::CreateFrameBuffer(mTexture[1]); } //---------------------------------------------------------------------------- bool GpuPyramid2::OnPreIteration () { if (!mProgram) { return false; } int j; if (!mOwner) { for (j = 0; j < 2; ++j) { if (mTexture[j] == 0 || mFrameBuffer[j] == 0) { return false; } } } glUseProgram(mProgram); glUniform1i(mRSamplerLocation, 0); glUniform4f(mDeltaLocation, mDelta[0], 0.0f, 0.0f, mDelta[1]); glUniform2f(mMultiplierLocation, mMultiplier[0], mMultiplier[1]); glUniform2f(mOffsetLocation, mDelta[0], mDelta[1]); return true; } //---------------------------------------------------------------------------- bool GpuPyramid2::OnPostIteration () { if (mProgram) { glUseProgram(0); return true; } return false; } //---------------------------------------------------------------------------- bool GpuPyramid2::OnPreDraw (int, int, int) { // Stub for derived classes. return true; } //---------------------------------------------------------------------------- bool GpuPyramid2::OnPostDraw (int, int, int) { // Stub for derived classes. return true; } //----------------------------------------------------------------------------
b1eb37ece88d5983fff470ffefc624df3e73a21d
806735c91d9fac50ac6a0e0b44c68ac438b9ecb6
/iitk interview/night-fury/J.cpp
8b3fe6801083b8f6df5192ce0ada0f919f8f8d49
[]
no_license
v-pratap/cp
a04119a5c42853b5ae5bb3535deaa726a23b113d
28ba7e27cd7b065800954445497642b852e20160
refs/heads/main
2023-06-05T03:46:55.685212
2021-06-28T05:56:06
2021-06-28T05:56:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,731
cpp
J.cpp
//LASER GRID #include <bits/stdc++.h> typedef long long ll; typedef long double ld; #define f(i,a,b) for(int i = a;i<b;i++) #define rep(i,a,b) for(int i = a;i<=b;i++) #define fd(i,a,b) for(int i = a;i>b;i--) #define repd(i,a,b) for(int i = a;i>=b;i--) #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second #define pb push_back #define sz(x) (int) (x).size() #define all(x) x.begin(),x.end() #define endl '\n' using namespace std; const int mod = 1000000007; const int maxn = 2e5; int dx[4] = {-1,0,0,1}; int dy[4] = {0,-1,1,0}; int main(){ int r,c;cin>>r>>c; int xi,yi,xf,yf; cin>>xi>>yi>>xf>>yf; vector<int> costx(r-1),costy(c-1); int t;cin>>t; f(i,0,r-1) cin>>costx[i]; cin>>t; f(i,0,c-1) cin>>costy[i]; vector<vector<bool>> visited(r,vector<bool>(c)); vector<vector<int>> dist(r,vector<int>(c,INT_MAX)); priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>> > pq; pq.push({0,xi,yi});dist[xi][yi] = 0; while(!pq.empty()){ vector<int> v = pq.top(); int di = v[0],x = v[1],y = v[2]; pq.pop(); if(visited[x][y]) continue; visited[x][y] = true; for(int d = 0;d<4;++d){ int nx = x+dx[d],ny = y+dy[d]; if(nx<0 || ny<0 ||nx>=r || ny>=c) continue; if((d==0 || d==3) && dist[nx][ny] > di + costx[x]){ dist[nx][ny] = di + costx[x]; pq.push({dist[nx][ny],nx,ny}); } if((d==1 || d==2) && dist[nx][ny] > di + costy[y]){ dist[nx][ny] = di + costy[y]; pq.push({dist[nx][ny],nx,ny}); } } } cout<<dist[xf][yf]<<endl; }
22d571938248f7203a3f70647baec04a18abd17c
62e6e04d4ab08ca4b5090179af1f670099f94780
/客户端组件/游戏广场/QiXingCai.cpp
41a985199dc36dcbd942f4bf996e4c5dae919635
[]
no_license
hanshouqing85/wh6603_hpkj
9895e3bc2e9948aacb15f6bc60f083146796ddf9
eed96681c75dcc2948f89c63088da21e3d8e0bc0
refs/heads/master
2020-04-13T13:48:10.811183
2019-06-15T10:49:21
2019-06-15T10:49:21
163,242,393
0
0
null
null
null
null
GB18030
C++
false
false
200,062
cpp
QiXingCai.cpp
#include "stdafx.h" #include "GamePlaza.h" #include "QiXingCai.h" #include "BmpUtil.h" /*#include "LuckMeDlg.h"*/ #include "MessageDlg.h" #include "DlgAddtional.h" #include "PlatformFrame.h" #include "DlgFandian.h" #include "GDIpng/MemDC.h" #include <map> extern map <int,CString> mapFandian; extern map <int,float> mapPercent; extern map <int,float> mapDanweiFandian; extern map <int,float> mapBonus; extern vector<wstring> vecData1, vecData2, vecData3; using namespace std; #define MAXN 100 extern vector<wstring> vecAllNums; CString CQiXingCai::m_strHaoma = _T(""); extern int g_arr[MAXN]; extern int g_nPos[512000][5]; extern int g_Counts; //得到组合后的 extern int GetComboArray(int DigitnCount, int nPosCount, int* szInput, int szOutput[10][5]); extern int InsertDouhaoAfter(int nDouhaoIndexAfter, wstring& strLine); //得到某一行带逗号的字符串 extern wstring GetXiaZhuString(int nLines, int nCols, int nIndex, int nValue [10][5], int nInsertCol=100); extern void Combo(int m,int k); //任选?倍数 extern int nRenXuan2[6]; extern int nRenXuan3[6]; extern int nRenXuan4[6]; //玩法分类数据 static const int wanfa_x = 9; static const int wanfa_y = 109; static const int wanfa_col_width = 64; static const int wanfa_row_height = 32; //玩法子分类数据 static const int wanfa_sel_x = 20; static const int wanfa_sel_y = 145; static const int wanfa_sel_width = 102; static const int wanfa_sel_height = 22; //号码数据 static const int haoma_btn_x = 83; static const int haoma_btn_y = 226; static const int haoma_btn_col_wdith = 40; static const int haoma_btn_row_height = 35; //号码提示数据 static const int haoma_tip_x = 20; static const int haoma_tip_y = haoma_btn_y; //单式选号编辑框 static const int edit_haomao_danshi_x = 20; static const int edit_haomao_danshi_y = 210; static const int edit_haomao_danshi_width = 752; static const int edit_haomao_danshi_height = 195; //添加号码按钮 static const int btn_chq_add_x = 571; static const int btn_chq_add_y = 415; // static const int btn_lock_x = 450; static const int btn_lock_y = 417; //选号显示区域数据 //删除选中按钮 static const int btn_del_sel_x = 470; static const int btn_del_sel_y = 543; //清空列表按钮 static const int btn_cls_list_x = 645; static const int btn_cls_list_y = 415; //号码列表 static const int list_haomao_x = 43; static const int list_haomao_y = 469; static const int list_haomao_width = 592; static const int list_haomao_height = 72; //倍投编辑框 static const int edit_beitou_x = 214; static const int edit_beitou_y = 423; static const int edit_beitou_width = 48; static const int edit_beitou_height = 21; //确认投注按钮 static const int btn_touzhu_x = 638; static const int btn_touzhu_y = 490; //追号按钮 static const int btn_zhuihao_x = 719; static const int btn_zhuihao_y = 415; //更多记录 static const int btn_more_x = 712; static const int btn_more_y = 92; //大开奖号 static const int kj_big_haoma_x = 261; static const int kj_big_haoma_y = 41; static const int czh_rc_left = 243; static const int czh_rc_top = 4; static const int czh_rc_width = 65; static const int czh_rc_height = 30; static CRect rcCzh(czh_rc_left, czh_rc_top, czh_rc_left + czh_rc_width, czh_rc_top + czh_rc_height); static const int qihao_rc_left = 325; static const int qihao_rc_top = 4; static const int qihao_rc_width = 125; static const int qihao_rc_height = 30; static CRect rcQiHao(qihao_rc_left, qihao_rc_top, qihao_rc_left + qihao_rc_width, qihao_rc_top + qihao_rc_height); static const int yugao_rc_left = 3; static const int yugao_rc_top = 4; static const int yugao_rc_width = 196; static const int yugao_rc_height = 30; static CRect rcYuGao(yugao_rc_left, yugao_rc_top, yugao_rc_left + yugao_rc_width, yugao_rc_top + yugao_rc_height); //小开奖号 static const int kj_small_haoma_x = 630; static const int kj_small_haoma_y = 28; static const int kj_small_haoma_col_span = 5; static const int kj_small_haoma_row_span = 6; //总注数 static const int zongzhushu_x = 71; static const int zongzhushu_y = 411; static const int zongzhushu_width = 150; static const int zongzhushu_height = 25; static CRect rcZongZhuShu(zongzhushu_x, zongzhushu_y, zongzhushu_x+zongzhushu_width, zongzhushu_y+zongzhushu_height); //总金额 static const int zongjine_x = 295; static const int zongjine_y = 428; static const int zongjine_width = 150; static const int zongjine_height = 25; static CRect rcZongJinE(zongjine_x, zongjine_y, zongjine_x+zongjine_width, zongjine_y+zongjine_height); //总注数 static const int allzongzhushu_x = 638; static const int allzongzhushu_y = 444; static const int allzongzhushu_width = 150; static const int allzongzhushu_height = 25; static CRect rcAllZongzhushu(allzongzhushu_x, allzongzhushu_y, allzongzhushu_x+allzongzhushu_width, allzongzhushu_y+allzongzhushu_height); //鼠标输入 static const int mouseinput_x = 597; static const int mouseinput_y = 175; //键盘输入 static const int keyboardinput_x = 670; static const int keyboardinput_y = 175; static const int redraw_rc_left = 0; static const int redraw_rc_top = 0; static const int redraw_rc_width = 756; static const int redraw_rc_height = 103; static CRect rcRedraw(redraw_rc_left, redraw_rc_top, redraw_rc_left + redraw_rc_width, redraw_rc_top + redraw_rc_height); static const int btn_yuan_x = 10; static const int btn_yuan_y = 415; static const int btn_jiao_x = 45; static const int btn_jiao_y = 415; static const int btn_fen_x = 80; static const int btn_fen_y = 415; static const int btn_li_x = 115; static const int btn_li_y = 415; static const int timer_id_get_luck_num = 1; static const int timer_id_kj_yugao = 2; static const int timer_id_kaijiangzhong=3; //计时 static const int TimerJiShi = 4; static const int TimerStatus = 6; //这个是用来本地刷新开奖数据的 static const int TimerZhunBeiData = 5; static const int TimerFandian = 6; IMPLEMENT_DYNAMIC(CQiXingCai, CDialog) CQiXingCai::CQiXingCai(CWnd* pParent /*=NULL*/) : CDialog(CQiXingCai::IDD, pParent) , m_bmpBk(NULL) , m_numImageList(NULL) , m_numImageList1(NULL) , m_numImageList2(NULL) , m_kjNumBig(NULL) , m_kjNumSmall(NULL) , m_bmpDxdsh(NULL) , m_bmpNumTip(NULL) , m_bmpNumTip1(NULL) , m_bigNumWidth(0) , m_bigNumHeight(0) , m_smallNumWidth(0) , m_smallNumHeight(0) , m_zongZhuShu(0) //, m_zongJinE(0.0) , m_beishu(1) , m_kjXinxiCont(0) /*, m_t1_start(0) , m_t1_end(2) , m_t2_start(10) , m_t2_end(22) , m_t3_start(22) , m_t3_end(24)*/ , m_pLuckMeDlg(NULL) { m_gameKind = QiXingCai_LiangDing; m_SocketID=0; m_nTzhSign = 1; m_nTzhSign1 = 0; m_nFrameIndex=0; m_nFrameCount=0; for (int i=0; i<Kj_XinXi_Count; i++) { memset(&m_kjXinxi[i], 0, sizeof(KjXinXi)); } m_RenxuanKeyboardInput=false; _tcscpy_s(m_lastExpect, KJ_QIHAO_LENGTH, _T("")); //任务组件 m_bGetUserFandian=false; m_Font.CreateFont(14,0,0,0,700,0,0,0,0,3,2,ANTIALIASED_QUALITY,2,TEXT("微软雅黑")); m_wGameHoverItem=INVALID_WORD; m_cbMenuType=0xff; InitWanFaMoShi(); m_bQueryTime=false; m_bGetCPUserInfo=false; m_bQueryLuckyNum=false; m_bTouzhu=false; m_bGetTime=false; m_bHovering=false; nPercent=0; m_bSetBonus=false; m_bGetLastYue=false; m_bGetMapBonus=false; m_fBonus = 0.0; m_fPercent = 0.0; fDanweiFandian=0.0f; m_zongJine = 0.0f; nBonus = 0.0f; m_nTouzhuCount=0; m_nZhuihaoCount = 0; m_bZhuihao=false; //设置组件 m_DlgStatus.SetStatusViewSink(this); } //取消连接 VOID CQiXingCai::OnStatusCancel() { //关闭房间 PostMessage(WM_COMMAND,IDM_DELETE_SERVER_ITEM,0); return; } BOOL CQiXingCai::PreTranslateMessage(MSG* pMsg) { //定义变量 BOOL bReturn=TRUE; if(pMsg-> message ==WM_RBUTTONDOWN) { if(pMsg->hwnd == m_richDanshiHaoma.m_hWnd) { CPoint pt(0,0); GetCursorPos(&pt); CMenu menu; menu.LoadMenu(IDR_MENU_RBTN); CMenu* pMenu = menu.GetSubMenu(0); if (pMenu != NULL) { pMenu->TrackPopupMenu(TPM_LEFTBUTTON, pt.x, pt.y, this); } return true; } } //提示消息 if (m_ToolTipCtrl.m_hWnd!=NULL) { m_ToolTipCtrl.RelayEvent(pMsg); } return __super::PreTranslateMessage(pMsg); } CQiXingCai::~CQiXingCai() { if (m_bmpBk != NULL) { delete m_bmpBk; } if (m_numImageList != NULL) { delete m_numImageList; } if (m_numImageList1 != NULL) { delete m_numImageList1; } if (m_numImageList2 != NULL) { delete m_numImageList2; } if (m_kjNumBig != NULL) { delete m_kjNumBig; } if (m_kjNumSmall != NULL) { delete m_kjNumSmall; } if (m_imgKaijiang != NULL) { delete m_imgKaijiang; } if (m_bmpDxdsh != NULL) { delete m_bmpDxdsh; } if (m_bmpNumTip != NULL) { delete m_bmpNumTip; } if (m_bmpNumTip1 != NULL) { delete m_bmpNumTip1; } } void CQiXingCai::ConnectMainDlg(CPlazaViewItem* luckMeDlg) { m_pLuckMeDlg = luckMeDlg; } void CQiXingCai::FlushZongjine() { InvalidateRect(&rcZongJinE); } void CQiXingCai::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_BTN_MORE_RECORD, m_btnMoreRecord); DDX_Control(pDX,IDC_BTN_BEITOU_JIA,m_btnBeiTouJia); DDX_Control(pDX,IDC_BTN_BEITOU_JIAN,m_btnBeiTouJian); DDX_Control(pDX,IDC_TIP_WXZX,m_btWxzxTip); DDX_Control(pDX, IDC_RIO_LIANGDING, m_btnLiangDing); DDX_Control(pDX, IDC_RIO_SANDING, m_btnSanDing); DDX_Control(pDX, IDC_RIO_SIDING, m_btnSiDing); DDX_Control(pDX, IDC_RIO_YIDING, m_btnYiDing); DDX_Control(pDX, IDC_RIO_LIANGZIXIAN, m_btnLiangZiXian); DDX_Control(pDX, IDC_RIO_SANZIXIAN, m_btnSanZiXian); DDX_Control(pDX, IDC_BTN_LOCK, m_btnLock); DDX_Control(pDX, IDC_RIO_MOUSE_INPUT,m_rioMouseInput); DDX_Control(pDX, IDC_RIO_KEYBOARD_INPUT,m_rioKeyboardInput); DDX_Control(pDX, IDC_BTN_WAN_0, m_btnWan_0); DDX_Control(pDX, IDC_BTN_WAN_1, m_btnWan_1); DDX_Control(pDX, IDC_BTN_WAN_2, m_btnWan_2); DDX_Control(pDX, IDC_BTN_WAN_3, m_btnWan_3); DDX_Control(pDX, IDC_BTN_WAN_4, m_btnWan_4); DDX_Control(pDX, IDC_BTN_WAN_5, m_btnWan_5); DDX_Control(pDX, IDC_BTN_WAN_6, m_btnWan_6); DDX_Control(pDX, IDC_BTN_WAN_7, m_btnWan_7); DDX_Control(pDX, IDC_BTN_WAN_8, m_btnWan_8); DDX_Control(pDX, IDC_BTN_WAN_9, m_btnWan_9); DDX_Control(pDX, IDC_BTN_QIAN_0, m_btnQian_0); DDX_Control(pDX, IDC_BTN_QIAN_1, m_btnQian_1); DDX_Control(pDX, IDC_BTN_QIAN_2, m_btnQian_2); DDX_Control(pDX, IDC_BTN_QIAN_3, m_btnQian_3); DDX_Control(pDX, IDC_BTN_QIAN_4, m_btnQian_4); DDX_Control(pDX, IDC_BTN_QIAN_5, m_btnQian_5); DDX_Control(pDX, IDC_BTN_QIAN_6, m_btnQian_6); DDX_Control(pDX, IDC_BTN_QIAN_7, m_btnQian_7); DDX_Control(pDX, IDC_BTN_QIAN_8, m_btnQian_8); DDX_Control(pDX, IDC_BTN_QIAN_9, m_btnQian_9); DDX_Control(pDX, IDC_BTN_BAI_0, m_btnBai_0); DDX_Control(pDX, IDC_BTN_BAI_1, m_btnBai_1); DDX_Control(pDX, IDC_BTN_BAI_2, m_btnBai_2); DDX_Control(pDX, IDC_BTN_BAI_3, m_btnBai_3); DDX_Control(pDX, IDC_BTN_BAI_4, m_btnBai_4); DDX_Control(pDX, IDC_BTN_BAI_5, m_btnBai_5); DDX_Control(pDX, IDC_BTN_BAI_6, m_btnBai_6); DDX_Control(pDX, IDC_BTN_BAI_7, m_btnBai_7); DDX_Control(pDX, IDC_BTN_BAI_8, m_btnBai_8); DDX_Control(pDX, IDC_BTN_BAI_9, m_btnBai_9); DDX_Control(pDX, IDC_BTN_SHI_0, m_btnShi_0); DDX_Control(pDX, IDC_BTN_SHI_1, m_btnShi_1); DDX_Control(pDX, IDC_BTN_SHI_2, m_btnShi_2); DDX_Control(pDX, IDC_BTN_SHI_3, m_btnShi_3); DDX_Control(pDX, IDC_BTN_SHI_4, m_btnShi_4); DDX_Control(pDX, IDC_BTN_SHI_5, m_btnShi_5); DDX_Control(pDX, IDC_BTN_SHI_6, m_btnShi_6); DDX_Control(pDX, IDC_BTN_SHI_7, m_btnShi_7); DDX_Control(pDX, IDC_BTN_SHI_8, m_btnShi_8); DDX_Control(pDX, IDC_BTN_SHI_9, m_btnShi_9); DDX_Control(pDX, IDC_BTN_GE_0, m_btnGe_0); DDX_Control(pDX, IDC_BTN_GE_1, m_btnGe_1); DDX_Control(pDX, IDC_BTN_GE_2, m_btnGe_2); DDX_Control(pDX, IDC_BTN_GE_3, m_btnGe_3); DDX_Control(pDX, IDC_BTN_GE_4, m_btnGe_4); DDX_Control(pDX, IDC_BTN_GE_5, m_btnGe_5); DDX_Control(pDX, IDC_BTN_GE_6, m_btnGe_6); DDX_Control(pDX, IDC_BTN_GE_7, m_btnGe_7); DDX_Control(pDX, IDC_BTN_GE_8, m_btnGe_8); DDX_Control(pDX, IDC_BTN_GE_9, m_btnGe_9); DDX_Text(pDX, IDC_EDIT_BEISHU, m_beishu); DDX_Control(pDX, IDC_EDIT_DANSHI_HAOMA, m_editDanShiHaoMa); DDX_Control(pDX, IDC_RICHEDIT_DANSHI, m_richDanshiHaoma); DDX_Control(pDX, IDC_STATIC_WAN, m_staticWan); DDX_Control(pDX, IDC_STATIC_QIAN, m_staticQian); DDX_Control(pDX, IDC_STATIC_BAI, m_staticBai); DDX_Control(pDX, IDC_STATIC_SHI, m_staticShi); DDX_Control(pDX, IDC_STATIC_GE, m_staticGe); DDX_Control(pDX, IDC_STATIC_NIU, m_staticNiu); DDX_Control(pDX, IDC_BTN_WAN_QUAN, m_btnWanQuan); DDX_Control(pDX, IDC_BTN_WAN_DA, m_btnWanDa); DDX_Control(pDX, IDC_BTN_WAN_XIAO, m_btnWanXiao); DDX_Control(pDX, IDC_BTN_WAN_DAN, m_btnWanDan); DDX_Control(pDX, IDC_BTN_WAN_SHUANG, m_btnWanShuang); DDX_Control(pDX, IDC_BTN_WAN_QING, m_btnWanQing); DDX_Control(pDX, IDC_BTN_QIAN_QUAN, m_btnQianQuan); DDX_Control(pDX, IDC_BTN_QIAN_DA, m_btnQianDa); DDX_Control(pDX, IDC_BTN_QIAN_XIAO, m_btnQianXiao); DDX_Control(pDX, IDC_BTN_QIAN_DAN, m_btnQianDan); DDX_Control(pDX, IDC_BTN_QIAN_SHUANG, m_btnQianShuang); DDX_Control(pDX, IDC_BTN_QIAN_QING, m_btnQianQing); DDX_Control(pDX, IDC_BTN_BAI_QUAN, m_btnBaiQuan); DDX_Control(pDX, IDC_BTN_BAI_DA, m_btnBaiDa); DDX_Control(pDX, IDC_BTN_BAI_XIAO, m_btnBaiXiao); DDX_Control(pDX, IDC_BTN_BAI_DAN, m_btnBaiDan); DDX_Control(pDX, IDC_BTN_BAI_SHUANG, m_btnBaiShuang); DDX_Control(pDX, IDC_BTN_BAI_QING, m_btnBaiQing); DDX_Control(pDX, IDC_BTN_SHI_QUAN, m_btnShiQuan); DDX_Control(pDX, IDC_BTN_SHI_DA, m_btnShiDa); DDX_Control(pDX, IDC_BTN_SHI_XIAO, m_btnShiXiao); DDX_Control(pDX, IDC_BTN_SHI_DAN, m_btnShiDan); DDX_Control(pDX, IDC_BTN_SHI_SHUANG, m_btnShiShuang); DDX_Control(pDX, IDC_BTN_SHI_QING, m_btnShiQing); DDX_Control(pDX, IDC_BTN_GE_QUAN, m_btnGeQuan); DDX_Control(pDX, IDC_BTN_GE_DA, m_btnGeDa); DDX_Control(pDX, IDC_BTN_GE_XIAO, m_btnGeXiao); DDX_Control(pDX, IDC_BTN_GE_DAN, m_btnGeDan); DDX_Control(pDX, IDC_BTN_GE_SHUANG, m_btnGeShuang); DDX_Control(pDX, IDC_BTN_GE_QING, m_btnGeQing); DDX_Control(pDX, IDC_LIST_CHQSSC, m_listChqSSC); DDX_Control(pDX, IDC_GRID_LIST, m_GridList); DDX_Control(pDX, IDC_BTN_CHQ_ADD, m_btnChqAdd); DDX_Control(pDX, IDC_BTN_DEL_SEL, m_btnDelSel); DDX_Control(pDX, IDC_BTN_CLS_LIST, m_btnClsList); DDX_Control(pDX, IDC_BTN_TOUZHU, m_btnTouZhu); DDX_Control(pDX, IDC_BTN_ZHUIHAO, m_btnZhuiHao); DDX_Control(pDX, IDC_EDIT_BEISHU, m_editBeiTou); DDX_Control(pDX, IDC_STATIC_BUDINGWEI, m_staticBuDingWei); DDX_Control(pDX, IDC_BTN_YUAN,m_btnYuan); DDX_Control(pDX, IDC_BTN_JIAO,m_btnJiao); DDX_Control(pDX, IDC_BTN_FEN,m_btnFen); DDX_Control(pDX, IDC_BTN_LI,m_btnLi); } BEGIN_MESSAGE_MAP(CQiXingCai, CDialog) ON_BN_CLICKED(IDC_BTN_YUAN, &CQiXingCai::OnBnClickedBtnYuan) ON_BN_CLICKED(IDC_BTN_JIAO, &CQiXingCai::OnBnClickedBtnJiao) ON_BN_CLICKED( IDC_BTN_FEN, &CQiXingCai::OnBnClickedBtnFen) ON_BN_CLICKED(IDC_BTN_LI, &CQiXingCai::OnBnClickedBtnLi) ON_BN_CLICKED(IDC_RIO_LIANGDING, &CQiXingCai::OnBnClickedRioLiangDing) ON_BN_CLICKED(IDC_RIO_SANDING, &CQiXingCai::OnBnClickedRioSanDing) ON_BN_CLICKED(IDC_RIO_SIDING, &CQiXingCai::OnBnClickedRioSiDing) ON_BN_CLICKED(IDC_RIO_YIDING, &CQiXingCai::OnBnClickedRioYiDing) ON_BN_CLICKED(IDC_RIO_LIANGZIXIAN, &CQiXingCai::OnBnClickedRioLiangZiXian) ON_BN_CLICKED(IDC_RIO_SANZIXIAN, &CQiXingCai::OnBnClickedRioSanZiXian) ON_MESSAGE( WM_BN_CLICK, &CQiXingCai::onBnCLick) ON_BN_CLICKED(IDC_BTN_MORE_RECORD, &CQiXingCai::OnBnClickedBtnMoreRecord) ON_BN_CLICKED(IDC_BTN_WAN_QUAN, &CQiXingCai::OnBnClickedBtnWanQuan) ON_BN_CLICKED(IDC_BTN_WAN_DA, &CQiXingCai::OnBnClickedBtnWanDa) ON_BN_CLICKED(IDC_BTN_WAN_XIAO, &CQiXingCai::OnBnClickedBtnWanXiao) ON_BN_CLICKED(IDC_BTN_WAN_DAN, &CQiXingCai::OnBnClickedBtnWanDan) ON_BN_CLICKED(IDC_BTN_WAN_SHUANG, &CQiXingCai::OnBnClickedBtnWanShuang) ON_BN_CLICKED(IDC_BTN_WAN_QING, &CQiXingCai::OnBnClickedBtnWanQing) ON_BN_CLICKED(IDC_BTN_QIAN_QUAN, &CQiXingCai::OnBnClickedBtnQianQuan) ON_BN_CLICKED(IDC_BTN_QIAN_DA, &CQiXingCai::OnBnClickedBtnQianDa) ON_BN_CLICKED(IDC_BTN_QIAN_XIAO, &CQiXingCai::OnBnClickedBtnQianXiao) ON_BN_CLICKED(IDC_BTN_QIAN_DAN, &CQiXingCai::OnBnClickedBtnQianDan) ON_BN_CLICKED(IDC_BTN_QIAN_SHUANG, &CQiXingCai::OnBnClickedBtnQianShuang) ON_BN_CLICKED(IDC_BTN_QIAN_QING, &CQiXingCai::OnBnClickedBtnQianQing) ON_BN_CLICKED(IDC_BTN_BAI_QUAN, &CQiXingCai::OnBnClickedBtnBaiQuan) ON_BN_CLICKED(IDC_BTN_BAI_DA, &CQiXingCai::OnBnClickedBtnBaiDa) ON_BN_CLICKED(IDC_BTN_BAI_XIAO, &CQiXingCai::OnBnClickedBtnBaiXiao) ON_BN_CLICKED(IDC_BTN_BAI_DAN, &CQiXingCai::OnBnClickedBtnBaiDan) ON_BN_CLICKED(IDC_BTN_BAI_SHUANG, &CQiXingCai::OnBnClickedBtnBaiShuang) ON_BN_CLICKED(IDC_BTN_BAI_QING, &CQiXingCai::OnBnClickedBtnBaiQing) ON_BN_CLICKED(IDC_BTN_SHI_QUAN, &CQiXingCai::OnBnClickedBtnShiQuan) ON_BN_CLICKED(IDC_BTN_SHI_DA, &CQiXingCai::OnBnClickedBtnShiDa) ON_BN_CLICKED(IDC_BTN_SHI_XIAO, &CQiXingCai::OnBnClickedBtnShiXiao) ON_BN_CLICKED(IDC_BTN_SHI_DAN, &CQiXingCai::OnBnClickedBtnShiDan) ON_BN_CLICKED(IDC_BTN_SHI_SHUANG, &CQiXingCai::OnBnClickedBtnShiShuang) ON_BN_CLICKED(IDC_BTN_SHI_QING, &CQiXingCai::OnBnClickedBtnShiQing) ON_BN_CLICKED(IDC_BTN_GE_QUAN, &CQiXingCai::OnBnClickedBtnGeQuan) ON_BN_CLICKED(IDC_BTN_GE_DA, &CQiXingCai::OnBnClickedBtnGeDa) ON_BN_CLICKED(IDC_BTN_GE_XIAO, &CQiXingCai::OnBnClickedBtnGeXiao) ON_BN_CLICKED(IDC_BTN_GE_DAN, &CQiXingCai::OnBnClickedBtnGeDan) ON_BN_CLICKED(IDC_BTN_GE_SHUANG, &CQiXingCai::OnBnClickedBtnGeShuang) ON_BN_CLICKED(IDC_BTN_GE_QING, &CQiXingCai::OnBnClickedBtnGeQing) //ON_BN_CLICKED(IDC_BTN_NIU_QUAN, &CQiXingCai::OnBnClickedBtnNiuQuan) //ON_BN_CLICKED(IDC_BTN_NIU_DA, &CQiXingCai::OnBnClickedBtnNiuDa) //ON_BN_CLICKED(IDC_BTN_NIU_XIAO, &CQiXingCai::OnBnClickedBtnNiuXiao) //ON_BN_CLICKED(IDC_BTN_NIU_DAN, &CQiXingCai::OnBnClickedBtnNiuDan) //ON_BN_CLICKED(IDC_BTN_NIU_SHUANG, &CQiXingCai::OnBnClickedBtnNiuShuang) //ON_BN_CLICKED(IDC_BTN_NIU_QING, &CQiXingCai::OnBnClickedBtnNiuQing) ON_BN_CLICKED(IDC_BTN_CHQ_ADD, &CQiXingCai::OnBnClickedBtnChqAdd) ON_COMMAND(ID_RBTN_CPY, &CQiXingCai::OnRichEditCopy) ON_BN_CLICKED(IDC_BTN_ZHUIHAO, &CQiXingCai::OnBnClickedBtnZhuihao) ON_BN_CLICKED(IDC_BTN_TOUZHU, &CQiXingCai::OnBnClickedBtnTouzhu) ON_BN_CLICKED(IDC_BTN_DEL_SEL, &CQiXingCai::OnBnClickedBtnDelSel) ON_BN_CLICKED(IDC_BTN_CLS_LIST, &CQiXingCai::OnBnClickedBtnClsList) ON_EN_CHANGE(IDC_EDIT_BEISHU, &CQiXingCai::OnEnChangeEditBeishu) ON_EN_CHANGE(IDC_EDIT_DANSHI_HAOMA, &CQiXingCai::OnEnChangeEditDanshiInput) ON_WM_CTLCOLOR() ON_WM_SIZE() ON_WM_PAINT() ON_WM_ERASEBKGND() ON_WM_TIMER() ON_WM_SHOWWINDOW() ON_WM_MOUSEMOVE() ON_WM_LBUTTONUP() ON_WM_LBUTTONDOWN() ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave) ON_BN_CLICKED(IDC_RIO_MOUSE_INPUT, &CQiXingCai::OnBnClickedRioMouseInput) ON_BN_CLICKED(IDC_RIO_KEYBOARD_INPUT, &CQiXingCai::OnBnClickedRioKeyboardInput) ON_BN_CLICKED(IDC_CHK_WAN, &CQiXingCai::OnBnClickedChkWan) ON_BN_CLICKED(IDC_CHK_QIAN, &CQiXingCai::OnBnClickedChkQian) ON_BN_CLICKED(IDC_CHK_BAI, &CQiXingCai::OnBnClickedChkBai) ON_BN_CLICKED(IDC_CHK_SHI, &CQiXingCai::OnBnClickedChkShi) ON_BN_CLICKED(IDC_CHKGE, &CQiXingCai::OnBnClickedChkge) ON_BN_CLICKED(IDC_BTN_LOCK, &CQiXingCai::OnBnClickedBtnLock) ON_BN_CLICKED(IDC_BTN_BEITOU_JIA, &CQiXingCai::OnBnClickedBeiTouJia) ON_BN_CLICKED(IDC_BTN_BEITOU_JIAN, &CQiXingCai::OnBnClickedBeiTouJian) ////LLY //ON_BN_CLICKED(IDC_RIO_LIANGDING, &CQiXingCai::OnBnClickedRioLiangDing) //ON_BN_CLICKED(IDC_RIO_SANDING, &CQiXingCai::OnBnClickedRioSanDing) //ON_BN_CLICKED(IDC_RIO_SIDING, &CQiXingCai::OnBnClickedRioSiDing) //ON_BN_CLICKED(IDC_RIO_YIDING, &CQiXingCai::OnBnClickedRioYiDing) //ON_BN_CLICKED(IDC_RIO_LIANGZIXIAN, &CQiXingCai::OnBnClickedRioLiangZiXian) //ON_BN_CLICKED(IDC_RIO_SANZIXIAN, &CQiXingCai::OnBnClickedRioSanZiXian) END_MESSAGE_MAP() void CQiXingCai::OnRichEditCopy() { char *buffer = NULL; CString fromClipboard; if(OpenClipboard()) { HANDLE hData = GetClipboardData(CF_TEXT); buffer = (char*)GlobalLock(hData); fromClipboard = buffer; GlobalUnlock(hData); CloseClipboard(); } m_richDanshiHaoma.SetWindowText(fromClipboard); //MyMessageBox(fromClipboard); return; } void CQiXingCai::OnBnClickedBtnYuan() { m_btnYuan.SetPushed(true); m_btnJiao.SetPushed(false); m_btnFen.SetPushed(false); m_btnLi.SetPushed(false); theAccount.Scoretype=MoShi_Yuan ; InvalidateRect(rcZongJinE); return; } void CQiXingCai::OnBnClickedBtnMoreRecord() { SendToServer(8); return; } void CQiXingCai::OnBnClickedBtnJiao() { m_btnYuan.SetPushed(false); m_btnJiao.SetPushed(true); m_btnFen.SetPushed(false); m_btnLi.SetPushed(false); theAccount.Scoretype=MoShi_Jiao ; InvalidateRect(rcZongJinE); return; } void CQiXingCai::OnBnClickedBtnFen() { m_btnYuan.SetPushed(false); m_btnJiao.SetPushed(false); m_btnFen.SetPushed(true); m_btnLi.SetPushed(false); theAccount.Scoretype=MoShi_Fen ; InvalidateRect(rcZongJinE); return; } void CQiXingCai::OnBnClickedBtnLi() { m_btnYuan.SetPushed(false); m_btnJiao.SetPushed(false); m_btnFen.SetPushed(false); m_btnLi.SetPushed(true); theAccount.Scoretype=MoShi_Li ; InvalidateRect(rcZongJinE); return; } // CQiXingCai 消息处理程序 void CQiXingCai::OnPaint() { CPaintDC dc(this); // device context for painting if(!IsWindowVisible()) return; // TODO: 在此处添加消息处理程序代码 if(!::IsWindow(m_hWnd)) { return; } CRect rect; GetClientRect(&rect); CDC cacheDC; cacheDC.CreateCompatibleDC(&dc); CBitmap cacheBmp; cacheBmp.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height()); CBitmap *pOldCacheBmp = cacheDC.SelectObject(&cacheBmp); Graphics graphics(cacheDC.m_hDC); graphics.DrawImage(m_bmpBk, Rect(0, 0, m_bmpBk->GetWidth(), m_bmpBk->GetHeight()), 0, 0, m_bmpBk->GetWidth(), m_bmpBk->GetHeight(), UnitPixel); //绘制开奖号 DrawLastKjHaoma(&cacheDC, graphics); DrawTopKjHaoma(&cacheDC, graphics); //绘制总注数和总金额 DrawZongZhushuJinE(&cacheDC); cacheDC.SetBkMode(TRANSPARENT); cacheDC.SetTextColor(RGB(88, 78, 77)); CFont* pOldFont = cacheDC.SelectObject(&m_Font); m_FandianView.DrawView(this,&cacheDC,rect.Width(),rect.Height()); dc.BitBlt(0, 0, rect.Width(), rect.Height(), &cacheDC, 0, 0, SRCCOPY); cacheDC.SelectObject(pOldFont); cacheDC.SelectObject(pOldCacheBmp); cacheDC.DeleteDC(); cacheBmp.DeleteObject(); // 不为绘图消息调用 CDialog::OnPaint() } BOOL CQiXingCai::OnEraseBkgnd(CDC* pDC) { return TRUE; } void CQiXingCai::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: 在此处添加消息处理程序代码 if (GetSafeHwnd() == NULL) { return; } AdjustWanFa(); AdjustRadio(); AdjustNumBtn(); AdjustNumView(); AdjustDanShi(); AdjustAdd(); } void CQiXingCai::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); if(bShow) { if(theAccount.user_id <=0) { return; } m_btnYuan.SetPushed(false); m_btnJiao.SetPushed(false); m_btnFen.SetPushed(false); m_btnLi.SetPushed(false); if(theAccount.Scoretype==MoShi_Yuan ) { m_btnYuan.SetPushed(true); } else if(theAccount.Scoretype == MoShi_Jiao) { m_btnJiao.SetPushed(true); } else if(theAccount.Scoretype == MoShi_Fen) { m_btnFen.SetPushed(true); } else if(theAccount.Scoretype == MoShi_Li) { m_btnLi.SetPushed(true); } LuckyNumCQSSC(); SendToServer(6); m_bKaiJiangzhong = false; // SetTimer(timer_id_get_luck_num, 10000, NULL); SetTimer(timer_id_kj_yugao, 1000, NULL); SetTimer(timer_id_kaijiangzhong, 100, NULL); OnBnClickedRioLiangDing(); } else { KillTimer(timer_id_get_luck_num); KillTimer(timer_id_kj_yugao); KillTimer(timer_id_kaijiangzhong); m_DlgOpenRecord.ShowWindow(SW_HIDE); } } HBRUSH CQiXingCai::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if (nCtlColor == CTLCOLOR_EDIT && pWnd->GetDlgCtrlID() == IDC_EDIT_DANSHI_HAOMA) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(88, 78, 77)); if(hBrush) { DeleteObject(hBrush); hBrush = CreateSolidBrush(RGB(61,47,42)); } else { hBrush = CreateSolidBrush(RGB(61,47,42)); } return hBrush; } if (pWnd->GetDlgCtrlID() == IDC_RICHEDIT_DANSHI) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(88, 78, 77)); if(hBrush) { DeleteObject(hBrush); hBrush = CreateSolidBrush(RGB(61,47,42)); } else { hBrush = CreateSolidBrush(RGB(61,47,42)); } return hBrush; } //混合模式,提示信息 if(CTLCOLOR_STATIC==nCtlColor && (pWnd->GetDlgCtrlID() == IDC_STATIC_HUNHE_TIP || pWnd->GetDlgCtrlID() == IDC_STATIC_NIUNIU_TIP)) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(88, 78, 77)); if(hBrush) { DeleteObject(hBrush); hBrush = CreateSolidBrush(RGB(61,47,42)); } else { hBrush = CreateSolidBrush(RGB(61,47,42)); } return hBrush; } //任选STATIC if(CTLCOLOR_STATIC==nCtlColor && pWnd->GetDlgCtrlID() == IDC_STATIC_RENXUAN_TIP) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(88, 78, 77)); if(hBrush) { DeleteObject(hBrush); hBrush = CreateSolidBrush(RGB(245,229,203)); } else { hBrush = CreateSolidBrush(RGB(245,229,203)); } return hBrush; } //任选,键盘输入的多选框 // if(CTLCOLOR_BTN == nCtlColor ) // { if((pWnd->GetDlgCtrlID() == IDC_CHK_WAN) || (pWnd->GetDlgCtrlID() ==IDC_CHK_QIAN) || (pWnd->GetDlgCtrlID() ==IDC_CHK_BAI) || (pWnd->GetDlgCtrlID() ==IDC_CHK_SHI) || (pWnd->GetDlgCtrlID() ==IDC_CHKGE)) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(88, 78, 77)); if(hBrush) { DeleteObject(hBrush); hBrush = CreateSolidBrush(RGB(245, 229, 203)); } else { hBrush = CreateSolidBrush(RGB(245, 229, 203)); } return hBrush; } // } return CDialog::OnCtlColor(pDC, pWnd, nCtlColor); } void CQiXingCai::OnTimer(UINT_PTR nIDEvent) { if(timer_id_get_luck_num == nIDEvent) { LuckyNumCQSSC(); } else if (timer_id_kj_yugao == nIDEvent) { CRect rcRect; rcRect.CopyRect(rcYuGao); //rcRect.right += 80; rcRect.bottom += 50; InvalidateRect(&rcRect); } else if(TimerJiShi == nIDEvent) { DWORD newCount = ::GetTickCount(); int i = 0; while (newCount - theBeginCount > 1000) { theTimeCS.Lock(); theTime += CTimeSpan(0, 0, 0, 1); theTimeCS.Unlock(); newCount -= 1000; i ++; } theBeginCount += i * 1000; } else if(TimerFandian == nIDEvent) { SendToServer(6); } else if(timer_id_kaijiangzhong == nIDEvent) { //处理开奖GIF动画 int nTimeLeft = GetKjShjDiff(); if(m_bKaiJiangzhong ) { CDC* pDC = GetDC(); if(pDC==NULL) return; //for(int n=0; n<m_nFrameCount; n++) { int nLeft=kj_big_haoma_x -15/*+ n *( m_bigNumWidth+8)*/; CMemDC mDC(pDC, CRect(nLeft, kj_big_haoma_y, nLeft+m_imgKaijiang->GetWidth(), kj_big_haoma_y+m_imgKaijiang->GetHeight())); Graphics gh(mDC.m_hDC); gh.DrawImage(m_imgKaijiang, nLeft, kj_big_haoma_y, m_imgKaijiang->GetWidth(), m_imgKaijiang->GetHeight()); } GUID Guid = FrameDimensionTime; m_imgKaijiang->SelectActiveFrame(&Guid, m_nFrameIndex++); if(m_nFrameIndex == m_nFrameCount) m_nFrameIndex=0; ReleaseDC(pDC); } else KillTimer(timer_id_kaijiangzhong); } else if(nIDEvent == TimerStatus) { KillTimer(TimerStatus); m_DlgStatus.HideStatusWindow(); CInformation Information; Information.ShowMessageBox(L"温馨提醒",L"服务器繁忙,投注失败",MB_OK,5); } CDialog::OnTimer(nIDEvent); } BOOL CQiXingCai::OnInitDialog() { CDialog::OnInitDialog(); ZeroMemory(m_szMD5Haoma,sizeof(m_szMD5Haoma)); hBrush = NULL; // TODO: 在此添加额外的初始化 m_bmpBk = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\game_bk3.png")); m_numImageList = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\num.png")); m_numImageList1 = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\num2.png")); m_numImageList2 = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\num3.png")); m_kjNumBig = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\Num_big.png")); m_imgKaijiang = new Bitmap( CBmpUtil::GetExePath() + _T("skin\\game\\KaiJiang.gif")); int nCount = m_imgKaijiang->GetFrameDimensionsCount(); //获取帧维数 GUID *pGuids = new GUID[nCount]; //定义一个GUID数组 m_imgKaijiang->GetFrameDimensionsList(pGuids,nCount); //获取图像帧的GUID m_nFrameCount=m_imgKaijiang->GetFrameCount(pGuids); //获取GIF帧数 m_bZhuiZjtz = true; m_btnYuan.SetBkImage(CBmpUtil::GetExePath() + _T("skin\\game\\BT_USER_INFO_1.png")); m_btnJiao.SetBkImage(CBmpUtil::GetExePath() + _T("skin\\game\\BT_USER_INFO_2.png")); m_btnFen.SetBkImage(CBmpUtil::GetExePath() + _T("skin\\game\\BT_USER_INFO_3.png")); m_btnLi.SetBkImage(CBmpUtil::GetExePath() + _T("skin\\game\\BT_USER_INFO_4.png")); m_bShowFail = true; m_bigNumWidth = m_kjNumBig->GetWidth() / 10; m_bigNumHeight = m_kjNumBig->GetHeight(); m_kjNumSmall = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\Num_small.png")); m_smallNumWidth = m_kjNumSmall->GetWidth() / 10; m_smallNumHeight = m_kjNumSmall->GetHeight(); m_bmpDxdsh = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\btn_dx2.png")); m_bmpNumTip = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\digit.png")); m_bmpNumTip1 = new Bitmap(CBmpUtil::GetExePath() + _T("skin\\game\\digit2.png")); m_btnMoreRecord.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_more.png")); m_bCanSend=true; InitNumberBtns(); InitListCtrl(); m_DlgOpenRecord.Create(COpenRecord::IDD,this); m_smallNumfont.CreateFont(16, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("微软雅黑")); m_zongFont.CreateFont(20, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("微软雅黑")); m_KjInfoFont1.CreateFont(20, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("微软雅黑")); m_KjInfoFont.CreateFont(30, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, _T("微软雅黑")); m_btnDelSel.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_delate.png")); m_btnClsList.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_clear.png")); m_btnTouZhu.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_bet.png")); m_btnZhuiHao.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_append.png")); m_btnChqAdd.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_addnum.png")); m_btnLock.SetBkImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_lock.png")); m_btnLock.SetTextColor(RGB(51, 45, 42)); m_btnBeiTouJia.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_jia.png")); m_btnBeiTouJian.SetImage(CBmpUtil::GetExePath() + _T("skin\\game\\btn_jian.png")); m_btnLock.SetTextFont(&m_zongFont); m_editBeiTou.SetEnableColor(RGB(0,0,0),RGB(250,243,227),RGB(250,243,227)); m_editBeiTou.SetFont(&m_zongFont); m_richDanshiHaoma.LimitText(-1); m_richDanshiHaoma.SetBackgroundColor(false,RGB(200,200,200)); CHARFORMAT cf; ZeroMemory(&cf, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR; cf.crTextColor = RGB(88, 78, 77); m_richDanshiHaoma.SetDefaultCharFormat(cf); LuckyNumCQSSC(); m_ToolTipCtrl.Create(this); m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.SetMaxTipWidth(150); m_btWxzxTip.SetImage(CBmpUtil::GetExePath() + _T("skin\\shili.png")); // SendQuerySystemTime(); // SendQueryLuckyNumCQSSC(); //SetTimer(TimerZhunBeiData, 2000, NULL); m_bKaiJiangzhong=false; return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CQiXingCai::OnCancel() { // TODO: 在此添加专用代码和/或调用基类 //CDialog::OnCancel(); } void CQiXingCai::OnOK() { // TODO: 在此添加专用代码和/或调用基类 //CDialog::OnOK(); } void CQiXingCai::OnBnClickedBtnWanQuan() { CheckNumBtn(m_btnWan_0); CheckNumBtn(m_btnWan_1); CheckNumBtn(m_btnWan_2); CheckNumBtn(m_btnWan_3); CheckNumBtn(m_btnWan_4); CheckNumBtn(m_btnWan_5); CheckNumBtn(m_btnWan_6); CheckNumBtn(m_btnWan_7); CheckNumBtn(m_btnWan_8); CheckNumBtn(m_btnWan_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnWanDa() { UnCheckNumBtn(m_btnWan_0); UnCheckNumBtn(m_btnWan_1); UnCheckNumBtn(m_btnWan_2); UnCheckNumBtn(m_btnWan_3); UnCheckNumBtn(m_btnWan_4); CheckNumBtn(m_btnWan_5); CheckNumBtn(m_btnWan_6); CheckNumBtn(m_btnWan_7); CheckNumBtn(m_btnWan_8); CheckNumBtn(m_btnWan_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnWanXiao() { CheckNumBtn(m_btnWan_0); CheckNumBtn(m_btnWan_1); CheckNumBtn(m_btnWan_2); CheckNumBtn(m_btnWan_3); CheckNumBtn(m_btnWan_4); UnCheckNumBtn(m_btnWan_5); UnCheckNumBtn(m_btnWan_6); UnCheckNumBtn(m_btnWan_7); UnCheckNumBtn(m_btnWan_8); UnCheckNumBtn(m_btnWan_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnWanDan() { UnCheckNumBtn(m_btnWan_0); CheckNumBtn(m_btnWan_1); UnCheckNumBtn(m_btnWan_2); CheckNumBtn(m_btnWan_3); UnCheckNumBtn(m_btnWan_4); CheckNumBtn(m_btnWan_5); UnCheckNumBtn(m_btnWan_6); CheckNumBtn(m_btnWan_7); UnCheckNumBtn(m_btnWan_8); CheckNumBtn(m_btnWan_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnWanShuang() { CheckNumBtn(m_btnWan_0); UnCheckNumBtn(m_btnWan_1); CheckNumBtn(m_btnWan_2); UnCheckNumBtn(m_btnWan_3); CheckNumBtn(m_btnWan_4); UnCheckNumBtn(m_btnWan_5); CheckNumBtn(m_btnWan_6); UnCheckNumBtn(m_btnWan_7); CheckNumBtn(m_btnWan_8); UnCheckNumBtn(m_btnWan_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnWanQing() { UnCheckNumBtn(m_btnWan_0); UnCheckNumBtn(m_btnWan_1); UnCheckNumBtn(m_btnWan_2); UnCheckNumBtn(m_btnWan_3); UnCheckNumBtn(m_btnWan_4); UnCheckNumBtn(m_btnWan_5); UnCheckNumBtn(m_btnWan_6); UnCheckNumBtn(m_btnWan_7); UnCheckNumBtn(m_btnWan_8); UnCheckNumBtn(m_btnWan_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnQianQuan() { CheckNumBtn(m_btnQian_0); CheckNumBtn(m_btnQian_1); CheckNumBtn(m_btnQian_2); CheckNumBtn(m_btnQian_3); CheckNumBtn(m_btnQian_4); CheckNumBtn(m_btnQian_5); CheckNumBtn(m_btnQian_6); CheckNumBtn(m_btnQian_7); CheckNumBtn(m_btnQian_8); CheckNumBtn(m_btnQian_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnQianDa() { UnCheckNumBtn(m_btnQian_0); UnCheckNumBtn(m_btnQian_1); UnCheckNumBtn(m_btnQian_2); UnCheckNumBtn(m_btnQian_3); UnCheckNumBtn(m_btnQian_4); CheckNumBtn(m_btnQian_5); CheckNumBtn(m_btnQian_6); CheckNumBtn(m_btnQian_7); CheckNumBtn(m_btnQian_8); CheckNumBtn(m_btnQian_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnQianXiao() { CheckNumBtn(m_btnQian_0); CheckNumBtn(m_btnQian_1); CheckNumBtn(m_btnQian_2); CheckNumBtn(m_btnQian_3); CheckNumBtn(m_btnQian_4); UnCheckNumBtn(m_btnQian_5); UnCheckNumBtn(m_btnQian_6); UnCheckNumBtn(m_btnQian_7); UnCheckNumBtn(m_btnQian_8); UnCheckNumBtn(m_btnQian_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnQianDan() { UnCheckNumBtn(m_btnQian_0); CheckNumBtn(m_btnQian_1); UnCheckNumBtn(m_btnQian_2); CheckNumBtn(m_btnQian_3); UnCheckNumBtn(m_btnQian_4); CheckNumBtn(m_btnQian_5); UnCheckNumBtn(m_btnQian_6); CheckNumBtn(m_btnQian_7); UnCheckNumBtn(m_btnQian_8); CheckNumBtn(m_btnQian_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnQianShuang() { CheckNumBtn(m_btnQian_0); UnCheckNumBtn(m_btnQian_1); CheckNumBtn(m_btnQian_2); UnCheckNumBtn(m_btnQian_3); CheckNumBtn(m_btnQian_4); UnCheckNumBtn(m_btnQian_5); CheckNumBtn(m_btnQian_6); UnCheckNumBtn(m_btnQian_7); CheckNumBtn(m_btnQian_8); UnCheckNumBtn(m_btnQian_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnQianQing() { UnCheckNumBtn(m_btnQian_0); UnCheckNumBtn(m_btnQian_1); UnCheckNumBtn(m_btnQian_2); UnCheckNumBtn(m_btnQian_3); UnCheckNumBtn(m_btnQian_4); UnCheckNumBtn(m_btnQian_5); UnCheckNumBtn(m_btnQian_6); UnCheckNumBtn(m_btnQian_7); UnCheckNumBtn(m_btnQian_8); UnCheckNumBtn(m_btnQian_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnBaiQuan() { CheckNumBtn(m_btnBai_0); CheckNumBtn(m_btnBai_1); CheckNumBtn(m_btnBai_2); CheckNumBtn(m_btnBai_3); CheckNumBtn(m_btnBai_4); CheckNumBtn(m_btnBai_5); CheckNumBtn(m_btnBai_6); CheckNumBtn(m_btnBai_7); CheckNumBtn(m_btnBai_8); CheckNumBtn(m_btnBai_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnBaiDa() { UnCheckNumBtn(m_btnBai_0); UnCheckNumBtn(m_btnBai_1); UnCheckNumBtn(m_btnBai_2); UnCheckNumBtn(m_btnBai_3); UnCheckNumBtn(m_btnBai_4); CheckNumBtn(m_btnBai_5); CheckNumBtn(m_btnBai_6); CheckNumBtn(m_btnBai_7); CheckNumBtn(m_btnBai_8); CheckNumBtn(m_btnBai_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnBaiXiao() { CheckNumBtn(m_btnBai_0); CheckNumBtn(m_btnBai_1); CheckNumBtn(m_btnBai_2); CheckNumBtn(m_btnBai_3); CheckNumBtn(m_btnBai_4); UnCheckNumBtn(m_btnBai_5); UnCheckNumBtn(m_btnBai_6); UnCheckNumBtn(m_btnBai_7); UnCheckNumBtn(m_btnBai_8); UnCheckNumBtn(m_btnBai_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnBaiDan() { UnCheckNumBtn(m_btnBai_0); CheckNumBtn(m_btnBai_1); UnCheckNumBtn(m_btnBai_2); CheckNumBtn(m_btnBai_3); UnCheckNumBtn(m_btnBai_4); CheckNumBtn(m_btnBai_5); UnCheckNumBtn(m_btnBai_6); CheckNumBtn(m_btnBai_7); UnCheckNumBtn(m_btnBai_8); CheckNumBtn(m_btnBai_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnBaiShuang() { CheckNumBtn(m_btnBai_0); UnCheckNumBtn(m_btnBai_1); CheckNumBtn(m_btnBai_2); UnCheckNumBtn(m_btnBai_3); CheckNumBtn(m_btnBai_4); UnCheckNumBtn(m_btnBai_5); CheckNumBtn(m_btnBai_6); UnCheckNumBtn(m_btnBai_7); CheckNumBtn(m_btnBai_8); UnCheckNumBtn(m_btnBai_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnBaiQing() { UnCheckNumBtn(m_btnBai_0); UnCheckNumBtn(m_btnBai_1); UnCheckNumBtn(m_btnBai_2); UnCheckNumBtn(m_btnBai_3); UnCheckNumBtn(m_btnBai_4); UnCheckNumBtn(m_btnBai_5); UnCheckNumBtn(m_btnBai_6); UnCheckNumBtn(m_btnBai_7); UnCheckNumBtn(m_btnBai_8); UnCheckNumBtn(m_btnBai_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnShiQuan() { CheckNumBtn(m_btnShi_0); CheckNumBtn(m_btnShi_1); CheckNumBtn(m_btnShi_2); CheckNumBtn(m_btnShi_3); CheckNumBtn(m_btnShi_4); CheckNumBtn(m_btnShi_5); CheckNumBtn(m_btnShi_6); CheckNumBtn(m_btnShi_7); CheckNumBtn(m_btnShi_8); CheckNumBtn(m_btnShi_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnShiDa() { UnCheckNumBtn(m_btnShi_0); UnCheckNumBtn(m_btnShi_1); UnCheckNumBtn(m_btnShi_2); UnCheckNumBtn(m_btnShi_3); UnCheckNumBtn(m_btnShi_4); CheckNumBtn(m_btnShi_5); CheckNumBtn(m_btnShi_6); CheckNumBtn(m_btnShi_7); CheckNumBtn(m_btnShi_8); CheckNumBtn(m_btnShi_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnShiXiao() { CheckNumBtn(m_btnShi_0); CheckNumBtn(m_btnShi_1); CheckNumBtn(m_btnShi_2); CheckNumBtn(m_btnShi_3); CheckNumBtn(m_btnShi_4); UnCheckNumBtn(m_btnShi_5); UnCheckNumBtn(m_btnShi_6); UnCheckNumBtn(m_btnShi_7); UnCheckNumBtn(m_btnShi_8); UnCheckNumBtn(m_btnShi_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnShiDan() { UnCheckNumBtn(m_btnShi_0); CheckNumBtn(m_btnShi_1); UnCheckNumBtn(m_btnShi_2); CheckNumBtn(m_btnShi_3); UnCheckNumBtn(m_btnShi_4); CheckNumBtn(m_btnShi_5); UnCheckNumBtn(m_btnShi_6); CheckNumBtn(m_btnShi_7); UnCheckNumBtn(m_btnShi_8); CheckNumBtn(m_btnShi_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnShiShuang() { CheckNumBtn(m_btnShi_0); UnCheckNumBtn(m_btnShi_1); CheckNumBtn(m_btnShi_2); UnCheckNumBtn(m_btnShi_3); CheckNumBtn(m_btnShi_4); UnCheckNumBtn(m_btnShi_5); CheckNumBtn(m_btnShi_6); UnCheckNumBtn(m_btnShi_7); CheckNumBtn(m_btnShi_8); UnCheckNumBtn(m_btnShi_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnShiQing() { UnCheckNumBtn(m_btnShi_0); UnCheckNumBtn(m_btnShi_1); UnCheckNumBtn(m_btnShi_2); UnCheckNumBtn(m_btnShi_3); UnCheckNumBtn(m_btnShi_4); UnCheckNumBtn(m_btnShi_5); UnCheckNumBtn(m_btnShi_6); UnCheckNumBtn(m_btnShi_7); UnCheckNumBtn(m_btnShi_8); UnCheckNumBtn(m_btnShi_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnGeQuan() { CheckNumBtn(m_btnGe_0); CheckNumBtn(m_btnGe_1); CheckNumBtn(m_btnGe_2); CheckNumBtn(m_btnGe_3); CheckNumBtn(m_btnGe_4); CheckNumBtn(m_btnGe_5); CheckNumBtn(m_btnGe_6); CheckNumBtn(m_btnGe_7); CheckNumBtn(m_btnGe_8); CheckNumBtn(m_btnGe_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnGeDa() { UnCheckNumBtn(m_btnGe_0); UnCheckNumBtn(m_btnGe_1); UnCheckNumBtn(m_btnGe_2); UnCheckNumBtn(m_btnGe_3); UnCheckNumBtn(m_btnGe_4); CheckNumBtn(m_btnGe_5); CheckNumBtn(m_btnGe_6); CheckNumBtn(m_btnGe_7); CheckNumBtn(m_btnGe_8); CheckNumBtn(m_btnGe_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnGeXiao() { CheckNumBtn(m_btnGe_0); CheckNumBtn(m_btnGe_1); CheckNumBtn(m_btnGe_2); CheckNumBtn(m_btnGe_3); CheckNumBtn(m_btnGe_4); UnCheckNumBtn(m_btnGe_5); UnCheckNumBtn(m_btnGe_6); UnCheckNumBtn(m_btnGe_7); UnCheckNumBtn(m_btnGe_8); UnCheckNumBtn(m_btnGe_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnGeDan() { UnCheckNumBtn(m_btnGe_0); CheckNumBtn(m_btnGe_1); UnCheckNumBtn(m_btnGe_2); CheckNumBtn(m_btnGe_3); UnCheckNumBtn(m_btnGe_4); CheckNumBtn(m_btnGe_5); UnCheckNumBtn(m_btnGe_6); CheckNumBtn(m_btnGe_7); UnCheckNumBtn(m_btnGe_8); CheckNumBtn(m_btnGe_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnGeShuang() { CheckNumBtn(m_btnGe_0); UnCheckNumBtn(m_btnGe_1); CheckNumBtn(m_btnGe_2); UnCheckNumBtn(m_btnGe_3); CheckNumBtn(m_btnGe_4); UnCheckNumBtn(m_btnGe_5); CheckNumBtn(m_btnGe_6); UnCheckNumBtn(m_btnGe_7); CheckNumBtn(m_btnGe_8); UnCheckNumBtn(m_btnGe_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } void CQiXingCai::OnBnClickedBtnGeQing() { UnCheckNumBtn(m_btnGe_0); UnCheckNumBtn(m_btnGe_1); UnCheckNumBtn(m_btnGe_2); UnCheckNumBtn(m_btnGe_3); UnCheckNumBtn(m_btnGe_4); UnCheckNumBtn(m_btnGe_5); UnCheckNumBtn(m_btnGe_6); UnCheckNumBtn(m_btnGe_7); UnCheckNumBtn(m_btnGe_8); UnCheckNumBtn(m_btnGe_9); GetQXCZhushu(CZ_QiXingCai,m_gameKind); } bool CQiXingCai::GetKeyBoardHaomaXian(CString& haoma, int size, int nLeast) { CStringArray strArr; CString line; m_richDanshiHaoma.SetSel(0,-1); line = m_richDanshiHaoma.GetSelText(); int nFind = line.Find(L","); if(nFind != -1) { line.Replace(_T(","),_T(",")); } line.Replace(L"\r",L" "); line.Replace(L"\n",L" "); if (!GetKeyHaomaStrsXian(strArr, line, size,nLeast)) { return false; } int count = strArr.GetCount(); CString strTemp; for(int i=0; i<count; i++) { strTemp = strArr.GetAt(i); int nWeishu = strTemp.GetLength(); if(nWeishu > nLeast) { MyMessageBox(_T("您输入的号码太多了")); return false; } for(int j = 0; j<strTemp.GetLength();j++) { haoma += strTemp.GetAt(j); if ((j!=nWeishu-1)) { haoma += _T(","); } if(j == nWeishu-1) { haoma +=_T("|"); } } } return true; } bool CQiXingCai::GetKeyHaomaStrsXian(CStringArray& strArr, CString line, int size, int nLeast) { int len = line.GetLength(); CString subStr; CString strTemp; int NumCount = 0; for (int i=0; i<len; i++) { CString str; str=line.GetAt(i); int nTemp = 10; if (iswdigit(line.GetAt(i))&&!str.IsEmpty()/*&&str.Compare(L"\r\n")!=0*/) { subStr += line.GetAt(i); strTemp+= line.GetAt(i); //校验数字有效性 nTemp = _ttoi(strTemp); strTemp=_T(""); if(nTemp<0||nTemp>9) { MyMessageBox(L"您的输入有误,数字只能在0~9之间 "); return false; } //校验数字重复 for (int j=0;j<subStr.GetLength()-1;j++) { strTemp = subStr.GetAt(j); if (nTemp == _ttoi(strTemp)) { CString msgtemp; msgtemp.Format(L"您的输入有误,第%d组有相同数字",(1+strArr.GetCount())); MyMessageBox(msgtemp.GetBuffer()); return false; } } NumCount++; strTemp=_T(""); //一组保存 if (NumCount == size) { NumCount = 0; strArr.Add(subStr); subStr.Empty(); } } } if(strArr.GetCount()==0) { MyMessageBox(_T("请输入号码!")); return false; } return true; } //添加号码 void CQiXingCai::OnBnClickedBtnChqAdd() { // m_DlgStatus.ShowStatusWindow(TEXT("正在添加数据,请稍候...")); CString strWan = GetWanString(); CString strQian = GetQianString(); CString strBai = GetBaiString(); CString strShi = GetShiString(); CString strGe = GetGeString(); CString strHezhi = GetHezhiString(); CString strNiuNiu = GetNiuString(); CString strNiuNum = GetNiuNumString(); CString strHaoMa; int zhushu = 1; if (QiXingCai_LiangDing == m_gameKind) { if(m_RenxuanKeyboardInput) { if(!GetKeyBoardHaoma(strHaoMa,3,2)) { CString strTips; strTips.Format(L"您的号码输入有误,请重新输入!"); MyMessageBox(strTips); m_DlgStatus.HideStatusWindow(); return; } int nLength = strHaoMa.GetLength(); if(nLength > 4800) { MyMessageBox(L"你输入的号码超过限制注数,请重新输入!"); m_DlgStatus.HideStatusWindow(); return; } zhushu = 1; } else { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount<2) { MyMessageBox(_T("您选择的号码个数太少")); m_DlgStatus.HideStatusWindow(); return; } if(nTempHaoMaCount>2) { MyMessageBox(_T("您选择的号码个数太多")); m_DlgStatus.HideStatusWindow(); return; } strHaoMa = strQian + _T(",") + strBai + _T(",") + strShi + _T(",") + strGe; zhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } } else if (QiXingCai_SanDing == m_gameKind) { if(m_RenxuanKeyboardInput) { if(!GetKeyBoardHaoma(strHaoMa,3,3)) { CString strTips; strTips.Format(L"您的号码输入有误,请重新输入!"); MyMessageBox(strTips); m_DlgStatus.HideStatusWindow(); return; } int nLength = strHaoMa.GetLength(); if(nLength > 4800) { MyMessageBox(L"你输入的号码超过限制注数,请重新输入!"); m_DlgStatus.HideStatusWindow(); return; } zhushu = 1; } else { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount<3) { MyMessageBox(_T("您选择的号码个数太少")); m_DlgStatus.HideStatusWindow(); return; } if(nTempHaoMaCount>3) { MyMessageBox(_T("您选择的号码个数太多")); m_DlgStatus.HideStatusWindow(); return; } strHaoMa = strQian + _T(",") + strBai + _T(",") + strShi + _T(",") + strGe; zhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } } else if (QiXingCai_SiDing == m_gameKind) { if(m_RenxuanKeyboardInput) { if(!GetKeyBoardHaoma(strHaoMa,3,4)) { CString strTips; strTips.Format(L"您的号码输入有误,请重新输入!"); MyMessageBox(strTips); m_DlgStatus.HideStatusWindow(); return; } int nLength = strHaoMa.GetLength(); if(nLength > 4800) { MyMessageBox(L"你输入的号码超过限制注数,请重新输入!"); m_DlgStatus.HideStatusWindow(); return; } zhushu = 1; } else { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount<4) { MyMessageBox(_T("您选择的号码个数太少")); m_DlgStatus.HideStatusWindow(); return; } strHaoMa = strQian + _T(",") + strBai + _T(",") + strShi + _T(",") + strGe ; zhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } } else if (QiXingCai_YiDing == m_gameKind) { if(m_RenxuanKeyboardInput) { if(!GetKeyBoardHaoma(strHaoMa,3,1)) { CString strTips; strTips.Format(L"您的号码输入有误,请重新输入!"); MyMessageBox(strTips); m_DlgStatus.HideStatusWindow(); return; } int nLength = strHaoMa.GetLength(); if(nLength > 4800) { MyMessageBox(L"你输入的号码超过限制注数,请重新输入!"); m_DlgStatus.HideStatusWindow(); return; } zhushu = 1; } else { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount<1) { MyMessageBox(_T("您选择的号码个数太少")); m_DlgStatus.HideStatusWindow(); return; } if(nTempHaoMaCount>1) { MyMessageBox(_T("您选择的号码个数太多")); m_DlgStatus.HideStatusWindow(); return; } strHaoMa = strQian + _T(",") + strBai + _T(",") + strShi + _T(",") + strGe; zhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } } else if (QiXingCai_LiangZiXian == m_gameKind) { if(m_RenxuanKeyboardInput) { if(!GetKeyBoardHaomaXian(strHaoMa,2,4)) { CString strTips; strTips.Format(L"您的号码输入有误,请重新输入!"); MyMessageBox(strTips); m_DlgStatus.HideStatusWindow(); return; } int nLength = strHaoMa.GetLength(); if(nLength > 4800) { MyMessageBox(L"你输入的号码超过限制注数,请重新输入!"); m_DlgStatus.HideStatusWindow(); return; } zhushu = nLength/3; } else { if(strBai.GetLength()<2) { MyMessageBox(_T("您选择的号码个数太少")); m_DlgStatus.HideStatusWindow(); return; } if(strBai.GetLength()>2) { MyMessageBox(_T("您选择的号码个数太多")); m_DlgStatus.HideStatusWindow(); return; } for(int i = 0;i < strBai.GetLength();i++) { strHaoMa += strBai.GetAt(i); if (i != strBai.GetLength()-1) { strHaoMa += _T(","); } } zhushu = 1; } } else if (QiXingCai_SanZiXian == m_gameKind) { if(m_RenxuanKeyboardInput) { if(!GetKeyBoardHaomaXian(strHaoMa,3,4)) { CString strTips; strTips.Format(L"您的号码输入有误,请重新输入!"); MyMessageBox(strTips); m_DlgStatus.HideStatusWindow(); return; } int nLength = strHaoMa.GetLength(); if(nLength > 4800) { MyMessageBox(L"你输入的号码超过限制注数,请重新输入!"); m_DlgStatus.HideStatusWindow(); return; } zhushu = nLength/4; } else { if(strBai.GetLength()<3) { MyMessageBox(_T("您选择的号码个数太少")); m_DlgStatus.HideStatusWindow(); return; } if(strBai.GetLength()>3) { MyMessageBox(_T("您选择的号码个数太多")); m_DlgStatus.HideStatusWindow(); return; } for(int i = 0;i < strBai.GetLength();i++) { strHaoMa += strBai.GetAt(i); if (i != strBai.GetLength()-1) { strHaoMa += _T(","); } } zhushu = 1; } } UpdateData(); CStringArray strArr; if (!strHaoMa.IsEmpty()) { if(strHaoMa.GetLength()>1024) { m_DlgStatus.ShowStatusWindow(TEXT("正在添加数据,请稍候...")); } if(m_RenxuanKeyboardInput) { if(strHaoMa.GetLength()>10240) { if((!m_strHaoma.IsEmpty())||(m_zongZhuShu!=0)) { CInformation Information; if(Information.ShowMessageBox(L"温馨提醒",L"本操作将清除已添加号码,请确认",MB_YESNO)==IDYES) { OnBnClickedBtnClsList(); } else { m_DlgStatus.HideStatusWindow(); return ; } } m_strHaoma = strHaoMa; int nIndex = 0; CString strHaomaTemp; int nZongzhushu = 0; if(m_gameKind == WuxingZhixuan) { nZongzhushu += strHaoMa.GetLength()/6; } else if(m_gameKind == RenXuan4) { BOOL bWan=false, bQian=false, bBai=false, bShi=false, bGe=false; int nCount=GetRenXuanCheckBox(bWan, bQian, bBai, bShi, bGe); int nZhushu = strHaoMa.GetLength()/5; nZongzhushu = nZhushu *nRenXuan4[nCount]; } else { do { if(!AfxExtractSubString(strHaomaTemp, strHaoMa, nIndex++, '|')) break; if(strHaomaTemp.IsEmpty()) break; nZongzhushu ++; } while(nIndex<80000); } int nCount = m_listChqSSC.GetItemCount(); m_listChqSSC.InsertItem(nCount, L"号码添加成功"); m_listChqSSC.SetItemText(nCount, 1, GetScoreMoshi()); double danzhujine = 2.0; if(theAccount.Scoretype == MoShi_Yuan) { danzhujine = 2.0; } else if (theAccount.Scoretype == MoShi_Jiao) { danzhujine = 0.2; } else if(theAccount.Scoretype == MoShi_Fen) { danzhujine = 0.02; } else if(theAccount.Scoretype == MoShi_Li) danzhujine = 0.002; DOUBLE fJine = 0.0f; fJine = nZongzhushu*m_beishu*danzhujine; CString strZongzhu ; strZongzhu.Format(L"¥%.3lf",fJine); m_listChqSSC.SetItemText(nCount, 2, strZongzhu); m_listChqSSC.SetItemText(nCount, 3, GetWanDesc()); //CString strZongzhu ; strZongzhu.Format(L"%d",nZongzhushu); m_listChqSSC.SetItemText(nCount, 4, strZongzhu); strZongzhu.Format(_T("%d"), m_beishu); m_listChqSSC.SetItemText(nCount, 5, strZongzhu); m_listChqSSC.createItemButton(nCount, 6, this->GetSafeHwnd()); m_zongZhuShu += nZongzhushu; } else { int nCount = m_listChqSSC.GetItemCount(); int nIndex = 0; do { CString strHaomaTemp; if(!AfxExtractSubString(strHaomaTemp, strHaoMa, nIndex++, '|')) break; if(strHaomaTemp.IsEmpty()) break; wstring strdata; strdata = strHaomaTemp.GetBuffer(0); vecAllNums.insert(vecAllNums.begin(),1,strdata); m_listChqSSC.InsertItem(nCount, strHaomaTemp); m_listChqSSC.SetItemText(nCount, 1, GetScoreMoshi()); double danzhujine = 2.0; if(theAccount.Scoretype == MoShi_Yuan) { danzhujine = 2.0; } else if (theAccount.Scoretype == MoShi_Jiao) { danzhujine = 0.2; } else if(theAccount.Scoretype == MoShi_Fen) { danzhujine = 0.02; } else if(theAccount.Scoretype == MoShi_Li) danzhujine = 0.002; DOUBLE fJine = 0.0f; fJine = zhushu*m_beishu*danzhujine; CString strZongzhu ; strZongzhu.Format(L"¥%.3lf",fJine); m_listChqSSC.SetItemText(nCount, 2, strZongzhu); m_listChqSSC.SetItemText(nCount, 3, GetWanDesc()); zhushu = 1; CString strTmp; strTmp.Format(_T("%d"), zhushu); m_listChqSSC.SetItemText(nCount, 4, strTmp); strTmp.Format(_T("%d"), m_beishu); m_listChqSSC.SetItemText(nCount, 5, strTmp); m_listChqSSC.createItemButton(nCount++, 6, this->GetSafeHwnd()); m_zongZhuShu += zhushu; } while(nIndex < 80000); } } else { m_strHaoma.Empty(); wstring strdata; strdata = strHaoMa.GetBuffer(0); //vecAllNums.insert(vecAllNums.begin(),1,strdata); vecAllNums.insert(vecAllNums.begin(),1,strdata); int nCount = m_listChqSSC.GetItemCount(); m_listChqSSC.InsertItem(nCount, strHaoMa); m_listChqSSC.SetItemText(nCount, 1, GetScoreMoshi()); double danzhujine = 2.0; if(theAccount.Scoretype == MoShi_Yuan) { danzhujine = 2.0; } else if (theAccount.Scoretype == MoShi_Jiao) { danzhujine = 0.2; } else if(theAccount.Scoretype == MoShi_Fen) { danzhujine = 0.02; } else if(theAccount.Scoretype == MoShi_Li) danzhujine = 0.002; DOUBLE fJine = 0.0f; fJine = zhushu*m_beishu*danzhujine; CString strZongzhu ; strZongzhu.Format(L"¥%.3lf",fJine); m_listChqSSC.SetItemText(nCount, 2, strZongzhu); m_listChqSSC.SetItemText(nCount, 3, GetWanDesc()); CString strTmp; strTmp.Format(_T("%d"), zhushu); m_listChqSSC.SetItemText(nCount, 4, strTmp); strTmp.Format(_T("%d"), m_beishu); m_listChqSSC.SetItemText(nCount, 5, strTmp); m_listChqSSC.createItemButton(nCount, 6, this->GetSafeHwnd()); CString strMD5Haoma; for(int i = 0;i < vecAllNums.size();i++) { strMD5Haoma += vecAllNums[i].c_str(); strMD5Haoma += L"|"; } memset(m_szMD5Haoma, 0, sizeof(m_szMD5Haoma)); CMD5Encrypt::EncryptData(strMD5Haoma,m_szMD5Haoma); m_zongZhuShu += zhushu; } strHaoMa = _T(""); } int arrLen = strArr.GetCount(); if (arrLen > 0) { int nLen = m_strHaoma.GetLength(); for (int i=0; i<arrLen; i++) { m_strHaoma += strArr.GetAt(i); m_strHaoma += L"|"; } if(m_strHaoma.GetLength()>10240) { //CString strListHaoma = m_listChqSSC.GetItemText(0,0); if((nLen!=0)||(m_zongZhuShu!=0)) { CInformation Information; if(Information.ShowMessageBox(L"温馨提醒",L"本操作将清除已添加号码,请确认",MB_YESNO)==IDYES) { OnBnClickedBtnClsList(); } else { m_DlgStatus.HideStatusWindow(); return ; } } int nCount = m_listChqSSC.GetItemCount(); m_listChqSSC.InsertItem(nCount, L"号码添加成功"); m_listChqSSC.SetItemText(nCount, 1, GetScoreMoshi()); double danzhujine = 2.0; if(theAccount.Scoretype == MoShi_Yuan) { danzhujine = 2.0; } else if (theAccount.Scoretype == MoShi_Jiao) { danzhujine = 0.2; } else if(theAccount.Scoretype == MoShi_Fen) { danzhujine = 0.02; } else if(theAccount.Scoretype == MoShi_Li) danzhujine = 0.002; DOUBLE fJine = 0.0f; m_zongZhuShu += (arrLen*zhushu); fJine = m_zongZhuShu*m_beishu*danzhujine; CString strZongzhu ; strZongzhu.Format(L"¥%.3lf",fJine); m_listChqSSC.SetItemText(nCount, 2, strZongzhu); m_listChqSSC.SetItemText(nCount, 3, GetWanDesc()); CString strTmp; strTmp.Format(_T("%d"), m_zongZhuShu); m_listChqSSC.SetItemText(nCount, 4, strTmp); strTmp.Format(_T("%d"), m_beishu); m_listChqSSC.SetItemText(nCount, 5, strTmp); m_listChqSSC.createItemButton(nCount, 6, this->GetSafeHwnd()); strArr.RemoveAll(); memset(&g_arr, 0, sizeof(g_arr)); memset(&g_nPos, 0, sizeof(g_nPos)); g_Counts=0; } else { m_strHaoma.Empty(); int nCount = m_listChqSSC.GetItemCount(); CString strArrAt; for (int i=0; i<arrLen; i++) { strArrAt = strArr.GetAt(i); m_listChqSSC.InsertItem(nCount+i, strArrAt); m_listChqSSC.SetItemText(nCount+i, 1, GetScoreMoshi()); double danzhujine = 2.0; if(theAccount.Scoretype == MoShi_Yuan) { danzhujine = 2.0; } else if (theAccount.Scoretype == MoShi_Jiao) { danzhujine = 0.2; } else if(theAccount.Scoretype == MoShi_Fen) { danzhujine = 0.02; } else if(theAccount.Scoretype == MoShi_Li) danzhujine = 0.002; DOUBLE fJine = 0.0f; fJine = zhushu*m_beishu*danzhujine; CString strZongzhu ; strZongzhu.Format(L"¥%.3lf",fJine); m_listChqSSC.SetItemText(nCount+i, 2, strZongzhu); m_listChqSSC.SetItemText(nCount+i, 3, GetWanDesc()); CString strTmp; strTmp.Format(_T("%d"), zhushu); m_listChqSSC.SetItemText(nCount+i, 4, strTmp); strTmp.Format(_T("%d"), m_beishu); m_listChqSSC.SetItemText(nCount+i, 5, strTmp); m_listChqSSC.createItemButton(nCount+i, 6, this->GetSafeHwnd()); wstring strdata; strdata = strArrAt.GetBuffer(); vecAllNums.insert(vecAllNums.begin(),1,strdata);//.push_back(strdata); } m_zongZhuShu += (arrLen*zhushu); strArr.RemoveAll(); strArrAt.ReleaseBuffer(); memset(&g_arr, 0, sizeof(g_arr)); memset(&g_nPos, 0, sizeof(g_nPos)); g_Counts=0; } } int nItemCount = m_listChqSSC.GetItemCount(); m_zongJine = 0.00f; for(int i = 0;i < nItemCount;i++) { CString strBeiSHu = m_listChqSSC.GetItemText(i,5); CString strZhuSHu = m_listChqSSC.GetItemText(i,4); CString strMoshi = m_listChqSSC.GetItemText(i,1); int beishu = _ttoi(strBeiSHu); int zhushu = _ttoi(strZhuSHu); int nScoreType = GetMoshiRet(strMoshi); double danzhujine = 2.0; if(nScoreType == MoShi_Yuan) { danzhujine = 2.0; } else if (nScoreType == MoShi_Jiao) { danzhujine = 0.2; } else if(nScoreType == MoShi_Fen) { danzhujine = 0.02; } else if(nScoreType == MoShi_Li) danzhujine = 0.002; m_zongJine += zhushu*beishu*danzhujine; } CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); rcInvali.CopyRect(rcAllZongzhushu); rcInvali.bottom += 20; InvalidateRect(&rcInvali); m_DlgStatus.HideStatusWindow(); ResetAllNums(); } CString CQiXingCai::GetScoreMoshi() { if(theAccount.Scoretype == MoShi_Yuan) { return _T("元"); } else if(theAccount.Scoretype == MoShi_Jiao) { return _T("角"); } else if(theAccount.Scoretype == MoShi_Fen) { return _T("分"); } else if(theAccount.Scoretype == MoShi_Li) { return _T("厘"); } return _T("元"); } int CQiXingCai::GetMoshiRet(CString moshi) { if(moshi == _T("元")) { return MoShi_Yuan; } else if(moshi == _T("角")) { return MoShi_Jiao; } else if(moshi == _T("分")) { return MoShi_Fen; } else if (moshi == _T("厘")) { return MoShi_Li; } return MoShi_Yuan; } //初始化号码按钮 void CQiXingCai::InitNumberBtns() { m_btnWan_0.SetImage(m_numImageList, 0, 10); m_btnWan_1.SetImage(m_numImageList, 1, 10); m_btnWan_2.SetImage(m_numImageList, 2, 10); m_btnWan_3.SetImage(m_numImageList, 3, 10); m_btnWan_4.SetImage(m_numImageList, 4, 10); m_btnWan_5.SetImage(m_numImageList, 5, 10); m_btnWan_6.SetImage(m_numImageList, 6, 10); m_btnWan_7.SetImage(m_numImageList, 7, 10); m_btnWan_8.SetImage(m_numImageList, 8, 10); m_btnWan_9.SetImage(m_numImageList, 9, 10); m_btnQian_0.SetImage(m_numImageList, 0, 10); m_btnQian_1.SetImage(m_numImageList, 1, 10); m_btnQian_2.SetImage(m_numImageList, 2, 10); m_btnQian_3.SetImage(m_numImageList, 3, 10); m_btnQian_4.SetImage(m_numImageList, 4, 10); m_btnQian_5.SetImage(m_numImageList, 5, 10); m_btnQian_6.SetImage(m_numImageList, 6, 10); m_btnQian_7.SetImage(m_numImageList, 7, 10); m_btnQian_8.SetImage(m_numImageList, 8, 10); m_btnQian_9.SetImage(m_numImageList, 9, 10); m_btnBai_0.SetImage(m_numImageList, 0, 10); m_btnBai_1.SetImage(m_numImageList, 1, 10); m_btnBai_2.SetImage(m_numImageList, 2, 10); m_btnBai_3.SetImage(m_numImageList, 3, 10); m_btnBai_4.SetImage(m_numImageList, 4, 10); m_btnBai_5.SetImage(m_numImageList, 5, 10); m_btnBai_6.SetImage(m_numImageList, 6, 10); m_btnBai_7.SetImage(m_numImageList, 7, 10); m_btnBai_8.SetImage(m_numImageList, 8, 10); m_btnBai_9.SetImage(m_numImageList, 9, 10); m_btnShi_0.SetImage(m_numImageList, 0, 10); m_btnShi_1.SetImage(m_numImageList, 1, 10); m_btnShi_2.SetImage(m_numImageList, 2, 10); m_btnShi_3.SetImage(m_numImageList, 3, 10); m_btnShi_4.SetImage(m_numImageList, 4, 10); m_btnShi_5.SetImage(m_numImageList, 5, 10); m_btnShi_6.SetImage(m_numImageList, 6, 10); m_btnShi_7.SetImage(m_numImageList, 7, 10); m_btnShi_8.SetImage(m_numImageList, 8, 10); m_btnShi_9.SetImage(m_numImageList, 9, 10); m_btnGe_0.SetImage(m_numImageList, 0, 10); m_btnGe_1.SetImage(m_numImageList, 1, 10); m_btnGe_2.SetImage(m_numImageList, 2, 10); m_btnGe_3.SetImage(m_numImageList, 3, 10); m_btnGe_4.SetImage(m_numImageList, 4, 10); m_btnGe_5.SetImage(m_numImageList, 5, 10); m_btnGe_6.SetImage(m_numImageList, 6, 10); m_btnGe_7.SetImage(m_numImageList, 7, 10); m_btnGe_8.SetImage(m_numImageList, 8, 10); m_btnGe_9.SetImage(m_numImageList, 9, 10); //m_staticZuXuan.SetImage(m_bmpNumTip, 0, 8); m_staticBuDingWei.SetImage(m_bmpNumTip, 1, 10); m_staticWan.SetImage(m_bmpNumTip, 2, 10); m_staticQian.SetImage(m_bmpNumTip, 3, 10); m_staticBai.SetImage(m_bmpNumTip, 4, 10); m_staticShi.SetImage(m_bmpNumTip, 5, 10); m_staticGe.SetImage(m_bmpNumTip, 6, 10); //m_staticNiu.SetImage(m_bmpNumTip, 7, 8); //m_staticZu120.SetImage(m_bmpNumTip1, 0, 6); //m_staticDanHao.SetImage(m_bmpNumTip1, 1, 6); //m_staticErChong.SetImage(m_bmpNumTip1, 2, 6); //m_staticErChong1.SetImage(m_bmpNumTip1, 2, 6); //m_staticSanChong.SetImage(m_bmpNumTip1, 3, 6); //m_staticSiChong.SetImage(m_bmpNumTip1, 4, 6); //m_staticXuanHao.SetImage(m_bmpNumTip1, 5, 6); //m_btnDaShi.SetImage(m_bmpDxdsh, 0, 4); //m_btnXiaoShi.SetImage(m_bmpDxdsh, 1, 4); //m_btnDanShi.SetImage(m_bmpDxdsh, 2, 4); //m_btnShuangShi.SetImage(m_bmpDxdsh, 3, 4); //m_btnDaGe.SetImage(m_bmpDxdsh, 0, 4); //m_btnXiaoGe.SetImage(m_bmpDxdsh, 1, 4); //m_btnDanGe.SetImage(m_bmpDxdsh, 2, 4); //m_btnShuangGe.SetImage(m_bmpDxdsh, 3, 4); CString numTextBk = CBmpUtil::GetExePath() + _T("skin\\game\\btn_dx.png"); m_btnWanQuan.SetBkImage(numTextBk); m_btnWanDa.SetBkImage(numTextBk); m_btnWanXiao.SetBkImage(numTextBk); m_btnWanDan.SetBkImage(numTextBk); m_btnWanShuang.SetBkImage(numTextBk); m_btnWanQing.SetBkImage(numTextBk); m_btnQianQuan.SetBkImage(numTextBk); m_btnQianDa.SetBkImage(numTextBk); m_btnQianXiao.SetBkImage(numTextBk); m_btnQianDan.SetBkImage(numTextBk); m_btnQianShuang.SetBkImage(numTextBk); m_btnQianQing.SetBkImage(numTextBk); m_btnBaiQuan.SetBkImage(numTextBk); m_btnBaiDa.SetBkImage(numTextBk); m_btnBaiXiao.SetBkImage(numTextBk); m_btnBaiDan.SetBkImage(numTextBk); m_btnBaiShuang.SetBkImage(numTextBk); m_btnBaiQing.SetBkImage(numTextBk); m_btnNiuQuan.SetBkImage(numTextBk); m_btnNiuDa.SetBkImage(numTextBk); m_btnNiuXiao.SetBkImage(numTextBk); m_btnNiuDan.SetBkImage(numTextBk); m_btnNiuShuang.SetBkImage(numTextBk); m_btnNiuQing.SetBkImage(numTextBk); m_btnShiQuan.SetBkImage(numTextBk); m_btnShiDa.SetBkImage(numTextBk); m_btnShiXiao.SetBkImage(numTextBk); m_btnShiDan.SetBkImage(numTextBk); m_btnShiShuang.SetBkImage(numTextBk); m_btnShiQing.SetBkImage(numTextBk); m_btnGeQuan.SetBkImage(numTextBk); m_btnGeDa.SetBkImage(numTextBk); m_btnGeXiao.SetBkImage(numTextBk); m_btnGeDan.SetBkImage(numTextBk); m_btnGeShuang.SetBkImage(numTextBk); m_btnGeQing.SetBkImage(numTextBk); m_btnWanQuan.SetTextColor(RGB(97,76,59)); m_btnWanDa.SetTextColor(RGB(97,76,59)); m_btnWanXiao.SetTextColor(RGB(97,76,59)); m_btnWanDan.SetTextColor(RGB(97,76,59)); m_btnWanShuang.SetTextColor(RGB(97,76,59)); m_btnWanQing.SetTextColor(RGB(97,76,59)); m_btnQianQuan.SetTextColor(RGB(97,76,59)); m_btnQianDa.SetTextColor(RGB(97,76,59)); m_btnQianXiao.SetTextColor(RGB(97,76,59)); m_btnQianDan.SetTextColor(RGB(97,76,59)); m_btnQianShuang.SetTextColor(RGB(97,76,59)); m_btnQianQing.SetTextColor(RGB(97,76,59)); m_btnBaiQuan.SetTextColor(RGB(97,76,59)); m_btnBaiDa.SetTextColor(RGB(97,76,59)); m_btnBaiXiao.SetTextColor(RGB(97,76,59)); m_btnBaiDan.SetTextColor(RGB(97,76,59)); m_btnBaiShuang.SetTextColor(RGB(97,76,59)); m_btnBaiQing.SetTextColor(RGB(97,76,59)); m_btnShiQuan.SetTextColor(RGB(97,76,59)); m_btnShiDa.SetTextColor(RGB(97,76,59)); m_btnShiXiao.SetTextColor(RGB(97,76,59)); m_btnShiDan.SetTextColor(RGB(97,76,59)); m_btnShiShuang.SetTextColor(RGB(97,76,59)); m_btnShiQing.SetTextColor(RGB(97,76,59)); m_btnGeQuan.SetTextColor(RGB(97,76,59)); m_btnGeDa.SetTextColor(RGB(97,76,59)); m_btnGeXiao.SetTextColor(RGB(97,76,59)); m_btnGeDan.SetTextColor(RGB(97,76,59)); m_btnGeShuang.SetTextColor(RGB(97,76,59)); m_btnGeQing.SetTextColor(RGB(97,76,59)); } void CQiXingCai::InitListCtrl() { m_listChqSSC.SetExtendedStyle(m_listChqSSC.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_FLATSB); m_listChqSSC.ModifyStyle(0, LVS_NOCOLUMNHEADER); m_listChqSSC.SetPenColor(RGB(247,233,216)); m_listChqSSC.InsertColumn(0, _T("号码"), LVCFMT_CENTER, 240); m_listChqSSC.InsertColumn(1, _T("模式"), LVCFMT_CENTER, 25); m_listChqSSC.InsertColumn(2, _T("金额"), LVCFMT_CENTER, 95); m_listChqSSC.InsertColumn(3, _T("玩法"), LVCFMT_CENTER, 80); m_listChqSSC.InsertColumn(4, _T("注法"), LVCFMT_CENTER, 55); m_listChqSSC.InsertColumn(5, _T("倍数"), LVCFMT_CENTER, 50); m_listChqSSC.InsertColumn(6, _T("删除"), LVCFMT_CENTER, 31); } //两定玩法 void CQiXingCai::OnBnClickedRioLiangDing() { ResetAllNums(); m_gameKind = QiXingCai_LiangDing; CheckWanFaBtn(m_btnLiangDing); SendToServer(3); SetLockText(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideCtrl(IDC_RIO_MOUSE_INPUT); HideCtrl(IDC_RIO_KEYBOARD_INPUT); HideDaXiaoDanShuang(); HideHeZhiNums(); HideWanNums();//隐藏万 ShowQianNums(); ShowBaiNums(); ShowShiNums(); ShowGeNums(); HideDanShiEdit(); } //三定 void CQiXingCai::OnBnClickedRioSanDing() { ResetAllNums(); m_gameKind = QiXingCai_SanDing; CheckWanFaBtn(m_btnSanDing); SendToServer(3); SetLockText(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideDaXiaoDanShuang(); HideHeZhiNums(); HideWanNums();//隐藏万 ShowQianNums(); ShowBaiNums(); ShowShiNums(); ShowGeNums(); HideDanShiEdit(); } //四定 void CQiXingCai::OnBnClickedRioSiDing() { ResetAllNums(); m_gameKind = QiXingCai_SiDing; CheckWanFaBtn(m_btnSiDing); SendToServer(3); SetLockText(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideDaXiaoDanShuang(); HideHeZhiNums(); HideWanNums();//隐藏万 ShowQianNums(); ShowBaiNums(); ShowShiNums(); ShowGeNums(); HideDanShiEdit(); } //一定 void CQiXingCai::OnBnClickedRioYiDing() { ResetAllNums(); m_gameKind = QiXingCai_YiDing; CheckWanFaBtn(m_btnYiDing); SendToServer(3); SetLockText(); HideNiuNums(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideDaXiaoDanShuang(); HideHeZhiNums(); HideNiuNums(); HideWanNums();//隐藏万 ShowQianNums(); ShowBaiNums(); ShowShiNums(); ShowGeNums(); HideDanShiEdit(); } //两字现 void CQiXingCai::OnBnClickedRioLiangZiXian() { ResetAllNums(); m_gameKind = QiXingCai_LiangZiXian; CheckWanFaBtn(m_btnLiangZiXian); SendToServer(3); SetLockText(); HideNiuNums(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideDaXiaoDanShuang(); HideHeZhiNums(); HideNiuNums(); HideWanNums();//隐藏万 HideQianNums(); ShowBaiNums(); HideShiNums(); HideGeNums(); m_staticBai.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_SHOW); HideDanShiEdit(); } //三字现 void CQiXingCai::OnBnClickedRioSanZiXian() { ResetAllNums(); m_gameKind = QiXingCai_SanZiXian; CheckWanFaBtn(m_btnSanZiXian); SendToServer(3); SetLockText(); HideNiuNums(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideDaXiaoDanShuang(); HideHeZhiNums(); HideNiuNums(); HideWanNums();//隐藏万 HideQianNums(); ShowBaiNums(); HideShiNums(); HideGeNums(); m_staticBai.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_SHOW); HideDanShiEdit(); } //追号 void CQiXingCai::OnBnClickedBtnZhuihao() { if(!CheckInput()) return ; CDlgAddtional dlgZhuiHao; CString strBeishu ; strBeishu.Format(L"%d",m_beishu); dlgZhuiHao.SetCurrentQihaoTime(m_chqRule.GetNextExpect(-1)/* m_kjXinxi[0].qihao*/, strBeishu,4,3, m_zongJine,156,CZ_QiXingCai); if(dlgZhuiHao.DoModal() == IDOK) { //判断是否临近开奖点 long kjing = m_chqRule.GetKjShjDiff(); if (kjing < 60) // || kjing > 540 { MyMessageBox(_T("此期封单,请稍后再试")); return ; } m_nZhuihaoCount = dlgZhuiHao.GetZhuiHaoQiShu(); dlgZhuiHao.GetZhuiHaoData(vecData1, vecData2, vecData3); m_bZhuiZjtz = dlgZhuiHao.GetPrizeStop(); DOUBLE fZongJine = 0.0; for(int i = 0;i < m_nZhuihaoCount;i++) { int nBeishu = _ttoi(vecData1[i].c_str()); fZongJine += m_zongJine*nBeishu; } if(fZongJine > theAccount.yue) { MyMessageBox(_T("您余额不足,请充值后再试")); } else SendToServer(4); } else return; //初始化参数 m_zongZhuShu = 0; m_beishu = 1; //UpdateData(FALSE); OnBnClickedBtnClsList(); CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); } //校验输入 bool CQiXingCai::CheckInput() { if (_tcslen(m_lastExpect) == 0) { MyMessageBox(_T("正在获取数据…… ")); return false; } CString str; m_editBeiTou.GetWindowText(str); if (str.IsEmpty()) { MyMessageBox(_T("投注倍数不可为空")); return false; } int itm_cnt = m_listChqSSC.GetItemCount(); if (m_strHaoma.IsEmpty() && vecAllNums.size()==0) { MyMessageBox(_T("您并未选择号码")); return false; } //判断余额是否充足 if(theAccount.yue < m_zongJine) { MyMessageBox(_T("您余额不足,请充值后再试")); return false; } //判断是否临近开奖点 long kjing = m_chqRule.GetKjShjDiff(); if (kjing < 60) // || kjing > 540 { MyMessageBox(_T("此期封单,请稍后再试")); return false; } return true; } //普通下注 void CQiXingCai::OnBnClickedBtnTouzhu() { CString strHao = m_listChqSSC.GetItemText(0,0); if(strHao.IsEmpty()) { OnBnClickedBtnChqAdd(); } //校验输入 if(!CheckInput()) return; //请用户确认信息 CQrTzhDlg qrDlg; qrDlg.m_gamekind = _T("七星彩"); qrDlg.m_zhushu = m_zongZhuShu * m_beishu; qrDlg.m_moshi = theAccount.Scoretype; if (qrDlg.DoModal() != IDOK) { return; } //判断是否临近开奖点 long kjing = m_chqRule.GetKjShjDiff(); if (kjing < 60) // || kjing > 540 { MyMessageBox(_T("此期封单,请稍后再试")); return ; } bool bSucc = true; int itm_cnt = m_listChqSSC.GetItemCount(); m_nTouzhuCount=0; m_nTouzhuCount = itm_cnt; SendToServer(1); OnBnClickedBtnClsList(); m_zongZhuShu = 0; m_beishu = 1; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); } void CQiXingCai::OnBnClickedBtnDelSel() { if(!m_strHaoma.IsEmpty()) { m_strHaoma.Empty(); } POSITION pos = m_listChqSSC.GetFirstSelectedItemPosition(); if (pos != NULL) { int nItem = m_listChqSSC.GetNextSelectedItem(pos); int zhushu = _ttoi(m_listChqSSC.GetItemText(nItem, 2)); m_zongZhuShu -= zhushu; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); m_listChqSSC.DeleteItem(nItem); if(vecAllNums.size() >0) { vector<wstring>::iterator iter = vecAllNums.begin()+nItem; vecAllNums.erase(iter); } } } void CQiXingCai::OnBnClickedBtnClsList() { m_zongZhuShu = 0; m_zongJine=0; m_listChqSSC.deleteAllItemEx(); vecAllNums.clear(); vecData1.clear(); vecData2.clear(); vecData3.clear(); m_editBeiTou.SetWindowText(L"1"); m_richDanshiHaoma.SetWindowText(L""); m_strHaoma.Empty(); CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); rcInvali.CopyRect(rcAllZongzhushu); rcInvali.bottom += 20; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); } void CQiXingCai::OnEnChangeEditDanshiInput() { //m_editDanShiHaoMa.RedrawWindow(NULL, NULL,RDW_INVALIDATE | RDW_ERASE ); m_richDanshiHaoma.RedrawWindow(NULL, NULL,RDW_INVALIDATE | RDW_ERASE ); } void CQiXingCai::OnEnChangeEditBeishu() { // TODO: 如果该控件是 RICHEDIT 控件,它将不 // 发送此通知,除非重写 CDialog::OnInitDialog() // 函数并调用 CRichEditCtrl().SetEventMask(), // 同时将 ENM_CHANGE 标志“或”运算到掩码中。 // TODO: 在此添加控件通知处理程序代码 CString str; m_editBeiTou.GetWindowText(str); if ( (_ttoi(str) < 1)) { if(!str.IsEmpty()) { MyMessageBox(_T("投注倍数必须是一个正整数")); m_beishu = 1; UpdateData(FALSE); } } else { UpdateData(); GetQXCZhushu(CZ_QiXingCai,m_gameKind); CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); rcInvali.CopyRect(rcAllZongzhushu); rcInvali.bottom += 20; InvalidateRect(&rcInvali); } } void CQiXingCai::CheckNumBtn(CNumerButton& btn) { btn.SetSelect(true); } void CQiXingCai::UnCheckNumBtn(CNumerButton& btn) { btn.SetSelect(false); } bool CQiXingCai::IsNumBtnCheck(CNumerButton& btn) { return btn.IsSelect(); } void CQiXingCai::HideCtrl(int ctrl_id) { CWnd* pWnd = GetDlgItem(ctrl_id); if (pWnd != NULL) { pWnd->ShowWindow(SW_HIDE); } } void CQiXingCai::ShowCtrl(int ctrl_id) { CWnd* pWnd = GetDlgItem(ctrl_id); if (pWnd != NULL) { pWnd->ShowWindow(SW_SHOW); } } void CQiXingCai::HideAllRio() { ////任选2,3,4 //HideCtrl(IDC_RIO_RENXUAN2); //HideCtrl(IDC_RIO_RENXUAN3); //HideCtrl(IDC_RIO_RENXUAN4); ////后三 //HideCtrl(IDC_RIO_HSZHX_FUSHI); //HideCtrl(IDC_RIO_HSZHX_DANSHI); //HideCtrl(IDC_RIO_YFFS); //一帆风顺 //HideCtrl(IDC_RIO_HSCS); //好事成双 //HideCtrl(IDC_RIO_SXBX); //三星报喜 //HideCtrl(IDC_RIO_SJFC); //四季发财 //HideCtrl(IDC_RIO_WXZX); //五星直选 //HideCtrl(IDC_RIO_WXQS); //五星前四 //HideCtrl(IDC_RIO_WXHS); //五星后四 //HideCtrl(IDC_RIO_WXZS); //五星中三 //HideCtrl(IDC_RIO_QS_HEZHI); //五星后四 //HideCtrl(IDC_RIO_HS_HEZHI); //五星中三 //HideCtrl(IDC_RIO_NS); //牛数 //HideCtrl(IDC_RIO_NN); //牛牛 //HideCtrl(IDC_RIO_WN); //无牛 //HideCtrl(IDC_STATIC_NIUNIU_TIP); //牛数 ////前三 //HideCtrl(IDC_RIO_QSZHX_FUSHI); //HideCtrl(IDC_RIO_QSZHX_DANSHI); //HideCtrl(IDC_RIO_HSZS_FUSHI); //HideCtrl(IDC_RIO_HSZS_DANSHI); //HideCtrl(IDC_RIO_HSZL_FUSHI); //HideCtrl(IDC_RIO_HSZL_DANSHI); //HideCtrl(IDC_RIO_QSZS_FUSHI); //HideCtrl(IDC_RIO_QSZS_DANSHI); //HideCtrl(IDC_RIO_QSZL_FUSHI); //HideCtrl(IDC_RIO_QSZL_DANSHI); //HideCtrl(IDC_RIO_ZSZS_FUSHI); //HideCtrl(IDC_RIO_QSZS_DANSHI); //HideCtrl(IDC_RIO_ZSZL_FUSHI); //HideCtrl(IDC_RIO_HEZHX_FUSHI); //HideCtrl(IDC_RIO_HEZHX_DANSHI); //HideCtrl(IDC_RIO_QEZHX_FUSHI); //HideCtrl(IDC_RIO_QEZHX_DANSHI); //HideCtrl(IDC_RIO_HEZX_FUSHI); //HideCtrl(IDC_RIO_HEZX_DANSHI); //HideCtrl(IDC_RIO_QEZX_FUSHI); //HideCtrl(IDC_RIO_QEZX_DANSHI); //HideCtrl(IDC_RIO_ZX_120); //HideCtrl(IDC_RIO_ZX_60); //HideCtrl(IDC_RIO_ZX_30); //HideCtrl(IDC_RIO_ZX_20); //HideCtrl(IDC_RIO_ZX_10); //HideCtrl(IDC_RIO_ZX_5); //HideCtrl(IDC_RIO_YFFS); //HideCtrl(IDC_RIO_HSCS); //HideCtrl(IDC_RIO_SXBX); //HideCtrl(IDC_RIO_SJFC); //HideCtrl(IDC_RIO_QS_HEZHI); //五星后四 //HideCtrl(IDC_RIO_HS_HEZHI); //五星中三 //HideCtrl(IDC_RIO_DXDSH); //HideCtrl(IDC_RIO_HSZHXHZH); //HideCtrl(IDC_RIO_HSBDW); //HideCtrl(IDC_RIO_QSBDW); //HideCtrl(IDC_RIO_HEBDW); //HideCtrl(IDC_RIO_QEBDW); //HideCtrl(IDC_RIO_DWD); //HideCtrl(IDC_RIO_QSHUNHE); //HideCtrl(IDC_RIO_ZSHUNHE); //HideCtrl(IDC_RIO_HSHUNHE); //HideCtrl(IDC_STATIC_HUNHE_TIP); ////这个是鼠标输入OR键盘输入 HideCtrl(IDC_RIO_MOUSE_INPUT); HideCtrl(IDC_RIO_KEYBOARD_INPUT); ////任选2,3,4时,键盘输入的万,千,百,十,个 //HideCtrl(IDC_CHK_WAN); //HideCtrl(IDC_CHK_QIAN); //HideCtrl(IDC_CHK_BAI); //HideCtrl(IDC_CHK_SHI); //HideCtrl(IDC_CHKGE); //HideCtrl(IDC_STATIC_RENXUAN_TIP); } //void CQiXingCai::SelctRadioBtn(int ctrl_id) //{ // CButton* pRadio = (CButton*)GetDlgItem(ctrl_id); // if (pRadio != NULL) // { // pRadio->SetCheck(BST_CHECKED); // } //} CString CQiXingCai::GetNiuString(int nNiu) { CString str; switch(nNiu) { case 0: { str = _T("牛牛"); break; } case 1: { str = _T("牛一"); break; } case 2: { str = _T("牛二"); break; } case 3: { str = _T("牛三"); break; } case 4: { str = _T("牛四"); break; } case 5: { str = _T("牛五"); break; } case 6: { str = _T("牛六"); break; } case 7: { str = _T("牛七"); break; } case 8: { str = _T("牛八"); break; } case 9: { str = _T("牛九"); break; } } return str; } CString CQiXingCai::GetNiuString() { CString str; if (IsNumBtnCheck(m_btnNiu_0)) { str += _T("无牛"); } if (IsNumBtnCheck(m_btnNiu_1)) { str += _T("牛一"); } if (IsNumBtnCheck(m_btnNiu_2)) { str += _T("牛二"); } if (IsNumBtnCheck(m_btnNiu_3)) { str += _T("牛三"); } if (IsNumBtnCheck(m_btnNiu_4)) { str += _T("牛四"); } if (IsNumBtnCheck(m_btnNiu_5)) { str += _T("牛五"); } if (IsNumBtnCheck(m_btnNiu_6)) { str += _T("牛六"); } if (IsNumBtnCheck(m_btnNiu_7)) { str += _T("牛七"); } if (IsNumBtnCheck(m_btnNiu_8)) { str += _T("牛八"); } if (IsNumBtnCheck(m_btnNiu_9)) { str += _T("牛九"); } if (IsNumBtnCheck(m_btnNiu_10)) { str += _T("牛牛"); } return str; } CString CQiXingCai::GetNiuNumString() { CString str; if (IsNumBtnCheck(m_btnNiu_0)) { str += _T("00"); } if (IsNumBtnCheck(m_btnNiu_1)) { str += _T("01"); } if (IsNumBtnCheck(m_btnNiu_2)) { str += _T("02"); } if (IsNumBtnCheck(m_btnNiu_3)) { str += _T("03"); } if (IsNumBtnCheck(m_btnNiu_4)) { str += _T("04"); } if (IsNumBtnCheck(m_btnNiu_5)) { str += _T("05"); } if (IsNumBtnCheck(m_btnNiu_6)) { str += _T("06"); } if (IsNumBtnCheck(m_btnNiu_7)) { str += _T("07"); } if (IsNumBtnCheck(m_btnNiu_8)) { str += _T("08"); } if (IsNumBtnCheck(m_btnNiu_9)) { str += _T("09"); } if (IsNumBtnCheck(m_btnNiu_10)) { str += _T("10"); } return str; } CString CQiXingCai::GetHezhiString() { CString str; if (IsNumBtnCheck(m_btnHeZhi_0)) { str += _T("00"); } if (IsNumBtnCheck(m_btnHeZhi_1)) { str += _T("01"); } if (IsNumBtnCheck(m_btnHeZhi_2)) { str += _T("02"); } if (IsNumBtnCheck(m_btnHeZhi_3)) { str += _T("03"); } if (IsNumBtnCheck(m_btnHeZhi_4)) { str += _T("04"); } if (IsNumBtnCheck(m_btnHeZhi_5)) { str += _T("05"); } if (IsNumBtnCheck(m_btnHeZhi_6)) { str += _T("06"); } if (IsNumBtnCheck(m_btnHeZhi_7)) { str += _T("07"); } if (IsNumBtnCheck(m_btnHeZhi_8)) { str += _T("08"); } if (IsNumBtnCheck(m_btnHeZhi_9)) { str += _T("09"); } if (IsNumBtnCheck(m_btnHeZhi_10)) { str += _T("10"); } if (IsNumBtnCheck(m_btnHeZhi_11)) { str += _T("11"); } if (IsNumBtnCheck(m_btnHeZhi_12)) { str += _T("12"); } if (IsNumBtnCheck(m_btnHeZhi_13)) { str += _T("13"); } if (IsNumBtnCheck(m_btnHeZhi_14)) { str += _T("14"); } if (IsNumBtnCheck(m_btnHeZhi_15)) { str += _T("15"); } if (IsNumBtnCheck(m_btnHeZhi_16)) { str += _T("16"); } if (IsNumBtnCheck(m_btnHeZhi_17)) { str += _T("17"); } if (IsNumBtnCheck(m_btnHeZhi_18)) { str += _T("18"); } if (IsNumBtnCheck(m_btnHeZhi_19)) { str += _T("19"); } if (IsNumBtnCheck(m_btnHeZhi_20)) { str += _T("20"); } if (IsNumBtnCheck(m_btnHeZhi_21)) { str += _T("21"); } if (IsNumBtnCheck(m_btnHeZhi_22)) { str += _T("22"); } if (IsNumBtnCheck(m_btnHeZhi_23)) { str += _T("23"); } if (IsNumBtnCheck(m_btnHeZhi_24)) { str += _T("24"); } if (IsNumBtnCheck(m_btnHeZhi_25)) { str += _T("25"); } if (IsNumBtnCheck(m_btnHeZhi_26)) { str += _T("26"); } if (IsNumBtnCheck(m_btnHeZhi_27)) { str += _T("27"); } return str; } CString CQiXingCai::GetWanString() { CString str; if (IsNumBtnCheck(m_btnWan_0)) { str += _T("0"); } if (IsNumBtnCheck(m_btnWan_1)) { str += _T("1"); } if (IsNumBtnCheck(m_btnWan_2)) { str += _T("2"); } if (IsNumBtnCheck(m_btnWan_3)) { str += _T("3"); } if (IsNumBtnCheck(m_btnWan_4)) { str += _T("4"); } if (IsNumBtnCheck(m_btnWan_5)) { str += _T("5"); } if (IsNumBtnCheck(m_btnWan_6)) { str += _T("6"); } if (IsNumBtnCheck(m_btnWan_7)) { str += _T("7"); } if (IsNumBtnCheck(m_btnWan_8)) { str += _T("8"); } if (IsNumBtnCheck(m_btnWan_9)) { str += _T("9"); } return str; } CString CQiXingCai::GetQianString() { CString str; if (IsNumBtnCheck(m_btnQian_0)) { str += _T("0"); } if (IsNumBtnCheck(m_btnQian_1)) { str += _T("1"); } if (IsNumBtnCheck(m_btnQian_2)) { str += _T("2"); } if (IsNumBtnCheck(m_btnQian_3)) { str += _T("3"); } if (IsNumBtnCheck(m_btnQian_4)) { str += _T("4"); } if (IsNumBtnCheck(m_btnQian_5)) { str += _T("5"); } if (IsNumBtnCheck(m_btnQian_6)) { str += _T("6"); } if (IsNumBtnCheck(m_btnQian_7)) { str += _T("7"); } if (IsNumBtnCheck(m_btnQian_8)) { str += _T("8"); } if (IsNumBtnCheck(m_btnQian_9)) { str += _T("9"); } return str; } CString CQiXingCai::GetBaiString() { CString str; if (IsNumBtnCheck(m_btnBai_0)) { str += _T("0"); } if (IsNumBtnCheck(m_btnBai_1)) { str += _T("1"); } if (IsNumBtnCheck(m_btnBai_2)) { str += _T("2"); } if (IsNumBtnCheck(m_btnBai_3)) { str += _T("3"); } if (IsNumBtnCheck(m_btnBai_4)) { str += _T("4"); } if (IsNumBtnCheck(m_btnBai_5)) { str += _T("5"); } if (IsNumBtnCheck(m_btnBai_6)) { str += _T("6"); } if (IsNumBtnCheck(m_btnBai_7)) { str += _T("7"); } if (IsNumBtnCheck(m_btnBai_8)) { str += _T("8"); } if (IsNumBtnCheck(m_btnBai_9)) { str += _T("9"); } return str; } CString CQiXingCai::GetShiString() { CString str; if (IsNumBtnCheck(m_btnShi_0)) { str += _T("0"); } if (IsNumBtnCheck(m_btnShi_1)) { str += _T("1"); } if (IsNumBtnCheck(m_btnShi_2)) { str += _T("2"); } if (IsNumBtnCheck(m_btnShi_3)) { str += _T("3"); } if (IsNumBtnCheck(m_btnShi_4)) { str += _T("4"); } if (IsNumBtnCheck(m_btnShi_5)) { str += _T("5"); } if (IsNumBtnCheck(m_btnShi_6)) { str += _T("6"); } if (IsNumBtnCheck(m_btnShi_7)) { str += _T("7"); } if (IsNumBtnCheck(m_btnShi_8)) { str += _T("8"); } if (IsNumBtnCheck(m_btnShi_9)) { str += _T("9"); } return str; } CString CQiXingCai::GetGeString() { CString str; if (IsNumBtnCheck(m_btnGe_0)) { str += _T("0"); } if (IsNumBtnCheck(m_btnGe_1)) { str += _T("1"); } if (IsNumBtnCheck(m_btnGe_2)) { str += _T("2"); } if (IsNumBtnCheck(m_btnGe_3)) { str += _T("3"); } if (IsNumBtnCheck(m_btnGe_4)) { str += _T("4"); } if (IsNumBtnCheck(m_btnGe_5)) { str += _T("5"); } if (IsNumBtnCheck(m_btnGe_6)) { str += _T("6"); } if (IsNumBtnCheck(m_btnGe_7)) { str += _T("7"); } if (IsNumBtnCheck(m_btnGe_8)) { str += _T("8"); } if (IsNumBtnCheck(m_btnGe_9)) { str += _T("9"); } return str; } CString CQiXingCai::GetShiDxdshString() { CString strShi; if (IsNumBtnCheck(m_btnDaShi)) { strShi += _T("9"); } if (IsNumBtnCheck(m_btnXiaoShi)) { strShi += _T("1"); } if (IsNumBtnCheck(m_btnDanShi)) { strShi += _T("3"); } if (IsNumBtnCheck(m_btnShuangShi)) { strShi += _T("2"); } return strShi; } CString CQiXingCai::GetGeDxdshString() { CString strGe; if (IsNumBtnCheck(m_btnDaGe)) { strGe += _T("9"); } if (IsNumBtnCheck(m_btnXiaoGe)) { strGe += _T("1"); } if (IsNumBtnCheck(m_btnDanGe)) { strGe += _T("3"); } if (IsNumBtnCheck(m_btnShuangGe)) { strGe += _T("2"); } return strGe; } CString CQiXingCai::GetWanDesc() { return theGameKind[(CZ_QiXingCai << 16) | (unsigned short)m_gameKind]; } QiXingCaiKind CQiXingCai::GetGameKindByDesc(const CString& desc) { if (desc == _T("两定玩法")) { return QiXingCai_LiangDing; } else if (desc == _T("三定玩法")) { return QiXingCai_SanDing; } else if (desc == _T("四定玩法")) { return QiXingCai_SiDing; } else if (desc == _T("两字现")) { return QiXingCai_LiangZiXian; } else if (desc == _T("三字现")) { return QiXingCai_SanZiXian; } return QiXingCai_LiangDing; } void CQiXingCai::AdjustWanFa() { if (m_btnLiangDing.GetSafeHwnd() != NULL) { m_btnLiangDing.SetWindowPos(NULL, wanfa_x, wanfa_y, m_btnLiangDing.Width(), m_btnLiangDing.Height(), SWP_NOZORDER); } if (m_btnYiDing.GetSafeHwnd() != NULL) { m_btnYiDing.SetWindowPos(NULL, wanfa_x + wanfa_col_width*3, wanfa_y, m_btnYiDing.Width(), m_btnYiDing.Height(), SWP_NOZORDER); } if (m_btnSanDing.GetSafeHwnd() != NULL) { m_btnSanDing.SetWindowPos(NULL, wanfa_x + wanfa_col_width/**2*/, wanfa_y /*+ wanfa_row_height*/, m_btnSanDing.Width(), m_btnSanDing.Height(), SWP_NOZORDER); } if (m_btnSiDing.GetSafeHwnd() != NULL) { m_btnSiDing.SetWindowPos(NULL, wanfa_x + wanfa_col_width*2, wanfa_y /*+ wanfa_row_height*/, m_btnSiDing.Width(), m_btnSiDing.Height(), SWP_NOZORDER); } if (m_btnSanZiXian.GetSafeHwnd() != NULL) { m_btnSanZiXian.SetWindowPos(NULL, wanfa_x + wanfa_col_width*5-10*2, wanfa_y/* + wanfa_row_height*/, m_btnSanZiXian.Width(), m_btnSanZiXian.Height(), SWP_NOZORDER); } if (m_btnLiangZiXian.GetSafeHwnd() != NULL) { m_btnLiangZiXian.SetWindowPos(NULL, wanfa_x + wanfa_col_width*4-10, wanfa_y, m_btnLiangZiXian.Width(), m_btnLiangZiXian.Height(), SWP_NOZORDER); } } //调整投注方式 单选框 void CQiXingCai::AdjustRadio() { CWnd *pWnd; ////lly //pWnd = GetDlgItem(IDC_RIO_LIANGDING); //if (pWnd != NULL) //{ // pWnd->SetWindowPos(NULL, wanfa_sel_x, wanfa_sel_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); //} //pWnd = GetDlgItem(IDC_RIO_SANDING); //if (pWnd != NULL) //{ // pWnd->SetWindowPos(NULL, wanfa_sel_x+wanfa_sel_width, wanfa_sel_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); //} //pWnd = GetDlgItem(IDC_RIO_SIDING); //if (pWnd != NULL) //{ // pWnd->SetWindowPos(NULL, wanfa_sel_x+wanfa_sel_width*2, wanfa_sel_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); //} //pWnd = GetDlgItem(IDC_RIO_YIDING); //if (pWnd != NULL) //{ // pWnd->SetWindowPos(NULL, wanfa_sel_x+wanfa_sel_width*3, wanfa_sel_y,wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); //} //pWnd = GetDlgItem(IDC_RIO_LIANGZIXIAN); //if (pWnd != NULL) //{ // pWnd->SetWindowPos(NULL, wanfa_sel_x+wanfa_sel_width*4, wanfa_sel_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); //} //pWnd = GetDlgItem(IDC_RIO_SANZIXIAN); //if (pWnd != NULL) //{ // pWnd->SetWindowPos(NULL, wanfa_sel_x+wanfa_sel_width*5, wanfa_sel_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); //} pWnd = GetDlgItem(IDC_RIO_MOUSE_INPUT); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, mouseinput_x, mouseinput_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); } pWnd = GetDlgItem(IDC_RIO_KEYBOARD_INPUT); if (pWnd != NULL) { pWnd->SetWindowPos(NULL,keyboardinput_x, keyboardinput_y, wanfa_sel_width, wanfa_sel_height, SWP_NOZORDER); } } //投注框:选择数字,5位数字,0--9的选择 void CQiXingCai::AdjustNumBtn() { //和值------------------------------ if(m_btnHeZhi_0.GetSafeHwnd() != NULL) { m_btnHeZhi_0.SetWindowPos(NULL, haoma_btn_x, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_0.Width(), m_btnHeZhi_0.Height(), SWP_NOZORDER); } if(m_btnHeZhi_1.GetSafeHwnd() != NULL) { m_btnHeZhi_1.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_1.Width(), m_btnHeZhi_1.Height(), SWP_NOZORDER); } if(m_btnHeZhi_2.GetSafeHwnd() != NULL) { m_btnHeZhi_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_2.Width(), m_btnHeZhi_2.Height(), SWP_NOZORDER); } if(m_btnHeZhi_3.GetSafeHwnd() != NULL) { m_btnHeZhi_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_3.Width(), m_btnHeZhi_3.Height(), SWP_NOZORDER); } if(m_btnHeZhi_4.GetSafeHwnd() != NULL) { m_btnHeZhi_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_4.Width(), m_btnHeZhi_4.Height(), SWP_NOZORDER); } if(m_btnHeZhi_5.GetSafeHwnd() != NULL) { m_btnHeZhi_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_5.Width(), m_btnHeZhi_5.Height(), SWP_NOZORDER); } if(m_btnHeZhi_6.GetSafeHwnd() != NULL) { m_btnHeZhi_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_6.Width(), m_btnHeZhi_6.Height(), SWP_NOZORDER); } if(m_btnHeZhi_7.GetSafeHwnd() != NULL) { m_btnHeZhi_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_7.Width(), m_btnHeZhi_7.Height(), SWP_NOZORDER); } if(m_btnHeZhi_8.GetSafeHwnd() != NULL) { m_btnHeZhi_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_8.Width(), m_btnHeZhi_8.Height(), SWP_NOZORDER); } if(m_btnHeZhi_9.GetSafeHwnd() != NULL) { m_btnHeZhi_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_9.Width(), m_btnHeZhi_9.Height(), SWP_NOZORDER); } if(m_btnHeZhi_10.GetSafeHwnd() != NULL) { m_btnHeZhi_10.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_10.Width(), m_btnHeZhi_10.Height(), SWP_NOZORDER); } if(m_btnHeZhi_11.GetSafeHwnd() != NULL) { m_btnHeZhi_11.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_11.Width(), m_btnHeZhi_11.Height(), SWP_NOZORDER); } if(m_btnHeZhi_12.GetSafeHwnd() != NULL) { m_btnHeZhi_12.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_12.Width(), m_btnHeZhi_12.Height(), SWP_NOZORDER); } if(m_btnHeZhi_13.GetSafeHwnd() != NULL) { m_btnHeZhi_13.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13, haoma_btn_y+haoma_btn_row_height, m_btnHeZhi_13.Width(), m_btnHeZhi_13.Height(), SWP_NOZORDER); } if(m_btnHeZhi_14.GetSafeHwnd() != NULL) { m_btnHeZhi_14.SetWindowPos(NULL, haoma_btn_x, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_14.Width(), m_btnHeZhi_14.Height(), SWP_NOZORDER); } if(m_btnHeZhi_15.GetSafeHwnd() != NULL) { m_btnHeZhi_15.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_15.Width(), m_btnHeZhi_15.Height(), SWP_NOZORDER); } if(m_btnHeZhi_16.GetSafeHwnd() != NULL) { m_btnHeZhi_16.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_16.Width(), m_btnHeZhi_16.Height(), SWP_NOZORDER); } if(m_btnHeZhi_17.GetSafeHwnd() != NULL) { m_btnHeZhi_17.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_3.Width(), m_btnHeZhi_3.Height(), SWP_NOZORDER); } if(m_btnHeZhi_18.GetSafeHwnd() != NULL) { m_btnHeZhi_18.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_4.Width(), m_btnHeZhi_4.Height(), SWP_NOZORDER); } if(m_btnHeZhi_19.GetSafeHwnd() != NULL) { m_btnHeZhi_19.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_5.Width(), m_btnHeZhi_5.Height(), SWP_NOZORDER); } if(m_btnHeZhi_20.GetSafeHwnd() != NULL) { m_btnHeZhi_20.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_6.Width(), m_btnHeZhi_6.Height(), SWP_NOZORDER); } if(m_btnHeZhi_21.GetSafeHwnd() != NULL) { m_btnHeZhi_21.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_7.Width(), m_btnHeZhi_7.Height(), SWP_NOZORDER); } if(m_btnHeZhi_22.GetSafeHwnd() != NULL) { m_btnHeZhi_22.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_8.Width(), m_btnHeZhi_8.Height(), SWP_NOZORDER); } if(m_btnHeZhi_23.GetSafeHwnd() != NULL) { m_btnHeZhi_23.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_9.Width(), m_btnHeZhi_9.Height(), SWP_NOZORDER); } if(m_btnHeZhi_24.GetSafeHwnd() != NULL) { m_btnHeZhi_24.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_10.Width(), m_btnHeZhi_10.Height(), SWP_NOZORDER); } if(m_btnHeZhi_25.GetSafeHwnd() != NULL) { m_btnHeZhi_25.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_11.Width(), m_btnHeZhi_11.Height(), SWP_NOZORDER); } if(m_btnHeZhi_26.GetSafeHwnd() != NULL) { m_btnHeZhi_26.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_12.Width(), m_btnHeZhi_12.Height(), SWP_NOZORDER); } if(m_btnHeZhi_27.GetSafeHwnd() != NULL) { m_btnHeZhi_27.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13, haoma_btn_y+haoma_btn_row_height*2, m_btnHeZhi_13.Width(), m_btnHeZhi_13.Height(), SWP_NOZORDER); } //牛牛---------------------------- if(m_btnNiu_0.GetSafeHwnd() != NULL) { m_btnNiu_0.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_0.Width(), m_btnNiu_0.Height(), SWP_NOZORDER); } if(m_btnNiu_1.GetSafeHwnd() != NULL) { m_btnNiu_1.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_1.Width(), m_btnNiu_1.Height(), SWP_NOZORDER); } if(m_btnNiu_2.GetSafeHwnd() != NULL) { m_btnNiu_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_2.Width(), m_btnNiu_2.Height(), SWP_NOZORDER); } if(m_btnNiu_3.GetSafeHwnd() != NULL) { m_btnNiu_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_3.Width(), m_btnNiu_3.Height(), SWP_NOZORDER); } if(m_btnNiu_4.GetSafeHwnd() != NULL) { m_btnNiu_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_4.Width(), m_btnNiu_4.Height(), SWP_NOZORDER); } if(m_btnNiu_5.GetSafeHwnd() != NULL) { m_btnNiu_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_5.Width(), m_btnNiu_5.Height(), SWP_NOZORDER); } if(m_btnNiu_6.GetSafeHwnd() != NULL) { m_btnNiu_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_6.Width(), m_btnNiu_6.Height(), SWP_NOZORDER); } if(m_btnNiu_7.GetSafeHwnd() != NULL) { m_btnNiu_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_7.Width(), m_btnNiu_7.Height(), SWP_NOZORDER); } if(m_btnNiu_8.GetSafeHwnd() != NULL) { m_btnNiu_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_8.Width(), m_btnNiu_8.Height(), SWP_NOZORDER); } if(m_btnNiu_9.GetSafeHwnd() != NULL) { m_btnNiu_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_9.Width(), m_btnNiu_9.Height(), SWP_NOZORDER); } if(m_btnNiu_10.GetSafeHwnd() != NULL) { m_btnNiu_10.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9+20, haoma_btn_y + haoma_btn_row_height*2-10, m_btnNiu_10.Width(), m_btnNiu_10.Height(), SWP_NOZORDER); } if (m_btnNiuQuan.GetSafeHwnd() != NULL) { m_btnNiuQuan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10+20*2, haoma_btn_y + haoma_btn_row_height*2, m_btnNiuQuan.Width(), m_btnNiuQuan.Height(), SWP_NOZORDER); } if (m_btnNiuDa.GetSafeHwnd() != NULL) { m_btnNiuDa.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11+20*2, haoma_btn_y + haoma_btn_row_height*2, m_btnNiuDa.Width(), m_btnNiuDa.Height(), SWP_NOZORDER); } if (m_btnNiuXiao.GetSafeHwnd() != NULL) { m_btnNiuXiao.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12+20*2, haoma_btn_y + haoma_btn_row_height*2, m_btnNiuXiao.Width(), m_btnNiuXiao.Height(), SWP_NOZORDER); } if (m_btnNiuDan.GetSafeHwnd() != NULL) { m_btnNiuDan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13+20*2+7, haoma_btn_y + haoma_btn_row_height*2, m_btnNiuDan.Width(), m_btnNiuDan.Height(), SWP_NOZORDER); } if (m_btnNiuShuang.GetSafeHwnd() != NULL) { m_btnNiuShuang.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*14+20*2+7, haoma_btn_y + haoma_btn_row_height*2, m_btnNiuShuang.Width(), m_btnNiuShuang.Height(), SWP_NOZORDER); } if (m_btnNiuQing.GetSafeHwnd() != NULL) { m_btnNiuQing.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*15+20*2+7, haoma_btn_y + haoma_btn_row_height*2, m_btnNiuQing.Width(), m_btnNiuQing.Height(), SWP_NOZORDER); } //万位------------------------------ if (m_staticWan.GetSafeHwnd() != NULL) { m_staticWan.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y, m_staticWan.Width(), m_staticWan.Height(), SWP_NOZORDER); } if(m_btnWan_0.GetSafeHwnd() != NULL) { m_btnWan_0.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y, m_btnWan_0.Width(), m_btnWan_0.Height(), SWP_NOZORDER); } if(m_btnWan_1.GetSafeHwnd() != NULL) { m_btnWan_1.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y, m_btnWan_1.Width(), m_btnWan_1.Height(), SWP_NOZORDER); } if(m_btnWan_2.GetSafeHwnd() != NULL) { m_btnWan_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y, m_btnWan_2.Width(), m_btnWan_2.Height(), SWP_NOZORDER); } if(m_btnWan_3.GetSafeHwnd() != NULL) { m_btnWan_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y, m_btnWan_3.Width(), m_btnWan_3.Height(), SWP_NOZORDER); } if(m_btnWan_4.GetSafeHwnd() != NULL) { m_btnWan_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4+20, haoma_btn_y, m_btnWan_4.Width(), m_btnWan_4.Height(), SWP_NOZORDER); } if(m_btnWan_5.GetSafeHwnd() != NULL) { m_btnWan_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5+20, haoma_btn_y, m_btnWan_5.Width(), m_btnWan_5.Height(), SWP_NOZORDER); } if(m_btnWan_6.GetSafeHwnd() != NULL) { m_btnWan_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6+20, haoma_btn_y, m_btnWan_6.Width(), m_btnWan_6.Height(), SWP_NOZORDER); } if(m_btnWan_7.GetSafeHwnd() != NULL) { m_btnWan_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7+20, haoma_btn_y, m_btnWan_7.Width(), m_btnWan_7.Height(), SWP_NOZORDER); } if(m_btnWan_8.GetSafeHwnd() != NULL) { m_btnWan_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8+20, haoma_btn_y, m_btnWan_8.Width(), m_btnWan_8.Height(), SWP_NOZORDER); } if(m_btnWan_9.GetSafeHwnd() != NULL) { m_btnWan_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9+20, haoma_btn_y, m_btnWan_9.Width(), m_btnWan_9.Height(), SWP_NOZORDER); } if (m_btnWanQuan.GetSafeHwnd() != NULL) { m_btnWanQuan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10+40, haoma_btn_y, m_btnWanQuan.Width(), m_btnWanQuan.Height(), SWP_NOZORDER); } if (m_btnWanDa.GetSafeHwnd() != NULL) { m_btnWanDa.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11+40, haoma_btn_y, m_btnWanDa.Width(), m_btnWanDa.Height(), SWP_NOZORDER); } if (m_btnWanXiao.GetSafeHwnd() != NULL) { m_btnWanXiao.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12+40, haoma_btn_y, m_btnWanXiao.Width(), m_btnWanXiao.Height(), SWP_NOZORDER); } if (m_btnWanDan.GetSafeHwnd() != NULL) { m_btnWanDan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13+47, haoma_btn_y, m_btnWanDan.Width(), m_btnWanDan.Height(), SWP_NOZORDER); } if (m_btnWanShuang.GetSafeHwnd() != NULL) { m_btnWanShuang.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*14+47, haoma_btn_y, m_btnWanShuang.Width(), m_btnWanShuang.Height(), SWP_NOZORDER); } if (m_btnWanQing.GetSafeHwnd() != NULL) { m_btnWanQing.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*15+47, haoma_btn_y, m_btnWanQing.Width(), m_btnWanQing.Height(), SWP_NOZORDER); } //千位------------------------------- if (m_staticQian.GetSafeHwnd() != NULL) { m_staticQian.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height, m_staticQian.Width(), m_staticQian.Height(), SWP_NOZORDER); } if(m_btnQian_0.GetSafeHwnd() != NULL) { m_btnQian_0.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_0.Width(), m_btnQian_0.Height(), SWP_NOZORDER); } if(m_btnQian_1.GetSafeHwnd() != NULL) { m_btnQian_1.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_1.Width(), m_btnQian_1.Height(), SWP_NOZORDER); } if(m_btnQian_2.GetSafeHwnd() != NULL) { m_btnQian_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_2.Width(), m_btnQian_2.Height(), SWP_NOZORDER); } if(m_btnQian_3.GetSafeHwnd() != NULL) { m_btnQian_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_3.Width(), m_btnQian_3.Height(), SWP_NOZORDER); } if(m_btnQian_4.GetSafeHwnd() != NULL) { m_btnQian_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_4.Width(), m_btnQian_4.Height(), SWP_NOZORDER); } if(m_btnQian_5.GetSafeHwnd() != NULL) { m_btnQian_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_5.Width(), m_btnQian_5.Height(), SWP_NOZORDER); } if(m_btnQian_6.GetSafeHwnd() != NULL) { m_btnQian_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_6.Width(), m_btnQian_6.Height(), SWP_NOZORDER); } if(m_btnQian_7.GetSafeHwnd() != NULL) { m_btnQian_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_7.Width(), m_btnQian_7.Height(), SWP_NOZORDER); } if(m_btnQian_8.GetSafeHwnd() != NULL) { m_btnQian_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_8.Width(), m_btnQian_8.Height(), SWP_NOZORDER); } if(m_btnQian_9.GetSafeHwnd() != NULL) { m_btnQian_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9+20, haoma_btn_y + haoma_btn_row_height, m_btnQian_9.Width(), m_btnQian_9.Height(), SWP_NOZORDER); } if (m_btnQianQuan.GetSafeHwnd() != NULL) { m_btnQianQuan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10+40, haoma_btn_y + haoma_btn_row_height, m_btnQianQuan.Width(), m_btnQianQuan.Height(), SWP_NOZORDER); } if (m_btnQianDa.GetSafeHwnd() != NULL) { m_btnQianDa.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11+40, haoma_btn_y + haoma_btn_row_height, m_btnQianDa.Width(), m_btnQianDa.Height(), SWP_NOZORDER); } if (m_btnQianXiao.GetSafeHwnd() != NULL) { m_btnQianXiao.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12+40, haoma_btn_y + haoma_btn_row_height, m_btnQianXiao.Width(), m_btnQianXiao.Height(), SWP_NOZORDER); } if (m_btnQianDan.GetSafeHwnd() != NULL) { m_btnQianDan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13+47, haoma_btn_y + haoma_btn_row_height, m_btnQianDan.Width(), m_btnQianDan.Height(), SWP_NOZORDER); } if (m_btnQianShuang.GetSafeHwnd() != NULL) { m_btnQianShuang.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*14+40+7, haoma_btn_y + haoma_btn_row_height, m_btnQianShuang.Width(), m_btnQianShuang.Height(), SWP_NOZORDER); } if (m_btnQianQing.GetSafeHwnd() != NULL) { m_btnQianQing.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*15+40+7, haoma_btn_y + haoma_btn_row_height, m_btnQianQing.Width(), m_btnQianQing.Height(), SWP_NOZORDER); } //牛牛static if (m_staticNiu.GetSafeHwnd() != NULL) { m_staticNiu.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticNiu.Width(), m_staticNiu.Height(), SWP_NOZORDER); } //百位------------------------------- //组选 if (m_staticZuXuan.GetSafeHwnd() != NULL) { m_staticZuXuan.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticDanHao.GetSafeHwnd() != NULL) { m_staticDanHao.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*3, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticXuanHao.GetSafeHwnd() != NULL) { m_staticXuanHao.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticZu120.GetSafeHwnd() != NULL) { m_staticZu120.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticErChong.GetSafeHwnd() != NULL) { m_staticErChong.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticErChong1.GetSafeHwnd() != NULL) { m_staticErChong1.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*3, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticSanChong.GetSafeHwnd() != NULL) { m_staticSanChong.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticSiChong.GetSafeHwnd() != NULL) { m_staticSiChong.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } //不定位 if (m_staticBuDingWei.GetSafeHwnd() != NULL) { m_staticBuDingWei.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if (m_staticBai.GetSafeHwnd() != NULL) { m_staticBai.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*2, m_staticBai.Width(), m_staticBai.Height(), SWP_NOZORDER); } if(m_btnBai_0.GetSafeHwnd() != NULL) { m_btnBai_0.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_0.Width(), m_btnBai_0.Height(), SWP_NOZORDER); } if(m_btnBai_1.GetSafeHwnd() != NULL) { m_btnBai_1.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_1.Width(), m_btnBai_1.Height(), SWP_NOZORDER); } if(m_btnBai_2.GetSafeHwnd() != NULL) { m_btnBai_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_2.Width(), m_btnBai_2.Height(), SWP_NOZORDER); } if(m_btnBai_3.GetSafeHwnd() != NULL) { m_btnBai_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_3.Width(), m_btnBai_3.Height(), SWP_NOZORDER); } if(m_btnBai_4.GetSafeHwnd() != NULL) { m_btnBai_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_4.Width(), m_btnBai_4.Height(), SWP_NOZORDER); } if(m_btnBai_5.GetSafeHwnd() != NULL) { m_btnBai_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_5.Width(), m_btnBai_5.Height(), SWP_NOZORDER); } if(m_btnBai_6.GetSafeHwnd() != NULL) { m_btnBai_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_6.Width(), m_btnBai_6.Height(), SWP_NOZORDER); } if(m_btnBai_7.GetSafeHwnd() != NULL) { m_btnBai_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_7.Width(), m_btnBai_7.Height(), SWP_NOZORDER); } if(m_btnBai_8.GetSafeHwnd() != NULL) { m_btnBai_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_8.Width(), m_btnBai_8.Height(), SWP_NOZORDER); } if(m_btnBai_9.GetSafeHwnd() != NULL) { m_btnBai_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9+20, haoma_btn_y + haoma_btn_row_height*2, m_btnBai_9.Width(), m_btnBai_9.Height(), SWP_NOZORDER); } if (m_btnBaiQuan.GetSafeHwnd() != NULL) { m_btnBaiQuan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10+20*2, haoma_btn_y + haoma_btn_row_height*2, m_btnBaiQuan.Width(), m_btnBaiQuan.Height(), SWP_NOZORDER); } if (m_btnBaiDa.GetSafeHwnd() != NULL) { m_btnBaiDa.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11+20*2, haoma_btn_y + haoma_btn_row_height*2, m_btnBaiDa.Width(), m_btnBaiDa.Height(), SWP_NOZORDER); } if (m_btnBaiXiao.GetSafeHwnd() != NULL) { m_btnBaiXiao.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12+20*2, haoma_btn_y + haoma_btn_row_height*2, m_btnBaiXiao.Width(), m_btnBaiXiao.Height(), SWP_NOZORDER); } if (m_btnBaiDan.GetSafeHwnd() != NULL) { m_btnBaiDan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13+20*2+7, haoma_btn_y + haoma_btn_row_height*2, m_btnBaiDan.Width(), m_btnBaiDan.Height(), SWP_NOZORDER); } if (m_btnBaiShuang.GetSafeHwnd() != NULL) { m_btnBaiShuang.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*14+20*2+7, haoma_btn_y + haoma_btn_row_height*2, m_btnBaiShuang.Width(), m_btnBaiShuang.Height(), SWP_NOZORDER); } if (m_btnBaiQing.GetSafeHwnd() != NULL) { m_btnBaiQing.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*15+20*2+7, haoma_btn_y + haoma_btn_row_height*2, m_btnBaiQing.Width(), m_btnBaiQing.Height(), SWP_NOZORDER); } //大小单双 if(m_btnDaShi.GetSafeHwnd() != NULL) { m_btnDaShi.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*3, m_btnDaShi.Width(), m_btnDaShi.Height(), SWP_NOZORDER); } if(m_btnXiaoShi.GetSafeHwnd() != NULL) { m_btnXiaoShi.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height*3, m_btnXiaoShi.Width(), m_btnXiaoShi.Height(), SWP_NOZORDER); } if(m_btnDanShi.GetSafeHwnd() != NULL) { m_btnDanShi.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height*3, m_btnDanShi.Width(), m_btnDanShi.Height(), SWP_NOZORDER); } if(m_btnShuangShi.GetSafeHwnd() != NULL) { m_btnShuangShi.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShuangShi.Width(), m_btnShuangShi.Height(), SWP_NOZORDER); } //十位------------------------------- if (m_staticShi.GetSafeHwnd() != NULL) { m_staticShi.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*3, m_staticShi.Width(), m_staticShi.Height(), SWP_NOZORDER); } if(m_btnShi_0.GetSafeHwnd() != NULL) { m_btnShi_0.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_0.Width(), m_btnShi_0.Height(), SWP_NOZORDER); } if(m_btnShi_1.GetSafeHwnd() != NULL) { m_btnShi_1.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_1.Width(), m_btnShi_1.Height(), SWP_NOZORDER); } if(m_btnShi_2.GetSafeHwnd() != NULL) { m_btnShi_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_2.Width(), m_btnShi_2.Height(), SWP_NOZORDER); } if(m_btnShi_3.GetSafeHwnd() != NULL) { m_btnShi_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_3.Width(), m_btnShi_3.Height(), SWP_NOZORDER); } if(m_btnShi_4.GetSafeHwnd() != NULL) { m_btnShi_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_4.Width(), m_btnShi_4.Height(), SWP_NOZORDER); } if(m_btnShi_5.GetSafeHwnd() != NULL) { m_btnShi_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_5.Width(), m_btnShi_5.Height(), SWP_NOZORDER); } if(m_btnShi_6.GetSafeHwnd() != NULL) { m_btnShi_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_6.Width(), m_btnShi_6.Height(), SWP_NOZORDER); } if(m_btnShi_7.GetSafeHwnd() != NULL) { m_btnShi_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_7.Width(), m_btnShi_7.Height(), SWP_NOZORDER); } if(m_btnShi_8.GetSafeHwnd() != NULL) { m_btnShi_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_8.Width(), m_btnShi_8.Height(), SWP_NOZORDER); } if(m_btnShi_9.GetSafeHwnd() != NULL) { m_btnShi_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9+20, haoma_btn_y + haoma_btn_row_height*3, m_btnShi_9.Width(), m_btnShi_9.Height(), SWP_NOZORDER); } if (m_btnShiQuan.GetSafeHwnd() != NULL) { m_btnShiQuan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10+20*2, haoma_btn_y + haoma_btn_row_height*3, m_btnShiQuan.Width(), m_btnShiQuan.Height(), SWP_NOZORDER); } if (m_btnShiDa.GetSafeHwnd() != NULL) { m_btnShiDa.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11+20*2, haoma_btn_y + haoma_btn_row_height*3, m_btnShiDa.Width(), m_btnShiDa.Height(), SWP_NOZORDER); } if (m_btnShiXiao.GetSafeHwnd() != NULL) { m_btnShiXiao.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12+20*2, haoma_btn_y + haoma_btn_row_height*3, m_btnShiXiao.Width(), m_btnShiXiao.Height(), SWP_NOZORDER); } if (m_btnShiDan.GetSafeHwnd() != NULL) { m_btnShiDan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13+20*2+7, haoma_btn_y + haoma_btn_row_height*3, m_btnShiDan.Width(), m_btnShiDan.Height(), SWP_NOZORDER); } if (m_btnShiShuang.GetSafeHwnd() != NULL) { m_btnShiShuang.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*14+20*2+7, haoma_btn_y + haoma_btn_row_height*3, m_btnShiShuang.Width(), m_btnShiShuang.Height(), SWP_NOZORDER); } if (m_btnShiQing.GetSafeHwnd() != NULL) { m_btnShiQing.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*15+20*2+7, haoma_btn_y + haoma_btn_row_height*3, m_btnShiQing.Width(), m_btnShiQing.Height(), SWP_NOZORDER); } //大小单双 if(m_btnDaGe.GetSafeHwnd() != NULL) { m_btnDaGe.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*4, m_btnDaGe.Width(), m_btnDaGe.Height(), SWP_NOZORDER); } if(m_btnXiaoGe.GetSafeHwnd() != NULL) { m_btnXiaoGe.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height*4, m_btnXiaoGe.Width(), m_btnXiaoGe.Height(), SWP_NOZORDER); } if(m_btnDanGe.GetSafeHwnd() != NULL) { m_btnDanGe.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height*4, m_btnDanGe.Width(), m_btnDanGe.Height(), SWP_NOZORDER); } if(m_btnShuangGe.GetSafeHwnd() != NULL) { m_btnShuangGe.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height*4, m_btnShuangGe.Width(), m_btnShuangGe.Height(), SWP_NOZORDER); } //个位------------------------------- if (m_staticGe.GetSafeHwnd() != NULL) { m_staticGe.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y + haoma_btn_row_height*4, m_staticGe.Width(), m_staticGe.Height(), SWP_NOZORDER); } if(m_btnGe_0.GetSafeHwnd() != NULL) { m_btnGe_0.SetWindowPos(NULL, haoma_btn_x+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_0.Width(), m_btnGe_0.Height(), SWP_NOZORDER); } if(m_btnGe_1.GetSafeHwnd() != NULL) { m_btnGe_1.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_1.Width(), m_btnGe_1.Height(), SWP_NOZORDER); } if(m_btnGe_2.GetSafeHwnd() != NULL) { m_btnGe_2.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*2+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_2.Width(), m_btnGe_2.Height(), SWP_NOZORDER); } if(m_btnGe_3.GetSafeHwnd() != NULL) { m_btnGe_3.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*3+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_3.Width(), m_btnGe_3.Height(), SWP_NOZORDER); } if(m_btnGe_4.GetSafeHwnd() != NULL) { m_btnGe_4.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*4+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_4.Width(), m_btnGe_4.Height(), SWP_NOZORDER); } if(m_btnGe_5.GetSafeHwnd() != NULL) { m_btnGe_5.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*5+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_5.Width(), m_btnGe_5.Height(), SWP_NOZORDER); } if(m_btnGe_6.GetSafeHwnd() != NULL) { m_btnGe_6.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*6+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_6.Width(), m_btnGe_6.Height(), SWP_NOZORDER); } if(m_btnGe_7.GetSafeHwnd() != NULL) { m_btnGe_7.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*7+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_7.Width(), m_btnGe_7.Height(), SWP_NOZORDER); } if(m_btnGe_8.GetSafeHwnd() != NULL) { m_btnGe_8.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*8+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_8.Width(), m_btnGe_8.Height(), SWP_NOZORDER); } if(m_btnGe_9.GetSafeHwnd() != NULL) { m_btnGe_9.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*9+20, haoma_btn_y + haoma_btn_row_height*4, m_btnGe_9.Width(), m_btnGe_9.Height(), SWP_NOZORDER); } if (m_btnGeQuan.GetSafeHwnd() != NULL) { m_btnGeQuan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*10+20*2, haoma_btn_y + haoma_btn_row_height*4, m_btnGeQuan.Width(), m_btnGeQuan.Height(), SWP_NOZORDER); } if (m_btnGeDa.GetSafeHwnd() != NULL) { m_btnGeDa.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*11+20*2, haoma_btn_y + haoma_btn_row_height*4, m_btnGeDa.Width(), m_btnGeDa.Height(), SWP_NOZORDER); } if (m_btnGeXiao.GetSafeHwnd() != NULL) { m_btnGeXiao.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*12+20*2, haoma_btn_y + haoma_btn_row_height*4, m_btnGeXiao.Width(), m_btnGeXiao.Height(), SWP_NOZORDER); } if (m_btnGeDan.GetSafeHwnd() != NULL) { m_btnGeDan.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*13+20*2+7, haoma_btn_y + haoma_btn_row_height*4, m_btnGeDan.Width(), m_btnGeDan.Height(), SWP_NOZORDER); } if (m_btnGeShuang.GetSafeHwnd() != NULL) { m_btnGeShuang.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*14+20*2+7, haoma_btn_y + haoma_btn_row_height*4, m_btnGeShuang.Width(), m_btnGeShuang.Height(), SWP_NOZORDER); } if (m_btnGeQing.GetSafeHwnd() != NULL) { m_btnGeQing.SetWindowPos(NULL, haoma_btn_x + haoma_btn_col_wdith*15+20*2+7, haoma_btn_y + haoma_btn_row_height*4, m_btnGeQing.Width(), m_btnGeQing.Height(), SWP_NOZORDER); } } //按钮调整:删除,清零,倍投,投注,追号 void CQiXingCai::AdjustNumView() { if(m_btnBeiTouJia.GetSafeHwnd() != NULL) { m_btnBeiTouJia.SetWindowPos(NULL,edit_beitou_x+edit_beitou_width , edit_beitou_y-8, m_btnBeiTouJia.Width(), m_btnBeiTouJia.Height(), SWP_NOZORDER); } if(m_btnBeiTouJian.GetSafeHwnd() != NULL) { m_btnBeiTouJian.SetWindowPos(NULL,edit_beitou_x-m_btnBeiTouJian.Width() , edit_beitou_y-8, m_btnBeiTouJian.Width(), m_btnBeiTouJian.Height(), SWP_NOZORDER); } if(m_btnDelSel.GetSafeHwnd() != NULL) { m_btnDelSel.SetWindowPos(NULL, btn_del_sel_x, btn_del_sel_y, m_btnDelSel.Width(), m_btnDelSel.Height(), SWP_NOZORDER); m_btnDelSel.ShowWindow(SW_HIDE); } if(m_btnClsList.GetSafeHwnd() != NULL) { m_btnClsList.SetWindowPos(NULL, btn_cls_list_x, btn_cls_list_y, m_btnClsList.Width(), m_btnClsList.Height(), SWP_NOZORDER); } if (m_listChqSSC.GetSafeHwnd() != NULL) { m_listChqSSC.SetWindowPos(NULL, list_haomao_x, list_haomao_y, list_haomao_width, list_haomao_height, SWP_NOZORDER); } if(m_editBeiTou.GetSafeHwnd() != NULL) { m_editBeiTou.SetWindowPos(NULL, edit_beitou_x, edit_beitou_y, edit_beitou_width, edit_beitou_height, SWP_NOZORDER); } if(m_btnTouZhu.GetSafeHwnd() != NULL) { m_btnTouZhu.SetWindowPos(NULL, btn_touzhu_x, btn_touzhu_y, m_btnTouZhu.Width(), m_btnTouZhu.Height(), SWP_NOZORDER); } if(m_btnZhuiHao.GetSafeHwnd() != NULL) { m_btnZhuiHao.SetWindowPos(NULL, btn_zhuihao_x, btn_zhuihao_y, m_btnZhuiHao.Width(), m_btnZhuiHao.Height(), SWP_NOZORDER); } if(m_btnMoreRecord.GetSafeHwnd() != NULL) { m_btnMoreRecord.SetWindowPos(NULL, btn_more_x, btn_more_y, m_btnMoreRecord.Width(), m_btnMoreRecord.Height(), SWP_NOZORDER); } } //单式调整 void CQiXingCai::AdjustDanShi() { //if (m_staticDanShi.GetSafeHwnd() != NULL) //{ // m_staticDanShi.SetWindowPos(NULL, haoma_tip_x, haoma_tip_y, m_staticDanShi.Width(), m_staticDanShi.Height(), SWP_NOZORDER); //} //if (m_editDanShiHaoMa.GetSafeHwnd() != NULL) //{ // m_editDanShiHaoMa.SetWindowPos(NULL, edit_haomao_danshi_x, edit_haomao_danshi_y, edit_haomao_danshi_width, edit_haomao_danshi_height, SWP_NOZORDER); //} if (m_richDanshiHaoma.GetSafeHwnd() != NULL) { m_richDanshiHaoma.SetWindowPos(NULL, edit_haomao_danshi_x, edit_haomao_danshi_y, edit_haomao_danshi_width, edit_haomao_danshi_height, SWP_NOZORDER); } CWnd* pWnd = GetDlgItem(IDC_CHK_WAN); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, edit_haomao_danshi_x, edit_haomao_danshi_y-24, 45, wanfa_sel_height, SWP_NOZORDER); } pWnd = GetDlgItem(IDC_CHK_QIAN); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, edit_haomao_danshi_x+60, edit_haomao_danshi_y-24, 45, wanfa_sel_height, SWP_NOZORDER); } pWnd = GetDlgItem(IDC_CHK_BAI); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, edit_haomao_danshi_x+120, edit_haomao_danshi_y-24, 45, wanfa_sel_height, SWP_NOZORDER); } pWnd = GetDlgItem(IDC_CHK_SHI); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, edit_haomao_danshi_x+180, edit_haomao_danshi_y-24, 45, wanfa_sel_height, SWP_NOZORDER); } pWnd = GetDlgItem(IDC_CHKGE); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, edit_haomao_danshi_x+240, edit_haomao_danshi_y-24, 45, wanfa_sel_height, SWP_NOZORDER); } pWnd = GetDlgItem(IDC_STATIC_RENXUAN_TIP); if (pWnd != NULL) { pWnd->SetWindowPos(NULL, edit_haomao_danshi_x+300, edit_haomao_danshi_y-24, 300, wanfa_sel_height, SWP_NOZORDER); } } //加注按钮 void CQiXingCai::AdjustAdd() { if (m_btnChqAdd.GetSafeHwnd() != NULL) { m_btnChqAdd.SetWindowPos(NULL, btn_chq_add_x, btn_chq_add_y, m_btnChqAdd.Width(), m_btnChqAdd.Height(), SWP_NOZORDER); } if (m_btnLock.GetSafeHwnd() != NULL) { m_btnLock.SetWindowPos(NULL, btn_lock_x, btn_lock_y, m_btnLock.Width(), m_btnLock.Height(), SWP_NOZORDER); } if(m_btnYuan.GetSafeHwnd() != NULL) { m_btnYuan.SetWindowPos(NULL,btn_yuan_x,btn_yuan_y,m_btnYuan.Width(),m_btnYuan.Height(),SWP_NOZORDER); } if(m_btnJiao.GetSafeHwnd() != NULL) { m_btnJiao.SetWindowPos(NULL,btn_jiao_x,btn_jiao_y,m_btnJiao.Width(),m_btnJiao.Height(),SWP_NOZORDER); } if(m_btnFen.GetSafeHwnd() != NULL) { m_btnFen.SetWindowPos(NULL,btn_fen_x,btn_fen_y,m_btnFen.Width(),m_btnFen.Height(),SWP_NOZORDER); } if(m_btnLi.GetSafeHwnd() != NULL) { m_btnLi.SetWindowPos(NULL,btn_li_x,btn_li_y,m_btnLi.Width(),m_btnLi.Height(),SWP_NOZORDER); } } void CQiXingCai::HideHeZhiNums() { m_btnHeZhi_0.ShowWindow(SW_HIDE); m_btnHeZhi_1.ShowWindow(SW_HIDE); m_btnHeZhi_2.ShowWindow(SW_HIDE); m_btnHeZhi_3.ShowWindow(SW_HIDE); m_btnHeZhi_4.ShowWindow(SW_HIDE); m_btnHeZhi_5.ShowWindow(SW_HIDE); m_btnHeZhi_6.ShowWindow(SW_HIDE); m_btnHeZhi_7.ShowWindow(SW_HIDE); m_btnHeZhi_8.ShowWindow(SW_HIDE); m_btnHeZhi_9.ShowWindow(SW_HIDE); m_btnHeZhi_10.ShowWindow(SW_HIDE); m_btnHeZhi_11.ShowWindow(SW_HIDE); m_btnHeZhi_12.ShowWindow(SW_HIDE); m_btnHeZhi_13.ShowWindow(SW_HIDE); m_btnHeZhi_14.ShowWindow(SW_HIDE); m_btnHeZhi_15.ShowWindow(SW_HIDE); m_btnHeZhi_16.ShowWindow(SW_HIDE); m_btnHeZhi_17.ShowWindow(SW_HIDE); m_btnHeZhi_18.ShowWindow(SW_HIDE); m_btnHeZhi_19.ShowWindow(SW_HIDE); m_btnHeZhi_20.ShowWindow(SW_HIDE); m_btnHeZhi_21.ShowWindow(SW_HIDE); m_btnHeZhi_22.ShowWindow(SW_HIDE); m_btnHeZhi_23.ShowWindow(SW_HIDE); m_btnHeZhi_24.ShowWindow(SW_HIDE); m_btnHeZhi_25.ShowWindow(SW_HIDE); m_btnHeZhi_26.ShowWindow(SW_HIDE); m_btnHeZhi_27.ShowWindow(SW_HIDE); } void CQiXingCai::ShowHeZhiNums() { m_btnHeZhi_0.ShowWindow(SW_SHOW); m_btnHeZhi_1.ShowWindow(SW_SHOW); m_btnHeZhi_2.ShowWindow(SW_SHOW); m_btnHeZhi_3.ShowWindow(SW_SHOW); m_btnHeZhi_4.ShowWindow(SW_SHOW); m_btnHeZhi_5.ShowWindow(SW_SHOW); m_btnHeZhi_6.ShowWindow(SW_SHOW); m_btnHeZhi_7.ShowWindow(SW_SHOW); m_btnHeZhi_8.ShowWindow(SW_SHOW); m_btnHeZhi_9.ShowWindow(SW_SHOW); m_btnHeZhi_10.ShowWindow(SW_SHOW); m_btnHeZhi_11.ShowWindow(SW_SHOW); m_btnHeZhi_12.ShowWindow(SW_SHOW); m_btnHeZhi_13.ShowWindow(SW_SHOW); m_btnHeZhi_14.ShowWindow(SW_SHOW); m_btnHeZhi_15.ShowWindow(SW_SHOW); m_btnHeZhi_16.ShowWindow(SW_SHOW); m_btnHeZhi_17.ShowWindow(SW_SHOW); m_btnHeZhi_18.ShowWindow(SW_SHOW); m_btnHeZhi_19.ShowWindow(SW_SHOW); m_btnHeZhi_20.ShowWindow(SW_SHOW); m_btnHeZhi_21.ShowWindow(SW_SHOW); m_btnHeZhi_22.ShowWindow(SW_SHOW); m_btnHeZhi_23.ShowWindow(SW_SHOW); m_btnHeZhi_24.ShowWindow(SW_SHOW); m_btnHeZhi_25.ShowWindow(SW_SHOW); m_btnHeZhi_26.ShowWindow(SW_SHOW); m_btnHeZhi_27.ShowWindow(SW_SHOW); } void CQiXingCai::HideWanNums() { m_btnWan_0.ShowWindow(SW_HIDE); m_btnWan_1.ShowWindow(SW_HIDE); m_btnWan_2.ShowWindow(SW_HIDE); m_btnWan_3.ShowWindow(SW_HIDE); m_btnWan_4.ShowWindow(SW_HIDE); m_btnWan_5.ShowWindow(SW_HIDE); m_btnWan_6.ShowWindow(SW_HIDE); m_btnWan_7.ShowWindow(SW_HIDE); m_btnWan_8.ShowWindow(SW_HIDE); m_btnWan_9.ShowWindow(SW_HIDE); m_staticWan.ShowWindow(SW_HIDE); m_btnWanQuan.ShowWindow(SW_HIDE); m_btnWanDa.ShowWindow(SW_HIDE); m_btnWanXiao.ShowWindow(SW_HIDE); m_btnWanDan.ShowWindow(SW_HIDE); m_btnWanShuang.ShowWindow(SW_HIDE); m_btnWanQing.ShowWindow(SW_HIDE); } void CQiXingCai::HideQianNums() { m_btnQian_0.ShowWindow(SW_HIDE); m_btnQian_1.ShowWindow(SW_HIDE); m_btnQian_2.ShowWindow(SW_HIDE); m_btnQian_3.ShowWindow(SW_HIDE); m_btnQian_4.ShowWindow(SW_HIDE); m_btnQian_5.ShowWindow(SW_HIDE); m_btnQian_6.ShowWindow(SW_HIDE); m_btnQian_7.ShowWindow(SW_HIDE); m_btnQian_8.ShowWindow(SW_HIDE); m_btnQian_9.ShowWindow(SW_HIDE); m_staticQian.ShowWindow(SW_HIDE); m_btnQianQuan.ShowWindow(SW_HIDE); m_btnQianDa.ShowWindow(SW_HIDE); m_btnQianXiao.ShowWindow(SW_HIDE); m_btnQianDan.ShowWindow(SW_HIDE); m_btnQianShuang.ShowWindow(SW_HIDE); m_btnQianQing.ShowWindow(SW_HIDE); } void CQiXingCai::HideBaiNums() { m_btnBai_0.ShowWindow(SW_HIDE); m_btnBai_1.ShowWindow(SW_HIDE); m_btnBai_2.ShowWindow(SW_HIDE); m_btnBai_3.ShowWindow(SW_HIDE); m_btnBai_4.ShowWindow(SW_HIDE); m_btnBai_5.ShowWindow(SW_HIDE); m_btnBai_6.ShowWindow(SW_HIDE); m_btnBai_7.ShowWindow(SW_HIDE); m_btnBai_8.ShowWindow(SW_HIDE); m_btnBai_9.ShowWindow(SW_HIDE); m_staticZuXuan.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticErChong1.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); m_btnBaiQuan.ShowWindow(SW_HIDE); m_btnBaiDa.ShowWindow(SW_HIDE); m_btnBaiXiao.ShowWindow(SW_HIDE); m_btnBaiDan.ShowWindow(SW_HIDE); m_btnBaiShuang.ShowWindow(SW_HIDE); m_btnBaiQing.ShowWindow(SW_HIDE); } void CQiXingCai::HideShiNums() { m_btnShi_0.ShowWindow(SW_HIDE); m_btnShi_1.ShowWindow(SW_HIDE); m_btnShi_2.ShowWindow(SW_HIDE); m_btnShi_3.ShowWindow(SW_HIDE); m_btnShi_4.ShowWindow(SW_HIDE); m_btnShi_5.ShowWindow(SW_HIDE); m_btnShi_6.ShowWindow(SW_HIDE); m_btnShi_7.ShowWindow(SW_HIDE); m_btnShi_8.ShowWindow(SW_HIDE); m_btnShi_9.ShowWindow(SW_HIDE); m_staticShi.ShowWindow(SW_HIDE); m_staticDanHao.ShowWindow(SW_HIDE); m_btnShiQuan.ShowWindow(SW_HIDE); m_btnShiDa.ShowWindow(SW_HIDE); m_btnShiXiao.ShowWindow(SW_HIDE); m_btnShiDan.ShowWindow(SW_HIDE); m_btnShiShuang.ShowWindow(SW_HIDE); m_btnShiQing.ShowWindow(SW_HIDE); } void CQiXingCai::HideGeNums() { m_btnGe_0.ShowWindow(SW_HIDE); m_btnGe_1.ShowWindow(SW_HIDE); m_btnGe_2.ShowWindow(SW_HIDE); m_btnGe_3.ShowWindow(SW_HIDE); m_btnGe_4.ShowWindow(SW_HIDE); m_btnGe_5.ShowWindow(SW_HIDE); m_btnGe_6.ShowWindow(SW_HIDE); m_btnGe_7.ShowWindow(SW_HIDE); m_btnGe_8.ShowWindow(SW_HIDE); m_btnGe_9.ShowWindow(SW_HIDE); m_staticGe.ShowWindow(SW_HIDE); m_btnGeQuan.ShowWindow(SW_HIDE); m_btnGeDa.ShowWindow(SW_HIDE); m_btnGeXiao.ShowWindow(SW_HIDE); m_btnGeDan.ShowWindow(SW_HIDE); m_btnGeShuang.ShowWindow(SW_HIDE); m_btnGeQing.ShowWindow(SW_HIDE); } void CQiXingCai::ShowWanNums() { m_btnWan_0.ShowWindow(SW_SHOW); m_btnWan_1.ShowWindow(SW_SHOW); m_btnWan_2.ShowWindow(SW_SHOW); m_btnWan_3.ShowWindow(SW_SHOW); m_btnWan_4.ShowWindow(SW_SHOW); m_btnWan_5.ShowWindow(SW_SHOW); m_btnWan_6.ShowWindow(SW_SHOW); m_btnWan_7.ShowWindow(SW_SHOW); m_btnWan_8.ShowWindow(SW_SHOW); m_btnWan_9.ShowWindow(SW_SHOW); m_staticWan.ShowWindow(SW_SHOW); m_btnWanQuan.ShowWindow(SW_SHOW); m_btnWanDa.ShowWindow(SW_SHOW); m_btnWanXiao.ShowWindow(SW_SHOW); m_btnWanDan.ShowWindow(SW_SHOW); m_btnWanShuang.ShowWindow(SW_SHOW); m_btnWanQing.ShowWindow(SW_SHOW); } void CQiXingCai::ShowNiuNums() { m_btnNiu_1.ShowWindow(SW_SHOW); m_btnNiu_2.ShowWindow(SW_SHOW); m_btnNiu_3.ShowWindow(SW_SHOW); m_btnNiu_4.ShowWindow(SW_SHOW); m_btnNiu_5.ShowWindow(SW_SHOW); m_btnNiu_6.ShowWindow(SW_SHOW); m_btnNiu_7.ShowWindow(SW_SHOW); m_btnNiu_8.ShowWindow(SW_SHOW); m_btnNiu_9.ShowWindow(SW_SHOW); m_btnNiu_10.ShowWindow(SW_SHOW); m_staticNiu.ShowWindow(SW_SHOW); m_btnNiuQuan.ShowWindow(SW_SHOW); m_btnNiuDa.ShowWindow(SW_SHOW); m_btnNiuXiao.ShowWindow(SW_SHOW); m_btnNiuDan.ShowWindow(SW_SHOW); m_btnNiuShuang.ShowWindow(SW_SHOW); m_btnNiuQing.ShowWindow(SW_SHOW); } void CQiXingCai::HideNiuNums() { m_btnNiu_0.ShowWindow(SW_HIDE); m_btnNiu_1.ShowWindow(SW_HIDE); m_btnNiu_2.ShowWindow(SW_HIDE); m_btnNiu_3.ShowWindow(SW_HIDE); m_btnNiu_4.ShowWindow(SW_HIDE); m_btnNiu_5.ShowWindow(SW_HIDE); m_btnNiu_6.ShowWindow(SW_HIDE); m_btnNiu_7.ShowWindow(SW_HIDE); m_btnNiu_8.ShowWindow(SW_HIDE); m_btnNiu_9.ShowWindow(SW_HIDE); m_btnNiu_10.ShowWindow(SW_HIDE); m_staticNiu.ShowWindow(SW_HIDE); m_btnNiuQuan.ShowWindow(SW_HIDE); m_btnNiuDa.ShowWindow(SW_HIDE); m_btnNiuXiao.ShowWindow(SW_HIDE); m_btnNiuDan.ShowWindow(SW_HIDE); m_btnNiuShuang.ShowWindow(SW_HIDE); m_btnNiuQing.ShowWindow(SW_HIDE); } void CQiXingCai::ShowQianNums() { m_btnQian_0.ShowWindow(SW_SHOW); m_btnQian_1.ShowWindow(SW_SHOW); m_btnQian_2.ShowWindow(SW_SHOW); m_btnQian_3.ShowWindow(SW_SHOW); m_btnQian_4.ShowWindow(SW_SHOW); m_btnQian_5.ShowWindow(SW_SHOW); m_btnQian_6.ShowWindow(SW_SHOW); m_btnQian_7.ShowWindow(SW_SHOW); m_btnQian_8.ShowWindow(SW_SHOW); m_btnQian_9.ShowWindow(SW_SHOW); m_staticQian.ShowWindow(SW_SHOW); m_btnQianQuan.ShowWindow(SW_SHOW); m_btnQianDa.ShowWindow(SW_SHOW); m_btnQianXiao.ShowWindow(SW_SHOW); m_btnQianDan.ShowWindow(SW_SHOW); m_btnQianShuang.ShowWindow(SW_SHOW); m_btnQianQing.ShowWindow(SW_SHOW); } void CQiXingCai::ShowBaiNums() { m_btnBai_0.ShowWindow(SW_SHOW); m_btnBai_1.ShowWindow(SW_SHOW); m_btnBai_2.ShowWindow(SW_SHOW); m_btnBai_3.ShowWindow(SW_SHOW); m_btnBai_4.ShowWindow(SW_SHOW); m_btnBai_5.ShowWindow(SW_SHOW); m_btnBai_6.ShowWindow(SW_SHOW); m_btnBai_7.ShowWindow(SW_SHOW); m_btnBai_8.ShowWindow(SW_SHOW); m_btnBai_9.ShowWindow(SW_SHOW); m_staticZuXuan.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_SHOW); m_staticErChong.ShowWindow(SW_HIDE); m_staticErChong1.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); m_btnBaiQuan.ShowWindow(SW_SHOW); m_btnBaiDa.ShowWindow(SW_SHOW); m_btnBaiXiao.ShowWindow(SW_SHOW); m_btnBaiDan.ShowWindow(SW_SHOW); m_btnBaiShuang.ShowWindow(SW_SHOW); m_btnBaiQing.ShowWindow(SW_SHOW); } void CQiXingCai::ShowShiNums() { m_btnShi_0.ShowWindow(SW_SHOW); m_btnShi_1.ShowWindow(SW_SHOW); m_btnShi_2.ShowWindow(SW_SHOW); m_btnShi_3.ShowWindow(SW_SHOW); m_btnShi_4.ShowWindow(SW_SHOW); m_btnShi_5.ShowWindow(SW_SHOW); m_btnShi_6.ShowWindow(SW_SHOW); m_btnShi_7.ShowWindow(SW_SHOW); m_btnShi_8.ShowWindow(SW_SHOW); m_btnShi_9.ShowWindow(SW_SHOW); m_staticShi.ShowWindow(SW_SHOW); m_staticDanHao.ShowWindow(SW_HIDE); m_btnShiQuan.ShowWindow(SW_SHOW); m_btnShiDa.ShowWindow(SW_SHOW); m_btnShiXiao.ShowWindow(SW_SHOW); m_btnShiDan.ShowWindow(SW_SHOW); m_btnShiShuang.ShowWindow(SW_SHOW); m_btnShiQing.ShowWindow(SW_SHOW); m_staticErChong1.ShowWindow(SW_HIDE); } void CQiXingCai::ShowGeNums() { m_btnGe_0.ShowWindow(SW_SHOW); m_btnGe_1.ShowWindow(SW_SHOW); m_btnGe_2.ShowWindow(SW_SHOW); m_btnGe_3.ShowWindow(SW_SHOW); m_btnGe_4.ShowWindow(SW_SHOW); m_btnGe_5.ShowWindow(SW_SHOW); m_btnGe_6.ShowWindow(SW_SHOW); m_btnGe_7.ShowWindow(SW_SHOW); m_btnGe_8.ShowWindow(SW_SHOW); m_btnGe_9.ShowWindow(SW_SHOW); m_staticGe.ShowWindow(SW_SHOW); m_btnGeQuan.ShowWindow(SW_SHOW); m_btnGeDa.ShowWindow(SW_SHOW); m_btnGeXiao.ShowWindow(SW_SHOW); m_btnGeDan.ShowWindow(SW_SHOW); m_btnGeShuang.ShowWindow(SW_SHOW); m_btnGeQing.ShowWindow(SW_SHOW); } void CQiXingCai::ShowZuXuan() { m_staticZuXuan.ShowWindow(SW_SHOW); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_HIDE); } void CQiXingCai::ShowDanHao() { m_staticDanHao.ShowWindow(SW_SHOW); m_staticShi.ShowWindow(SW_HIDE); m_staticErChong1.ShowWindow(SW_HIDE); } void CQiXingCai::ShowErChong1() { m_staticDanHao.ShowWindow(SW_HIDE); m_staticShi.ShowWindow(SW_HIDE); m_staticErChong1.ShowWindow(SW_SHOW); } void CQiXingCai::ShowXuanHao() { m_staticZuXuan.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_SHOW); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); } void CQiXingCai::ShowZu120() { m_staticZuXuan.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_SHOW); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); } // void CQiXingCai::HideZuXuan() // { // m_staticZuXuan.ShowWindow(SW_HIDE); // m_staticBuDingWei.ShowWindow(SW_HIDE); // m_staticBai.ShowWindow(SW_HIDE); // } void CQiXingCai::ShowBuDingWei() { m_staticZuXuan.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_SHOW); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); } void CQiXingCai::ShowErChong() { m_staticZuXuan.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_SHOW); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_HIDE); } void CQiXingCai::ShowSanChong() { m_staticZuXuan.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_SHOW); m_staticSiChong.ShowWindow(SW_HIDE); } void CQiXingCai::ShowSiChong() { m_staticZuXuan.ShowWindow(SW_HIDE); m_staticXuanHao.ShowWindow(SW_HIDE); m_staticZu120.ShowWindow(SW_HIDE); m_staticBuDingWei.ShowWindow(SW_HIDE); m_staticBai.ShowWindow(SW_HIDE); m_staticErChong.ShowWindow(SW_HIDE); m_staticSanChong.ShowWindow(SW_HIDE); m_staticSiChong.ShowWindow(SW_SHOW); } void CQiXingCai::ShowDaXiaoDanShuang() { m_staticShi.ShowWindow(SW_SHOW); m_staticGe.ShowWindow(SW_SHOW); m_btnDaShi.ShowWindow(SW_SHOW); m_btnXiaoShi.ShowWindow(SW_SHOW); m_btnDanShi.ShowWindow(SW_SHOW); m_btnShuangShi.ShowWindow(SW_SHOW); m_btnDaGe.ShowWindow(SW_SHOW); m_btnXiaoGe.ShowWindow(SW_SHOW); m_btnDanGe.ShowWindow(SW_SHOW); m_btnShuangGe.ShowWindow(SW_SHOW); } void CQiXingCai::HideDaXiaoDanShuang() { m_btnDaShi.ShowWindow(SW_HIDE); m_btnXiaoShi.ShowWindow(SW_HIDE); m_btnDanShi.ShowWindow(SW_HIDE); m_btnShuangShi.ShowWindow(SW_HIDE); m_btnDaGe.ShowWindow(SW_HIDE); m_btnXiaoGe.ShowWindow(SW_HIDE); m_btnDanGe.ShowWindow(SW_HIDE); m_btnShuangGe.ShowWindow(SW_HIDE); } void CQiXingCai::HideDanShiEdit() { m_RenxuanKeyboardInput = false; //m_editDanShiHaoMa.ShowWindow(SW_HIDE); m_richDanshiHaoma.ShowWindow(SW_HIDE); } void CQiXingCai::ShowDanShiEdit() { m_RenxuanKeyboardInput = true; m_richDanshiHaoma.ShowWindow(SW_SHOW); // m_editDanShiHaoMa.ShowWindow(SW_SHOW); } //任选当中的万,千,百,十,个位数 void CQiXingCai::ShowRenxuanWeiShu() { CButton* pBtn = (CButton*)GetDlgItem(IDC_CHK_WAN); if(pBtn) pBtn->ShowWindow(SW_SHOW); pBtn = (CButton*)GetDlgItem(IDC_CHK_QIAN); if(pBtn) pBtn->ShowWindow(SW_SHOW); pBtn = (CButton*)GetDlgItem(IDC_CHK_BAI); if(pBtn) pBtn->ShowWindow(SW_SHOW); pBtn = (CButton*)GetDlgItem(IDC_CHK_SHI); if(pBtn) pBtn->ShowWindow(SW_SHOW); pBtn = (CButton*)GetDlgItem(IDC_CHKGE); if(pBtn) pBtn->ShowWindow(SW_SHOW); CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_RENXUAN_TIP); if(pStatic) pStatic->ShowWindow(SW_SHOW); SetCheckRenXuan(false); } void CQiXingCai::HideRenxuanWeiShu() { CButton* pBtn = (CButton*)GetDlgItem(IDC_CHK_WAN); if(pBtn) pBtn->ShowWindow(SW_HIDE); pBtn = (CButton*)GetDlgItem(IDC_CHK_QIAN); if(pBtn) pBtn->ShowWindow(SW_HIDE); pBtn = (CButton*)GetDlgItem(IDC_CHK_BAI); if(pBtn) pBtn->ShowWindow(SW_HIDE); pBtn = (CButton*)GetDlgItem(IDC_CHK_SHI); if(pBtn) pBtn->ShowWindow(SW_HIDE); pBtn = (CButton*)GetDlgItem(IDC_CHKGE); if(pBtn) pBtn->ShowWindow(SW_HIDE); CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_RENXUAN_TIP); if(pStatic) pStatic->ShowWindow(SW_HIDE); SetCheckRenXuan(false); } void CQiXingCai::CheckWanFaBtn(CTextButton& btn) { m_btnLiangDing.SetPushed(false); m_btnYiDing.SetPushed(false); m_btnSanDing.SetPushed(false); m_btnSiDing.SetPushed(false); m_btnSanZiXian.SetPushed(false); m_btnLiangZiXian.SetPushed(false); btn.SetPushed(true); } VOID CQiXingCai::SendQuerySystemTime() { return; } VOID CQiXingCai::SendToServer(int nSendType) { if(nSendType == 1) { m_bTouzhu = true; if(m_bTouzhu) { m_bTouzhu = false; m_strHaoma.Empty(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int itm_cnt = m_listChqSSC.GetItemCount(); int nNowKind = 10000; int nNowBeishu = 100000; int nNowMoshi = 10000; CString strTouZhuhaoma; map<int,int> mapHaoma; mapHaoma.clear(); for(int i = 0;i < itm_cnt;i++) { strTouZhuhaoma.Empty(); CString haoma = m_listChqSSC.GetItemText(i,0); if(haoma == _T("号码添加成功")) continue; CString strWanfa = m_listChqSSC.GetItemText(i, 3); CString strBeishu = m_listChqSSC.GetItemText(i, 5); CString strMoshi = m_listChqSSC.GetItemText(i, 1); int nKind = GetGameKindByDesc(strWanfa); int nBeishu = _ttoi(strBeishu); int nMoshi = GetMoshiRet(strMoshi); if(nNowKind == nKind && nNowBeishu == nBeishu && nNowMoshi == nMoshi && nNowMoshi!= 10000 && nNowBeishu != 100000 && nNowKind != 10000&&nNowKind != SSC_LongHu) continue; bool bContinue = false; for (map<int,int>::iterator pos = mapHaoma.begin(); pos != mapHaoma.end();++pos) { if(i == pos->second) { bContinue = true; break; } } if(bContinue) continue; nNowBeishu = nBeishu; nNowKind = nKind; nNowMoshi = nMoshi; int nZhushu = 0; for(int j = i;j<itm_cnt;j++) { haoma = m_listChqSSC.GetItemText(j,0); if(haoma == _T("号码添加成功")) continue; CString wanfa = m_listChqSSC.GetItemText(j, 3); int kind = GetGameKindByDesc(wanfa); CString sbeishu = m_listChqSSC.GetItemText(j, 5); int beishu = _ttoi(sbeishu); CString sMoshi = m_listChqSSC.GetItemText(j, 1); int scoremoshi = 0; scoremoshi = GetMoshiRet(sMoshi); if (kind == nNowKind && beishu == nNowBeishu && scoremoshi == nNowMoshi) { CString strZhu = m_listChqSSC.GetItemText(j, 4); nZhushu += _ttoi(strZhu); int nSize = mapHaoma.size(); mapHaoma[nSize] = j; CString haoma = m_listChqSSC.GetItemText(j, 0); strTouZhuhaoma+= haoma; if(haoma[haoma.GetLength()-1] != '|') strTouZhuhaoma+=TEXT("|"); } } int nSendCount = 0; int nEnd = 1; CMD_GP_TouZhuCQSSC_Dan TouzhuCQSSC; ZeroMemory(&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Dan)); TouzhuCQSSC.dwUserID = theAccount.user_id; TouzhuCQSSC.nBeitou = nNowBeishu; TouzhuCQSSC.nGameKind = nNowKind; TouzhuCQSSC.nGameType = CZ_QiXingCai; TouzhuCQSSC.nMoshi = nNowMoshi; TouzhuCQSSC.nSign = m_nTzhSign; // CString strQiHao; CString strQiHao = m_chqRule.GetNextExpect(); string strAllHaoma; ChangeStringToA(strTouZhuhaoma, strAllHaoma); string strQi; ChangeStringToA(strQiHao, strQi); memcpy(TouzhuCQSSC.strQishu ,strQi.c_str(),strQi.length()); if(strTouZhuhaoma.IsEmpty()) { m_DlgStatus.HideStatusWindow(); MyMessageBox(L"你还未选择号码,请选择!"); return ; } byte pDestBuffer[102400]; int nLen = CWHService::LZCompressData((byte*)strAllHaoma.c_str(), strAllHaoma.length(), pDestBuffer, sizeof(pDestBuffer)); int nSendSize = 0; TouzhuCQSSC.nEnd = 1; if(m_zongZhuShu<=0) { m_DlgStatus.HideStatusWindow(); OnBnClickedBtnClsList(); return; } TouzhuCQSSC.nZhushu = nZhushu; int nSize = sizeof(TouzhuCQSSC.strHaoma); DWORD dwTick=GetTickCount(); int nHaoMaLen = 0; nHaoMaLen = min(nSize,nLen-nSendSize); TouzhuCQSSC.nHaoMaLen = nHaoMaLen; //nLen; TouzhuCQSSC.nIndex = nSendCount; memset(TouzhuCQSSC.strHaoma, 0, sizeof(TouzhuCQSSC.strHaoma)); memcpy((byte*)TouzhuCQSSC.strHaoma, pDestBuffer+nSendSize, nSize); if(nSendSize + nSize >= nLen) TouzhuCQSSC.nEnd = 0; CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); bool bSuccess = pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_TOUZHU_CQSSC_DAN,&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Dan)); m_bShowFail=true; nSendSize += nHaoMaLen; nSendCount++; m_bCanSend = true; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // for(int i = 0;i < vecAllNums.size();i++) // { // m_strHaoma += vecAllNums[i].c_str(); // m_strHaoma += L"|"; // } // if(m_strHaoma.GetLength()>1024) // { // m_DlgStatus.ShowStatusWindow(TEXT("正在提交数据,请稍候...")); // } /* int nSendCount = 0; int nEnd = 1; CMD_GP_TouZhuCQSSC_Dan TouzhuCQSSC; ZeroMemory(&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Dan)); TouzhuCQSSC.dwUserID = theAccount.user_id; TouzhuCQSSC.nBeitou = m_beishu; TouzhuCQSSC.nGameKind = m_gameKind; TouzhuCQSSC.nGameType = CZ_QiXingCai; TouzhuCQSSC.nMoshi = theAccount.Scoretype; TouzhuCQSSC.nSign = m_nTzhSign; CString strQiHao = m_chqRule.GetNextExpect(); string strAllHaoma; ChangeStringToA(m_strHaoma, strAllHaoma); //int itm_cnt = strAllHaoma.length(); if (m_gameKind == 0) { AfxGetMainWnd()->MessageBox(L"kindId = 0"); } string strQi; ChangeStringToA(strQiHao, strQi); memcpy(TouzhuCQSSC.strQishu ,strQi.c_str(),strQi.length()); if(m_strHaoma.IsEmpty()) { m_DlgStatus.HideStatusWindow(); MyMessageBox(L"你还未选择号码,请选择!"); return ; } byte pDestBuffer[102400]; int nLen = CWHService::LZCompressData((byte*)strAllHaoma.c_str(), strAllHaoma.length(), pDestBuffer, sizeof(pDestBuffer)); int nSendSize = 0; TouzhuCQSSC.nEnd = 1; if(m_zongZhuShu<=0) { m_DlgStatus.HideStatusWindow(); OnBnClickedBtnClsList(); return; } TouzhuCQSSC.nZhushu = m_zongZhuShu; int nSize = sizeof(TouzhuCQSSC.strHaoma); DWORD dwTick=GetTickCount(); while (nSendSize < nLen) { while ((GetTickCount() - dwTick ) < 30000) { MSG msg; if(GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } if(m_bCanSend) break; } int nHaoMaLen = 0; nHaoMaLen = min(nSize,nLen-nSendSize); TouzhuCQSSC.nHaoMaLen = nHaoMaLen; //nLen; TouzhuCQSSC.nIndex = nSendCount; memset(TouzhuCQSSC.strHaoma, 0, sizeof(TouzhuCQSSC.strHaoma)); memcpy((byte*)TouzhuCQSSC.strHaoma, pDestBuffer+nSendSize, nSize); if(nSendSize + nSize >= nLen) TouzhuCQSSC.nEnd = 0; CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); bool bSuccess = pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_TOUZHU_CQSSC_DAN,&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Dan)); m_bShowFail=true; nSendSize += nHaoMaLen; m_bCanSend = false; nSendCount++; } */ m_bCanSend = true; m_nTzhSign++; SetTimer(TimerStatus,60000,NULL); // m_strHaoma = _T(""); OnBnClickedBtnClsList(); } return; } if(nSendType == 2) //没用 { m_bGetCPUserInfo = true; return; } if(nSendType == 3) { m_btnLock.SetWindowText(mapFandian[m_gameKind]); m_btWxzxTip.ShowWindow(SW_HIDE); if(m_gameKind == QiXingCai_LiangDing) { m_ToolTipCtrl.AddTool(&m_btWxzxTip,TEXT("")); } OnBnClickedBtnClsList(); m_bGetUserFandian = true; m_zongZhuShu = 0; m_editBeiTou.SetWindowText(L"1"); m_beishu=1; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return; } if(nSendType == 4) { m_bZhuihao = true; if(m_bZhuihao) { m_bZhuihao = false; m_DlgStatus.ShowStatusWindow(TEXT("正在提交数据,请稍候...")); //if(m_RenxuanKeyboardInput/*&&m_strHaoma.GetLength() >10240*/) /* { if(m_strHaoma.IsEmpty() && vecAllNums.size()>0) { for(int i = 0;i < vecAllNums.size();i++) { m_strHaoma += vecAllNums[i].c_str(); m_strHaoma += L"|"; } } //for(int n=0; n< vecData2.size(); n++) { int nSendCount = 0; int nEnd = 1; CMD_GP_TouZhuCQSSC_Zhuihao TouzhuCQSSC; ZeroMemory(&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Zhuihao)); TouzhuCQSSC.dwUserID = theAccount.user_id; TouzhuCQSSC.nGameKind = m_gameKind; TouzhuCQSSC.nGameType = CZ_QiXingCai; TouzhuCQSSC.nMoshi = theAccount.Scoretype; TouzhuCQSSC.nSign = m_nTzhSign; if(m_bZhuiZjtz) TouzhuCQSSC.bZhuihao = GetTickCount(); else TouzhuCQSSC.bZhuihao = 2; if(m_strHaoma.IsEmpty()) { m_DlgStatus.HideStatusWindow(); MyMessageBox(L"你还未选择号码,请选择!"); OnBnClickedBtnClsList(); return ; } string strAllHaoma; ChangeStringToA(m_strHaoma, strAllHaoma); memset(TouzhuCQSSC.strQishu,0,sizeof(TouzhuCQSSC.strQishu)); string sNowQi; ChangeStringToA(m_chqRule.GetNextExpect(),sNowQi); for(int n=0; n< vecData2.size(); n++) { string strQi; ChangeStringToA(vecData2[n].c_str(),strQi); if(strQi < sNowQi) { MyMessageBox(L"订单期号有误!可能原因,该期已经停止投注!"); OnBnClickedBtnClsList(); m_DlgStatus.HideStatusWindow(); return ; } memcpy(TouzhuCQSSC.strQishu[n],strQi.c_str(),strQi.length()); TouzhuCQSSC.nBeitou[n] = _ttoi(vecData1[n].c_str());; } byte pDestBuffer[102400]; int nLen = CWHService::LZCompressData((byte*)strAllHaoma.c_str(), strAllHaoma.length(), pDestBuffer, sizeof(pDestBuffer)); int nSendSize = 0; TouzhuCQSSC.nEnd = 1; if(m_zongZhuShu<=0) { m_DlgStatus.HideStatusWindow(); OnBnClickedBtnClsList(); return; } TouzhuCQSSC.nZhushu = m_zongZhuShu; int nSize = sizeof(TouzhuCQSSC.strHaoma); DWORD dwTick=GetTickCount(); while (nSendSize < nLen) { while ((GetTickCount() - dwTick ) < 30000) { MSG msg; if(GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } if(m_bCanSend) break; } int nHaoMaLen = 0; nHaoMaLen = min(nSize,nLen-nSendSize); TouzhuCQSSC.nHaoMaLen = nHaoMaLen; //nLen; TouzhuCQSSC.nIndex = nSendCount; memset(TouzhuCQSSC.strHaoma, 0, sizeof(TouzhuCQSSC.strHaoma)); memcpy((byte*)TouzhuCQSSC.strHaoma, pDestBuffer+nSendSize, nSize); if(nSendSize + nSize >= nLen) TouzhuCQSSC.nEnd = 0; CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); bool bSuccess = pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_TOUZHU_CQSSC_ZHUIHAO,&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Zhuihao)); m_bShowFail=true; nSendSize += nHaoMaLen; m_bCanSend = false; nSendCount++; } } } */ if(m_strHaoma.IsEmpty() && vecAllNums.size()>0) { for(int i = 0;i < vecAllNums.size();i++) { m_strHaoma += vecAllNums[i].c_str(); m_strHaoma += L"|"; } } int nSel = m_listChqSSC.GetSelectionMark(); if(nSel<0) nSel = 0; int nItemCount = m_listChqSSC.GetItemCount(); CMD_GP_TouZhuCQSSC_Zhuihao TouzhuCQSSC; ZeroMemory(&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Zhuihao)); TouzhuCQSSC.dwUserID = theAccount.user_id; TouzhuCQSSC.nGameType = CZ_QiXingCai; TouzhuCQSSC.nSign = m_nTzhSign; if(m_bZhuiZjtz) TouzhuCQSSC.bZhuihao = GetTickCount(); else TouzhuCQSSC.bZhuihao = 2; for(int n=0; n< nItemCount; n++) { int nSendCount = 0; int nEnd = 1; CString wanfa = m_listChqSSC.GetItemText(n, 3); int kind = GetGameKindByDesc(wanfa); TouzhuCQSSC.nGameKind = kind; CString moshi = m_listChqSSC.GetItemText(n, 1); int nScoreType = GetMoshiRet(moshi); TouzhuCQSSC.nMoshi = nScoreType; m_strHaoma = vecAllNums[nItemCount-n-1].c_str(); if(m_strHaoma.IsEmpty()) { m_DlgStatus.HideStatusWindow(); MyMessageBox(L"你还未选择号码,请选择!"); OnBnClickedBtnClsList(); return ; } if(m_strHaoma[m_strHaoma.GetLength()-1] != '|') m_strHaoma+=TEXT("|"); string strAllHaoma; ChangeStringToA(m_strHaoma, strAllHaoma); memset(TouzhuCQSSC.strQishu,0,sizeof(TouzhuCQSSC.strQishu)); CString strQiHao; // if(m_TypeID == CZChongQingSSC) // strQiHao = m_chqRule.GetNextExpect(); // else if(m_TypeID == CZ_TianJinSSC) // strQiHao = m_jxRule.GetNextExpect(); // else if(m_TypeID == CZXinJiangSSC) // strQiHao = m_xjRule.GetNextExpect(); // else if(m_TypeID == CZ_FENFEN_CAI) // strQiHao = m_ffcRule.GetNextExpect(); // else if(m_TypeID == CZ_WUFEN_CAI) strQiHao = m_chqRule.GetNextExpect(); string sNowQi; ChangeStringToA(strQiHao,sNowQi); for(int o=0; o< vecData2.size(); o++) { string strQi; ChangeStringToA(vecData2[o].c_str(),strQi); if(strQi < sNowQi) { MyMessageBox(L"订单期号有误!可能原因,该期已经停止投注!"); OnBnClickedBtnClsList(); m_DlgStatus.HideStatusWindow(); return ; } memcpy(TouzhuCQSSC.strQishu[o],strQi.c_str(),strQi.length()); TouzhuCQSSC.nBeitou[o] = _ttoi(vecData1[o].c_str());; } byte pDestBuffer[102400]; int nLen = CWHService::LZCompressData((byte*)strAllHaoma.c_str(), strAllHaoma.length(), pDestBuffer, sizeof(pDestBuffer)); int nSendSize = 0; TouzhuCQSSC.nEnd = 1; if(m_zongZhuShu<=0) { m_DlgStatus.HideStatusWindow(); OnBnClickedBtnClsList(); return; } int nZhushu = 0; CString strZhu = m_listChqSSC.GetItemText(n, 4); nZhushu += _ttoi(strZhu); TouzhuCQSSC.nZhushu = nZhushu; int nSize = sizeof(TouzhuCQSSC.strHaoma); DWORD dwTick=GetTickCount(); while (nSendSize < nLen) { while ((GetTickCount() - dwTick ) < 30000) { MSG msg; if(GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } if(m_bCanSend) break; } int nHaoMaLen = 0; nHaoMaLen = min(nSize,nLen-nSendSize); TouzhuCQSSC.nHaoMaLen = nHaoMaLen; //nLen; TouzhuCQSSC.nIndex = nSendCount; memset(TouzhuCQSSC.strHaoma, 0, sizeof(TouzhuCQSSC.strHaoma)); memcpy((byte*)TouzhuCQSSC.strHaoma, pDestBuffer+nSendSize, nSize); if(nSendSize + nSize >= nLen) TouzhuCQSSC.nEnd = 0; CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); bool bSuccess = pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_TOUZHU_CQSSC_ZHUIHAO,&TouzhuCQSSC,sizeof(CMD_GP_TouZhuCQSSC_Zhuihao)); m_bShowFail=true; nSendSize += nHaoMaLen; m_bCanSend = false; nSendCount++; } } m_nTzhSign++; SetTimer(TimerStatus,60000,NULL); m_strHaoma = _T(""); OnBnClickedBtnClsList(); } return; } if(nSendType == 5) { m_bSetBonus = true; if(m_bSetBonus) { m_bSetBonus=false; CMD_GP_SetUserBonus SetUserBonus; ZeroMemory(&SetUserBonus,sizeof(SetUserBonus)); SetUserBonus.n_t_userid = theAccount.user_id; SetUserBonus.n_t_type_id = CZ_QiXingCai; SetUserBonus.n_t_kind_id = m_gameKind; SetUserBonus.f_t_bonus = m_fBonus; SetUserBonus.f_bonuspercent = m_fPercent; //发送数据 CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_SET_USER_BONUS,&SetUserBonus,sizeof(SetUserBonus)); } return; } if(nSendType == 6) { m_bGetUserFandian = true; //m_btnLock.EnableTextButton(true); if(m_bGetUserFandian) { m_bGetUserFandian=false; CMD_GP_GetUserFandian GetUserFandian; ZeroMemory(&GetUserFandian,sizeof(GetUserFandian)); GetUserFandian.n_t_userid = theAccount.user_id; GetUserFandian.n_t_type_id = CZ_QiXingCai; GetUserFandian.n_t_kind_id = m_gameKind; //发送数据 CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_GET_USER_FANDIAN,&GetUserFandian,sizeof(GetUserFandian)); } return; } if(nSendType == 7) { // m_bGetLastYue =true; // if(m_bGetLastYue) // { // m_bGetLastYue = false; // CMD_GP_GetLastYue GetLastYue; // ZeroMemory(&GetLastYue,sizeof(GetLastYue)); // // GetLastYue.dwUserID = theAccount.user_id; // // CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); // pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_GET_LAST_YUE,&GetLastYue,sizeof(GetLastYue)); // } return; } if(nSendType == 8) { CMD_GP_GetMoreRecord GetMoreRecord; ZeroMemory(&GetMoreRecord,sizeof(GetMoreRecord)); GetMoreRecord.n_t_type = CZ_QiXingCai; CPlatformFrame *pPlatformFrame = CPlatformFrame::GetInstance(); pPlatformFrame->m_MissionManager.SendData(MDM_GP_USER_SERVICE,SUB_GP_GET_MORE_RECORD,&GetMoreRecord,sizeof(GetMoreRecord)); return; } } VOID CQiXingCai::SendQueryLuckyNumCQSSC() { return; } //服务器端返回前N个开奖号码 bool CQiXingCai::GetTopLuckyNumber(CMD_GP_QueryLotResult* pResult, int nIndex) { _tcscpy_s(m_kjXinxi[nIndex].qihao, KJ_QIHAO_LENGTH, pResult->wPeriod); _tcscpy_s(m_kjXinxi[nIndex].haoma, KJ_HAOMA_LENGTH, pResult->szLotNum); _tcscpy_s(m_kjXinxi[nIndex].shijian, KJ_SHIJIAN_LENGTH, pResult->szShijian); if(nIndex+1 < TOP_KAIJIANG_NUMBERS) { return true; } m_kjXinxiCont = TOP_KAIJIANG_NUMBERS; if(!IsWindowVisible()) return false; if (_tcscmp(m_lastExpect, m_kjXinxi[0].qihao) != 0) { //第一次进入 if(m_lastExpect[0] == 0) _tcscpy_s(m_lastExpect, KJ_HAOMA_LENGTH, m_kjXinxi[0].qihao); m_bKaiJiangzhong=false; //开奖结束 long secDiff = m_chqRule.GetKjShjDiff(); KillTimer(timer_id_kaijiangzhong); } // if(m_bKaiJiangzhong) // { // CRect rcCnt; // rcCnt.left = rcRedraw.left+200; // rcCnt.right = rcRedraw.right; // rcCnt.top = rcRedraw.top; // rcCnt.bottom = rcRedraw.bottom; // RedrawWindow(&rcCnt,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW|RDW_ERASENOW); // } // else { RedrawWindow(&rcRedraw,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW|RDW_ERASENOW); } return true; } bool CQiXingCai::LuckyNumCQSSC() { return true; } long CQiXingCai::GetKjShjDiff() { long secDiff = m_chqRule.GetKjShjDiff(); if (secDiff <= 60 ) { return 0; } else if(secDiff > (m_chqRule.GetQiSpan() )) { return 0; } return secDiff; } //上期开奖号码 void CQiXingCai::DrawLastKjHaoma(CDC* pDC, Graphics& graphics) { long secDiff = m_chqRule.GetKjShjDiff(); if(IsWindowVisible() && secDiff > 60 && secDiff <=65) { CPlatformFrame* pPlatforFrame = CPlatformFrame::GetInstance(); if(pPlatforFrame->m_bSound) sndPlaySound(MAKEINTRESOURCE(IDR_CLOCK), SND_RESOURCE |SND_ASYNC); } if(IsWindowVisible() && secDiff == 61) { if(m_listChqSSC.GetItemCount() != 0) { CWnd *pParent = GetParent(); if(pParent!=NULL) { pParent->PostMessage(IDM_TANCHUANG,0,0); } } } int nTimeLeft = GetKjShjDiff(); //时间用尽了,显示开奖动画; //m_kjXinxi 存的是本地最新开奖号码 //更新上期的期号 if (_tcscmp(m_lastExpect, m_kjXinxi[0].qihao) != 0) { _tcscpy_s(m_lastExpect, KJ_HAOMA_LENGTH, m_kjXinxi[0].qihao); } int oldBkMode = pDC->SetBkMode(TRANSPARENT); CFont* pOldFont = pDC->SelectObject(&m_KjInfoFont1); COLORREF oldTextClr = pDC->SetTextColor(RGB(255, 255, 255)); pDC->DrawText(_T("七星彩"), &rcCzh, DT_CENTER|DT_VCENTER|DT_SINGLELINE); CRect rcDi; rcDi.left = rcCzh.right+10; rcDi.right = rcDi.left+20; rcDi.top = rcCzh.top; rcDi.bottom = rcCzh.bottom; pDC->DrawText(_T("第"), &rcDi, DT_CENTER|DT_VCENTER|DT_SINGLELINE); pDC->SetTextColor(RGB(253, 191, 6)); if(m_bKaiJiangzhong) { pDC->DrawText(m_chqRule.GetNextExpect(-1), &rcQiHao, DT_CENTER|DT_VCENTER|DT_SINGLELINE); } else pDC->DrawText(m_lastExpect, &rcQiHao, DT_CENTER|DT_VCENTER|DT_SINGLELINE); pDC->SetTextColor(RGB(255, 255, 255)); rcDi.left = rcQiHao.right-12; rcDi.right = rcDi.left+90; rcDi.top = rcCzh.top; rcDi.bottom = rcCzh.bottom; pDC->DrawText(_T("开奖号码"), &rcDi, DT_CENTER|DT_VCENTER|DT_SINGLELINE); pDC->SelectObject(&m_KjInfoFont1); CString strYg; CRect rcYuGao1; //strYg.Format(_T("正在销售")); //pDC->DrawText(strYg, &rcYuGao, DT_CENTER|DT_VCENTER|DT_SINGLELINE); strYg.Format(_T("第%s 下单时间"), m_chqRule.GetNextExpect()); //pDC->SetTextColor(RGB(255, 125, 0)); rcYuGao1.left = rcYuGao.left+15; rcYuGao1.top = rcYuGao.top+40; rcYuGao1.bottom = rcYuGao.bottom+70; rcYuGao1.right = rcYuGao.right+50; pDC->DrawText(strYg, &rcYuGao, DT_CENTER|DT_VCENTER|DT_SINGLELINE); // strYg.Format(_T("距封单还有")); // //pDC->SetTextColor(RGB(255, 226, 109)); // rcYuGao1.left = rcYuGao1.left; // rcYuGao1.top = rcYuGao1.top+20; // rcYuGao1.bottom = rcYuGao1.bottom+20; // rcYuGao1.right = rcYuGao1.right; // pDC->DrawText(strYg, &rcYuGao1, DT_CENTER|DT_SINGLELINE); pDC->SelectObject(&m_KjInfoFont); strYg.Format(_T("%s"), GetKjShjDiffDesc(20)); pDC->SetTextColor(RGB(219, 219, 219)); rcYuGao1.left = rcYuGao1.left-30; rcYuGao1.top = rcYuGao1.top+12; rcYuGao1.bottom = rcYuGao1.bottom+3; rcYuGao1.right = rcYuGao1.right-30; pDC->DrawText(strYg, &rcYuGao1,DT_CENTER|DT_SINGLELINE); pDC->SetTextColor(oldTextClr); pDC->SelectObject(&pOldFont); pDC->SetBkMode(oldBkMode); CString str = m_kjXinxi[0].haoma; CString temp; temp.Format(L"%c",m_kjXinxi[0].haoma[0]); if(_ttoi(temp) > 9) { m_bKaiJiangzhong=true; KillTimer(timer_id_kaijiangzhong); SetTimer(timer_id_kaijiangzhong, 100, NULL); return; } int index = 0; for (int i=0; i<4; i++) { if (iswdigit(str.GetAt(i))) { int num = _ttoi(CString(str.GetAt(i))); if (num >=0 && num < 10) { if(m_bKaiJiangzhong ) { KillTimer(timer_id_kaijiangzhong); SetTimer(timer_id_kaijiangzhong, 100, NULL); } else { DrawBigNum(graphics, m_kjNumBig, Rect(kj_big_haoma_x + index * (m_bigNumWidth+2), kj_big_haoma_y, m_bigNumWidth, m_bigNumHeight), num); } } index ++; } } } CString CQiXingCai::GetKjShjDiffDesc(int nSecond) { long secDiff = m_chqRule.GetKjShjDiff(); int hour = 0; int minute = 0; int second = 0; int nTemp = 0; int day = secDiff/(24*3600); nTemp = secDiff%(24*3600); hour = nTemp/3600; nTemp = secDiff%3600; minute = nTemp / 60 /*- 1*/; second = nTemp % 60; CString str; str.Format(_T("%d天%02d:%02d:%02d"),day,hour, minute, second); return str; } //开奖号码 void CQiXingCai::DrawTopKjHaoma(CDC* pDC, Graphics& graphics) { CString strText; int oldBkMode = pDC->SetBkMode(TRANSPARENT); CFont *pOldFont = pDC->SelectObject(&m_smallNumfont); COLORREF oldTextClr = pDC->SetTextColor(RGB(250 ,250 ,250)); CRect rcRect; rcRect.left = rcCzh.left+100; rcRect.top = rcCzh.top; rcRect.right = rcCzh.right+100; rcRect.bottom = rcCzh.bottom; //pDC->DrawText(_T("七星彩"), &rcRect, DT_CENTER|DT_VCENTER|DT_SINGLELINE); for (int cnt=0; cnt<4; cnt++) { CString str = m_kjXinxi[cnt].qihao; if(str.IsEmpty()) { continue; } CRect rcText(kj_small_haoma_x - 55, kj_small_haoma_y + cnt * (m_smallNumHeight + kj_small_haoma_row_span), kj_small_haoma_x + 80, kj_small_haoma_y + cnt * (m_smallNumHeight + kj_small_haoma_row_span) + m_smallNumHeight); pDC->DrawText(str, &rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE); str = m_kjXinxi[cnt].haoma; CString temp; temp = str.GetAt(cnt); if(_ttoi(temp) > 9) { // index ++; continue; } int index = 0; for (int i=0; i<str.GetLength(); i++) { if (iswdigit(str.GetAt(i))) { int num = _ttoi(CString(str.GetAt(i))); if (num >=0 && num < 10) { Rect rc(kj_small_haoma_x+10 + index * (m_smallNumWidth + kj_small_haoma_col_span), kj_small_haoma_y + cnt * (m_smallNumHeight + kj_small_haoma_row_span), m_smallNumWidth, m_smallNumHeight); DrawSmallNum(graphics, m_kjNumSmall, rc, num); } index ++; } } } pDC->DrawText(strText, &rcZongJinE, DT_CENTER|DT_VCENTER|DT_SINGLELINE); pDC->SetTextColor(oldTextClr); pDC->SelectObject(pOldFont); pDC->SetBkMode(oldBkMode); } void CQiXingCai::DrawBigNum(Graphics& graphics, Bitmap* img, Rect& rc_dest, int num) { graphics.DrawImage(img, rc_dest, num*m_bigNumWidth, 0, m_bigNumWidth, m_bigNumHeight, UnitPixel); } void CQiXingCai::DrawSmallNum(Graphics& graphics, Bitmap* img, Rect& rc_dest, int num) { graphics.DrawImage(img, rc_dest, num*m_smallNumWidth, 0, m_smallNumWidth, m_smallNumHeight, UnitPixel); } void CQiXingCai::DrawZongZhushuJinE(CDC* pDC) { CString strText; int oldBkMode = pDC->SetBkMode(TRANSPARENT); CFont *pOldFont = pDC->SelectObject(&m_zongFont); COLORREF oldTextClr = pDC->SetTextColor(RGB(160, 8, 8)); strText.Format(_T("你选择了%d注"), m_singlezhushu); CRect rcZhu; rcZhu.CopyRect(rcZongZhuShu); rcZhu.left += 225; // rcZhu.top -= 17; // rcZhu.bottom -= 17; rcZhu.right += 475; pDC->DrawText(strText, &rcZhu, DT_LEFT|DT_VCENTER|DT_SINGLELINE); CRect rcRect; rcRect.left = rcZongZhuShu.left+27; rcRect.right = rcZongZhuShu.right+27; rcRect.top = rcZongZhuShu.top+15; rcRect.bottom = rcZongZhuShu.bottom+15; strText.Format(L"倍数:"); pDC->DrawText(strText, &rcRect, DT_CENTER|DT_VCENTER|DT_SINGLELINE); double danzhujine = 2.0; if(theAccount.Scoretype == MoShi_Yuan) { danzhujine = 2.0; } else if (theAccount.Scoretype == MoShi_Jiao) { danzhujine = 0.2; } else if(theAccount.Scoretype == MoShi_Fen) { danzhujine = 0.02; } else if(theAccount.Scoretype == MoShi_Li) danzhujine = 0.002; strText.Format(_T("共:%.3lf元"), m_singlezhushu * m_beishu * danzhujine); pDC->DrawText(strText, &rcZongJinE, DT_LEFT|DT_VCENTER|DT_SINGLELINE); strText.Format(_T("共计%d注"),m_zongZhuShu); pDC->DrawText(strText, &rcAllZongzhushu, DT_LEFT|DT_VCENTER|DT_SINGLELINE); rcZhu.CopyRect(rcAllZongzhushu); rcZhu.top += 20; rcZhu.bottom += 20; strText.Format(_T("共计:%.3lf元"),m_zongJine); pDC->DrawText(strText, &rcZhu, DT_LEFT|DT_VCENTER|DT_SINGLELINE); pDC->SetTextColor(oldTextClr); pDC->SelectObject(pOldFont); pDC->SetBkMode(oldBkMode); } void CQiXingCai::ResetAllNums() { m_singlezhushu = 0; UnCheckNumBtn(m_btnHeZhi_0); UnCheckNumBtn(m_btnHeZhi_1); UnCheckNumBtn(m_btnHeZhi_2); UnCheckNumBtn(m_btnHeZhi_3); UnCheckNumBtn(m_btnHeZhi_4); UnCheckNumBtn(m_btnHeZhi_5); UnCheckNumBtn(m_btnHeZhi_6); UnCheckNumBtn(m_btnHeZhi_7); UnCheckNumBtn(m_btnHeZhi_8); UnCheckNumBtn(m_btnHeZhi_9); UnCheckNumBtn(m_btnHeZhi_10); UnCheckNumBtn(m_btnHeZhi_11); UnCheckNumBtn(m_btnHeZhi_12); UnCheckNumBtn(m_btnHeZhi_13); UnCheckNumBtn(m_btnHeZhi_14); UnCheckNumBtn(m_btnHeZhi_15); UnCheckNumBtn(m_btnHeZhi_16); UnCheckNumBtn(m_btnHeZhi_17); UnCheckNumBtn(m_btnHeZhi_18); UnCheckNumBtn(m_btnHeZhi_19); UnCheckNumBtn(m_btnHeZhi_20); UnCheckNumBtn(m_btnHeZhi_21); UnCheckNumBtn(m_btnHeZhi_22); UnCheckNumBtn(m_btnHeZhi_23); UnCheckNumBtn(m_btnHeZhi_24); UnCheckNumBtn(m_btnHeZhi_25); UnCheckNumBtn(m_btnHeZhi_26); UnCheckNumBtn(m_btnHeZhi_27); UnCheckNumBtn(m_btnNiu_0); UnCheckNumBtn(m_btnNiu_1); UnCheckNumBtn(m_btnNiu_2); UnCheckNumBtn(m_btnNiu_3); UnCheckNumBtn(m_btnNiu_4); UnCheckNumBtn(m_btnNiu_5); UnCheckNumBtn(m_btnNiu_6); UnCheckNumBtn(m_btnNiu_7); UnCheckNumBtn(m_btnNiu_8); UnCheckNumBtn(m_btnNiu_9); UnCheckNumBtn(m_btnNiu_10); UnCheckNumBtn(m_btnWan_0); UnCheckNumBtn(m_btnWan_1); UnCheckNumBtn(m_btnWan_2); UnCheckNumBtn(m_btnWan_3); UnCheckNumBtn(m_btnWan_4); UnCheckNumBtn(m_btnWan_5); UnCheckNumBtn(m_btnWan_6); UnCheckNumBtn(m_btnWan_7); UnCheckNumBtn(m_btnWan_8); UnCheckNumBtn(m_btnWan_9); UnCheckNumBtn(m_btnQian_0); UnCheckNumBtn(m_btnQian_1); UnCheckNumBtn(m_btnQian_2); UnCheckNumBtn(m_btnQian_3); UnCheckNumBtn(m_btnQian_4); UnCheckNumBtn(m_btnQian_5); UnCheckNumBtn(m_btnQian_6); UnCheckNumBtn(m_btnQian_7); UnCheckNumBtn(m_btnQian_8); UnCheckNumBtn(m_btnQian_9); UnCheckNumBtn(m_btnBai_0); UnCheckNumBtn(m_btnBai_1); UnCheckNumBtn(m_btnBai_2); UnCheckNumBtn(m_btnBai_3); UnCheckNumBtn(m_btnBai_4); UnCheckNumBtn(m_btnBai_5); UnCheckNumBtn(m_btnBai_6); UnCheckNumBtn(m_btnBai_7); UnCheckNumBtn(m_btnBai_8); UnCheckNumBtn(m_btnBai_9); UnCheckNumBtn(m_btnShi_0); UnCheckNumBtn(m_btnShi_1); UnCheckNumBtn(m_btnShi_2); UnCheckNumBtn(m_btnShi_3); UnCheckNumBtn(m_btnShi_4); UnCheckNumBtn(m_btnShi_5); UnCheckNumBtn(m_btnShi_6); UnCheckNumBtn(m_btnShi_7); UnCheckNumBtn(m_btnShi_8); UnCheckNumBtn(m_btnShi_9); UnCheckNumBtn(m_btnGe_0); UnCheckNumBtn(m_btnGe_1); UnCheckNumBtn(m_btnGe_2); UnCheckNumBtn(m_btnGe_3); UnCheckNumBtn(m_btnGe_4); UnCheckNumBtn(m_btnGe_5); UnCheckNumBtn(m_btnGe_6); UnCheckNumBtn(m_btnGe_7); UnCheckNumBtn(m_btnGe_8); UnCheckNumBtn(m_btnGe_9); UnCheckNumBtn(m_btnDaShi); UnCheckNumBtn(m_btnXiaoShi); UnCheckNumBtn(m_btnDanShi); UnCheckNumBtn(m_btnShuangShi); UnCheckNumBtn(m_btnDaGe); UnCheckNumBtn(m_btnXiaoGe); UnCheckNumBtn(m_btnDanGe); UnCheckNumBtn(m_btnShuangGe); m_richDanshiHaoma.SetWindowText(_T("")); //m_editDanShiHaoMa.SetWindowText(_T("")); } void CQiXingCai::SetLockText(float fBonus, float fBonusPercent) { const float EPSINON = 0.00001; if((fBonus >= - EPSINON) && (fBonus <= EPSINON)) { } else { CString strText; strText.Format(L"%.2lf/%.2lf", fBonus, fBonusPercent); m_btnLock.SetWindowText(strText + _T("%")); } } //获取组三形式的号码 bool CQiXingCai::GetZuSanHaoma(CStringArray& strArr) { CString line; //m_editDanShiHaoMa.GetWindowText(line); m_richDanshiHaoma.GetWindowText(line); if(line.GetLength() > 2999) { // MyMessageBox(_T("您输入的号码太多了")); MyMessageBox(_T("您输入的号码太多了")); return false; } if (!GetHaomaStrs(strArr, line, 3)) { return false; } int count = strArr.GetCount(); for(int i=0; i<count; i++) { if (!IsZuSanHaoma(strArr[i])) { return false; } } return true; } bool CQiXingCai::GetZuSanHaoma(CString& haoma, int& zhushu) { CStringArray strArr; if(!GetZuSanHaoma(strArr)) { zhushu = 0; return false; } int count = strArr.GetCount(); for(int i=0; i<count; i++) { haoma += strArr.GetAt(i); if (i < count - 1) { haoma += _T(","); } } zhushu = count; return true; } bool CQiXingCai::IsZuSanHaoma(const CString& str) { if(str.GetLength() != 3) { return false; } TCHAR ch0 = str.GetAt(0); TCHAR ch1 = str.GetAt(1); TCHAR ch2 = str.GetAt(2); return (ch0 == ch1 || ch0 == ch2 || ch1 == ch2) && (ch0 != ch1 || ch0 != ch2 || ch1 != ch2); } bool CQiXingCai::GetDanShiHaoma(CStringArray& strArr, int size) { CString line; //m_editDanShiHaoMa.GetWindowText(line); m_richDanshiHaoma.GetWindowText(line); if(line.IsEmpty()) { MyMessageBox(_T("请输入号码!")); return false; } if(line.GetLength() > 2999) { // MyMessageBox(_T("您输入的号码太多了")); MyMessageBox(_T("您输入的号码太多了")); return false; } if (!GetHaomaStrs(strArr, line, size)) { return false; } return true; } bool CQiXingCai::GetDanShiHaoma(CString& haoma, int size, int& zhushu, int nMax) { CStringArray strArr; CString line; if(nMax == 0) nMax = 512000; m_richDanshiHaoma.GetWindowText(line); if(line.IsEmpty()) { MyMessageBox(_T("请输入号码!")); return false; } if(line.GetLength() > nMax) { MyMessageBox(_T("您输入的号码太多了")); return false; } if (!GetHaomaStrs(strArr, line, size)) { return false; } int count = strArr.GetCount(); for(int i=0; i<count; i++) { if(m_gameKind == WuXingQianEr_DanShi || m_gameKind == WuXingHouEr_DanShi|| m_gameKind == QianErZuXuan_DanShi|| m_gameKind == HouErZuXuan_DanShi) { CString strTempHaoma; strTempHaoma += strArr.GetAt(i); int nLength = strTempHaoma.GetLength(); for (int j = 0;j < nLength;j++) { haoma += strTempHaoma.GetAt(j); if(j!=nLength-1) { haoma+=_T(","); } } } else { haoma += strArr.GetAt(i); } // if (i < count - 1) { haoma += _T("|"); } } zhushu = count; return true; } bool CQiXingCai::GetHaomaStrs(CStringArray& strArr, CString line, int size) { int len = line.GetLength(); CString subStr,str; for (int i=0; i<len; i++) { str = line.GetAt(i); if (iswdigit(line.GetAt(i))&&!str.IsEmpty()) { subStr += line.GetAt(i); if(m_gameKind == QianErZuXuan_DanShi || m_gameKind == HouErZuXuan_DanShi) { if (subStr.GetLength() == size) { if(subStr[0] == subStr[1]) { MyMessageBox(L"组选二不能选重复数字!"); return false; } } } else if(m_gameKind == QianSanHunhe || m_gameKind == ZhongSanHunhe|| m_gameKind == HouSanHunhe) { if (subStr.GetLength() == size) { if(subStr[0] == subStr[1]&&subStr[2] == subStr[1]) { // MyMessageBox(L"混合不能选豹子数字!"); return false; } } } if (subStr.GetLength() > size) { return false; } } else { if (subStr.GetLength() != size && subStr.GetLength() != 0) { return false; } if (subStr.GetLength() == size) { strArr.Add(subStr); subStr = _T(""); } } } if(( subStr.GetLength() == 0)&&(strArr.GetCount()==0)) { MyMessageBox(_T("请输入号码!")); return false; } if (subStr.GetLength() != size && subStr.GetLength() != 0) { return false; } if (subStr.GetLength() == size) { strArr.Add(subStr); subStr = _T(""); } return true; } //初始化玩法信息 void CQiXingCai::InitWanFaMoShi() { theGameKind[(CZ_QiXingCai << 16) | (unsigned short)QiXingCai_LiangDing] = _T("两定玩法"); theGameKind[(CZ_QiXingCai << 16) | (unsigned short)QiXingCai_SanDing] = _T("三定玩法"); theGameKind[(CZ_QiXingCai << 16) | (unsigned short)QiXingCai_SiDing] = _T("四定玩法"); theGameKind[(CZ_QiXingCai << 16) | (unsigned short)QiXingCai_YiDing] = _T("一定玩法"); theGameKind[(CZ_QiXingCai << 16) | (unsigned short)QiXingCai_LiangZiXian] = _T("两字现"); theGameKind[(CZ_QiXingCai << 16) | (unsigned short)QiXingCai_SanZiXian] = _T("三字现"); } bool CQiXingCai::ChangeStringToA(CString strInput, string& strOutput) { int len=WideCharToMultiByte(CP_ACP,0,LPCWSTR(strInput),-1,NULL,0,NULL,NULL); char *str=new char[len]; memset(str,0,len); WideCharToMultiByte(CP_ACP,0,LPCWSTR(strInput),-1,str,len,NULL,NULL); strOutput=str; delete[] str; return true; } // bool CQiXingCai::ChangeStringToA(CString strInput, string& strOutput) // { // USES_CONVERSION; // // strOutput = T2A(strInput); // return true; // } void CQiXingCai::GetSubStringA(CStringA& strInput, int nPos, int nLen, CStringA& strOutput) { strOutput = strInput.Mid(nPos, nLen); } CString CQiXingCai::ChangeStringToT(CStringA strInput) { CString strOutput; USES_CONVERSION; strOutput = A2T(strInput); return strOutput; } //读取事件 bool CQiXingCai::OnEventMissionRead(TCP_Command Command, VOID * pData, WORD wDataSize) { //命令处理 if (Command.wMainCmdID==MDM_GP_USER_SERVICE) { switch (Command.wSubCmdID) { case SUB_GP_GET_MORE_RECORD_RET: { ASSERT((wDataSize % sizeof(CMD_GP_GetMoreRecordRet))==0); if((wDataSize %sizeof(CMD_GP_GetMoreRecordRet)) !=0)return false; int nCount = wDataSize/sizeof(CMD_GP_GetMoreRecordRet); for(int i = 0;i < nCount;i++) { CMD_GP_GetMoreRecordRet *pGetMoreRecord = ((CMD_GP_GetMoreRecordRet*)pData+i); m_DlgOpenRecord.SetOpenRecord(pGetMoreRecord,i); } m_DlgOpenRecord.ShowWindow(SW_SHOW); return true; } case SUB_GP_GET_USER_FANDIAN_RET: { ASSERT((wDataSize % sizeof(CMD_GR_GetUserFandianRet))==0); if((wDataSize %sizeof(CMD_GR_GetUserFandianRet)) !=0)return false; KillTimer(TimerFandian); mapBonus.clear(); mapDanweiFandian.clear(); mapPercent.clear(); mapFandian.clear(); WORD wCount = wDataSize / sizeof(CMD_GR_GetUserFandianRet); for(int i = 0;i < wCount;i++) { CMD_GR_GetUserFandianRet* pGetUserFandian = ((CMD_GR_GetUserFandianRet*)pData+i); int nKindid = pGetUserFandian->n_t_kindid; nPercent = pGetUserFandian->f_t_bonusPercent; fDanweiFandian = pGetUserFandian->f_t_fandian; nBonus = pGetUserFandian->f_t_bonus; mapPercent.insert(make_pair(nKindid,nPercent)); mapDanweiFandian.insert(make_pair(nKindid,fDanweiFandian)); mapBonus.insert(make_pair(nKindid,nBonus)); CString strText; strText.Format(L"%.2lf/%.2lf", nBonus, nPercent); strText+=_T("%"); mapFandian.insert(make_pair(nKindid,strText)); } m_btnLock.SetWindowText(mapFandian[m_gameKind]); m_btnLock.EnableTextButton(false); return true; } case SUB_GP_TOUZHU_CONTINUE_RET: { m_bCanSend = true; return true; } case SUB_GP_GET_MAP_BONUS_RET: { ASSERT(wDataSize % sizeof(CMD_GR_GetMapBonusRet)==0); if(wDataSize % sizeof(CMD_GR_GetMapBonusRet)!=0) return false; int nCount = wDataSize/sizeof(CMD_GR_GetMapBonusRet); for(int i = 0;i < nCount;i++) { CMD_GR_GetMapBonusRet* pGetMapBonus = ((CMD_GR_GetMapBonusRet*)pData+i); int index = (pGetMapBonus->n_t_type_id << 16) | (unsigned short)pGetMapBonus->n_t_kind_id; theBonus[index] = pGetMapBonus->f_t_bonus; } return true; } case SUB_GP_QUERY_TIME_RET: { ASSERT(wDataSize >= sizeof(CMD_GR_GetSystemTime)); if(wDataSize < sizeof(CMD_GR_GetSystemTime)) return false; CMD_GR_GetSystemTime* pSystemTime = (CMD_GR_GetSystemTime*)pData; theTime = pSystemTime->ServerTime; //SendToServer(3); return true; } case SUB_GP_SET_USER_BONUS_RET: { ASSERT(wDataSize >= sizeof(CMD_GR_SetUserBonusRet)); if(wDataSize < sizeof(CMD_GR_SetUserBonusRet)) return false; CMD_GR_SetUserBonusRet* pSetUserBonus = (CMD_GR_SetUserBonusRet*)pData; int nResult = pSetUserBonus->n_t_result; if(nResult==0) { SendToServer(6); SetLockText(m_fBonus, m_fPercent); MyMessageBox(L"返点数据修改成功!", L"温馨提示"); } else if(nResult == 1) { MyMessageBox(L"你修改的返点不符合!", L"提示"); } else if(nResult == 2) { MyMessageBox(L"此玩法不支持修改返点!", L"提示"); } else { MyMessageBox(L"返点修改失败!",L"提示"); } return true; } case SUB_GP_TOUZHU_CQSSC_RET: { ASSERT(wDataSize >= sizeof(CMD_GR_TouzhuRes)); if(wDataSize < sizeof(CMD_GR_TouzhuRes)) return false; KillTimer(TimerStatus); CMD_GR_TouzhuRes* pTouzhuRes = (CMD_GR_TouzhuRes*)pData; LONG lResult = pTouzhuRes->lResult; m_bCanSend = true; m_DlgStatus.HideStatusWindow(); if (lResult == 0) { if((pTouzhuRes->nSign != m_nTzhSign1)) { m_nTzhSign1 = pTouzhuRes->nSign; m_listChqSSC.DeleteAllItems(); MyMessageBox(_T("成功投注!"), _T("【祝君好运 投注成功】")); SendToServer(7); } } else if(lResult == 1) { MyMessageBox(_T("注数错误,或者投注内容不正确!")); } else if(lResult == 2) { MyMessageBox(_T("该期号已经开奖,投注失败!")); } else if(lResult == 3) { MyMessageBox(_T("该期号已经过期,投注失败!")); } else if(lResult == 4) { MyMessageBox(_T("由于期号出现错误,投注失败!")); } else if(lResult == 5) { MyMessageBox(_T("无法获取玩法对应的奖金,投注失败!")); } else if(lResult == 6) { MyMessageBox(_T("其他错误,有订单没有成功提交!")); } else if(lResult == 7) { MyMessageBox(_T("其他错误,有订单没有成功提交!")); } else if(lResult == 8) { MyMessageBox(_T("投注过程返回提示:余额不足")); } else if(lResult == 9) { MyMessageBox(_T("其他错误,有订单没有成功提交!")); } else if(lResult == 10) { MyMessageBox(_T("对不起,您的账户没有投注权限!")); } else if(lResult == 11) { MyMessageBox(_T("注数不正确,投注失败!")); } else if(lResult == 12) { MyMessageBox(_T("对不起,该玩法维护中,请选择其他玩法进行投注!")); } else if(lResult>=20 && lResult <= 30) { MyMessageBox(_T("该账户没有投注权限!")); } else if(lResult == 111) { CInformation information; int nResult = information.ShowMessageBox(_T("投注未成功!由于您密码设置过于简单,请设置复杂登陆密码和取款密码!"),MB_ICONWARNING,30); if(nResult==1) { CWnd* pParent = GetParent(); if(pParent!=NULL) { pParent->SendMessage(IDM_SHOW_XGMM,0,0); } } } else if(lResult > 18) { CString strLog; int nFandian = 1900+lResult*2; strLog.Format(L"抱歉返点在%d以上的玩家不能投注!",nFandian); MyMessageBox(strLog); } else { if( m_bShowFail == true) { m_bShowFail = false; MyMessageBox(_T("有订单未成功提交!")); } } return true; } case SUB_GP_GET_LAST_YUE_RET: { ASSERT(wDataSize == sizeof(CMD_GP_GetLastYueRet)); if(wDataSize!=sizeof(CMD_GP_GetLastYueRet)) return false; CMD_GP_GetLastYueRet* pCountRet = (CMD_GP_GetLastYueRet*)pData; theAccount.yue = pCountRet->f_t_yue; theAccount.dongjie = pCountRet->f_t_dongjie; CWnd* pParent = GetParent(); if(pParent!=NULL) { pParent->SendMessage(IDM_UPDATE_ACCOUNT,0,0); } break; } case SUB_GP_GET_CP_USER_RET: { ASSERT(wDataSize >= sizeof(CMD_GR_GetCpUserInfoRet)); if(wDataSize < sizeof(CMD_GR_GetCpUserInfoRet)) return false; CMD_GR_GetCpUserInfoRet* pGetCpUser = (CMD_GR_GetCpUserInfoRet*)pData; lstrcpyn(theAccount.account,pGetCpUser->s_t_account,sizeof(theAccount.account)); theAccount.type = pGetCpUser->n_t_type; theAccount.fandian = pGetCpUser->f_t_fandian; theAccount.yue = pGetCpUser->f_t_yue; theAccount.dongjie = pGetCpUser->f_t_dongjie; return true; } } } //错误断言 ASSERT(FALSE); return true; } //对象索引 WORD CQiXingCai::GetGameHoverIndex(CPoint MousePoint) { if(!m_GameListRect.PtInRect(MousePoint)) { return INVALID_WORD; } WORD wHoverItem = INVALID_WORD; return wHoverItem; } //鼠标消息 VOID CQiXingCai::OnMouseMove(UINT nFlags, CPoint Point) { __super::OnMouseMove(nFlags, Point); //进入判断 if (m_bHovering==false) { //设置变量 m_bHovering=true; //变量定义 TRACKMOUSEEVENT TrackMouseEvent; ZeroMemory(&TrackMouseEvent,sizeof(TrackMouseEvent)); //注册消息 TrackMouseEvent.hwndTrack=m_hWnd; TrackMouseEvent.dwFlags=TME_LEAVE; TrackMouseEvent.dwHoverTime=HOVER_DEFAULT; TrackMouseEvent.cbSize=sizeof(TrackMouseEvent); //注册事件 _TrackMouseEvent(&TrackMouseEvent); } } //鼠标消息 VOID CQiXingCai::OnLButtonDown(UINT nFlags, CPoint Point) { __super::OnLButtonDown(nFlags,Point); //设置焦点 SetFocus(); if(m_GameListRect.PtInRect(Point)) { WORD wDownItem = GetGameHoverIndex(Point); if(wDownItem == INVALID_WORD) return; //m_cbButtonDown = wDownItem; m_wViewItemDown = wDownItem; } return; } //鼠标消息 VOID CQiXingCai::OnLButtonUp(UINT nFlags, CPoint Point) { __super::OnLButtonUp(nFlags,Point); WORD wButtonUp = GetGameHoverIndex(Point); if((m_wViewItemDown!=INVALID_WORD)&&(m_wViewItemDown == wButtonUp)) { ShowWindow(SW_HIDE); CWnd* pParent = GetParent(); if(pParent!=NULL) { pParent->SendMessage(IDM_CLICKED_TYPE_SSC,m_wViewItemDown,m_cbMenuType); } } } //鼠标消息 LRESULT CQiXingCai::OnMouseLeave(WPARAM wParam, LPARAM lParam) { //设置状态 m_bHovering=false; // // m_wGameHoverItem=INVALID_WORD; // CWnd* pParent = GetParent(); // if(pParent!=NULL) // { // pParent->SendMessage(IDM_SHOW_MENU_SSC,0,INVALID_WORD); // } // m_bShowMenu = false; //更新界面 // RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW|RDW_ERASENOW); return 0; } //鼠标输入(任选2,任选3,任选4) void CQiXingCai::OnBnClickedRioMouseInput() { OnBnClickedBtnClsList(); if( m_gameKind == QiXingCai_LiangDing) { OnBnClickedRioLiangDing(); } else if(m_gameKind == QiXingCai_SanDing) { OnBnClickedRioSanDing(); } else if(m_gameKind == QiXingCai_SiDing) { OnBnClickedRioSiDing(); } else if(m_gameKind == QiXingCai_YiDing) { OnBnClickedRioYiDing(); } else if(m_gameKind == QiXingCai_LiangZiXian) { OnBnClickedRioLiangZiXian(); } else if(m_gameKind == QiXingCai_SanZiXian) { OnBnClickedRioSanZiXian(); } ShowCtrl(IDC_RIO_MOUSE_INPUT); ShowCtrl(IDC_RIO_KEYBOARD_INPUT); ResetAllNums(); m_rioMouseInput.SetPushed(true);m_RenxuanKeyboardInput = false; m_rioKeyboardInput.SetPushed(false); HideDanShiEdit(); m_RenxuanKeyboardInput=false; } //键盘输入(任选2,任选3,任选4) void CQiXingCai::OnBnClickedRioKeyboardInput() { OnBnClickedBtnClsList(); ShowCtrl(IDC_RIO_MOUSE_INPUT); ShowCtrl(IDC_RIO_KEYBOARD_INPUT); //任选2,3,4时,键盘输入的万,千,百,十,个 if(m_gameKind == RenXuan2 || m_gameKind == RenXuan4||m_gameKind == RenXuan3) ShowRenxuanWeiShu(); ResetAllNums(); m_rioMouseInput.SetPushed(false); m_rioKeyboardInput.SetPushed(true); HideDaXiaoDanShuang(); HideWanNums(); HideQianNums(); HideBaiNums(); HideShiNums(); HideGeNums(); ShowDanShiEdit(); m_RenxuanKeyboardInput=true; } //修改任选的 状态 void CQiXingCai::SetCheckRenXuan(bool bChecked) { CButton* pBtn = (CButton*)GetDlgItem(IDC_CHK_WAN); if(pBtn) pBtn->SetCheck(bChecked); pBtn = (CButton*)GetDlgItem(IDC_CHK_QIAN); if(pBtn) pBtn->SetCheck(bChecked); pBtn = (CButton*)GetDlgItem(IDC_CHK_BAI); if(pBtn) pBtn->SetCheck(bChecked); pBtn = (CButton*)GetDlgItem(IDC_CHK_SHI); if(pBtn) pBtn->SetCheck(bChecked); pBtn = (CButton*)GetDlgItem(IDC_CHKGE); if(pBtn) pBtn->SetCheck(bChecked); ValidateTips(); } void CQiXingCai::OnBnClickedChkWan() { ValidateTips(); } void CQiXingCai::OnBnClickedChkQian() { ValidateTips(); } void CQiXingCai::OnBnClickedChkBai() { ValidateTips(); } void CQiXingCai::OnBnClickedChkShi() { ValidateTips(); } void CQiXingCai::OnBnClickedChkge() { ValidateTips(); } //更新提示 void CQiXingCai::ValidateTips() { int nCheckCount=0; CButton* pBtn = (CButton*)GetDlgItem(IDC_CHK_WAN); if(pBtn && pBtn->GetCheck()) nCheckCount++; pBtn = (CButton*)GetDlgItem(IDC_CHK_QIAN); if(pBtn && pBtn->GetCheck()) nCheckCount++; pBtn = (CButton*)GetDlgItem(IDC_CHK_BAI); if(pBtn && pBtn->GetCheck()) nCheckCount++; pBtn = (CButton*)GetDlgItem(IDC_CHK_SHI); if(pBtn && pBtn->GetCheck()) nCheckCount++; pBtn = (CButton*)GetDlgItem(IDC_CHKGE); if(pBtn && pBtn->GetCheck()) nCheckCount++; //判断是任选? CStatic* pSta = (CStatic*)GetDlgItem(IDC_STATIC_RENXUAN_TIP); if(RenXuan2 == m_gameKind) { if(nRenXuan2[nCheckCount] == 0) { if(pSta) pSta->SetWindowText(L"系统会自动根据勾选位置,组合对应的方数"); } else { CString strTips; strTips.Format(L"您选择了%ld个位置,系统自动根据位置组合为%ld方", nCheckCount, nRenXuan2[nCheckCount]); if(pSta) pSta->SetWindowText(strTips); } } else if(RenXuan3 == m_gameKind) { if(nRenXuan3[nCheckCount] == 0) { if(pSta) pSta->SetWindowText(L"系统会自动根据勾选位置,组合对应的方数"); } else { CString strTips; strTips.Format(L"您选择了%ld个位置,系统自动根据位置组合为%ld方", nCheckCount, nRenXuan3[nCheckCount]); if(pSta) pSta->SetWindowText(strTips); } } else if(RenXuan4 == m_gameKind) { if(nRenXuan4[nCheckCount] == 0) { if(pSta) pSta->SetWindowText(L"系统会自动根据勾选位置,组合对应的方数"); } else { CString strTips; strTips.Format(L"您选择了%ld个位置,系统自动根据位置组合为%ld方", nCheckCount, nRenXuan4[nCheckCount]); if(pSta) pSta->SetWindowText(strTips); } } } //任选的万,千,百,十,个 int CQiXingCai::GetRenXuanCheckBox(BOOL& bWan, BOOL& bQian, BOOL& bBai, BOOL& bShi, BOOL& bGe) { CButton* pBtn = (CButton*)GetDlgItem(IDC_CHK_WAN); if(pBtn) bWan = pBtn->GetCheck(); pBtn = (CButton*)GetDlgItem(IDC_CHK_QIAN); if(pBtn) bQian = pBtn->GetCheck(); pBtn = (CButton*)GetDlgItem(IDC_CHK_BAI); if(pBtn) bBai = pBtn->GetCheck(); pBtn = (CButton*)GetDlgItem(IDC_CHK_SHI); if(pBtn) bShi = pBtn->GetCheck(); pBtn = (CButton*)GetDlgItem(IDC_CHKGE); if(pBtn) bGe = pBtn->GetCheck(); int nNums=0; nNums = bWan + bQian + bBai+ bShi+bGe; return nNums; } //设置返点 void CQiXingCai::OnBnClickedBtnLock() { int index = (CZ_QiXingCai << 16) | (unsigned short)m_gameKind; CDlgFandian dlg; dlg.SetBonus(mapBonus[m_gameKind], theBonus[index], mapPercent[m_gameKind], theAccount.fandian*100.0, mapDanweiFandian[m_gameKind]); if(IDOK == dlg.DoModal()) { dlg.GetBonus(m_fBonus, m_fPercent); SendToServer(5); } } //倍投加 void CQiXingCai::OnBnClickedBeiTouJia() { CString strBeishu; m_beishu += 1; strBeishu.Format(L"%d",m_beishu); m_editBeiTou.SetWindowText(strBeishu); return; } //倍投减 void CQiXingCai::OnBnClickedBeiTouJian() { CString strBeishu; m_beishu -= 1; if(m_beishu<1) { m_beishu = 1; } strBeishu.Format(L"%d",m_beishu); m_editBeiTou.SetWindowText(strBeishu); return; } ///////////////////////////////////////////////////////////////////////////////////// bool CQiXingCai::GetKeyBoardHaoma(CString& haoma, int size, int nLeast) { CStringArray strArr; CString line; m_richDanshiHaoma.SetSel(0,-1); line = m_richDanshiHaoma.GetSelText(); int nFind = line.Find(L","); if(nFind != -1) { line.Replace(_T(","),_T(",")); } line.Replace(L"\r",L" "); line.Replace(L"\n",L" "); if (!GetKeyHaomaStrs(strArr, line, size,nLeast)) { return false; } //haoma = strArr.GetAt(0); int count = strArr.GetCount(); CString strTemp; for(int i=0; i<count; i++) { haoma += strArr.GetAt(i); haoma +=_T("|"); //strTemp = strArr.GetAt(i); //int nWeishu = strTemp.GetLength(); //if(nWeishu > nLeast) //{ // MyMessageBox(_T("您输入的号码太多了")); // return false; //} //for(int j = 0; j<strTemp.GetLength();j++) //{ // haoma += strTemp.GetAt(j); // //if (m_gameKind!=WuxingZhixuan && (j!=nWeishu-1)) // //{ // // haoma += _T(","); // //} // //if(j == nWeishu-1) // //{ // // haoma +=_T("|"); // //} //} } return true; } bool CQiXingCai::GetKeyHaomaStrs(CStringArray& strArr, CString line, int size, int nLeast) { int len = line.GetLength(); CString subStr; CString strTemp; int nWayCount = 0; int NumCount = 0; int LastNumCount = 0; for (int i=0; i<len; i++) { CString str; str=line.GetAt(i); int nTemp = 10; if (iswdigit(line.GetAt(i))&&!str.IsEmpty()/*&&str.Compare(L"\r\n")!=0*/) { subStr += line.GetAt(i); strTemp+= line.GetAt(i); nTemp = _ttoi(strTemp); strTemp=_T(""); if(nTemp<0||nTemp>9) { MyMessageBox(L"您的输入有误,数字只能在0~9之间 "); return false; } } else { NumCount++; if (subStr.GetLength()!=LastNumCount)//如果和上次比,增加了数字,表示有一位已填 { nWayCount++; } if (NumCount > size ) { if (nWayCount != nLeast)//需要对应位数 的号码。 { return false; } NumCount = 0; strArr.Add(subStr); subStr = _T(""); } else { subStr = _T(","); } } } if(( subStr.GetLength() == 0)&&(strArr.GetCount()==0)) { MyMessageBox(_T("请输入号码!")); return false; } if (NumCount != size && strArr.GetCount()) { return false; } else if (subStr.GetLength() != 0) { strArr.Add(subStr); subStr = _T(""); } return true; } LRESULT CQiXingCai::onBnCLick( WPARAM wParam, LPARAM lParam ) { int nItem = (int)wParam; int nSubItem = (int)lParam; //OnBnClickedBtnDelSel(); nSubItem--; int zhushu = _ttoi(m_listChqSSC.GetItemText(nItem, 4)); m_zongZhuShu -= zhushu; m_listChqSSC.deleteItemEx( nItem ); int nItemCount = m_listChqSSC.GetItemCount(); m_zongJine = 0.00f; for(int i = 0;i < nItemCount;i++) { CString strBeiSHu = m_listChqSSC.GetItemText(i,5); CString strZhuSHu = m_listChqSSC.GetItemText(i,4); CString strMoshi = m_listChqSSC.GetItemText(i,1); int nMoshi = GetMoshiRet(strMoshi); double danzhujine = 2.0; if(nMoshi == MoShi_Yuan) { danzhujine = 2.0; } else if (nMoshi == MoShi_Jiao) { danzhujine = 0.2; } else if(nMoshi == MoShi_Fen) { danzhujine = 0.02; } else if(nMoshi == MoShi_Li) danzhujine = 0.002; int beishu = _ttoi(strBeiSHu); int zhushu = _ttoi(strZhuSHu); m_zongJine += zhushu*beishu*danzhujine; } CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); // rcInvali.CopyRect(rcAllZongzhushu); // rcInvali.bottom += 20; // InvalidateRect(&rcInvali); // m_listChqSSC.DeleteItem(nItem); if(vecAllNums.size() >0) { int nSize = vecAllNums.size(); nSize -=1; vector<wstring>::iterator iter = vecAllNums.begin()+nSize-nItem; vecAllNums.erase(iter); } return 0; } BOOL CQiXingCai::OnCommand(WPARAM wParam, LPARAM lParam) { //变量定义 UINT nCommandID=LOWORD(wParam); if((nCommandID >= IDC_BTN_WAN_0 && nCommandID <= IDC_BTN_GE_9)||(nCommandID >= IDC_BTN_DA_SHI && nCommandID <= IDC_BTN_WAN_2)||(nCommandID >= IDC_BTN_HEZHI_0 && nCommandID <= IDC_BTN_HEZHI_27)||(nCommandID >= IDC_BTN_DA_WAN && nCommandID <= IDC_BTN_SHUANG_BAI)||(nCommandID >= IDC_BTN_NIU_1 && nCommandID <= IDC_BTN_NIU_10)) { int nZhushu = GetQXCZhushu(CZ_QiXingCai,m_gameKind); } return __super::OnCommand(wParam,lParam);; } int CQiXingCai::GetQXCZhushu(int nTypeID,int nKindID) { CString strWan = GetWanString(); CString strQian = GetQianString(); CString strBai = GetBaiString(); CString strShi = GetShiString(); CString strGe = GetGeString(); m_singlezhushu = 0; if(m_gameKind == QiXingCai_LiangDing) { int zhushu = 1; int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount!=2) { m_singlezhushu = 0; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; } m_singlezhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } else if (m_gameKind == QiXingCai_SanDing) { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount!=3) { m_singlezhushu = 0; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; } m_singlezhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } else if(m_gameKind == QiXingCai_SiDing) { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount!=4) { m_singlezhushu = 0; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; } m_singlezhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } else if(m_gameKind == QiXingCai_YiDing) { int nTempHaoMaCount =0; if (!strQian.IsEmpty())//千 nTempHaoMaCount+=1; if (!strBai.IsEmpty())//百 nTempHaoMaCount+=1; if (!strShi.IsEmpty())//十 nTempHaoMaCount+=1; if (!strGe.IsEmpty())//个 nTempHaoMaCount+=1; if(nTempHaoMaCount!=1) { m_singlezhushu = 0; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; } m_singlezhushu = max(strQian.GetLength(),1) * max(strBai.GetLength(),1) * max(strShi.GetLength(),1) * max(strGe.GetLength(),1); } else if (m_gameKind == QiXingCai_LiangZiXian) { if(strBai.GetLength()!=2) { m_singlezhushu = 0; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; } m_singlezhushu = 1; } else if (m_gameKind == QiXingCai_SanZiXian) { if(strBai.GetLength()!=3) { m_singlezhushu = 0; CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; } m_singlezhushu = 1; } CRect rcInvali; rcInvali.CopyRect(rcZongZhuShu); rcInvali.right+=400; InvalidateRect(&rcInvali); InvalidateRect(&rcZongJinE); return m_singlezhushu; }
b5136c4810838bdd9e8d1f9b4d5fc9b30d3e7cba
0f2b08b31fab269c77d4b14240b8746a3ba17d5e
/orttraining/orttraining/core/session/tensor_helper.cc
6a36dcc65644bebcc54877d516f4674310676275
[ "MIT" ]
permissive
microsoft/onnxruntime
f75aa499496f4d0a07ab68ffa589d06f83b7db1d
5e747071be882efd6b54d7a7421042e68dcd6aff
refs/heads/main
2023-09-04T03:14:50.888927
2023-09-02T07:16:28
2023-09-02T07:16:28
156,939,672
9,912
2,451
MIT
2023-09-14T21:22:46
2018-11-10T02:22:53
C++
UTF-8
C++
false
false
12,668
cc
tensor_helper.cc
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "orttraining/core/session/tensor_helper.h" namespace onnxruntime { // Copy a chunk of memory to CPU from GPU. void CopyGpuToCpu(void* dst_ptr, const void* src_ptr, const size_t size, const OrtMemoryInfo& dst_location, const OrtMemoryInfo& src_location); namespace training { // Return the shape of a tensor slice. TensorShapeVector GetSliceShape( gsl::span<const int64_t> shape, // before-slicing tensor shape const size_t slice_axis, // axis to slice along const size_t num_slices) { // number of slices along the slicing axis ORT_ENFORCE(shape.size() > 0); ORT_ENFORCE(slice_axis < shape.size()); ORT_ENFORCE(num_slices > 0); ORT_ENFORCE(shape[slice_axis] > 0); ORT_ENFORCE(shape[slice_axis] % num_slices == 0); // Shape of slice along slice_axis. TensorShapeVector slice_shape(shape.size()); // Compute original slice's shape. std::copy(shape.begin(), shape.end(), slice_shape.begin()); // Replace the sliced dimension. slice_shape[slice_axis] = shape[slice_axis] / num_slices; return slice_shape; } // Given tensor's element type and shape, this function creates a tensor in the passed-in session. OrtValue CreateCpuTensorValue( const MLDataType elem_type, gsl::span<const int64_t> shape, onnxruntime::InferenceSession& session_state) { ORT_ENFORCE(elem_type->AsPrimitiveDataType(), "Tensor's element type must be a scalar type."); ORT_ENFORCE(shape.size() > 0, "Shape vector must be non-empty."); // Get CPU allocator from the session. OrtMemoryInfo cpu_location(onnxruntime::CPU, OrtDeviceAllocator); AllocatorPtr cpu_allocator = session_state.GetAllocator(cpu_location); // Given a shape, allocate a tensor using CPU allocator. auto cpu_tensor = std::make_unique<Tensor>(elem_type, shape, cpu_allocator); // Create type definition for the created tensor. auto tensor_type = DataTypeImpl::GetType<Tensor>(); // Create OrtValue to wrap the allocated tensor. OrtValue cpu_value{cpu_tensor.release(), tensor_type, tensor_type->GetDeleteFunc()}; return cpu_value; } // Copy a chunk of memory to CPU from CPU. void CopyCpuToCpu( void* dst_ptr, const void* src_ptr, const size_t size, const OrtMemoryInfo& dst_location, const OrtMemoryInfo& src_location) { ORT_ENFORCE(src_location.device.Type() == OrtDevice::CPU); ORT_ENFORCE(dst_location.device.Type() == OrtDevice::CPU); memcpy(dst_ptr, src_ptr, size); } // Copy a tensor allocated on GPU/CPU to CPU buffer. void CopyToCpuTensor(Tensor& dst, const Tensor& src) { // Get the tensor shape. const TensorShape& dst_shape = dst.Shape(); const TensorShape& src_shape = src.Shape(); ORT_ENFORCE(dst_shape == src_shape); // Get tensor's element type. const MLDataType src_type = src.DataType(); const MLDataType dst_type = dst.DataType(); ORT_ENFORCE(dst_type == src_type); // Get tensor's memory location. const OrtMemoryInfo& dst_location = dst.Location(); const OrtMemoryInfo& src_location = src.Location(); ORT_ENFORCE(src_location.device.Type() == OrtDevice::CPU || src_location.device.Type() == OrtDevice::GPU, "The copy function can only copy source tensor from CPU/GPU to CPU."); ORT_ENFORCE(dst_location.device.Type() == OrtDevice::CPU, "Destination tensor must be a CPU tensor."); auto src_ptr = src.DataRaw(); auto dst_ptr = dst.MutableDataRaw(); if (src_location.device.Type() == OrtDevice::GPU) { CopyGpuToCpu(dst_ptr, src_ptr, src.SizeInBytes(), dst_location, src_location); } else { CopyCpuToCpu(dst_ptr, src_ptr, src.SizeInBytes(), dst_location, src_location); } } // Update the linear index as if one extra axis is appended to the original shape. // For a tensor with shape [D1, D2, D3], the linear index of element at (x, y, z) is // i = x * (D2 * D3) + y * D3 + z. If we append one dimension to form a new shape [D1, D2, D3, D4], // the new linear index at (x, y, z, u) can be computed using i * D4 + u. constexpr size_t UpdateLinearIndex(const size_t linear_index, const size_t new_axis_index, const size_t new_axis_dim) { return linear_index * new_axis_dim + new_axis_index; } // If we slice tensor with shape [D_1, D_2, ..., D_j, D_{axis}, D_k, ..., D_n], then segment_size is Dk * ... * Dn and // the num_segments is D1 * ... * Dj. "axis" is the axis to slice or concatenate along. void ComputeSegment(const size_t axis, const TensorShape& shape, size_t& num_segments, size_t& segment_size) { segment_size = 1; num_segments = 1; for (size_t i = 0; i < static_cast<size_t>(shape.NumDimensions()); ++i) { if (i > axis) { segment_size *= shape[i]; } if (i < axis) { num_segments *= shape[i]; } } } // Copy a slice from source tensor to destination tensor. // Assume that input shape is [10, 8, 2], slice_axis=1, num_slices=4. // The destination's tensor is computed using // dst = src[:, lower:upper, :], // where // slice_stride = 8 / num_slices, // lower = slice_id * slice_stride, // upper = (slice_id + 1) * slice_stride. void CopySlice(Tensor& dst, const Tensor& src, const size_t slice_id, const size_t slice_axis, const size_t num_slices) { ORT_ENFORCE(dst.Location().device.Type() == OrtDevice::CPU, "Source must be a CPU tensor."); ORT_ENFORCE(src.Location().device.Type() == OrtDevice::CPU, "Destination must be a CPU tensor."); const TensorShape& src_shape = src.Shape(); ORT_ENFORCE(src_shape[slice_axis] % num_slices == 0, "The dimension along the sliced axis must be divisible by the number of slices.", " We have sliced dimension ", src_shape[slice_axis], " and number slices ", num_slices, "."); // Cache sliced dimension. const size_t slice_dim = src_shape[slice_axis]; // The number of slices along the sliced axis. const size_t slice_size = src_shape[slice_axis] / num_slices; auto src_ptr = src.DataRaw(); auto dst_ptr = dst.MutableDataRaw(); // If we slice tensor with shape [D1, D2, ..., Dj, sliced_dim, Dk, ..., Dn], then segment_size is Dk * ... * Dn. size_t segment_size = 0; // The total number of combinations of (D1, D2, ..., Dj). It's used as the total count of segments. size_t num_segments = 0; ComputeSegment(slice_axis, src_shape, num_segments, segment_size); // For each segment, we have several consecutive memory blocks to copy. For example, the first segment is // input[0, ..., 0, slice_id*slice_size : (slice_id + 1) * slice_size, :, ..., :], where its memory blocks // are // input[0, ..., 0, 0, :, ..., :], // input[0, ..., 0, 1, :, ..., :], // ... // input[0, ..., slize_size - 1, 1, :, ..., :]. for (size_t i = 0; i < num_segments; ++i) { // Do pointer arithmetic operations using "char*" because things are stored in terms of bytes. // Copy input[i, slice_id*slice_size : (slice_id + 1) * slice_size, :, ..., :] to buffer. const void* src_addr = reinterpret_cast<const char*>(src_ptr) + UpdateLinearIndex(i, slice_id * slice_size, slice_dim) * segment_size * src.DataType()->Size(); void* dst_addr = reinterpret_cast<char*>(dst_ptr) + UpdateLinearIndex(i, 0 * slice_size, 1) * segment_size * dst.DataType()->Size(); memcpy(dst_addr, src_addr, segment_size * slice_size * src.DataType()->Size()); } } // Slice the input tensor "value" along the axis indicated by "slice_axis". // It's the "slice_id"-th slice along the indicated axis and the total number // of slices is "num_slices". OrtValue SliceTensor( const OrtValue& value, const size_t slice_id, const size_t slice_axis, const size_t num_slices, onnxruntime::InferenceSession& session_state) { ORT_ENFORCE(value.IsTensor(), "Sliced value must be a tensor."); auto& src = value.Get<Tensor>(); auto src_shape = src.Shape().GetDims(); auto buf_value = CreateCpuTensorValue(src.DataType(), src_shape, session_state); ORT_ENFORCE(buf_value.IsTensor(), "Buffer value must be a tensor."); auto& buf = *buf_value.GetMutable<Tensor>(); CopyToCpuTensor(buf, src); // Compute the shape of the slice_id-th slice in the original tensor. auto slice_shape = GetSliceShape(src_shape, slice_axis, num_slices); // Allocate the slice as a tensor. auto dst_value = CreateCpuTensorValue(src.DataType(), slice_shape, session_state); ORT_ENFORCE(dst_value.IsTensor(), "Buffer value must be a tensor."); auto& dst = *dst_value.GetMutable<Tensor>(); // Copy the content of slice from the original tensor to the newly allocated tensor. CopySlice(dst, buf, slice_id, slice_axis, num_slices); return dst_value; } void CopyConcat( const size_t concat_axis, const std::vector<OrtValue>& values, OrtValue& result) { // Dimension product before concat_axis; d_0 x d_1 x ... x d_{concat_axis - 1}. size_t num_segments = 0; // Assume the concatenated tensors are n-dimensional. // Dimension product after concat_axis; d_{concat_axis + 1} x d_{concat_axis + 2} x ... x d_n. size_t segment_size = 0; ComputeSegment(concat_axis, result.Get<Tensor>().Shape(), num_segments, segment_size); auto& dst = *result.GetMutable<Tensor>(); auto& dst_shape = dst.Shape(); for (size_t i_seg = 0; i_seg < static_cast<size_t>(num_segments); ++i_seg) { // Accumulated dimension sum along the "concat_axis" of processed input tensors. // If we concatenate 3 tensors with shape [1, 2, 3] and "concat_axis" is 1, "anchor_bias" would be // 0 when processing the 1st tensor, 2 when processing the 2nd tensor, 2+2 when processing the last tensor. size_t anchor_bias = 0; for (size_t i_tensor = 0; i_tensor < values.size(); ++i_tensor) { auto& src = values[i_tensor].Get<Tensor>(); auto& src_shape = src.Shape(); auto src_ptr = src.DataRaw(); auto dst_ptr = dst.MutableDataRaw(); // Copied chunk size. Its unit is the number of tensor elements. auto chunk_size = src_shape[concat_axis] * segment_size; // Bias of the i_seg-th segment in input tensor. Its unit is the number of tensor elements. // chunk_size * auto src_bias = UpdateLinearIndex(i_seg, 0, src_shape[concat_axis]) * segment_size; auto dst_bias = UpdateLinearIndex(i_seg, anchor_bias, dst_shape[concat_axis]) * segment_size; memcpy(reinterpret_cast<char*>(dst_ptr) + dst_bias * dst.DataType()->Size(), reinterpret_cast<const char*>(src_ptr) + src_bias * src.DataType()->Size(), chunk_size * src.DataType()->Size()); anchor_bias += src_shape[concat_axis]; } } } OrtValue ConcatenateTensors( const std::vector<OrtValue>& orig_values, const size_t axis, onnxruntime::InferenceSession& session_state) { // Concatenated tensors in CPU buffers. std::vector<OrtValue> cpu_values; // Result tensor's shape. TensorShapeVector new_shape = orig_values.front().Get<Tensor>().Shape().AsShapeVector(); // Tensor elements' type. MLDataType elem_type = orig_values.front().Get<Tensor>().DataType(); int64_t new_dim = 0; for (auto& src : orig_values) { ORT_ENFORCE(src.IsTensor(), "Only tensors can be concatenated."); // Extract the shape of the original tensor. auto& src_tensor = src.Get<Tensor>(); auto src_shape = src_tensor.Shape().GetDims(); ORT_ENFORCE(src_shape.size() == new_shape.size(), "Tensors to be concatenated must have the same rank."); ORT_ENFORCE(src_tensor.DataType() == elem_type, "Tensors to be concatenated must have the same rank."); // Allocate the same size of tensor on CPU. auto cpu_value = CreateCpuTensorValue(elem_type, src_shape, session_state); auto& cpu_tensor = *cpu_value.GetMutable<Tensor>(); // Get source and destination for memory copy. auto src_ptr = src_tensor.DataRaw(); auto dst_ptr = cpu_tensor.MutableDataRaw(); const OrtMemoryInfo& dst_location = cpu_tensor.Location(); const OrtMemoryInfo& src_location = src_tensor.Location(); if (src_location.device.Type() == OrtDevice::GPU) { CopyGpuToCpu(dst_ptr, src_ptr, src_tensor.SizeInBytes(), dst_location, src_location); } else { CopyCpuToCpu(dst_ptr, src_ptr, src_tensor.SizeInBytes(), dst_location, src_location); } cpu_values.push_back(cpu_value); new_dim += src_shape[axis]; } new_shape[axis] = new_dim; auto result_value = CreateCpuTensorValue(elem_type, new_shape, session_state); // With concatenated tensors in CPU buffer and allocated result tensor, we start the concatenation. CopyConcat(axis, cpu_values, result_value); return result_value; } } // namespace training } // namespace onnxruntime
282df2f277f6a3d83d28577265242fa1580c62da
7eeb08de415c20d867495821880c6b24a6fef4be
/includes/MazeCore.hh
efdfc00317541a6e3ef7add8a0d4a6806f6f9d5d
[]
no_license
girard-r/mazer
bfa1e79b2e0c3f721f610959a04f0ca83fe30ddf
6d4add8b2042dad9a170e1fb22c3f60a67fba78a
refs/heads/master
2021-01-19T17:19:47.670692
2017-02-19T08:29:40
2017-02-19T08:29:40
82,444,971
0
0
null
null
null
null
UTF-8
C++
false
false
1,318
hh
MazeCore.hh
/* ** ** Author : Aurelien Girardeau ** */ #pragma once # include <string> # include <map> # include "ArgsTree.hh" # include "Maze.hh" # include "LoadMaze.hh" # include "GenMaze.hh" # include "SVGGenerator.hh" # include "Utils.hh" # include "Exceptions.hpp" # include "SolveMaze.hh" # define USAGE "USAGE ORDER : ./mazer --g [PARAMS] --sb [PARAMS] --sv \ [PARAMS]\nOR : --lb [PARAMS] --sv [PARAMS]\n--g [seed] [width] [height]\ <-- Optional parameters, Generate Maze\n--sb [filename.maze] <-- Save \ maze in binary code into filename.maze\n--sv [filename.svg] <-- Save maze\ in svg into filename.svg\n--lb [filename.maze] <-- Load Maze from binary \ file filename.maze" class MazeCore { typedef void (MazeCore::*ptr)(Node *); private : ArgsTree _container; std::map<std::string, ptr> _occur; Maze* _maze; GenMaze* _generator; SVGGenerator* _svgEngine; LoadMaze* _loader; SolveMaze* _solver; public : MazeCore(); ~MazeCore(); void init(int, char **); void run(); private : void constructMazeTree(); void fillMazeTree(int, char **); void fillNodeArgs(Node*, int*, int, char **); void processGenMaze(Node *); void processLoadBinaryMaze(Node *); void processSaveBinaryMaze(Node *); void processSaveSvgMaze(Node *); void processSolveMaze(Node *); };
072a91059f72b1bcb1428e80233527712f83ec65
e10c4397a97157c2161f638802ca95c80f3e4f20
/active-active/simulator/readTraces/src/IRandomReadTraceAddressGenerator.cpp
c72e2eaf3f4eaab3bcd6d55f3424a1b925fcb0c7
[]
no_license
OSLL/cache-simulator
d8fc45c310b9716f60252598aa3c48483d798475
21535acfc72c787bee55db1ae931912562666db7
refs/heads/master
2021-01-10T15:01:24.044661
2015-05-23T07:03:09
2015-05-23T07:03:09
36,111,034
0
0
null
null
null
null
UTF-8
C++
false
false
542
cpp
IRandomReadTraceAddressGenerator.cpp
#include "IRandomReadTraceAddressGenerator.h" qulonglong IRandomReadTraceAddressGenerator::getRaidSize() const { return m_raidSize; } qulonglong IRandomReadTraceAddressGenerator::getQulonglongRand(const qulonglong raidSize) const { qulonglong result=0; qulonglong n = raidSize / (qulonglong)RAND_MAX; for (qulonglong i=0; i<n+1; i++){ result += qrand() % raidSize; } return result; } IRandomReadTraceAddressGenerator::IRandomReadTraceAddressGenerator(const qulonglong raidSize): m_raidSize(raidSize) { }
bbeddaf640a92a8d42325484efa071862bf7b5be
993635387a5f4868e442df7d4a0d87cc215069c1
/OMV/OMV/ViewTree.cpp
b6d3e15a779d96486aef4ee98d2ffe7f6c9c051f
[]
no_license
windrobin/ogremeshviewer
90475b25f53f9d1aee821c150a8517ee4ee4d37d
679a2979320af09469894a6d99a90ec1adc5f658
refs/heads/master
2021-01-10T02:18:50.523143
2011-02-16T01:06:03
2011-02-16T01:06:03
43,444,741
0
2
null
null
null
null
UTF-8
C++
false
false
2,407
cpp
ViewTree.cpp
/* ----------------------------------------------------------------------------- This source file is part of Tiger Viewer(An Ogre Mesh Viewer) For the latest info, see http://code.google.com/p/ogremeshviewer/ Copyright (c) 2010 Zhang Kun(zhk.tiger@gmail.com) This program 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 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- This software also uses Microsoft Fluent UI. License terms to copy, use or distribute the Fluent UI are available separately. To learn more about our Fluent UI licensing program, please visit http://msdn.microsoft.com/officeui. Generally speaking, Fluent UI is free, if you do not use it make a contest software like Office. ----------------------------------------------------------------------------- */ #include "stdafx.h" #include "ViewTree.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CViewTree CViewTree::CViewTree() { } CViewTree::~CViewTree() { } BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CViewTree message handlers BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult); NMHDR* pNMHDR = (NMHDR*)lParam; ASSERT(pNMHDR != NULL); if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != NULL) { GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE); } return bRes; }
1018550f74a7037dad38334e84fb0ec7f58c4096
199fbf48ca10bd4cf60ed7ee1e66d75523f3c75c
/Blatt 1/Aufgabe 3/Aufgabe 3/Vektor.cpp
dbc03e59a727e6d7791987967ec8f37a012bed3a
[]
no_license
Nawygator/Info2
a1c9486dd1638a0fa6e58aac666bf031bb641ccf
8deb4f5dea4540df5ec202c076b08df03c244413
refs/heads/master
2021-01-19T10:15:21.804017
2017-04-25T06:41:23
2017-04-25T06:41:23
87,846,494
0
0
null
2017-04-13T13:08:30
2017-04-10T18:54:01
C++
UTF-8
C++
false
false
950
cpp
Vektor.cpp
#include <iostream> using namespace std; static double PI = 3.141562; struct VektorT { int a; int b; int c; }; void Ausgabe(VektorT a); double Skalarprodukt(VektorT a, VektorT b); VektorT Addition(VektorT a, VektorT b); double Laenge(VektorT a); double Winkel(VektorT a, VektorT b); void Ausgabe(VektorT a) { cout << a.a << endl << a.b << endl << a.c << endl; } VektorT Addition(VektorT a, VektorT b) { VektorT result; result.a = a.a + b.a; result.b = a.b + b.b; result.c = a.c + b.c; return result; } double Laenge(VektorT a) { double result; result = pow(a.a, 2) + pow(a.b, 2) + pow(a.c, 2); result = sqrt(result); return result; } double Skalarprodukt(VektorT a, VektorT b) { double result; result = a.a*b.a + a.b*b.b + a.c*b.c; return result; } double Winkel(VektorT a, VektorT b) { double result = Skalarprodukt(a, b); result = result / (Laenge(a)* Laenge(b)); result = acos(result) * 180 / PI; return result; }
ab7c8fb1c366b5e53b91795e64dcbd0b0f00179f
41e035a17acba996a0090602485d7d25ef6b1b77
/include/base3d/math.inc
f7d11068256fa1ea7a43a0c4aa490af0bbc2fe6c
[]
no_license
sabareeshrg/rayer
37bede1884a60cea4bac39aac3d3dcc572e57c04
c7dc3bdd08c063ca91bc5dc6dbcf533f594c63aa
refs/heads/master
2021-01-17T22:15:02.733195
2012-10-30T03:25:01
2012-10-30T03:25:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
703
inc
math.inc
inline double rad2deg(double r) { return r*180/M_PI; } inline double deg2rad(double r) { return r*M_PI/180; } inline double clamp(double x, double minx, double maxx) { if (x<minx) return minx; else if (x>maxx) return maxx; else return x; } inline double angle_normalize(double angle) { if (angle>2*M_PI) { int i = int(angle/(2*M_PI)); angle -= i*2*M_PI; } if (angle<0) { int i = int(angle/(2*M_PI))-1; angle -= i*2*M_PI; } return angle; } #define PERMMASK 0xff inline double _noise_catmull(double t, int size, double *v) { double t2 = t*t, t3 = t2*t; return 0.5*( (2*v[1]) + (-v[0]+v[2])*t + (2*v[0]-5*v[1]+4*v[2]-v[3])*t2 + (-v[0]+3*v[1]-3*v[2]+v[3])*t3 ); }
caca61522951681bc80dad2acb701e4f4050b41b
0a3f5acdbfdf0f8e49dbecc2477d934f6853ae6c
/code/Degree Centrality/Degree Centrality/Degree Centrality/Source.cpp
c7a76c160f5365fe0ab833fa952631a849fa1720
[]
no_license
sanody/Social-Media-Analysis
a4cf1bd996121b3b74b9498d846755b521ed9deb
e1268b418d5659650f6bbcc908559f4ac4c90a74
refs/heads/master
2020-06-12T02:24:35.867146
2019-07-03T23:36:58
2019-07-03T23:36:58
194,166,311
0
0
null
null
null
null
UTF-8
C++
false
false
800
cpp
Source.cpp
#include <iostream> #include <vector> #include <set> #include <stack> #include <algorithm> using namespace std; struct node1 { int No_Node; int Size; //bool mark = false; }; bool operator<(const node1& l, const node1& r) { return r.Size < l.Size; } bool operator==(const node1& l, const node1& r) { return l.No_Node == r.No_Node; } void main() { int A, Num; long M, count, N; node1 B, A1; cin >> N >> M; vector<vector<node1>> Gragh(N, vector<node1>()); count = M; for (int i = 0; i < M; i++) { cin >> A >> B.No_Node >> B.Size; A1.No_Node = A; A1.Size = B.Size; Gragh[A].push_back(B); Gragh[B.No_Node].push_back(A1); } ////////////--------------------------Degree Centrality---//////// for (int i = 0; i < Gragh.size(); i++) { cout << Gragh[i].size() << "\n"; } }
94e28909b92c1ebe05a356928c918c43770676e8
d266d98b0801fb755cd8280fdc50354486cd3170
/3.5.3/pointer.hpp
9ee61e65e5020f02bdc2d076a0511f2208e4b389
[]
no_license
stephennovis/C-For-Financial-Engineering
ad528fa3d4b72e8c24d0c574d540e324e4ec7e4a
9277bda2c39dcf576ac58216feaf96730a7ca09a
refs/heads/master
2020-04-10T01:33:50.544935
2018-12-06T22:18:55
2018-12-06T22:18:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
390
hpp
pointer.hpp
// // Created by Steve on 11/1/18. // #ifndef INC_3_5_2_POINTER_HPP #define INC_3_5_2_POINTER_HPP #include "shape.hpp" class Point : public Shape { private: double x; double y; public: Point(); Point(double m_x, double m_y); Point(Point& p); virtual ~Point(); Point& operator = (const Point& p); string ToString() const; }; #endif //INC_3_5_2_POINTER_HPP
785e3e53a2a28c9f9706665b41f53adda7332625
621817aaa661aae8205905df9566342f8bfb03ad
/myprog.cpp
290004d69b3204417b150de270c19f1983517900
[]
no_license
4638434/praktika01
15d28a5c0a16317aa13a294f9893c3281ff94111
8d1d2e1741e4551cd09a6f277ea6347795fb335e
refs/heads/master
2020-04-17T07:29:58.215875
2019-01-22T08:25:53
2019-01-22T08:25:53
166,372,334
0
0
null
null
null
null
UTF-8
C++
false
false
240
cpp
myprog.cpp
#include <stdio.h> #include <iostream> using namespace std; class troad { public: float Length; int Width; troad(); }; troad::troad() { Length=0; Width=0.0; } int main() { troad road; road.Length=60.0; return 0; }
57ecf109de8f5c3fb49c5026aa545344109809e5
ffc7dd59c9dcbfcfd5ee7abd246f8d8038ac7b39
/app/jni/src/spacebiem/spacebiem/entities/InputIndicatorEntity.h
84049d818c3aa938ade945aa7f8048e934d20665
[]
no_license
luukspierings/SpaceBiem
a1dd0cfb629a27f0c884236d91648cd2cbd428fa
679e1f4194653ec94b204bad494337b29f64a344
refs/heads/master
2023-01-01T13:51:00.696797
2020-10-11T16:02:47
2020-10-11T16:02:47
265,687,796
1
0
null
null
null
null
UTF-8
C++
false
false
1,534
h
InputIndicatorEntity.h
#pragma once #include "../../biemgine/Biemgine.h" using biemgine::Entity; using biemgine::PositionComponent; using biemgine::ColorComponent; using biemgine::UIComponent; using biemgine::RectangleComponent; using biemgine::TextureComponent; #include "../components/OxygenComponent.h" #include "../globals/Fonts.h" namespace spacebiem { class InputIndicatorEntity : public Entity { public: InputIndicatorEntity(int wW, int wH) { auto aspectRatio = 3; auto margin = 50; auto halfW = wW / 2; auto arrowW = (halfW - (2 * margin)) / 3; auto arrowH = arrowW / aspectRatio; auto arrowY = wH - arrowH - margin; // auto xOffset = (halfW - arrowW - (2 * margin)) / 2; auto xOffset = margin; addComponent("position", new PositionComponent(0, 0)); addComponent("ui", new UIComponent); addComponent("texture", new TextureComponent("textures/arrow_left.png", xOffset , arrowY, arrowW, arrowH, 190u, true, "arrow_left", { 255, 255, 255, 50 })); addComponent("texture", new TextureComponent("textures/arrow_right.png", wW - arrowW - xOffset, arrowY, arrowW, arrowH, 190u, true, "arrow_right", { 255, 255, 255, 50 })); auto textW = 30; addComponent("text", new TextComponent(Fonts::Roboto(), "Swipe up to jump!", { 255,255,255,255 }, true, halfW, wH - margin - (arrowH / 2) + 20)); setTag("InputIndicator"); }; }; }
9f31ed9f4088c11942377d5a03d453585131cd2e
64b358f9339f05267c70e43658903fb5da349659
/sanfaust/Counter.h
f1846f5e573baf7f32828719b8719fb8fe566b6f
[ "MIT" ]
permissive
astagi/sanfaust.ino
1812680bac1bc67569d4e28de05e3a95c39d969a
5bc76c81f1f702ff73a50f8aa628a12c3df81bb6
refs/heads/master
2020-04-11T08:07:19.367696
2016-02-14T15:25:42
2016-02-14T15:25:42
50,996,367
1
0
null
null
null
null
UTF-8
C++
false
false
360
h
Counter.h
#pragma once class Counter { protected: // Everything's protected for performances int _size; int _current; public: Counter(int _size); bool isOver(int n, bool equal=false); bool isBelow(int n, bool equal=false); bool isBetween(int n1, int n2, bool equal1=false, bool equal2=false); int next(); int getCurrentValue(); };
f0c264a0f4b4cc61216d12f6304c887e5ce93732
9b86131182f9c46a96b96acf7a238073ebaa9556
/chapter-03/exercise-3.36-mz.cpp
f0e3f6a7d10bfdf2294f363ff1a0aff9d5d84f87
[]
no_license
SBU-Cpp-Club/cpp-exercises
a39e7a97b5b6b5dfcdc61fb1e1f07e14b8f04c64
f12e3dc0370d80f23712190e5de52a5e5d5cb783
refs/heads/master
2023-08-16T19:40:22.262570
2023-08-13T14:19:56
2023-08-13T14:19:56
75,423,067
1
2
null
null
null
null
UTF-8
C++
false
false
807
cpp
exercise-3.36-mz.cpp
#include <iostream> #include <vector> int main() { int a1[] = {0, 1, 2, 3, 4, 5}; int a2[] = {0, 1, 2, 3, 4, 5}; std::vector<int> v1 = {0, 1, 2, 3, 4, 5}; std::vector<int> v2 = {0, 1, 2, 3, 4, 6}; // check equality int *p1 = std::begin(a1); int *p2 = std::begin(a2); for (int i=0; i < std::end(a1) - std::begin(a1); i++) { if (*p1 != *p2) { std::cout << "arrays don't match" << std::endl; } p1++; p2++; } auto q1 = v1.begin(); auto q2 = v2.begin(); while (q1 != v1.end() || q2 != v2.end()) { // kinda assuming same length here if (*q1 != *q2) { std::cout << "vector elements don't match" << std::endl; } q1++; q2++; } // easier way if (v1 != v2) { std::cout << "vectors don't match" << std::endl; } return 0; }
992f0baf748757e174499c646f7abed7d98f191f
2ecd4792f9a76ed3b0aa8bbbe568a881d6f675e1
/01 - naveGL/src/nave.cpp
1c030b7274cc0f8574ebecf5a458fea7ec72d95d
[]
no_license
andersori/Computacao-Grafica
1daa33811f6bbe0ce91c18598ae166df8fea454c
4c6c3c22c60445e0d7d8466cdffc9c865d2c82ac
refs/heads/master
2020-03-14T04:12:52.398424
2018-04-28T23:06:40
2018-04-28T23:06:40
131,437,216
0
0
null
null
null
null
UTF-8
C++
false
false
4,081
cpp
nave.cpp
#include "nave.h" #include <QtOpenGL> #define A 0 #define B 1 #define C 2 #define D 3 Nave::Nave() { this->vertices = new float*[4]; for(int i=0; i<4; i++) this->vertices[i] = new float[3]; set_vertice_1(-0.08, 0.0, 0.0); set_vertice_2(0.0, 0.2, 0.0); set_vertice_3(0.08, 0.0, 0.0); set_vertice_4(0.0, 0.1, 0.0); set_raio(); } Nave::~Nave() { for(int i = 0; i<4;i++) delete this->vertices[i]; delete this->vertices; } void Nave::mover(Desenho::Direcao dir) { Desenho::mover(dir); if(this->centro[1] < -1.0) { this->pos[1] = 1.0; } if(this->pos[1] > 1.0 && this->centro[1] > 1.0) { this->pos[1] = -1.0; } if(this->centro[0] < -1.0) { this->pos[0] = 1.0; } if(this->centro[0] > 1.0) { this->pos[0] = -1.0; } } Bala *Nave::atirar() { float t[4][3] = {{(vertices[A][0] + pos[0]), vertices[A][1] + pos[1] , vertices[A][2] + pos[2] }, {vertices[B][0] + pos[0] , vertices[B][1] + pos[1] , vertices[B][2] + pos[2] }, {vertices[C][0] + pos[0] , vertices[C][1] + pos[1] , vertices[C][2] + pos[2] }, {vertices[D][0] + pos[0] , vertices[D][1] + pos[1] , vertices[D][2] + pos[2] }, }; Bala* temp = new Bala(); temp->set_pos_x(t[3][0]); temp->set_pos_y(t[3][1]); return temp; } void Nave::set_vertice_1(float x, float y, float z) { this->vertices[0][0] = x; this->vertices[0][1] = y; this->vertices[0][2] = z; } void Nave::set_vertice_2(float x, float y, float z) { this->vertices[1][0] = x; this->vertices[1][1] = y; this->vertices[1][2] = z; } void Nave::set_vertice_3(float x, float y, float z) { this->vertices[2][0] = x; this->vertices[2][1] = y; this->vertices[2][2] = z; } void Nave::set_vertice_4(float x, float y, float z) { this->vertices[3][0] = x; this->vertices[3][1] = y; this->vertices[3][2] = z; } void Nave::paint() { float temp[4][3] = {{(vertices[A][0] + pos[0]), vertices[A][1] + pos[1] , vertices[A][2] + pos[2] }, {vertices[B][0] + pos[0] , vertices[B][1] + pos[1] , vertices[B][2] + pos[2] }, {vertices[C][0] + pos[0] , vertices[C][1] + pos[1] , vertices[C][2] + pos[2] }, {vertices[D][0] + pos[0] , vertices[D][1] + pos[1] , vertices[D][2] + pos[2] }, }; set_centro(temp); glBegin(GL_LINES); glColor3fv(cor); glVertex3fv(temp[A]); glVertex3fv(temp[D]); glVertex3fv(temp[A]); glVertex3fv(temp[B]); glVertex3fv(temp[A]); glVertex3fv(temp[C]); glVertex3fv(temp[B]); glVertex3fv(temp[D]); glVertex3fv(temp[B]); glVertex3fv(temp[C]); glVertex3fv(temp[C]); glVertex3fv(temp[D]); glEnd(); glPointSize(5); glBegin(GL_POINTS); glColor3f(1.0, 1.0, 1.0); glVertex3fv(centro); glEnd(); glFlush(); } void Nave::set_centro(float temp[4][3]) { float x_max = temp[0][0]; float y_max = temp[0][1]; float x_min = temp[0][0]; float y_min = temp[0][1]; //procurando maiores for(int i=0;i<4;i++) { if (x_max < temp[i][0]) x_max = temp[i][0]; if (y_max < temp[i][1]) y_max = temp[i][1]; } //procurando menores for(int i=0;i<4;i++) { if (x_min > temp[i][0]) x_min = temp[i][0]; if (y_min > temp[i][1]) y_min = temp[i][1]; } this->centro[0] = (x_max + x_min) / 2.0; this->centro[1] = (y_max + y_min) / 2.0; }