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
4552038f2330bf19e57c833d299e0bbc028c50a3
d621036509a2766f5b0f911eaeea7bcbd372744f
/chapter5INIfileRead/mainwindow.cpp
de790b777484416ad545a0c352d7e7b28dada659
[]
no_license
A-zeroman/C-QT5
8c259ca9afdb44e97f3b5c9b477a1cc3d5706762
75f7af1cfa2efdedaac54d487d230bb67489b12d
refs/heads/master
2020-05-17T07:13:10.579968
2019-04-26T08:29:55
2019-04-26T08:29:55
183,575,279
0
0
null
null
null
null
UTF-8
C++
false
false
2,051
cpp
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //ini 文件路径 Label filePathL = new QLabel; filePathL->setText("ini 文件完整路径"); //ini 文件路径输入框 filePath = new QLineEdit; filePath->setText("D:/a001.ini"); //节点 Label nodeL = new QLabel; nodeL->setText("节点名"); //节点输入框 nodeEdit = new QLineEdit; nodeEdit->setText("node"); //键 Label keyL = new QLabel; keyL->setText("键值"); //键输入框 keyEdit = new QLineEdit; keyEdit->setText("ip"); //值 Label valL = new QLabel; valL->setText("值"); //值输入框 valEdit = new QLineEdit; //按钮 readBt = new QPushButton; readBt->setText("读取文件"); connect(readBt,SIGNAL(clicked()),this,SLOT(readFile())); gLayout = new QGridLayout; gLayout->addWidget(filePathL,0,0,1,1); gLayout->addWidget(filePath,0,1,1,4); gLayout->addWidget(nodeL,1,0,1,1); gLayout->addWidget(nodeEdit,1,1,1,1); gLayout->addWidget(keyL,2,0,1,1); gLayout->addWidget(keyEdit,2,1,1,1); gLayout->addWidget(valL,2,3,1,1); gLayout->addWidget(valEdit,2,4,1,1); gLayout->addWidget(readBt,3,4,1,1); //实例 QWidget widget = new QWidget(); //绑定布局 widget->setLayout(gLayout); this->setCentralWidget(widget); } //读取文件 void MainWindow::readFile() { //QSettings 构造函数的第一个参数是 ini 文件的路径,第二个参数表示针对 ini 文件 readIni = new QSettings(filePath->text(), QSettings::IniFormat); //将读取到的 ini 文件保存在 QString 中,先取值,然后通过 toString()函数转换成QString 类型 QString ipResult = readIni->value(nodeEdit->text()+"/"+keyEdit->text()).toString(); //将结果绑定 IP 值控件上 valEdit->setText(ipResult); //写入完成删除指针 delete readIni; } MainWindow::~MainWindow() { delete ui; }
2635d7d5b3488db07fd419c2126b7c40a67505b8
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/base/win32/fusion/appweek/uiviews/edit/edit.cpp
cd22918c65df7571e8b54b947108bf7d245f48e1
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,393
cpp
edit.cpp
#include "stdinc.h" #include "edit.h" #include <stdio.h> #include "FusionTrace.h" static ATL::CComModule Module; BEGIN_OBJECT_MAP(ObjectMap) OBJECT_ENTRY(__uuidof(CSxApwEditView), CSxApwEditView) END_OBJECT_MAP() ATL::CComModule* GetModule() { return &Module; } ATL::_ATL_OBJMAP_ENTRY* GetObjectMap() { return ObjectMap; } const CLSID* GetTypeLibraryId() { return NULL; } STDMETHODIMP CSxApwEditView::CreateWindow( HWND hwndParent ) { HRESULT hr = S_OK; RECT rc; ATL::CWindow parent(hwndParent); HWND hwnd; IFFALSE_WIN32TOHR_EXIT(hr, parent.GetClientRect(&rc)); IFFALSE_WIN32TOHR_EXIT(hr, parent.ScreenToClient(&rc)); // GetLastError wrong on Win9x IFFALSE_WIN32TOHR_EXIT( hr, hwnd = CreateWindowW( L"Edit", NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, parent, NULL, NULL, NULL )); m_edit.Attach(hwnd); hr = S_OK; Exit: return hr; } STDMETHODIMP CSxApwEditView::OnNextRow( int nColumns, const LPCWSTR rgpszColumns[] ) { for (int i = 0 ; i < nColumns ; i++) { m_string.append(rgpszColumns[i]); m_string.append((i == nColumns - 1) ? L"\r\n" : L" "); } m_edit.SetWindowText(m_string.c_str()); return S_OK; }
ed4d74e031b1ce694fb03682853910554b03a933
c20f4eac1aa7f5ab216d8703b3d9d48507fde759
/C++/Book_store_polymorphism/UImanager.h
ce2468ac86fbee9e5923433adc8053428524379f
[]
no_license
Harpreetsingh31/object_oriented_projects
d1d9a652bdd8e03e71b610c90d793fb185842141
f942414e1e01e288115c62062b14c31382fe2af2
refs/heads/master
2020-12-22T01:11:51.212555
2020-02-04T19:46:59
2020-02-04T19:46:59
236,625,725
0
0
null
null
null
null
UTF-8
C++
false
false
10,960
h
UImanager.h
#ifndef UIMANAGER_H #define UIMANAGER_H #include "Dlist.h" #include "Course.h" #include "Product.h" #include "Computer.h" #include "Apparel.h" #include "Book.h" #include "Pen.h" #define TEST_MODE class UImanager { public: void mainMenu(int*); template <class T> void getCourseData(Dlist<T>*); template <class T> void deleteCourse(Dlist<T>*); template <class T> void deleteCourses(Dlist<T>*); template <class T> void printCourses(Dlist<T>*); void pause(); template <class T> void addTextBook(Dlist<T>*); template <class T> void addCourses(Dlist<T>*); template <class T> void listTextbooks(Dlist<T>*); template <class T> void addComputer(Dlist<T>*); template <class T> void addApparel(Dlist<T>*); template <class T> void addBook(Dlist<T>*); template <class T> void addPen(Dlist<T>*); template <class T> void printInventory(Dlist<T>*); template <class T> void buyProduct(Dlist<T>*); private: int getInt(); }; template <class T> void UImanager::getCourseData(Dlist<T>* Clist) { string str = ""; string subj, num, name, inst; int enrol; Course* courseNew; cout << endl; while (str.length() != 8) { cout << "Enter course code (e.g. COMP2404): "; getline(cin, str); } subj = str.substr(0,4); num = str.substr(4); cout << endl << "Enter course name (e.g. Introduction to SE): "; getline(cin, name); cout << endl << "Enter instructor name: " ; getline(cin, inst); cout << endl << "Enter enrolment: " ; getline(cin, str); stringstream ss(str); ss >> enrol; courseNew = new Course(subj, num, name, inst, enrol); *(Clist)+=(courseNew); cout << endl << Clist->getSize(); } template <class T> void UImanager::addCourses(Dlist<T>* Clist){ Dlist<T> templist; int num,choice; choice = -1; while (choice != 1 && choice != 2) { cout << "Choose (1) to add one course and (2) to add list of courses: "; choice = getInt(); } if (choice == 1){ getCourseData(Clist); }else if(choice == 2){ cout <<"Number of courses to be added: "; cin>>num; for(int i=0;i<num;i++){ getCourseData(&templist); } *(Clist)+=templist; } } template <class T> void UImanager::deleteCourse(Dlist<T>* Clist){ Course* course; string sr; while (sr.length() != 8) { //valid input cout << endl << "Enter Course Code: "; getline (cin, sr); } while(Clist->getSize()!=0){ for (int i=0;i<Clist->getSize();++i){ if(sr==Clist->get(i)->getCode()) {//Course exists course = Clist->get(i); *(Clist)-=(course); return; }//end if }//end for }//end while } template <class T> // Function uses delete function to delete one or more courses void UImanager::deleteCourses(Dlist<T>* Clist){ Course* course; Dlist<T> templist; string sr =""; int num,choice; choice = -1; cout << endl; while (choice != 1 && choice != 2) { cout << "Choose (1) to delete one course and (2) to delete list of courses: "; choice = getInt(); } if (choice == 1){ deleteCourse(Clist); }else if(choice == 2){ cout << endl <<"Number of courses to be deleted: "; cin>>num; if (num <= Clist->getSize()) { for(int i=0;i<num;i++){ while (sr.length() != 8) { //valid input cout << endl << "Enter Course Code: "; getline (cin, sr); } for (int i=0;i<Clist->getSize();++i){ if(sr==Clist->get(i)->getCode()) {//Course exists course = Clist->get(i); templist+=course; }//end if }//end for sr =""; }//end for *(Clist)-=templist; } else { cout << "Courses to delete is larger than actual list" << endl; return; }// end else if } } template <class T> void UImanager::addTextBook(Dlist<T>* Clist){ string sr; while (sr.length() != 8) { //valid input cout << "Enter Course Code: "; getline (cin, sr); } for(int i=0;i<Clist->getSize();++i){ if(sr==Clist->get(i)->getCode()){ //Course exists Book* bookNew; string b="",a="",is="",id=""; int ed=0,ye=0,p=0; cout << endl << "Enter Book name: ";getline(cin, b); cout << endl << "Enter Author name: ";getline(cin, a); cout << endl << "Enter ISBN: ";getline(cin, is); cout << endl << "Enter edition: ";cin>>ed; cout << endl << "Enter year: ";cin>>ye; cout << endl << "Enter Serial id: ";cin>>id; cout << endl << "Enter Price: ";cin>>p; bookNew = new Book(b,a,is,ed,ye,id,p); Clist->get(i)->addBook(bookNew); } } cout << "Course does not exist."<< endl; } template <class T> void UImanager::printCourses(Dlist<T> *Clist) { Course* course; string string; cout << endl << endl << "ALL COURSES: " << endl << endl; if (Clist->getSize()==0) { cout << endl << "Empty"<< endl; }else{ cout << endl << "Forward printing" << endl; cout << *Clist; //using operator '<<' cout << endl << "Reverse printing" << endl; cout << endl << Clist->bwdPrint() <<endl; } } template <class T> void UImanager::listTextbooks(Dlist<T> *Clist){ Book* book; string sr; if (Clist->getSize()==0){ cout << "No Courses" << endl; }else{ while (sr.length() != 8) { //valid input cout << "Enter Course Code: "; getline (cin, sr); } for(int i=0;i<Clist->getSize(); ++i){ if(sr==Clist->get(i)->getCode()){ //Course exists for(int k = 0; k<Clist->get(i)->getNumBooks(); k++){ //Header line for printing all the books cout << endl << "Title Author ISBN Edition Year" << endl; book = Clist->get(i)->getBooks()->getBook(k); //getting book from the course cout << endl << book->getName() <<" "<< book->getAuthors() <<" "<< book->getISBN() << " " << book->getEdition() << " " << book->getYear(); }//end for printing books }else{ cout<<"The course code doesn't exist"<<endl; }//end if }//end for courselist size equals zero }//end larger if } template <class T> void UImanager::addComputer(Dlist<T>* Plist){ string str = ""; string name,id,pro,rm; int pr; cout << endl; cout << endl << "Enter computer model name (e.g. HP Envy): "; getline(cin, name); cout << endl << "Enter product id (e.g. B5T11XXXXXX): "; getline(cin, id); cout << endl << "Enter processor (e.g. intel i3): "; getline(cin, pro); cout << endl << "Enter ram: " ; getline(cin, rm); cout << endl << "Enter price: " ; cin>>pr; Computer* comp = new Computer(name,id,pr,pro,rm); comp->incStock(); Plist->add(comp); } template <class T> void UImanager::addPen(Dlist<T>* Plist){ string str = ""; string name, id , ty,cl; int pr; cout << endl; cout << endl << "Enter brand name (e.g. BIC): " ; getline(cin, name); cout << endl << "Enter product id (e.g. B5T11XXXXXX): "; getline(cin, id); cout << endl << "Enter type (Fountain): " ; getline(cin, ty); cout << endl << "Enter color: " ; getline(cin, cl); cout << endl << "Enter price: " ; cin>>pr; Pen* pen = new Pen(name,id,pr,ty,cl); pen->incStock(); Plist->add(pen); } template <class T> void UImanager::addApparel(Dlist<T>* Plist){ string str = ""; string name,id,size,ty; int pr; cout << endl; cout << endl << "Enter Apparel brand name (e.g. Bench.): "; getline(cin, name); cout << endl << "Enter product id (e.g. B5T11XXXXXX): "; getline(cin, id); cout << endl << "Enter type: " ; getline(cin, ty); cout << endl << "Enter size: " ; getline(cin, size); cout << endl << "Enter price: " ; cin>>pr; Apparel* app = new Apparel(name,id,pr,size,ty); app->incStock(); Plist->add(app); } template <class T> void UImanager::addBook(Dlist<T>* Plist){ string b="",a="",is="",id=""; int ed=0,ye=0,p=0; cout << endl << "Enter Book name: ";getline(cin, b); cout << endl << "Enter Author name: ";getline(cin, a); cout << endl << "Enter ISBN: ";getline(cin, is); cout << endl << "Enter edition: ";cin>>ed; cout << endl << "Enter year: ";cin>>ye; cout << endl << "Enter serial id: ";cin>>id; cout << endl << "Enter price: ";cin>>p; Book* book= new Book(b,a,is,ed,ye,id,p); book->incStock(); Plist->add(book); } template <class T> void UImanager::printInventory(Dlist<T>* Plist){ for(int i=0;i<Plist->getSize(); ++i) Plist->get(i)->print(); } template <class T> void UImanager::buyProduct(Dlist<T>* Plist){ int lr,hr,choice =-1; string pro; Dlist<T> cart; cout << endl; while (choice != 0 && choice != 1 && choice != 2 && choice != 3 && choice != 4 && choice != 5) { cout << endl << " (1) List products in the Stock "; cout << endl << " (2) List products for given price range "; cout << endl << " (3) Add product to your cart "; cout << endl << " (4) Products in your cart "; cout << endl << " (5) Check out " <<endl; cout << " (0) Return to main menu" << endl << endl; cout << endl << "Enter your selection: "; choice = getInt(); } while (1) { if (choice == 0){ break; }else if (choice == 1){ for(int i=0;i<Plist->getSize(); ++i) cout<<Plist->get(i)->print(); return; }else if(choice == 2){ cout << endl << " Enter a price range like (100 - 1000) "; cout << endl << " The least amount you could pay: "; cin >> lr; cout << endl << " The highest amount you could spend: "; cin >> hr; for(int i=0; i<Plist->getSize();++i) Plist->get(i)->range(lr,hr); return; }else if(choice ==3){ cout << endl << "Enter Product id: "; cin >> pro; while(Plist->getSize()!=0){ for (int i=0;i<Plist->getSize();++i){ if(pro==Plist->get(i)->getid()) {//Product exists cart+=(Plist->get(i)); // return; }//end if }//end for }//end while }else if(choice ==4){ //cout << endl << cart.fwdPrint(); for(int i=0; i<cart.getSize();++i) cout<<cart.get(i)->print(); return; }else if(choice ==5){ //decrementing stock of each item sold for(int i=0;i<Plist->getSize(); ++i){ if(Plist->get(i)->getid() == cart.get(i)->getid()) Plist->get(i)->decStock(); } *(Plist)-=cart; return; }//end of else if's }//endwhile } #endif
0d48b69d923c44f8472b602dc46a00b89f674606
6d162c19c9f1dc1d03f330cad63d0dcde1df082d
/qrenderdoc/3rdparty/qt/include/QtCore/5.9.4/QtCore/private/qppsobjectprivate_p.h
dae44e3609180b925d08e3ad06c0571ce80f960a
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "LGPL-2.0-or-later", "LGPL-3.0-only", "GPL-3.0-only", "Python-2.0", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-mit-old-style", "LGPL-2.1-or-later", "LGPL-2.1-only", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-sc...
permissive
baldurk/renderdoc
24efbb84446a9d443bb9350013f3bfab9e9c5923
a214ffcaf38bf5319b2b23d3d014cf3772cda3c6
refs/heads/v1.x
2023-08-16T21:20:43.886587
2023-07-28T22:34:10
2023-08-15T09:09:40
17,253,131
7,729
1,358
MIT
2023-09-13T09:36:53
2014-02-27T15:16:30
C++
UTF-8
C++
false
false
4,757
h
qppsobjectprivate_p.h
/**************************************************************************** ** ** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QPPSOBJECTPRIVATE_P_H_ #define QPPSOBJECTPRIVATE_P_H_ // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include "qppsattribute_p.h" #include <QMap> #include <QDebug> #include <sys/pps.h> #include <private/qobject_p.h> QT_BEGIN_NAMESPACE class QSocketNotifier; class QPpsObjectPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QPpsObject) public: explicit QPpsObjectPrivate(const QString &path); static QPpsAttributeMap decode(const QByteArray &rawData, bool *ok); static QByteArray encode(const QVariantMap &ppsData, bool *ok); static QVariantMap variantMapFromPpsAttributeMap(const QPpsAttributeMap &data); QSocketNotifier *notifier; QString path; mutable int error; int fd; bool readyReadEnabled; private: static QPpsAttribute::Flags readFlags(pps_decoder_t *decoder); static QPpsAttribute decodeString(pps_decoder_t *decoder); static QPpsAttribute decodeNumber(pps_decoder_t *decoder); static QPpsAttribute decodeBool(pps_decoder_t *decoder); static QPpsAttribute decodeData(pps_decoder_t *decoder); static QPpsAttributeList decodeArray(pps_decoder_t *decoder, bool *ok); static QPpsAttributeMap decodeObject(pps_decoder_t *decoder, bool *ok); static bool decoderPush(pps_decoder_t *decoder, const char *name = 0); static bool decoderPop(pps_decoder_t *decoder); template<typename T> static QPpsAttribute decodeNestedData(T (*decodeFunction)(pps_decoder_t *, bool *), pps_decoder_t *decoder); static void encodeData(pps_encoder_t *encoder, const char *name, const QVariant &data, bool *ok); static void encodeArray(pps_encoder_t *encoder, const QVariantList &data, bool *ok); static void encodeObject(pps_encoder_t *encoder, const QVariantMap &data, bool *ok); static QVariant variantFromPpsAttribute(const QPpsAttribute &attribute); }; inline bool QPpsObjectPrivate::decoderPush(pps_decoder_t *decoder, const char *name) { pps_decoder_error_t error = pps_decoder_push(decoder, name); if (error != PPS_DECODER_OK) { qWarning("QPpsObjectPrivate::decodeData: pps_decoder_push failed"); return false; } return true; } inline bool QPpsObjectPrivate::decoderPop(pps_decoder_t *decoder) { pps_decoder_error_t error = pps_decoder_pop(decoder); if (error != PPS_DECODER_OK) { qWarning("QPpsObjectPrivate::decodeData: pps_decoder_pop failed"); return false; } return true; } QT_END_NAMESPACE #endif /* QPPSOBJECTPRIVATE_P_H_ */
a2b50940bfac3a7c17cca0ebe778c9643a190823
00d69e58470663deef5d9541093ed6af9ad01526
/Team19/Code19/extensions/spa/src/PQL/Query.h
e453769f40e4b2e3a97f9732aff28f1f18e1c23c
[]
no_license
zixinn/20s2-cp-spa-team-19
ea4b801d61b8f278a5e1d02f8560cf2487e67a8b
c673145ad68f49f9dd22fd17bbc0315eac5f6b41
refs/heads/master
2023-05-08T08:31:09.211600
2021-04-16T02:56:02
2021-04-16T02:56:02
372,253,453
0
0
null
null
null
null
UTF-8
C++
false
false
2,283
h
Query.h
#pragma once #include "Clause.h" using namespace std; // Represents a PQL query class Query { public: // Constructor for Query Query(); Query(unordered_map<STRING, STRING> declarations, vector<STRING> toSelect, vector<vector<Clause>> clauses, bool isSyntacticallyValid, bool isSemanticallyValid); // Returns a map of the synonyms declared to its synonym types unordered_map<STRING, STRING> getDeclarations(); // Returns a vector of the arguments in a Select clause vector<STRING> getToSelect(); // Returns a vector of vectors of clauses // where each vector of clauses is a group of clauses vector<vector<Clause>> getClauses(); // Returns a vector of sets of synonyms // where each set of synonyms correspond to the synonyms found in a group of clauses vector<unordered_set<STRING>> getSynonyms(); // Returns true if the query is syntactically valid, false otherwise bool getIsSyntacticallyValid(); // Returns true if the query is semantically valid, false otherwise bool getIsSemanticallyValid(); // Sets a new vector of vectors of clauses in the Query Object void setClauses(vector<vector<Clause>> clauses); // Sets a new vector of clauses at a specific index in the vector of vectors clauses void setClausesAtIdx(vector<Clause> clauses, int idx); // Sets a new vector of sets of synonyms void setSynonyms(vector<unordered_set<STRING>> synonyms); // Overrides the equals method to compare Query objects friend bool operator==(const Query& q1, const Query& q2); // Destructor for Query ~Query(); private: // Maps synonyms declared to its type unordered_map<STRING, STRING> declarations; // A vector of the synonyms to select vector<STRING> toSelect; // A vector of vectors of clauses // where each vector of clauses is a group of clauses vector<vector<Clause>> clauses; // A vector of sets of synonyms // where each set of synonyms correspond to the synonyms found in a group of clauses vector<unordered_set<STRING>> synonyms; // Boolean to indicate if the query is syntactically valid bool isSyntacticallyValid; // Boolean to indicate if the query is semantically valid bool isSemanticallyValid; };
4fe1ba4f82a99e441ee3ea02eedc673e0f7992e5
22b817c31ce2a54cba4f7a8597a6867dd0414f87
/femm/Preferences.cpp
0a124278240919ea23e4478e5d6ffaf934a4e853
[ "MIT" ]
permissive
philm001/FEMM
904c72e653f89784693bf1b83aefb3b26aed4848
e091281e86ac22ed31a3bfc7d854ff42527ffdc7
refs/heads/master
2020-03-14T23:56:28.511905
2018-05-02T13:41:10
2018-05-02T13:41:10
131,856,027
0
0
null
2018-05-02T13:38:43
2018-05-02T13:38:42
null
UTF-8
C++
false
false
1,719
cpp
Preferences.cpp
// Preferences.cpp : implementation file // #include "stdafx.h" #include "femm.h" #include "Preferences.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPreferences dialog CPreferences::CPreferences(CWnd* pParent /*=NULL*/) : CDialog(CPreferences::IDD, pParent) { //{{AFX_DATA_INIT(CPreferences) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CPreferences::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPreferences) DDX_Control(pDX, IDC_TAB1, m_tab1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPreferences, CDialog) //{{AFX_MSG_MAP(CPreferences) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPreferences message handlers BOOL CPreferences::OnInitDialog() { CDialog::OnInitDialog(); m_tab1.InsertItem(0, _T("Magnetics Input")); m_tab1.InsertItem(1, _T("Magnetics Output")); m_tab1.InsertItem(2, _T("Electrostatics Input")); m_tab1.InsertItem(3, _T("Electrostatics Output")); m_tab1.InsertItem(4, _T("Heat Flow Input")); m_tab1.InsertItem(5, _T("Heat Flow Output")); m_tab1.InsertItem(6, _T("Current Flow Input")); m_tab1.InsertItem(7, _T("Current Flow Output")); m_tab1.InsertItem(8, _T("General Attributes")); m_tab1.Init(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CPreferences::OnOK() { m_tab1.WritePrefs(); CDialog::OnOK(); }
0a9494185a1eee0350115c077dc5225369386bd4
08bacb60e1da024f5e9f4763b3e3d8c13536f9f3
/src/convert.hpp
64fe07b0f7568a38c09b8085a53ac7613d7cc874
[]
no_license
ggobi/qtpaint
94b7a38e9f28a56dd0f3fdd0e0b2a82c2fa8f61c
bbdb3386ad101821a53db5c36344a2a99fdb3318
refs/heads/master
2021-01-19T08:04:22.742357
2015-11-12T14:12:12
2015-11-12T14:17:35
954,678
7
4
null
2014-09-28T22:49:08
2010-10-01T16:42:52
C++
UTF-8
C++
false
false
219
hpp
convert.hpp
#include <QColor> #include <Rinternals.h> /* colors */ QColor asQColor(SEXP c); QColor *asQColors(SEXP c); /* string arrays */ const char ** asStringArray(SEXP s_strs); SEXP asRStringArray(const char * const * strs);
c501aec3d0c699bf80f4f628a7cd35517b5d2db0
3c2e81c99d1511a162139f8a6ff27ccbc8ac3145
/Lab7/csortingalgorithms.h
1e1571b1bc5fb1f6c9bb5cc67b33f3b63f9d664c
[]
no_license
BolotnyaBoss/ASD
0324f2cc2a93080f3b4d6b8ad8a1ea1aeb5123b1
4ef31c7cf33485be0e95c2b87e80435847950587
refs/heads/main
2023-02-04T14:25:43.764298
2020-12-21T22:04:23
2020-12-21T22:04:23
301,191,884
0
0
null
null
null
null
UTF-8
C++
false
false
1,045
h
csortingalgorithms.h
#ifndef CSORTINGALGORITHMS_H #define CSORTINGALGORITHMS_H #include <QTextEdit> #include <QTime> #include<QTableWidget> #include <QLineEdit> #include <iostream> #include <fstream> #include <iomanip> #include <QMessageBox> #include <QDebug> #include<vector> class CSortingAlgorithms { private: int *arr; int size; double time; public: CSortingAlgorithms(){} CSortingAlgorithms(int); ~CSortingAlgorithms(); void generateArr(int); void setArr(const CSortingAlgorithms &); void printArray(std::string); void bubbleSort(); void selectionSort(); void shellSort (); void mergeSorting(int, int); void mergeSort(int,int); void merge(int, int, int); void quickSorting(int, int); int partition(int, int); void quickSort(int, int); void countingSort(); void swap(int *, int*); int *getArray() { return arr;}; int getSize() {return size;} long double getTime(){return time;} }; #endif // CSORTINGALGORITHMS_H
6cdbf4de28d5887d23cb90c363e5877391ba4e75
d493276f3a09b6f161b9d3a79d5df55f48a0557c
/4299_태혁이의사랑은타이밍_D3.cpp
2c801119075e6192686017a94dfd20f4cdd3800e
[]
no_license
AnneMayor/algorithmstudy
31e034e9e7c8ffab0601f58b9ec29bea62aacf24
944870759ff43d0c275b28f0dcf54f5dd4b8f4b1
refs/heads/master
2023-04-26T21:25:21.679777
2023-04-15T09:08:02
2023-04-15T09:08:02
182,223,870
0
0
null
2021-06-20T06:49:02
2019-04-19T07:42:00
C++
UTF-8
C++
false
false
1,690
cpp
4299_태혁이의사랑은타이밍_D3.cpp
#include <iostream> using namespace std; int main() { int T; scanf("%d", &T); for (int tc = 1; tc <= T; tc++) { int d, h, m; scanf("%d %d %d", &d, &h, &m); if (d <= 11 && h < 11 && m < 11) { printf("#%d -1\n", tc); } else { int timeOfDay = 24 * 60 * ((d - 1) - 11); if (timeOfDay < 0) timeOfDay = 0; int timeOfHour, timeOfMin; if (d <= 11) { if (h < 11) { printf("#%d -1\n", tc); continue; } else { if (h == 11) { timeOfHour = 0; if (m < 11) { printf("#%d -1\n", tc); continue; } else { timeOfMin = m - 11; } } else { timeOfHour = 60 * ((h - 1) - 11); timeOfMin = 49 + m; } } } else { int defaultH = 12 * 60; int defaultM = 49; timeOfHour = defaultH; timeOfMin = defaultM; timeOfHour += 60 * h; timeOfMin += m; } printf("#%d %d\n", tc, (timeOfDay + timeOfHour + timeOfMin)); } } return 0; }
f43e789677f4126b2fe422f2b3ec81dbe55f3203
e82a4837c82f572aeec9ea3bf82c0d27936fb10d
/include/forecast.h
d070550a216b547b85057f61677d53d44d6530f9
[]
no_license
gabru-md/dragnet
5e3602c52e805cb5dbdace68c2ac61d5efeff505
0d429e1584ad90da030babc4ffab58ec34e8ea76
refs/heads/master
2020-11-23T20:24:43.279718
2019-12-13T09:53:32
2019-12-13T09:53:32
227,807,683
0
0
null
null
null
null
UTF-8
C++
false
false
3,158
h
forecast.h
#ifndef FORECAST_STL_H #define FORECAST_STL_H #include "numcpp.h" #include <cmath> enum SEVERITY {IGNORE, LOW, MEDIUM, HIGH, HIGHRISK}; double antilog(double value) { return static_cast<double>(exp(value)); } SEVERITY eval_severity(double expected, double observed) { if(expected >= observed) return IGNORE; double diff = observed - expected; double perc_diff = diff / expected; if(perc_diff < 2) return LOW; else if(perc_diff < 4) return MEDIUM; else if(perc_diff < 10) return HIGH; else return HIGHRISK; } struct Anomaly { bool is_anomaly; SEVERITY severity; double expected_log; double observed_log; double expected_value; double observed_value; Anomaly() { is_anomaly = false; severity = IGNORE; expected_value = 0; expected_log = 0; observed_value = 0; observed_log = 0; } Anomaly(double expectedLog, double observed) { expected_log = expectedLog; observed_value = observed; observed_log = log(observed_value); expected_value = antilog(expected_log); severity = eval_severity(expected_value, observed_value); if(severity == LOW || severity == MEDIUM || severity == IGNORE) is_anomaly = false; else is_anomaly = true; } }; struct Sample { long long max_size; long long forecast_size; nc::array inputs; nc::array season; nc::array trends; nc::array remainders; Sample(long long sz) { max_size = sz; forecast_size = sz; } Sample(long long sz, long long fsz) { max_size = sz; forecast_size = fsz; } Sample(nc::array inps, nc::array _season, nc::array _trends, nc::array _remainders) { inputs = inps; season = _season; trends = _trends; remainders = _remainders; // assert(inps.size() == season.size() && season.size() == remainders.size() && season.size() == trends.size()); max_size = season.size(); } }; bool insert_to_sample(Sample *sample, double toInsert) { try { while(sample->inputs.size() > sample->max_size) { sample->inputs.erase(sample->inputs.begin()); } sample->inputs.push_back(toInsert); return true; } catch(int error) { return false; } } struct Anomaly *build_anomaly(Sample *sample, double expected_log, double observed) { insert_to_sample(sample, observed); return new Anomaly(expected_log, observed); } struct Anomaly *predict(Sample *sample, double observed) { long long max_size = sample->max_size; long long forecast_size = sample->forecast_size; long long index_0 = max_size - forecast_size - 1; long long index_k = max_size - 1; double y1, yk; double predicted_seasonal = sample->season[index_0]; y1 = sample->trends[index_0] + sample->remainders[index_0]; yk = sample->trends[index_k] + sample->remainders[index_k]; double expected_log = predicted_seasonal + yk + (yk - y1) / (forecast_size - 1); return build_anomaly(sample, expected_log, observed); } #endif
297b2a0562ee3de605634cec71255c2d0e2e023c
31ad05c294917106b3a12fa7329edd2bd4985f09
/code/peerchat/server/Driver.cpp
c3aa8187af2400c29ddae834ad5867e2e374097e
[]
no_license
zmmmspy/openspy-core-v2
b06fc167430072ad7fff0c750ad7adb2ca8b68a0
9dc3345e9ae42d1d5673725673c0372eacfd96d6
refs/heads/master
2023-03-27T01:41:05.865465
2021-03-28T17:30:14
2021-03-28T17:30:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,801
cpp
Driver.cpp
#include <stdio.h> #include <stdlib.h> #include <algorithm> #include <peerchat/tasks/tasks.h> #include <OS/SharedTasks/tasks.h> #include "Driver.h" #include <sstream> namespace Peerchat { Driver::Driver(INetServer *server, const char *host, uint16_t port, bool proxyHeaders) : TCPDriver(server, host, port, proxyHeaders) { } Peer *Driver::FindPeerByProfileID(int profileid) { return NULL; } Peer *Driver::FindPeerByUserSummary(UserSummary summary) { mp_mutex->lock(); std::vector<INetPeer *>::iterator it = m_connections.begin(); while (it != m_connections.end()) { Peer *peer = (Peer *)*it; if (stricmp(peer->GetUserDetails().ToString().c_str(), summary.ToString().c_str()) == 0 && !peer->ShouldDelete()) { mp_mutex->unlock(); return peer; } it++; } mp_mutex->unlock(); return NULL; } INetPeer *Driver::CreatePeer(INetIOSocket *socket) { return new Peer(this, socket); } void Driver::SendUserMessageToVisibleUsers(std::string fromSummary, std::string messageType, std::string message, bool includeSelf) { mp_mutex->lock(); std::vector<INetPeer *>::iterator it = m_connections.begin(); while (it != m_connections.end()) { Peer *peer = (Peer *)*it; bool summaryMatch = peer->GetUserDetails().ToString().compare(fromSummary); if(summaryMatch && includeSelf) { peer->send_message(messageType, message, fromSummary); } else if(!summaryMatch) { peer->send_message(messageType, message, fromSummary); } it++; } mp_mutex->unlock(); } void Driver::OnChannelMessage(std::string type, ChannelUserSummary from, ChannelSummary channel, std::string message, ChannelUserSummary target, bool includeSelf, int requiredChanUserModes, int requiredOperFlags) { mp_mutex->lock(); std::vector<INetPeer *>::iterator it = m_connections.begin(); while (it != m_connections.end()) { Peer *peer = (Peer *)*it; if (from.modeflags & EUserChannelFlag_Invisible) { if (~peer->GetOperFlags() & OPERPRIVS_INVISIBLE) { it++; continue; } } bool in_channel = peer->GetChannelFlags(channel.channel_id) & EUserChannelFlag_IsInChannel && (peer->GetChannelFlags(channel.channel_id) & requiredChanUserModes || requiredChanUserModes == 0); int has_oper = peer->GetOperFlags() & requiredOperFlags || requiredOperFlags == 0; bool selfMatch = (includeSelf && from.user_id == peer->GetBackendId()) || (from.user_id != peer->GetBackendId()); if(in_channel && selfMatch && has_oper) { peer->send_message(type, message,from.userSummary.ToString(), channel.channel_name, target.userSummary.nick); if (type.compare("JOIN") == 0 && from.user_id == peer->GetBackendId()) { peer->handle_channel_join_events(channel); } } it++; } mp_mutex->unlock(); } void Driver::OnSetUserChannelKeys(ChannelSummary summary, UserSummary user_summary, OS::KVReader keys) { mp_mutex->lock(); std::vector<INetPeer *>::iterator it = m_connections.begin(); std::ostringstream ss; ss << summary.channel_name << " " << user_summary.nick << " BCAST :" << keys.ToString(); while (it != m_connections.end()) { Peer *peer = (Peer *)*it; if(peer->GetChannelFlags(summary.channel_id) & EUserChannelFlag_IsInChannel) { peer->send_numeric(702,ss.str(), true, summary.channel_name, false); } it++; } mp_mutex->unlock(); } void Driver::OnSetChannelKeys(ChannelSummary summary, OS::KVReader keys) { mp_mutex->lock(); std::vector<INetPeer *>::iterator it = m_connections.begin(); std::ostringstream ss; ss << summary.channel_name << " BCAST :" << keys.ToString(); while (it != m_connections.end()) { Peer *peer = (Peer *)*it; if(peer->GetChannelFlags(summary.channel_id) & EUserChannelFlag_IsInChannel) { peer->send_numeric(704,ss.str(), true, summary.channel_name, false); } it++; } mp_mutex->unlock(); } void Driver::OnChannelBroadcast(std::string type, UserSummary target, std::map<int, int> channel_list, std::string message, bool includeSelf) { mp_mutex->lock(); std::vector<INetPeer *>::iterator it = m_connections.begin(); while (it != m_connections.end()) { Peer *peer = (Peer *)*(it++); if (includeSelf && peer->GetUserDetails().ToString().compare(target.ToString()) == 0) { peer->send_message(type, message, target.ToString()); continue; } std::map<int, int>::iterator it2 = channel_list.begin(); while(it2 != channel_list.end()) { std::pair<int, int> p = *it2; bool shouldSend = ~p.second & EUserChannelFlag_Invisible || peer->GetOperFlags() & OPERPRIVS_INVISIBLE; if(peer->GetChannelFlags(p.first) & EUserChannelFlag_IsInChannel && shouldSend) { peer->send_message(type, message,target.ToString()); break; } it2++; } } mp_mutex->unlock(); } }
998d35e59cd1953296b03039707fbabf5f992779
bfc88535fa1495c64672f048a5559e8bb6de1ae1
/CoderClass/menghitunginversiii.cpp
24550f9b832fc285ae0e358ed453177ff347d17c
[]
no_license
famus2310/CP
59839ffe23cf74019e2f655f49af224390846776
d8a77572830fb3927de92f1e913ee729d04865e1
refs/heads/master
2021-07-05T00:23:31.113026
2020-08-07T22:28:24
2020-08-07T22:28:24
144,426,214
1
1
null
null
null
null
UTF-8
C++
false
false
2,599
cpp
menghitunginversiii.cpp
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define pb push_back #define debug(x) cout << x << endl #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define PI acos(-1) #define all(c) c.begin(), c.end() const int MOD = 1e9 + 7; const int INF = 1e9; const LL INF64 = 1e18; const int N = 1e5 + 5; LL _mergeSort(LL arr[], LL temp[], LL left, LL right); LL merge(LL arr[], LL temp[], LL left, LL mid, LL right); /* This function sorts the input array and returns the number of inversions in the array */ LL mergeSort(LL arr[], LL array_size) { LL *temp = (LL *)malloc(sizeof(LL)*array_size); return _mergeSort(arr, temp, 0, array_size - 1); } /* An auxiliary recursive function that sorts the input array and returns the number of inversions in the array. */ LL _mergeSort(LL arr[], LL temp[], LL left, LL right) { LL mid, inv_count = 0; if (right > left) { /* Divide the array LLo two parts and call _mergeSortAndCountInv() for each of the parts */ mid = (right + left)/2; /* Inversion count will be sum of inversions in left-part, right-part and number of inversions in merging */ inv_count = _mergeSort(arr, temp, left, mid); inv_count += _mergeSort(arr, temp, mid+1, right); /*Merge the two parts*/ inv_count += merge(arr, temp, left, mid+1, right); } return inv_count; } /* This funt merges two sorted arrays and returns inversion count in the arrays.*/ LL merge(LL arr[], LL temp[], LL left, LL mid, LL right) { LL i, j, k; LL inv_count = 0; i = left; /* i is index for left subarray*/ j = mid; /* j is index for right subarray*/ k = left; /* k is index for resultant merged subarray*/ while ((i <= mid - 1) && (j <= right)) { if (arr[i] <= arr[j]) { temp[k++] = arr[i++]; } else { temp[k++] = arr[j++]; /*this is tricky -- see above explanation/diagram for merge()*/ inv_count = inv_count + (mid - i); } } /* Copy the remaining elements of left subarray (if there are any) to temp*/ while (i <= mid - 1) temp[k++] = arr[i++]; /* Copy the remaining elements of right subarray (if there are any) to temp*/ while (j <= right) temp[k++] = arr[j++]; /*Copy back the merged elements to original array*/ for (i=left; i <= right; i++) arr[i] = temp[i]; return inv_count; } /* Driver program to test above functions */ LL arr[N]; int main() { LL n; scanf("%lld", &n); for (LL i = 0; i < n; i++) scanf("%lld", arr + i); printf("%lld\n", mergeSort(arr, n)); return 0; }
62ee8d68e36154fc596fdac100fb5f90c545ff28
77608ec2e368a86060e2495233939924cbed8f03
/interpreter/interpreter/browseroperations.h
186ae294195cb5193ecdf956b2bb510d81fba12e
[]
no_license
sugaryoleh/interpreter_web_browsers
9e3a5376cdd278acdb6a5d93375f96ca1f7b2598
58cb714843b3cf16f1e2278677af77cf1c6a05f7
refs/heads/master
2023-05-27T17:00:52.117247
2021-06-12T20:45:01
2021-06-12T20:45:01
282,283,677
2
0
null
null
null
null
UTF-8
C++
false
false
394
h
browseroperations.h
#pragma once #include "node.h" #include "lib.h" #include "interprocesscommunicator.h" #include "processdictionary.h" #include "varconverter.h" #include "ast.h" using namespace std; #include <iostream> namespace performers { namespace binop { void open(Node*); void click(Node*); void input(Node*); void clear(Node*); } namespace unop { void run(Node*); void qiut(Node*); } }
f1345f1600bd0b685ff4b650884567c6308f1214
1b3429d91531df34f96e4f3e5b10a59fb56347c5
/STRINGS/Implement strstr.cpp
6a1965113c925f3941a679932f6df79c78568339
[]
no_license
mkk96/IIIT-H-Initial-code
cc5d8c1bac2ad0f7239a76e46562ea8ab56769ca
ad9c40885a0a988a0b3d465dbbceb5eddfdb5002
refs/heads/main
2023-07-08T19:13:44.010889
2021-08-09T04:58:03
2021-08-09T04:58:03
387,806,725
0
0
null
null
null
null
UTF-8
C++
false
false
567
cpp
Implement strstr.cpp
#include<iostream> #include<bits/stdc++.h> #include<string> using namespace std; bool findImplementStrStr(string s1,string s2) { int i,j,k; for(i=0;i<s1.length();i++) { j=0; k=i; while(j<s2.length()) { if(s1[k]==s2[j]) { j++; k++; } else { break; } } if(j==s2.length()) { return true; } cout<<endl; } return false; } int main() { string s1,s2; getline(cin,s1); getline(cin,s2); if(findImplementStrStr(s1,s2)) { cout<<"Sub string present"; } else { cout<<"Sub string is not present"; } return 0; }
5e80411831e729f845010953477e604bd9545843
31561718bb5848a743ae4d3a4381cdace983c7d9
/Examples/FarmOperations/Testing/ChickenTester.h
65ff02ce9e6d5147995e1409d7f44686305d9681
[]
no_license
matthewshaw53/CS1440
454fa1dc0bbcd1605fa1a9557e4e9b900e0aafca
c8341f1033d59011ff6a3dcc92d049992707a749
refs/heads/master
2020-05-20T12:25:22.075749
2017-04-22T19:42:29
2017-04-22T19:42:29
80,482,088
0
0
null
null
null
null
UTF-8
C++
false
false
269
h
ChickenTester.h
// // Created by Stephen Clyde on 2/25/17. // #ifndef FARM_OPERATIONS_CHICKEN_TESTER_H #define FARM_OPERATIONS_CHICKEN_TESTER_H class ChickenTester { public: void testValidObjects(); void testInvalidObjects(); }; #endif //FARM_OPERATIONS_CHICKEN_TESTER_H
a56140f040a290b8b39edaf5178906f2e1fc7500
82661e261eeca6c2fc3344044892213f66604e92
/cf/cf276a.cpp
1712f86ea0b2e178abc2ee315bbc54006d03899f
[]
no_license
kevin20x2/acmcode
cb01cd571a1e21ffda159b5c0ce865e305a64ea3
636b39683f6f784a0da590cb6fcd531996b60cd8
refs/heads/master
2021-01-01T05:30:31.690408
2015-03-16T14:01:18
2015-03-16T14:01:18
30,408,267
0
0
null
null
null
null
UTF-8
C++
false
false
721
cpp
cf276a.cpp
/* *File: cf276a.cpp *Date : 2014-11-06 14:10:41 */ #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<vector> #include<algorithm> typedef long long LL; #define clr(x) memset((x),0,sizeof(x)) #define inf 0x3f3f3f3f #define loop(i,l,r) for(int (i)=(l);(i)<=(r);(i)++) #define iloop(i,l,r) for(int (i)=(r);(i)>=(l);(i)--) using namespace std; #define maxn 100050 int n,m; int vis[maxn]; int main() { clr(vis); scanf("%d%d",&n,&m); if(n>=m&&n%m==0) { puts("Yes"); return 0; } else n = n%m; while(n!=0) { if(vis[n] ==1) break; vis[n] =1; n=(n+(n%m))%m; } if(n) puts("No") ; else puts("Yes"); return 0; }
a59aeb1fcddd462b5e4aaf950fde0fddef05183c
93d1e11c01a31cf9b08ca980b7492f0b1bd841e1
/src/renderingwidget.cpp
cffa46640058f31779769e380e489896cbd5e5f1
[]
no_license
Superpeinture/ChefOeuvre
cc736ff2a503317f3c9962db740c6148017bdcbe
607589dbb90ee8f54b4e30d992fecbc68ff0460e
refs/heads/master
2020-05-27T21:48:16.320223
2017-02-20T15:45:38
2017-02-20T15:45:38
82,573,675
0
0
null
null
null
null
UTF-8
C++
false
false
3,061
cpp
renderingwidget.cpp
#include "renderingwidget.h" #include <QCoreApplication> #include <QKeyEvent> RenderingWidget::RenderingWidget(const QGLFormat & format, QWidget * parent) : QGLWidget(format, parent){ } RenderingWidget::~RenderingWidget(){ pipe_cpu->~Pipeline(); pipe_gpu->~Pipeline(); } void RenderingWidget::initializeGL() { glEnable(GL_DEPTH_TEST); glViewport(0,0,width(),height()); pipe_cpu = new Pipeline_CPU(); pipe_gpu = new Pipeline_GPU(); ConfigXML parseur; /** Indiquer le chemin vers les fichiers pigments */ parseur.loadFilesFromDirectory("../pigments/"); /* std::cout << "Nombre de pigments charges: " << parseur.pigmentList.size() << "\n" << std::endl; for(std::vector<Pigment>::iterator it = parseur.pigmentList.begin(); it != parseur.pigmentList.end(); ++it) (*it).printDataPigment(); */ /** Indiquer le chemin vers les fichiers lumieres */ parseur.loadFilesFromDirectory("../lumieres/"); /* std::cout << "Nombre de lumieres chargees: " << parseur.lightList.size() << std::endl; for(std::vector<Light>::iterator it = parseur.lightList.begin(); it != parseur.lightList.end(); ++it) (*it).printDataLight(); */ pigments = parseur.getPigmentList(); lumieres = parseur.getLightList(); slider_concentration = 1.f; label_pigment1 = "ac"; label_pigment2 = "ac"; lightLabel = "D65"; resultat = glm::vec3(0.0f, 0.0f, 0.0f); } void RenderingWidget::resizeGL(int w, int h) { glEnable(GL_DEPTH_TEST); glViewport(0,0,w,h); } void RenderingWidget::paintGL() { pipe_cpu->run_full_samples( getPigmentfromLabel(label_pigment1), getPigmentfromLabel(label_pigment2), slider_concentration, getLightfromLabel(lightLabel), resultat); glClearColor(resultat.x, resultat.y, resultat.z, 1.0f); glClear(GL_COLOR_BUFFER_BIT); } Pigment * RenderingWidget::getPigmentfromLabel(const QString& name){ int i=0; while(name.toStdString().compare(pigments.at(i).getLabel()) != 0) i++; return &(pigments.at(i)); } Light * RenderingWidget::getLightfromLabel(const QString& name){ int i=0; while(name.toStdString().compare(lumieres.at(i).getLabel()) != 0) i++; return &(lumieres.at(i)); } QColor RenderingWidget::getResultat(){ return QColor(resultat.x * 255, resultat.y * 255, resultat.z * 255); //return QColor(); } glm::vec3 RenderingWidget::getResultatFloatPrecision(){ return resultat; } vector<QString> RenderingWidget::getPigmentsLabels(){ vector<QString> list; for(int i = 0; i < pigments.size(); i++){ list.push_back(QString(pigments[i].getLabel().c_str())); } return list; } void RenderingWidget::setLabel_pigment1(QString label){ label_pigment1 = label; } void RenderingWidget::setLabel_pigment2(QString label){ label_pigment2 = label; } void RenderingWidget::setSlider_concentration(float concentration){ slider_concentration = concentration; }
3203e273a6dd3bf0342d78ee7443ed7a8f1bea27
f76ce7d98320f50e1e014bc22f09f22a8b27c8ed
/Torpedo/playerCPU.h
639cfe525986ed5f32564cc0673809c768e5483f
[]
no_license
AdamTamas/torpedo
ace5472eed5a69578899deb46ade6dad586b28fc
802be39de63a33f4cafdacd53e850e480c745064
refs/heads/main
2023-08-05T09:10:57.484363
2021-09-17T08:55:09
2021-09-17T08:55:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
630
h
playerCPU.h
#ifndef CPUPLAYER_H #define CPUPLAYER_H #include "playerBase.h" #include <map> class playerCPU : public playerBase { public: playerCPU(NewGameData newdata); Coordinate makeShot() override; virtual void initTable() override; void initOneTable(std::vector<std::vector<Area>> &t); virtual void resetTable() override; void resetOneTable(std::vector<std::vector<Area>> &t); virtual void shotResponse(int hit) override; protected: std::vector<std::vector<Area>> _enemyGameTable; // saját játéktábla std::map<Coordinate, bool> _priorityShots; Coordinate _lastShot; }; #endif // CPUPLAYER_H
48becf0fea36842e97c5a2f730ea4f674ea6e8ee
5db083de28ce3d342aeba75d23e3d40112c96bb0
/FinalFinalDB/FinalDB/person.h
ea6fdbd8db7b63d05bea731573d756972b4afb0d
[]
no_license
ciclop03/FinalFinalStatement
bcb65f044a11203dacdbc3b2e7fb5b530b0722a5
d49b6517a2be78fb504237f2cd437385e985a9ff
refs/heads/master
2020-06-03T05:20:43.008464
2019-06-28T12:21:38
2019-06-28T12:21:38
191,457,918
0
1
null
null
null
null
UTF-8
C++
false
false
454
h
person.h
#ifndef PERSON_H #define PERSON_H #include <string> #include <iostream> class Person { public: Person(std::string name, std::string lastname,std::string country, std::string gender, int age); Person(); virtual void showdata()=0; virtual ~Person(); //static Person makeperson(int choice); protected: std::string name, lastname,country, gender; int age; private: }; #endif // PERSON_H
9be8c14f4e61608eeb4975f7ac348dc5f822a088
17e7faa794bf25855a87dcd479bf353a0ea5c325
/utility/ConvexHull2D.cpp
04e019d39073b1d2c087b3e09db17e2cb8104347
[]
no_license
jietan/src
511a3f6418b508bf3afe43e1146bb56f58891c52
49f9aeba1373ba8d999878790e3d1958a2cb60af
refs/heads/master
2021-01-01T05:35:53.257784
2014-08-04T22:10:17
2014-08-04T22:10:17
20,268,252
1
0
null
null
null
null
UTF-8
C++
false
false
495
cpp
ConvexHull2D.cpp
#include "stdafx.h" #include "ConvexHull2D.h" #include "2dch.h" double* ConvexHull2D::P[N+1]; double ConvexHull2D::points[N][2]; vector<int> ConvexHull2D::GetConvexHull(const vector<vector3>& pts) { vector<int> ret; int numPoints = static_cast<int>(pts.size()); for (int i = 0; i < numPoints; ++i) { points[i][0] = pts[i].x; points[i][1] = pts[i].z; P[i] = points[i]; } int u = ch2d(P, numPoints); for (int i = 0; i < u; ++i) ret.push_back((P[i]-points[0])/2); return ret; }
e534f0b86467ed4e16a644d8b232a880ae460e31
18b3348d7b2e1f6fdf2750dcc24d67ce9305db43
/DronesManager/lab2_drones_manager.cpp
6e249c755ed32803334c3490b952f97b9c210d91
[]
no_license
mitchellostler/MTE140
9bdc22897437fa8e826adbc4026a0b39e7b53478
727dbcd603805524b0b0c9749c02cabebb6f110a
refs/heads/master
2022-10-19T05:50:04.684017
2020-06-09T18:04:04
2020-06-09T18:04:04
270,881,813
0
0
null
null
null
null
UTF-8
C++
false
false
6,164
cpp
lab2_drones_manager.cpp
#include "lab2_drones_manager.hpp" #include <iostream> // TODO: Implement all of the listed functions below // See the assignment specifications and the header file for details // Your code needs to pass at least all of the provided test cases DronesManager::DronesManager() { first = nullptr; last = nullptr; size = 0; } DronesManager::~DronesManager() { if(!empty()) { if(size==1) { delete first; first = nullptr; last = nullptr; } else { DroneRecord* current = last; DroneRecord* prev = last->prev; for(int node = 0; node < size - 1; node++) { current = prev; if (current->prev != nullptr) prev = current->prev; delete current; } // iterates through list freeing nodes first = nullptr; last=nullptr; } } } bool operator==(const DronesManager::DroneRecord& lhs, const DronesManager::DroneRecord& rhs) { bool checkA = (lhs.droneID==rhs.droneID && lhs.range==rhs.range && lhs.yearBought==rhs.yearBought); bool checkB = (lhs.batteryType==rhs.batteryType && lhs.description==rhs.description && lhs.droneType==rhs.droneType && lhs.manufacturer==rhs.manufacturer); return checkA && checkB; } unsigned int DronesManager::get_size() const { return size; } bool DronesManager::empty() const { return size==0; } DronesManager::DroneRecord* DronesManager::getDroneRecord(unsigned int index) const { if(index>=size || empty()) return nullptr; DroneRecord* current = first; DroneRecord* next; for(int node = 0; node < index; node++) { next = current->next; current = next; } return current; } DronesManager::DroneRecord DronesManager::select(unsigned int index) const { if(empty()) return DroneRecord(0); if(index>=size) return *last; return *getDroneRecord(index); } int DronesManager::search(DroneRecord value) const { if(empty()) return -1; DroneRecord* current = first; DroneRecord* next; for(int node = 0; node < size; node++){ if(value == *current) return node; next = current->next; current = next; } return size; } void DronesManager::print() const { for(int node = 0; node < size; node++) { DroneRecord* drone = getDroneRecord(node); cout << "DATA FOR DRONE: " << node + 1 << endl; cout << "Drone ID is: " << drone->droneID << endl; cout << "Drone Range: " << drone->range << endl; cout << "Drone Year bought is: " << drone->yearBought << endl; cout << "Drone Type : " << drone->droneType << endl; cout << "Drone Battery type is: " << drone->batteryType << endl; cout << "Drone Description: " << drone->description << endl << endl; cout << "this drone's address is: " << drone << endl << endl; cout << "prev is: " << drone->prev << endl; cout << "Next is: " << drone->next << endl << endl; } } bool DronesManager::insert(DroneRecord value, unsigned int index) { if(index>size) return false; DroneRecord* new_drone = new DroneRecord(value); DroneRecord* current = getDroneRecord(index); if(current == first || empty()) return insert_front(value); if(index == size) return insert_back(value); DroneRecord* prev = current->prev; new_drone->next = current; new_drone->prev = current->prev; prev->next = new_drone; current->prev = new_drone; size++; return true; } bool DronesManager::insert_front(DroneRecord value) { DroneRecord* new_drone = new DroneRecord(value); if(empty()) { first = new_drone; last = new_drone; new_drone->next = nullptr; new_drone->prev = nullptr; size++; return true; } else { DroneRecord* next = first; first = new_drone; new_drone->prev = nullptr; new_drone->next = next; next->prev = new_drone; } size++; return true; } bool DronesManager::insert_back(DroneRecord value) { DroneRecord* new_drone = new DroneRecord(value); if(empty()) { first = new_drone; last = new_drone; new_drone->next = nullptr; new_drone->prev = nullptr; size++; return true; } else { DroneRecord* prev = last; last = new_drone; new_drone->next = nullptr; new_drone->prev = prev; prev->next = new_drone; size++; return true; } } bool DronesManager::remove(unsigned int index) { if(index>size || empty()) return false; DroneRecord* current = getDroneRecord(index); if(current == first) return remove_front(); if(current == last) return remove_back(); DroneRecord* next = current->next; DroneRecord* prev = current->prev; delete current; next->prev = prev; prev->next = next; size--; return true; } bool DronesManager::remove_front() { if(empty()) return false; DroneRecord* current = first; if(size==1) { delete current; first = nullptr; last = nullptr; size--; return true; } else { DroneRecord* next = first->next; first = next; next->prev = nullptr; delete current; size--; } return true; } bool DronesManager::remove_back() { if(empty()) return false; DroneRecord* current = last; if(size==1) { delete current; last = nullptr; first = nullptr; size--; return true; } else { DroneRecord* prev = current->prev; delete current; last = prev; prev->next = nullptr; size--; } return true; } bool DronesManager::replace(unsigned int index, DroneRecord value) { if(index>size || empty()) return false; DroneRecord* current = getDroneRecord(index); current->batteryType = value.batteryType; current->droneID = value.droneID; current->droneType = value.droneType; current->description = value.description; current->manufacturer = value.manufacturer; current->range = value.range; current->yearBought = value.yearBought; return true; } bool DronesManager::reverse_list() { DroneRecord* current = first; DroneRecord* new_last = first; DroneRecord* next_node; DroneRecord* next_holder; for(int node = 0; node < size; node++) { next_node = current->next; next_holder = current->next; current->next = current->prev; current->prev = next_holder; current = next_node; } first = last; last = new_last; return true; }
f81db6377629ff7e2697cf649e18ee4ab695455a
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/chrome/browser/ash/accessibility/dictation.cc
869d2b99e16687a66843934c300c612875c356bd
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
9,444
cc
dictation.cc
// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ash/accessibility/dictation.h" #include "base/containers/contains.h" #include "base/containers/fixed_flat_map.h" #include "base/containers/flat_map.h" #include "base/strings/string_piece.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "components/language/core/browser/pref_names.h" #include "components/language/core/common/locale_util.h" #include "components/prefs/pref_service.h" #include "components/soda/soda_installer.h" #include "ui/accessibility/accessibility_features.h" #include "ui/base/ime/ash/input_method_manager.h" #include "ui/base/ime/ash/input_method_util.h" namespace ash { namespace { const char kDefaultProfileLocale[] = "en-US"; // Determines the user's language or locale from the system, first trying // the current IME language and falling back to the application locale. std::string GetUserLangOrLocaleFromSystem(Profile* profile) { // Convert from the ID used in the pref to a language identifier. std::vector<std::string> input_method_ids; input_method_ids.push_back( profile->GetPrefs()->GetString(::prefs::kLanguageCurrentInputMethod)); std::vector<std::string> languages; input_method::InputMethodManager::Get() ->GetInputMethodUtil() ->GetLanguageCodesFromInputMethodIds(input_method_ids, &languages); std::string user_language; if (!languages.empty()) user_language = languages[0]; // If we don't find an IME language, fall back to using the application // locale. if (user_language.empty()) user_language = g_browser_process->GetApplicationLocale(); return user_language.empty() ? kDefaultProfileLocale : user_language; } std::string GetSupportedLocale(const std::string& lang_or_locale) { if (lang_or_locale.empty()) return std::string(); // Map of language code to supported locale for the open web API. // Chrome OS does not support Chinese languages with "cmn", so this // map also includes a map from Open Speech API "cmn" languages to // their equivalent default locale. static constexpr auto kLangsToDefaultLocales = base::MakeFixedFlatMap<base::StringPiece, base::StringPiece>( {{"af", "af-ZA"}, {"am", "am-ET"}, {"ar", "ar-001"}, {"az", "az-AZ"}, {"bg", "bg-BG"}, {"bn", "bn-IN"}, {"bs", "bs-BA"}, {"ca", "ca-ES"}, {"cs", "cs-CZ"}, {"da", "da-DK"}, {"de", "de-DE"}, {"el", "el-GR"}, {"en", "en-US"}, {"es", "es-ES"}, {"et", "et-EE"}, {"eu", "eu-ES"}, {"fa", "fa-IR"}, {"fi", "fi-FI"}, {"fil", "fil-PH"}, {"fr", "fr-FR"}, {"gl", "gl-ES"}, {"gu", "gu-IN"}, {"he", "iw-IL"}, {"hi", "hi-IN"}, {"hr", "hr-HR"}, {"hu", "hu-HU"}, {"hy", "hy-AM"}, {"id", "id-ID"}, {"is", "is-IS"}, {"it", "it-IT"}, {"iw", "iw-IL"}, {"ja", "ja-JP"}, {"jv", "jv-ID"}, {"ka", "ka-GE"}, {"kk", "kk-KZ"}, {"km", "km-KH"}, {"kn", "kn-IN"}, {"ko", "ko-KR"}, {"lo", "lo-LA"}, {"lt", "lt-LT"}, {"lv", "lv-LV"}, {"mk", "mk-MK"}, {"ml", "ml-IN"}, {"mn", "mn-MN"}, {"mo", "ro-RO"}, {"mr", "mr-IN"}, {"ms", "ms-MY"}, {"my", "my-MM"}, {"ne", "ne-NP"}, {"nl", "nl-NL"}, {"no", "no-NO"}, {"pa", "pa-Guru-IN"}, {"pl", "pl-PL"}, {"pt", "pt-BR"}, {"ro", "ro-RO"}, {"ru", "ru-RU"}, {"si", "si-LK"}, {"sk", "sk-SK"}, {"sl", "sl-SI"}, {"sq", "sq-AL"}, {"sr", "sr-RS"}, {"su", "su-ID"}, {"sv", "sv-SE"}, {"sw", "sw-TZ"}, {"ta", "ta-IN"}, {"te", "te-IN"}, {"tl", "fil-PH"}, {"th", "th-TH"}, {"tr", "tr-TR"}, {"uk", "uk-UA"}, {"ur", "ur-PK"}, {"uz", "uz-UZ"}, {"vi", "vi-VN"}, {"yue", "yue-Hant-HK"}, {"zh", "zh-CN"}, {"zu", "zu-ZA"}, {"zh-cmn-CN", "zh-CN"}, {"zh-cmn", "zh-CN"}, {"zh-cmn-Hans", "zh-CN"}, {"zh-cmn-Hans-CN", "zh-CN"}, {"cmn-CN", "zh-CN"}, {"cmn-Hans", "zh-CN"}, {"cmn-Hans-CN", "zh-CN"}, {"cmn-Hant-TW", "zh-TW"}, {"zh-cmn-TW", "zh-TW"}, {"zh-cmn-Hant-TW", "zh-TW"}, {"cmn-TW", "zh-TW"}}); // First check if this is a language code supported in the map above. auto* iter = kLangsToDefaultLocales.find(lang_or_locale); if (iter != kLangsToDefaultLocales.end()) return std::string(iter->second); // If it's only a language code, we can return early, because no other // language-only codes are supported. std::pair<base::StringPiece, base::StringPiece> lang_and_locale_pair = language::SplitIntoMainAndTail(lang_or_locale); if (lang_and_locale_pair.second.size() == 0) return std::string(); // The code is a supported locale. Return itself. // Note that it doesn't matter if the supported locale is online or offline. if (base::Contains(Dictation::GetAllSupportedLocales(), lang_or_locale)) return lang_or_locale; // Finally, get the language code from the locale and try to use it to map // to a default locale. For example, "en-XX" should map to "en-US" if "en-XX" // does not exist. iter = kLangsToDefaultLocales.find(lang_and_locale_pair.first); if (iter != kLangsToDefaultLocales.end()) return std::string(iter->second); return std::string(); } } // namespace // static const base::flat_map<std::string, Dictation::LocaleData> Dictation::GetAllSupportedLocales() { base::flat_map<std::string, LocaleData> supported_locales; // If new RTL locales are added, ensure that // accessibility_common/dictation/commands.js RTLLocales is updated // appropriately. static const char* kWebSpeechSupportedLocales[] = { "af-ZA", "am-ET", "ar-AE", "ar-BH", "ar-DZ", "ar-EG", "ar-IL", "ar-IQ", "ar-JO", "ar-KW", "ar-LB", "ar-MA", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-TN", "ar-YE", "az-AZ", "bg-BG", "bn-BD", "bn-IN", "bs-BA", "ca-ES", "cs-CZ", "da-DK", "de-AT", "de-CH", "de-DE", "el-GR", "en-AU", "en-CA", "en-GB", "en-GH", "en-HK", "en-IE", "en-IN", "en-KE", "en-NG", "en-NZ", "en-PH", "en-PK", "en-SG", "en-TZ", "en-US", "en-ZA", "es-AR", "es-BO", "es-CL", "es-CO", "es-CR", "es-DO", "es-EC", "es-ES", "es-GT", "es-HN", "es-MX", "es-NI", "es-PA", "es-PE", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et-EE", "eu-ES", "fa-IR", "fi-FI", "fil-PH", "fr-BE", "fr-CA", "fr-CH", "fr-FR", "gl-ES", "gu-IN", "hi-IN", "hr-HR", "hu-HU", "hy-AM", "id-ID", "is-IS", "it-CH", "it-IT", "iw-IL", "ja-JP", "jv-ID", "ka-GE", "kk-KZ", "km-KH", "kn-IN", "ko-KR", "lo-LA", "lt-LT", "lv-LV", "mk-MK", "ml-IN", "mn-MN", "mr-IN", "ms-MY", "my-MM", "ne-NP", "nl-BE", "nl-NL", "no-NO", "pa-Guru-IN", "pl-PL", "pt-BR", "pt-PT", "ro-RO", "ru-RU", "si-LK", "sk-SK", "sl-SI", "sq-AL", "sr-RS", "su-ID", "sv-SE", "sw-KE", "sw-TZ", "ta-IN", "ta-LK", "ta-MY", "ta-SG", "te-IN", "th-TH", "tr-TR", "uk-UA", "ur-IN", "ur-PK", "uz-UZ", "vi-VN", "yue-Hant-HK", "zh-CN", "zh-TW", "zu-ZA", "ar-001"}; for (const char* locale : kWebSpeechSupportedLocales) { // By default these languages are not supported offline. supported_locales[locale] = LocaleData(); } if (features::IsDictationOfflineAvailable()) { speech::SodaInstaller* soda_installer = speech::SodaInstaller::GetInstance(); std::vector<std::string> offline_locales = soda_installer->GetAvailableLanguages(); for (auto locale : offline_locales) { // These are supported offline. supported_locales[locale] = LocaleData(); supported_locales[locale].works_offline = true; supported_locales[locale].installed = soda_installer->IsSodaInstalled(speech::GetLanguageCode(locale)); } } return supported_locales; } // static std::string Dictation::DetermineDefaultSupportedLocale(Profile* profile, bool new_user) { std::string lang_or_locale; if (new_user) { // This is the first time this user has enabled Dictation. Pick the default // language preference based on their application locale. lang_or_locale = g_browser_process->GetApplicationLocale(); } else { // This user has already had Dictation enabled, but now we need to map // from the language they've previously used to a supported locale. lang_or_locale = GetUserLangOrLocaleFromSystem(profile); } std::string supported_locale = GetSupportedLocale(lang_or_locale); return supported_locale.empty() ? kDefaultProfileLocale : supported_locale; } } // namespace ash
42f78c7445e8d9541f123f79a0f35304857de84f
fb283e5049c58ed19679d710d1635a897a4f68a9
/include/SDLpp/window/window_free_functions.hpp
90f3edcb74bd9f2396c5307e84beabb842f9f202
[ "MIT" ]
permissive
rbrugo/SDLpp
d84ad77058d5ded1b46cf9511a4b35d65a69f901
0387589065ac0a31d93945c0546f64330d824bf9
refs/heads/master
2023-03-21T23:21:52.418712
2018-04-29T23:22:58
2018-04-29T23:22:58
125,532,038
0
0
null
null
null
null
UTF-8
C++
false
false
577
hpp
window_free_functions.hpp
/** * @author : Riccardo Brugo (brugo.riccardo@gmail.com) * @file : window_free_functions * @created : Sunday Apr 22, 2018 18:28:44 CEST * @license : MIT * */ #ifndef SDLPP_WINDOW_FREE_FUNCTIONS_HPP #define SDLPP_WINDOW_FREE_FUNCTIONS_HPP #include "window.hpp" #include <tl/optional.hpp> namespace SDLpp { inline auto get_surface(window const & w) { return w.get_surface(); } inline auto get_surface(tl::optional<window> const & opt_w) { return opt_w->get_surface(); } } // namespace SDLpp #endif /* SDLPP_WINDOW_FREE_FUNCTIONS_HPP */
0c042f64e4d0c85941d62738c01e571576a021bc
212e652e863d0d88b46dfe200d21ca7f45c83db1
/ECOO/Fibonacci Spiral.cpp
12d62cd7fe5d194fc143cc1f5140b66d660b81da
[]
no_license
SouradeepSaha/DMOJ
8828020d7e98aacc6fed60cfa454a6817e430272
93c727be9f9b2b9bb6f4dddd423b48d843913fc1
refs/heads/master
2020-12-09T14:18:29.420357
2020-05-26T00:38:07
2020-05-26T00:38:07
233,331,392
0
0
null
null
null
null
UTF-8
C++
false
false
1,601
cpp
Fibonacci Spiral.cpp
#include <iostream> #include <vector> using namespace std; int main() { vector<pair<long,long>> grid[10001]; vector<long> fib(10001); pair<long,long> tr={1,0}, dr={1,-1}, tl={-1,0}, dl={-1,-1}; fib[1] = 1, fib[2] = 1; grid[1].push_back({0,1}), grid[1].push_back({-1, 0}); grid[2].push_back({-1,0}), grid[2].push_back({-1,0}); for (int i = 3; i <= 10000; i++){ fib[i] = fib[i-1] + fib[i-2]; if (i%4 == 1){ grid[i].push_back({dl.first, dr.first}); grid[i].push_back({dl.second - fib[i], dl.second}); dl.second -= fib[i], dr.second -= fib[i]; } else if (i%4 == 2) { grid[i].push_back({tl.first-fib[i], tl.first}); grid[i].push_back({dl.second, tl.second}); tl.first -= fib[i], dl.first -= fib[i]; } else if (i%4 == 3) { grid[i].push_back({tl.first, tr.first}); grid[i].push_back({tl.second, tl.second+fib[i]}); tl.second += fib[i], tr.second += fib[i]; } else { grid[i].push_back({tr.first, tr.first+fib[i]}); grid[i].push_back({dr.second, tr.second}); tr.first += fib[i], dr.first += fib[i]; } } for (int kase = 0; kase < 10; kase++) { long x, y; cin >> x >> y; for (int i = 1; i <= 10000; i++) { if (x >= grid[i][0].first and x <= grid[i][0].second and y >= grid[i][1].first and y <= grid[i][1].second) { cout << i << endl; break; } } } return 0; }
ee8c1ac70f00b15f8ab1d473ae38783c008cb119
fffb7371a614a942d8969bc25a497d92816c8f56
/SumofFact.cpp
5f2dfc5c23d7ae8b78e4aec9c0108f83631220f7
[]
no_license
breakitup/Java
f5ad5f053094afc749506fe9f053b74ae0ec8963
69ef85b93e1ab674baf031e3df038a8c4a0235f6
refs/heads/master
2021-06-18T08:44:17.382753
2017-06-18T07:41:57
2017-06-18T07:41:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
939
cpp
SumofFact.cpp
/* * SumofFact.cpp * * Created on: 24-Apr-2017 * Author: asingha6 */ #include<stdio.h> #include<iostream> using namespace std; int fact(int n){ if(n==1) return 1; else return n*fact(n-1); } long long sumoffact(int n,int i){ if(n==i) return n; else return (sumoffact(n,i+1)+1)*i; } void fun(int *a){ (*a)++; } class base{ public: virtual void fun(){ cout<<"base class\n"; } }; class Derived:public base{ public: void fun(){ cout<<"Derived class\n"; } Derived fun1(); }; Derived Derived::fun1(){ Derived obj; return obj; } Derived fun2(){ Derived obj; return obj; } int main(){ int n; cin>>n; cout<<sumoffact(n,1)<<endl; fun(&n); cout<<n<<endl; base *b=new Derived(); b->fun(); int *n1=new int[10]; n1[0]=8; return 0; int c=5; int const* d =&c; const int *a=&c; c=6; //d=&f; //a=8; //a=9; Derived obj; Derived (*fun_ptr)(); fun_ptr=&(fun2); (*fun_ptr)(); }
05817a30d878d7868aa7497aa6387cefbb93fe86
8b08287f243df6c8ed40968f00b28666103bb481
/pollclients.h
2549fe013248680b0163b65aec97b14d468e68df
[]
no_license
sconnet/pgserver
88cf20bf8908caf3326f9ec6c11e694363ba3b6d
6c8ede19d5cd7c9d0b63c5a4dfbbe2705f7b4fb3
refs/heads/master
2020-12-25T14:33:41.460924
2015-03-15T05:10:02
2015-03-15T05:10:02
66,329,300
0
0
null
null
null
null
UTF-8
C++
false
false
1,334
h
pollclients.h
//***************************************************************************** // // Copyright (C) 2001 Pear Gear, Inc. All rights reserved. // // Programmer : Steve Connet // Feb. 10, 2001 // // Source File Name : pollclients.h // // Version : $Id: pollclients.h,v 1.2 2001/04/23 01:05:46 sconnet Exp $ // // File Overview : // // Revision History : // // $Log: pollclients.h,v $ // Revision 1.2 2001/04/23 01:05:46 sconnet // continued development // // // //***************************************************************************** #ifndef __POLLCLIENTS_H_ #define __POLLCLIENTS_H_ #include "thread.h" #include "lock.h" #include "client.h" #include <map> typedef std::map<int, CClient> ClientMap; class CPollClients : public CThread, private CLock { public: CPollClients(); virtual ~CPollClients(); inline void operator<<(const CClient &client) { insert(client); } // inline void operator>>(const CClient& client) { erase(client); } void insert(const CClient &client); void erase(const CClient &client); int size(); void disconnectAll(); void start(); void stop(bool waitForThreadJoin = true); private: void thread(); private: ClientMap m_map; fd_set m_clients; int m_nMaxFd; }; #endif // __POLLCLIENTS_H_
ddb0867f4f8873c516f166538b12bef1562f0eb2
8194c153de598eaca637559443f71d13b729d4d2
/ogsr_engine/xrGame/agent_location_manager.cpp
baf8ff1deea97736c794e68901b037b273611fed
[ "Apache-2.0" ]
permissive
NikitaNikson/X-Ray_Renewal_Engine
8bb464b3e15eeabdae53ba69bd3c4c37b814e33e
38cfb4a047de85bb0ea6097439287c29718202d2
refs/heads/dev
2023-07-01T13:43:36.317546
2021-08-01T15:03:31
2021-08-01T15:03:31
391,685,134
4
4
Apache-2.0
2021-08-01T16:52:09
2021-08-01T16:52:09
null
UTF-8
C++
false
false
6,173
cpp
agent_location_manager.cpp
//////////////////////////////////////////////////////////////////////////// // Module : agent_location_manager.cpp // Created : 24.05.2004 // Modified : 14.01.2005 // Author : Dmitriy Iassenev // Description : Agent location manager //////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "agent_location_manager.h" #include "agent_manager.h" #include "agent_member_manager.h" #include "agent_enemy_manager.h" #include "ai/stalker/ai_stalker.h" #include "cover_point.h" const float MIN_SUITABLE_ENEMY_DISTANCE = 3.f;//10.f; struct CRemoveOldDangerCover { typedef CAgentMemberManager::MEMBER_STORAGE MEMBER_STORAGE; CAgentMemberManager *m_members; IC CRemoveOldDangerCover (CAgentMemberManager *members) { VERIFY (members); m_members = members; } IC bool operator() (const CAgentLocationManager::CDangerLocationPtr &location) const { if (!location->useful()) { MEMBER_STORAGE::iterator I = m_members->members().begin(); MEMBER_STORAGE::iterator E = m_members->members().end(); for ( ; I != E; ++I) { if (!location->mask().test(m_members->mask(&(*I)->object()))) continue; (*I)->object().on_danger_location_remove (*location); } } return (!location->useful()); } }; struct CDangerLocationPredicate { Fvector m_position; IC CDangerLocationPredicate (const Fvector &position) { m_position = position; } IC bool operator() (const CAgentLocationManager::CDangerLocationPtr &location) const { return (*location == m_position); } }; IC CAgentLocationManager::CDangerLocationPtr CAgentLocationManager::location (const Fvector &position) { LOCATIONS::iterator I = std::find_if(m_danger_locations.begin(),m_danger_locations.end(),CDangerLocationPredicate(position)); if (I != m_danger_locations.end()) return (*I); return (0); } bool CAgentLocationManager::suitable (CAI_Stalker *object, const CCoverPoint *location, bool use_enemy_info) const { CAgentMemberManager::const_iterator I = this->object().member().members().begin(); CAgentMemberManager::const_iterator E = this->object().member().members().end(); for ( ; I != E; ++I) { if ((*I)->object().ID() == object->ID()) continue; // if ((*I)->object().Position().distance_to_sqr(location->position()) <= _sqr(5.f)) // return (false); if (!(*I)->cover()) continue; // check if member cover is too close if ((*I)->cover()->m_position.distance_to_sqr(location->position()) <= _sqr(5.f)) // so member cover is too close // if ((*I)->object().Position().distance_to_sqr(location->position()) <= object->Position().distance_to_sqr(location->position())) // check if member to its cover is more close than we to our cover if ((*I)->object().Position().distance_to_sqr((*I)->cover()->m_position) <= object->Position().distance_to_sqr(location->position()) + 2.f) return (false); } if (use_enemy_info) { CAgentEnemyManager::ENEMIES::const_iterator I = this->object().enemy().enemies().begin(); CAgentEnemyManager::ENEMIES::const_iterator E = this->object().enemy().enemies().end(); for ( ; I != E; ++I) if ((*I).m_enemy_position.distance_to_sqr(location->position()) < _sqr(MIN_SUITABLE_ENEMY_DISTANCE)) return (false); } return (true); } void CAgentLocationManager::make_suitable (CAI_Stalker *object, const CCoverPoint *location) const { this->object().member().member(object).cover(location); if (!location) return; CAgentMemberManager::const_iterator I = this->object().member().members().begin(); CAgentMemberManager::const_iterator E = this->object().member().members().end(); for ( ; I != E; ++I) { if ((*I)->object().ID() == object->ID()) continue; if (!(*I)->cover()) continue; // check if member cover is too close if ((*I)->cover()->m_position.distance_to_sqr(location->position()) <= _sqr(5.f)) { // Msg ("%6d : object [%s] disabled cover for object [%s]",Device.dwFrame,*object->cName(),*(*I)->object().cName()); (*I)->object().on_cover_blocked ((*I)->cover()); (*I)->cover (0); } } } void CAgentLocationManager::add (CDangerLocationPtr location) { typedef CAgentMemberManager::MEMBER_STORAGE MEMBER_STORAGE; MEMBER_STORAGE::iterator I = object().member().members().begin(); MEMBER_STORAGE::iterator E = object().member().members().end(); for ( ; I != E; ++I) { if (!location->mask().test(object().member().mask(&(*I)->object()))) continue; (*I)->object().on_danger_location_add (*location); } CDangerLocationPtr danger = this->location(location->position()); if (!danger) { m_danger_locations.push_back(location); return; } danger->m_level_time = location->m_level_time; if (danger->m_interval < location->m_interval) danger->m_interval = location->m_interval; if (danger->m_radius < location->m_radius) danger->m_radius = location->m_radius; } void CAgentLocationManager::remove_old_danger_covers () { m_danger_locations.erase ( std::remove_if( m_danger_locations.begin(), m_danger_locations.end(), CRemoveOldDangerCover( &object().member() ) ), m_danger_locations.end() ); } float CAgentLocationManager::danger (const CCoverPoint *cover, CAI_Stalker *member) const { float result = 1; squad_mask_type mask = object().member().mask(member); LOCATIONS::const_iterator I = m_danger_locations.begin(); LOCATIONS::const_iterator E = m_danger_locations.end(); for ( ; I != E; ++I) { if (Device.dwTimeGlobal > (*I)->m_level_time + (*I)->m_interval) continue; if (!(*I)->mask().test(mask)) continue; float distance = 1.f + (*I)->position().distance_to(cover->position()); if (distance > (*I)->m_radius) continue; result *= float(Device.dwTimeGlobal - (*I)->m_level_time)/float((*I)->m_interval); } return (result); } void CAgentLocationManager::update () { remove_old_danger_covers (); } void CAgentLocationManager::remove_links(CObject *object) { m_danger_locations.erase ( std::remove_if( m_danger_locations.begin(), m_danger_locations.end(), CRemoveDangerObject(object) ), m_danger_locations.end() ); }
156de0012d7362a5e3f04819651bbbd7dc7e57ee
2f3e5e25acf92139fc1decde333444357cf20c3e
/deviceInterfaces/basedeviceinterface.cpp
69ab28a7c162ed6c5ae8a1aeb7873303d8181e92
[]
no_license
vkaliteevsky/Alcogram
830f1015190e8f88c1906eaf3403c68f09cde9c2
2af1c1c2db590a0da0d25204779096b5655bd69f
refs/heads/master
2021-03-27T15:26:23.192997
2018-02-03T00:08:32
2018-02-03T00:08:32
109,609,608
0
1
null
null
null
null
UTF-8
C++
false
false
131
cpp
basedeviceinterface.cpp
#include "baseDeviceInterface.h" void BaseDeviceInterface::setOnErrorCallback(DeviceCallback onError) { _onError = onError; }
602f39f7a3a1ae14748dfd37583cdca69bce09ec
228077466eda434f569a85cca69527dbf9f225d9
/CodeAnalyzer/AnalyzedFile.cpp
61e147004b0b26d99dfdc6de7c3cdcbfd173848d
[]
no_license
Pio-Woj/CodeAnalyzer
5e76dbf704f4225804a1d9a0831b1de530524c8d
de7cff9c086a8c02a73227f8577dd40181683f71
refs/heads/main
2023-02-20T05:29:34.241418
2021-01-19T18:37:12
2021-01-19T18:37:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,679
cpp
AnalyzedFile.cpp
#include <iostream> #include "AnalyzedFile.h" // Default constructor AnalyzedFile::AnalyzedFile() :fFilePathWstring{ L"" }, fNumberOfLetters{ 0 }, fNumberOfWords{ 0 }, fNumberOfLines{ 0 } { } // Parametric constructor -> initializing object of file with fixed path // statistics set to zero, because analyze hasn`t happened AnalyzedFile::AnalyzedFile(std::filesystem::path filePath) :fFilePathWstring{ filePath.wstring() }, fNumberOfLetters{ 0 }, fNumberOfWords{ 0 }, fNumberOfLines{ 0 } { } ////////////////////////////////////////////////////////////////////// // Function which analyzes a file and then sets all integer variables ////////////////////////////////////////////////////////////////////// // // INPUT: void // OUTPUT: void // REMARKS: Function saves results of file analyze in private // variables of class by setters // void AnalyzedFile::setFileStatistics() { // Checking whether file path points to folder // If yes, skip the analysis // Statistics for folder are set by different method in AnalyzedFolder class if (std::filesystem::is_directory(getFilePathWstring())) return; int numberOfLetters = 0; int numberOfLines = 0; int numberOfWords = 0; // Trying to open file std::wifstream fileHandler(getFilePathWstring()); // Checking whether file is open // If yes, start analysis if (fileHandler.good()) { std::wstring line{}; // Reading line by line from the file being currently analyzed while (std::getline(fileHandler, line)) { numberOfLines++; numberOfLetters += line.length(); // Initializing empty wstring and wstringstream with buffer // filled by one line from file std::wstring ws; std::wstringstream wss(line); // Cleaning buffer of wstringstream word by word and counting them // White spaces are omitted by this method. while (wss >> ws) numberOfWords++; } // Closing file fileHandler.close(); } setNumberOfLetters(numberOfLetters); setNumberOfLines(numberOfLines); setNumberOfWords(numberOfWords); } // Getters/setters std::wstring AnalyzedFile::getFilePathWstring() { return fFilePathWstring; } int AnalyzedFile::getNumberOfLetters() { return fNumberOfLetters; } int AnalyzedFile::getNumberOfWords() { return fNumberOfWords; } int AnalyzedFile::getNumberOfLines() { return fNumberOfLines; } void AnalyzedFile::setFilePathWstring(std::filesystem::path filePath) { fFilePathWstring = filePath.wstring(); } void AnalyzedFile::setNumberOfLetters(int letters) { fNumberOfLetters = letters; } void AnalyzedFile::setNumberOfLines(int lines) { fNumberOfLines = lines; } void AnalyzedFile::setNumberOfWords(int words) { fNumberOfWords = words; }
3b99c174b8bd18ac4ff895d55a678779ebfc6688
c255023a196cca028aa2eff783e7ffbf32760824
/source/un_finished/inet_addr/tcp_socket.h
ae8c4b46c927c53f1d7c78b0071a3075d86d878a
[]
no_license
wsa10054/misc-code
cdc20885027b00660a73cbcc32304044b55680cd
2161418287bc4a5b9e64368035f2ff90de6b0d70
refs/heads/master
2021-01-01T19:11:34.172140
2012-08-31T09:32:52
2012-08-31T09:32:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
862
h
tcp_socket.h
#ifndef MURADIN_NET_TCP_SOCKET_H_ #define MURADIN_NET_TCP_SOCKET_H_ namespace net{ class EndPointV4; //创建一个非阻塞套接字并带有FD_CLOEXEC选项 int tcp_nbsocket_create(); //创建一个阻塞套接字并带有FD_CLOEXEC选项 int tcp_socket_create(); int tcp_socket_bind(int fd,const EndPointV4& endpoint); int tcp_socket_accept(int listen_fd, EndPointV4& peer); //设置非阻塞 void set_nonblock(int fd); //设置FD_CLOEXEC void set_close_on_exec(int fd); // 关闭读端,所有套接字读缓冲区中残留的数据将被丢弃 int shutdown_r(int fd); // 关闭写端,所有套接字写缓冲区中残留的数据将被发送,并且附带一个FIN分节 int shutdown_w(int fd); // 等同于先调用shutdown_r,然后调用shutdown_w int shutdown_rw(int fd); };//net #endif//MURADIN_NET_TCP_SOCKET_H_
9843f97469181b172b118f02347efae78c9182dc
a2424637c2a63f990c6ee6bcf0929e74c4151e05
/BipartiteMatching/MaximumIndependentset/loj1356.cpp
5d012734c335c98da084b212b841d4387fa7bfc8
[]
no_license
Rajon-Chowdhury/Graph-Theory
ba9668e2e6fc9fe986e22bc6aaba50b6af90f054
20c6af32d43ca8972d0010e8730b14eec2a8e52d
refs/heads/main
2023-03-14T16:07:07.012037
2021-03-31T02:33:51
2021-03-31T02:33:51
334,974,614
0
0
null
null
null
null
UTF-8
C++
false
false
3,608
cpp
loj1356.cpp
#include<bits/stdc++.h> #define REP(i,n) for (int i = 1; i <= n; i++) #define mod 1000000007 #define pb push_back #define ff first #define ss second #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define lli unsigned long long #define ll long long #define endl '\n' using namespace std; const int NX = 500000 + 10; const int MX = 40000 + 10 ; const int INF = 1 << 29 ; int check[NX] , prime[NX] , id , n ; int num[MX]; int save[MX]; vector < int > adj[MX]; int dist[MX] , match[MX] ; int q[NX] , pos[NX] ; /// prime calculation #define mxx 1000006 bitset <mxx> mark; vector <int> primes; void sieve() { mark[0] = mark[1] = 1; primes.push_back(2); int lim = sqrt(mxx * 1.0) + 2; for (int i = 4; i < mxx; i += 2) mark[i] = 1; for (int i = 3; i < mxx; i += 2) { if (!mark[i]) { primes.push_back(i); if (i <= lim) for (int j = i * i; j < mxx; j += i) mark[j] = 1; } } } void init(){ for(int i=1;i<=n+1;i++) adj[i].clear(),match[i]=0; memset(pos,0,sizeof pos); } bool bfs() { int f = 0 , b = 0 , i ; for(int i=1;i<=n;i++) { if( match[i] == 0 ) { dist[i] = 0 ; q[f++] = i ; } else dist[i] = INF ; } dist[0] = INF ; while( b < f ) { int x = q[b++] ; if( x == 0 ) continue ; int sz = adj[x].size(); for(int i=0;i<sz;i++) { int y = adj[x][i]; if( dist[match[y]] == INF ) { dist[match[y]] = dist[x] + 1 ; q[f++] = match[y]; } } } return dist[0] != INF ; } bool dfs(int x) { if( x ) { int sz = adj[x].size(); for(int i=0;i<sz;i++) { int y = adj[x][i]; if( dist[match[y]] == dist[x] + 1 && dfs(match[y])) { match[x] = y ; match[y] = x ; return 1 ; } } dist[x] = INF ; return 0 ; } return 1 ; } int hopcropt() { int matching = 0 ; while( bfs() ) { for( int i = 1 ; i <= n ; i++ ) { if( match[i] == 0 && dfs(i) ) { matching++; } } } return n - matching ; } int main(){ sieve(); int t,cs=1; scanf("%d",&t); while(t--){ scanf("%d",&n); init(); for(int i=1;i<=n;i++) { scanf("%d",&num[i]); pos[num[i]]=i; } for(int i=1;i<=n;i++) { int x=num[i]; int cot=0; for(int k=0;primes[k]*primes[k]<=x;k++) { int f=0; while(x%primes[k]==0) { f=1; x/=primes[k]; } if(f) save[++cot]=primes[k]; } if(x>1) save[++cot]=x; for(int k=1;k<=cot;k++) { //cout<<save[k]<<endl; int y=num[i]/save[k]; if(pos[y]) { //cout<<i<<" "<<pos[y]<<endl; adj[i].push_back(pos[y]); adj[pos[y]].push_back(i); } } } int res=hopcropt(); printf("Case %d: %d\n",cs++,res); } }
d2c275219de85c94160408cab8a19bb3b19cecfc
801f7ed77fb05b1a19df738ad7903c3e3b302692
/optimisationRefactoring/differentiatedCAD/occt-min-topo-src/src/TDataStd/TDataStd_Integer.cxx
60ebf92e6a6a46b9cd3eee04e31a8631800b72fc
[]
no_license
salvAuri/optimisationRefactoring
9507bdb837cabe10099d9481bb10a7e65331aa9d
e39e19da548cb5b9c0885753fe2e3a306632d2ba
refs/heads/master
2021-01-20T03:47:54.825311
2017-04-27T11:31:24
2017-04-27T11:31:24
89,588,404
0
1
null
null
null
null
UTF-8
C++
false
false
4,631
cxx
TDataStd_Integer.cxx
// Created on: 1997-03-06 // Created by: Denis PASCAL // Copyright (c) 1997-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include <Standard_GUID.hxx> #include <Standard_Type.hxx> #include <TDataStd_Integer.hxx> #include <TDF_Attribute.hxx> #include <TDF_Label.hxx> #include <TDF_Reference.hxx> #include <TDF_RelocationTable.hxx> //======================================================================= //function : GetID //purpose : //======================================================================= const Standard_GUID& TDataStd_Integer::GetID() { static Standard_GUID TDataStd_IntegerID ("2a96b606-ec8b-11d0-bee7-080009dc3333"); return TDataStd_IntegerID; } //======================================================================= //function : Set //purpose : //======================================================================= Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L, const Standard_Integer V) { Handle(TDataStd_Integer) A; if (!L.FindAttribute (TDataStd_Integer::GetID(), A)) { A = new TDataStd_Integer (); L.AddAttribute(A); } A->Set (V); return A; } //======================================================================= //function : TDataStd_Integer //purpose : Empty Constructor //======================================================================= TDataStd_Integer::TDataStd_Integer () : myValue (-1) { } //======================================================================= //function : Set //purpose : //======================================================================= void TDataStd_Integer::Set(const Standard_Integer v) { // OCC2932 correction if(myValue == v) return; Backup(); myValue = v; } //======================================================================= //function : Get //purpose : //======================================================================= Standard_Integer TDataStd_Integer::Get () const { return myValue; } //======================================================================= //function : IsCaptured //purpose : //======================================================================= Standard_Boolean TDataStd_Integer::IsCaptured() const { Handle(TDF_Reference) R; return (Label().FindAttribute(TDF_Reference::GetID(),R)); } //======================================================================= //function : ID //purpose : //======================================================================= const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); } //======================================================================= //function : NewEmpty //purpose : //======================================================================= Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const { return new TDataStd_Integer (); } //======================================================================= //function : Restore //purpose : //======================================================================= void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With) { myValue = Handle(TDataStd_Integer)::DownCast (With)->Get(); } //======================================================================= //function : Paste //purpose : //======================================================================= void TDataStd_Integer::Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& /*RT*/) const { Handle(TDataStd_Integer)::DownCast(Into)->Set(myValue); } //======================================================================= //function : Dump //purpose : //======================================================================= Standard_OStream& TDataStd_Integer::Dump (Standard_OStream& anOS) const { anOS << "Integer:: "<< this <<" : "; anOS << myValue; // anOS <<"\nAttribute fields: "; TDF_Attribute::Dump(anOS); return anOS; }
66a539e73dd43386b4cd08960888581b17e4fdf3
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/extensions/browser/api/messaging/message_port.h
66e16ba183cf4a53d6c2cf67b89e994ba19f6a27
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
4,538
h
message_port.h
// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef EXTENSIONS_BROWSER_API_MESSAGING_MESSAGE_PORT_H_ #define EXTENSIONS_BROWSER_API_MESSAGING_MESSAGE_PORT_H_ #include <string> #include "base/values.h" #include "extensions/browser/activity.h" #include "extensions/browser/extension_api_frame_id_map.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" class GURL; namespace content { class RenderFrameHost; } namespace extensions { enum class ChannelType; struct Message; struct MessagingEndpoint; struct PortId; struct PortContext; // One side of the communication handled by extensions::MessageService. class MessagePort { public: // Delegate handling the channel between the port and its host. class ChannelDelegate { public: // Closes the message channel associated with the given port, and notifies // the other side. virtual void CloseChannel(const PortId& port_id, const std::string& error_message) = 0; // Enqueues a message on a pending channel, or sends a message to the given // port if the channel isn't pending. virtual void PostMessage(const PortId& port_id, const Message& message) = 0; }; MessagePort(const MessagePort&) = delete; MessagePort& operator=(const MessagePort&) = delete; virtual ~MessagePort(); // Called right before a channel is created for this MessagePort and |port|. // This allows us to ensure that the ports have no RenderFrameHost instances // in common. virtual void RemoveCommonFrames(const MessagePort& port); // Checks whether the given RenderFrameHost is associated with this port. virtual bool HasFrame(content::RenderFrameHost* render_frame_host) const; // Called right before a port is connected to a channel. If false, the port // is not used and the channel is closed. virtual bool IsValidPort() = 0; // Triggers the check of whether the port is still valid. If the port is // determined to be invalid, the channel will be closed. This should only be // called for opener ports. virtual void RevalidatePort(); // Notifies the port that the channel has been opened. virtual void DispatchOnConnect( ChannelType channel_type, const std::string& channel_name, absl::optional<base::Value::Dict> source_tab, const ExtensionApiFrameIdMap::FrameData& source_frame, int guest_process_id, int guest_render_frame_routing_id, const MessagingEndpoint& source_endpoint, const std::string& target_extension_id, const GURL& source_url, absl::optional<url::Origin> source_origin); // Notifies the port that the channel has been closed. If |error_message| is // non-empty, it indicates an error occurred while opening the connection. virtual void DispatchOnDisconnect(const std::string& error_message); // Dispatches a message to this end of the communication. virtual void DispatchOnMessage(const Message& message) = 0; // Marks the port as opened by the specific frame or service worker. virtual void OpenPort(int process_id, const PortContext& port_context); // Closes the port for the given frame or service worker. virtual void ClosePort(int process_id, int routing_id, int worker_thread_id); // MessagePorts that target extensions will need to adjust their keepalive // counts for their lazy background page. virtual void IncrementLazyKeepaliveCount(Activity::Type activity_type); virtual void DecrementLazyKeepaliveCount(Activity::Type activity_type); // Notifies the message port that one of the receivers intents to respond // later. virtual void NotifyResponsePending(); bool should_have_strong_keepalive() const { return should_have_strong_keepalive_; } bool is_for_onetime_channel() const { return is_for_onetime_channel_; } void set_should_have_strong_keepalive(bool should_have_strong_keepalive) { should_have_strong_keepalive_ = should_have_strong_keepalive; } void set_is_for_onetime_channel(bool is_for_onetime_channel) { is_for_onetime_channel_ = is_for_onetime_channel; } protected: MessagePort(); private: // This port should keep the service worker alive while it is open. bool should_have_strong_keepalive_ = false; // This port was created for one-time messaging channel. bool is_for_onetime_channel_ = false; }; } // namespace extensions #endif // EXTENSIONS_BROWSER_API_MESSAGING_MESSAGE_PORT_H_
72a60ac928a6411b07f8fa87a5dd0842b8beeba3
3a3002e883bd57840fef26146a187d613957b457
/其他/json/include/json/forwards.h
c1132067ed23ade6bda4bc34f94a90519dee9bbc
[ "BSD-2-Clause", "MIT" ]
permissive
juhuaguai/duilib
184f5ce6c4d1aa2056d7c954e902e41553cf6fca
eba087f6563ee67d405d867f647f579da1bf5dca
refs/heads/master
2023-04-13T16:42:09.454573
2023-04-12T09:58:13
2023-04-12T09:58:13
70,299,505
118
73
MIT
2021-02-02T09:18:04
2016-10-08T03:03:16
C++
UTF-8
C++
false
false
795
h
forwards.h
// Copyright 2007-2010 Baptiste Lepilleur // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE #ifndef JSON_FORWARDS_H_INCLUDED #define JSON_FORWARDS_H_INCLUDED #if !defined(JSON_IS_AMALGAMATION) #include "config.h" #endif // if !defined(JSON_IS_AMALGAMATION) namespace Json { // writer.h class FastWriter; class StyledWriter; // reader.h class Reader; // features.h class Features; // value.h typedef unsigned int ArrayIndex; class StaticString; class Path; class PathArgument; class Value; class ValueIteratorBase; class ValueIterator; class ValueConstIterator; } // namespace Json #endif // JSON_FORWARDS_H_INCLUDED
3ce0faa0a4fbdfeda11655a630bb8fce8e2cd430
1018cd353c4a1df2c50532909ce19e77a1f70769
/src/pet.h
1e531bdb5590ab9d1a943078d666a82c763a096d
[]
no_license
jaywuuu/keypet
e2227cff8f96734c5a7f6fd1369949a297c433e2
0917a02540fc74b85733b83b0889a914dc3a99fa
refs/heads/main
2023-09-05T12:09:15.146356
2021-11-02T21:11:49
2021-11-02T21:11:49
418,292,115
0
0
null
null
null
null
UTF-8
C++
false
false
964
h
pet.h
#ifndef __pet_h__ #define __pet_h__ #include "SDLlib.h" #include "assets.h" #include <memory> #include <string> namespace KeyPet { class Pet { public: enum AnimationIndex { AnimIdle = 0 }; public: Pet(const char *name, const char *file); Pet(const Pet &) = delete; // delete copy Pet &operator=(const Pet &) = delete; // delete copy assignment SDLSurface &getBaseSurface(); SDLTexture *createBaseTexture(SDL_Renderer *renderer); SDLTexture *getBaseTexture(); SDLTexture *addTexture(SDL_Renderer *renderer, const char *file); Animation &getAnimation(int index); void setAnimation(int index, Animation &anim); int getCurrentAnimationIndex() const; private: SDLSurface BaseSurface; std::unique_ptr<SDLTexture> BaseTexture; int Speed; std::string Name; std::vector<std::unique_ptr<SDLTexture>> Textures; std::vector<Animation> Animations; int CurrentAnimation; }; } // namespace KeyPet #endif /* __pet_h__ */
39430a298f5cab62a02fa5a38436bf1be03dcbcc
8c66f8e4da2783e784c90944ff9274c7f3c21239
/Source/RenderBeast/Include/BsShadowRendering.h
0574f631b015ff70e8f32086174b875c764a7f53
[]
no_license
JamesGbl/BansheeEngine
093f12ac297bd97512191902dd1e9b3f9edfec49
1c8b7834a45c0160ed5bb5a59d0a027dd7ef9d3e
refs/heads/master
2021-01-23T02:23:09.154190
2017-05-30T16:19:03
2017-05-30T16:19:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,358
h
BsShadowRendering.h
//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #pragma once #include "BsRenderBeastPrerequisites.h" #include "BsModule.h" #include "BsMatrix4.h" #include "BsConvexVolume.h" #include "BsParamBlocks.h" #include "BsRendererMaterial.h" #include "BsTextureAtlasLayout.h" #include "BsLight.h" #include "BsLightRendering.h" namespace bs { namespace ct { struct FrameInfo; class RendererLight; class RendererScene; /** @addtogroup RenderBeast * @{ */ /** Number of frustum splits when rendering cascaded shadow maps. */ const UINT32 NUM_CASCADE_SPLITS = 4; BS_PARAM_BLOCK_BEGIN(ShadowParamsDef) BS_PARAM_BLOCK_ENTRY(Matrix4, gMatViewProj) BS_PARAM_BLOCK_ENTRY(float, gDepthBias) BS_PARAM_BLOCK_ENTRY(float, gDepthRange) BS_PARAM_BLOCK_END extern ShadowParamsDef gShadowParamsDef; /** Material used for rendering a single face of a shadow map. */ class ShadowDepthNormalMat : public RendererMaterial<ShadowDepthNormalMat> { RMAT_DEF("ShadowDepthNormal.bsl"); public: ShadowDepthNormalMat(); /** Binds the material to the pipeline, ready to be used on subsequent draw calls. */ void bind(const SPtr<GpuParamBlockBuffer>& shadowParams); /** Sets a new buffer that determines per-object properties. */ void setPerObjectBuffer(const SPtr<GpuParamBlockBuffer>& perObjectParams); }; /** Material used for rendering a single face of a shadow map, for a directional light. */ class ShadowDepthDirectionalMat : public RendererMaterial<ShadowDepthDirectionalMat> { RMAT_DEF("ShadowDepthDirectional.bsl"); public: ShadowDepthDirectionalMat(); /** Binds the material to the pipeline, ready to be used on subsequent draw calls. */ void bind(const SPtr<GpuParamBlockBuffer>& shadowParams); /** Sets a new buffer that determines per-object properties. */ void setPerObjectBuffer(const SPtr<GpuParamBlockBuffer>& perObjectParams); }; BS_PARAM_BLOCK_BEGIN(ShadowCubeMatricesDef) BS_PARAM_BLOCK_ENTRY_ARRAY(Matrix4, gFaceVPMatrices, 6) BS_PARAM_BLOCK_END extern ShadowCubeMatricesDef gShadowCubeMatricesDef; BS_PARAM_BLOCK_BEGIN(ShadowCubeMasksDef) BS_PARAM_BLOCK_ENTRY_ARRAY(int, gFaceMasks, 6) BS_PARAM_BLOCK_END extern ShadowCubeMasksDef gShadowCubeMasksDef; /** Material used for rendering an omni directional cube shadow map. */ class ShadowDepthCubeMat : public RendererMaterial<ShadowDepthCubeMat> { RMAT_DEF("ShadowDepthCube.bsl"); public: ShadowDepthCubeMat(); /** Binds the material to the pipeline, ready to be used on subsequent draw calls. */ void bind(const SPtr<GpuParamBlockBuffer>& shadowParams, const SPtr<GpuParamBlockBuffer>& shadowCubeParams); /** Sets a new buffer that determines per-object properties. */ void setPerObjectBuffer(const SPtr<GpuParamBlockBuffer>& perObjectParams, const SPtr<GpuParamBlockBuffer>& shadowCubeMasks); }; BS_PARAM_BLOCK_BEGIN(ShadowProjectParamsDef) BS_PARAM_BLOCK_ENTRY(Matrix4, gMixedToShadowSpace) BS_PARAM_BLOCK_ENTRY(Vector2, gShadowMapSize) BS_PARAM_BLOCK_ENTRY(Vector2, gShadowMapSizeInv) BS_PARAM_BLOCK_ENTRY(float, gSoftTransitionScale) BS_PARAM_BLOCK_ENTRY(float, gFadePercent) BS_PARAM_BLOCK_ENTRY(float, gFadePlaneDepth) BS_PARAM_BLOCK_ENTRY(float, gInvFadePlaneRange) BS_PARAM_BLOCK_END extern ShadowProjectParamsDef gShadowProjectParamsDef; /** Material used for projecting depth into a shadow accumulation buffer for non-omnidirectional shadow maps. */ template<int ShadowQuality, bool Directional, bool MSAA> class ShadowProjectMat : public RendererMaterial<ShadowProjectMat<ShadowQuality, Directional, MSAA>> { RMAT_DEF("ShadowProject.bsl"); public: ShadowProjectMat(); /** Binds the material to the pipeline, ready to be used on subsequent draw calls. */ void bind(const SPtr<Texture>& shadowMap, const SPtr<GpuParamBlockBuffer>& shadowParams, const SPtr<GpuParamBlockBuffer>& perCamera); private: SPtr<SamplerState> mSamplerState; GBufferParams mGBufferParams; GpuParamTexture mShadowMapParam; GpuParamSampState mShadowSamplerParam; }; BS_PARAM_BLOCK_BEGIN(ShadowProjectOmniParamsDef) BS_PARAM_BLOCK_ENTRY_ARRAY(Matrix4, gFaceVPMatrices, 6) BS_PARAM_BLOCK_ENTRY(Vector4, gLightPosAndRadius) BS_PARAM_BLOCK_ENTRY(float, gInvResolution) BS_PARAM_BLOCK_ENTRY(float, gFadePercent) BS_PARAM_BLOCK_ENTRY(float, gDepthBias) BS_PARAM_BLOCK_END extern ShadowProjectOmniParamsDef gShadowProjectOmniParamsDef; /** Material used for projecting depth into a shadow accumulation buffer for omnidirectional shadow maps. */ template<int ShadowQuality, bool MSAA> class ShadowProjectOmniMat : public RendererMaterial<ShadowProjectOmniMat<ShadowQuality, MSAA>> { RMAT_DEF("ShadowProjectOmni.bsl"); public: ShadowProjectOmniMat(); /** Binds the material to the pipeline, ready to be used on subsequent draw calls. */ void bind(const SPtr<Texture>& shadowMap, const SPtr<GpuParamBlockBuffer>& shadowParams, const SPtr<GpuParamBlockBuffer>& perCamera); private: SPtr<SamplerState> mSamplerState; GBufferParams mGBufferParams; GpuParamTexture mShadowMapParam; GpuParamSampState mShadowSamplerParam; }; /** Information about a shadow cast from a single light. */ struct ShadowInfo { /** Updates normalized area coordinates based on the non-normalized ones and the provided atlas size. */ void updateNormArea(UINT32 atlasSize); UINT32 lightIdx; /**< Index of the light casting this shadow. */ Rect2I area; /**< Area of the shadow map in pixels, relative to its source texture. */ Rect2 normArea; /**< Normalized shadow map area in [0, 1] range. */ UINT32 textureIdx; /**< Index of the texture the shadow map is stored in. */ /** View-projection matrix from the shadow casters point of view. */ Matrix4 shadowVPTransform; /** View-projection matrix for each cubemap face, used for omni-directional shadows. */ Matrix4 shadowVPTransforms[6]; /** Determines the fade amount of the shadow, for each view in the scene. */ SmallVector<float, 4> fadePerView; }; /** * Contains a texture that serves as an atlas for one or multiple shadow maps. Provides methods for inserting new maps * in the atlas. */ class ShadowMapAtlas { public: ShadowMapAtlas(UINT32 size); ~ShadowMapAtlas(); /** * Registers a new map in the shadow map atlas. Returns true if the map fits in the atlas, or false otherwise. * Resets the last used counter to zero. */ bool addMap(UINT32 size, Rect2I& area, UINT32 border = 4); /** Clears all shadow maps from the atlas. Increments the last used counter.*/ void clear(); /** Checks have any maps been added to the atlas. */ bool isEmpty() const; /** * Returns the value of the last used counter. See addMap() and clear() for information on how the counter is * incremented/decremented. */ UINT32 getLastUsedCounter() const { return mLastUsedCounter; } /** Returns the bindable atlas texture. */ SPtr<Texture> getTexture() const; /** Returns the render target that allows you to render into the atlas. */ SPtr<RenderTexture> getTarget() const; private: SPtr<PooledRenderTexture> mAtlas; TextureAtlasLayout mLayout; UINT32 mLastUsedCounter; }; /** Contains common code for different shadow map types. */ class ShadowMapBase { public: ShadowMapBase(UINT32 size); virtual ~ShadowMapBase() {} /** Returns the bindable shadow map texture. */ SPtr<Texture> getTexture() const; /** Returns the size of a single face of the shadow map texture, in pixels. */ UINT32 getSize() const { return mSize; } /** Makes the shadow map available for re-use and increments the counter returned by getLastUsedCounter(). */ void clear() { mIsUsed = false; mLastUsedCounter++; } /** Marks the shadow map as used and resets the last used counter to zero. */ void markAsUsed() { mIsUsed = true; mLastUsedCounter = 0; } /** Returns true if the object is storing a valid shadow map. */ bool isUsed() const { return mIsUsed; } /** * Returns the value of the last used counter. See incrementUseCounter() and markAsUsed() for information on how is * the counter incremented/decremented. */ UINT32 getLastUsedCounter() const { return mLastUsedCounter; } protected: SPtr<PooledRenderTexture> mShadowMap; UINT32 mSize; bool mIsUsed; UINT32 mLastUsedCounter; }; /** Contains a cubemap for storing an omnidirectional cubemap. */ class ShadowCubemap : public ShadowMapBase { public: ShadowCubemap(UINT32 size); ~ShadowCubemap(); /** Returns a render target encompassing all six faces of the shadow cubemap. */ SPtr<RenderTexture> getTarget() const; }; /** Contains a texture required for rendering cascaded shadow maps. */ class ShadowCascadedMap : public ShadowMapBase { public: ShadowCascadedMap(UINT32 size); ~ShadowCascadedMap(); /** Returns a render target that allows rendering into a specific cascade of the cascaded shadow map. */ SPtr<RenderTexture> getTarget(UINT32 cascadeIdx) const; /** Provides information about a shadow for the specified cascade. */ void setShadowInfo(UINT32 cascadeIdx, const ShadowInfo& info) { mShadowInfos[cascadeIdx] = info; } /** @copydoc setShadowInfo */ const ShadowInfo& getShadowInfo(UINT32 cascadeIdx) const { return mShadowInfos[cascadeIdx]; } private: SPtr<RenderTexture> mTargets[NUM_CASCADE_SPLITS]; ShadowInfo mShadowInfos[NUM_CASCADE_SPLITS]; }; /** Provides functionality for rendering shadow maps. */ class ShadowRendering : public Module<ShadowRendering> { /** Contains information required for generating a shadow map for a specific light. */ struct ShadowMapOptions { UINT32 lightIdx; UINT32 mapSize; SmallVector<float, 4> fadePercents; }; /** Contains references to all shadows cast by a specific light. */ struct LightShadows { UINT32 startIdx; UINT32 numShadows; }; public: ShadowRendering(UINT32 shadowMapSize); /** For each visibile shadow casting light, renders a shadow map from its point of view. */ void renderShadowMaps(RendererScene& scene, const FrameInfo& frameInfo); /** * Renders shadow occlusion values for the specified light, into the currently bound render target. * The system uses shadow maps rendered by renderShadowMaps(). */ void renderShadowOcclusion(const RendererScene& scene, const RendererLight& light, UINT32 viewIdx); /** Changes the default shadow map size. Will cause all shadow maps to be rebuilt. */ void setShadowMapSize(UINT32 size); private: /** Renders cascaded shadow maps for the provided directional light viewed from the provided view. */ void renderCascadedShadowMaps(UINT32 viewIdx, UINT32 lightIdx, RendererScene& scene, const FrameInfo& frameInfo); /** Renders shadow maps for the provided spot light. */ void renderSpotShadowMap(const RendererLight& light, const ShadowMapOptions& options, RendererScene& scene, const FrameInfo& frameInfo); /** Renders shadow maps for the provided radial light. */ void renderRadialShadowMap(const RendererLight& light, const ShadowMapOptions& options, RendererScene& scene, const FrameInfo& frameInfo); /** * Calculates optimal shadow map size, taking into account all views in the scene. Also calculates a fade value * that can be used for fading out small shadow maps. * * @param[in] light Light for which to calculate the shadow map properties. Cannot be a directional light. * @param[in] scene Scene information containing all the views the light can be seen through. * @param[out] size Optimal size of the shadow map, in pixels. * @param[out] fadePercents Value in range [0, 1] determining how much should the shadow map be faded out. Each * entry corresponds to a single view. * @param[out] maxFadePercent Maximum value in the @p fadePercents array. */ void calcShadowMapProperties(const RendererLight& light, RendererScene& scene, UINT32& size, SmallVector<float, 4>& fadePercents, float& maxFadePercent) const; /** * Generates a frustum for a single cascade of a cascaded shadow map. Also outputs spherical bounds of the * split view frustum. * * @param[in] view View whose frustum to split. * @param[in] lightDir Direction of the light for which we're generating the shadow map. * @param[in] cascade Index of the cascade to generate the frustum for. * @param[in] numCascades Maximum number of cascades in the cascaded shadow map. Must be greater than zero. * @param[out] outBounds Spherical bounds of the split view frustum. * @return Convex volume covering the area of the split view frustum visible from the light. */ static ConvexVolume getCSMSplitFrustum(const RendererView& view, const Vector3& lightDir, UINT32 cascade, UINT32 numCascades, Sphere& outBounds); /** * Finds the distance (along the view direction) of the frustum split for the specified index. Used for cascaded * shadow maps. * * @param[in] view View whose frustum to split. * @param[in] index Index of the split. 0 = near plane. * @param[in] numCascades Maximum number of cascades in the cascaded shadow map. Must be greater than zero * and greater or equal to @p index. * @return Distance to the split position along the view direction. */ static float getCSMSplitDistance(const RendererView& view, UINT32 index, UINT32 numCascades); /** * Calculates a bias that can be applied when rendering shadow maps, in order to reduce shadow artifacts. * * @param[in] light Light to calculate the depth bias for. * @param[in] depthRange Range of depths (distance between near and far planes) covered by the shadow. * @param[in] mapSize Size of the shadow map, in pixels. * @return Depth bias that can be passed to shadow depth rendering shader. */ static float getDepthBias(const Light& light, float depthRange, UINT32 mapSize); /** Size of a single shadow map atlas, in pixels. */ static const UINT32 MAX_ATLAS_SIZE; /** Determines how long will an unused shadow map atlas stay allocated, in frames. */ static const UINT32 MAX_UNUSED_FRAMES; /** Determines the minimal resolution of a shadow map. */ static const UINT32 MIN_SHADOW_MAP_SIZE; /** Determines the resolution at which shadow maps begin fading out. */ static const UINT32 SHADOW_MAP_FADE_SIZE; /** Size of the border of a shadow map in a shadow map atlas, in pixels. */ static const UINT32 SHADOW_MAP_BORDER; ShadowDepthNormalMat mDepthNormalMat; ShadowDepthCubeMat mDepthCubeMat; ShadowDepthDirectionalMat mDepthDirectionalMat; UINT32 mShadowMapSize; Vector<ShadowMapAtlas> mDynamicShadowMaps; Vector<ShadowCascadedMap> mCascadedShadowMaps; Vector<ShadowCubemap> mShadowCubemaps; Vector<ShadowInfo> mShadowInfos; Vector<LightShadows> mSpotLightShadows; Vector<LightShadows> mRadialLightShadows; Vector<UINT32> mDirectionalLightShadows; Vector<bool> mRenderableVisibility; // Transient Vector<ShadowMapOptions> mSpotLightShadowOptions; // Transient Vector<ShadowMapOptions> mRadialLightShadowOptions; // Transient }; /* @} */ }}
b705b888eb9e2f3a7c06e3062368b48272e7db36
81fa315c297a2ce5053d869d35a8e8cea7989549
/include/client/client_board.h
0ed9a07faba08021a3f4b5bf9467ed66f2244dc1
[]
no_license
worldwar/crocus-c
c3ce02868ca7cad1589f9ca45fe55b590c610202
143e7716e10b71396abd08ff819e9a18802f6520
refs/heads/master
2021-08-28T14:09:23.307534
2017-12-12T12:23:31
2017-12-12T12:23:31
107,026,673
0
0
null
null
null
null
UTF-8
C++
false
false
4,461
h
client_board.h
#ifndef CROCUS_CLIENT_BOARD_H #define CROCUS_CLIENT_BOARD_H #include "client/animation.h" #include "client/client_common.h" #include "client/selection_state.h" #include "point.h" #include "sprites.h" #include <SFML/Graphics/RectangleShape.hpp> #include <SFML/Graphics/RenderTexture.hpp> #include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/Sprite.hpp> #include <board.h> #include <enums.h> #include <piece.h> #include <position.h> class ClientBoard { private: float _leftPadding; float _topPadding; float _grid; Board &_board; sf::RenderTexture _texture; Force _viewForce; Piece *_selectedPiece; Piece *_movingPiece; float scalar = 0.437f; std::list<Animation *> _animations; std::wstring _text; public: ClientBoard(Board &board, const Point &topLeft, float grid, Force viewForce) : _board(board), _leftPadding(topLeft.x()), _topPadding(topLeft.y()), _grid(grid), _viewForce(viewForce), _texture(), _selectedPiece(nullptr), _movingPiece(nullptr) { _texture.create(1360, 1500); _texture.setSmooth(true); } void draw(sf::RenderWindow &window, const Point &point, SelectionState *selectionState); void draw(SelectionState *selectionState); void drawText(); void draw(const Piece *piece) { const Point &point = transform(piece->position(), _viewForce); draw(piece, point); } void draw(const Piece *piece, const Point &point) { sf::Sprite *s = Sprites::sprite(piece); s->setPosition(point.x(), point.y()); _texture.draw(*s); if (piece == _selectedPiece || piece == _movingPiece) { const sf::IntRect &rect = s->getTextureRect(); sf::RectangleShape rectangle; rectangle.setSize({static_cast<float>(rect.width), static_cast<float>(rect.height)}); rectangle.setOrigin(rect.width / 2, rect.height / 2); rectangle.setOutlineColor(sf::Color::Red); rectangle.setFillColor(sf::Color::Transparent); rectangle.setOutlineThickness(5); rectangle.setScale(0.4, 0.4); rectangle.setPosition(point.x(), point.y()); _texture.draw(rectangle); } } Point topLeft() const { return Point(_leftPadding, _topPadding); } Point transform(const Position &position, Force viewer) const { const Position &viewPosition = common::view(position, viewer); float offsetX = (9 - viewPosition.x()) * _grid; float offsetY = (10 - viewPosition.y()) * _grid; return topLeft().move(offsetX, offsetY); } Position transform(const Point &point) const { int x = 9 - (int)((point.x() / scalar - topLeft().x() + _grid / 2.0) / _grid); int y = 10 - (int)((point.y() / scalar - topLeft().y() + _grid / 2.0) / _grid); return common::view({x, y}, _viewForce); } Piece *piece(const Position &position) const { return _board.piece(position); } void select(Piece *piece) { _selectedPiece = piece; } void unselect() { _selectedPiece = nullptr; } void moveTo(const Point &point) const { const Position &position = transform(point); const Action &action = _board.makeAction(_selectedPiece, position); if (legal(point)) { _board.apply(action); } } bool legal(const Point &point) const { const Position &position = transform(point); const Action &action = _board.makeAction(_selectedPiece, position); return _board.legal(action); } const Piece *selectedPiece() const { return _selectedPiece; } const Piece *movingPiece() const { return _movingPiece; } void moving(Piece *piece) { _movingPiece = piece; } void stopMoving() { _movingPiece = nullptr; } void add(Animation *animation) { _animations.push_back(animation); } void clearAnimations(); Board &board() { return _board; } void setView(Force force) { _viewForce = force; } void reset() { unselect(); stopMoving(); _animations.clear(); _text = L""; } void setText(const std::wstring &text) { _text = text; } }; #endif // CROCUS_CLIENT_BOARD_H
dce8fa9819423e7059adbe68fa6bc82549b3a412
98dc6f0f7c85dbfae6d40df288dde6f392311f43
/src/ai/sg/WordFormEnumerator_File3.cpp
345279bb8d6a38efcc1f129108afd1ad743183b0
[]
no_license
Atom9j/GrammarEngine
056cba6652a78e961cee6e9420f8b606563a3d77
7966a36b10d35cf6ba1c801701fa49d3c2c6add2
refs/heads/master
2021-04-27T00:10:28.165368
2018-03-03T12:19:37
2018-03-03T12:19:37
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,338
cpp
WordFormEnumerator_File3.cpp
#include <lem/solarix/WordEntry.h> #include <lem/solarix/WordEntries_File.h> #include <lem/solarix/WordFormEnumerator_File.h> using namespace Solarix; WordFormEnumerator_File3::WordFormEnumerator_File3( WordEntries_File * _entries, const lem::MCollect<lem::UCString> &_words ) :entries(_entries), words(_words), icur_entry(-1), icur_form(-1), imatched_word(-1), finished(false) { } bool WordFormEnumerator_File3::Fetch(void) { if( !finished ) { if( icur_entry==-1 ) { icur_entry=0; FetchEntry(); } else { // работаем с текущей статьей, просматриваем остаток форм в ней. const SG_Entry &e = entries->GetWordEntry(icur_entry); for( lem::Container::size_type i=icur_form+1; i<e.forms().size(); ++i ) { imatched_word=words.find(e.forms()[i].name()); if( imatched_word!=UNKNOWN ) { // нашли очередную подходящую форму в текущей статье icur_form = CastSizeToInt(i); return true; } } // в текущей статье больше нет подходящих форм, ищем следующую статью. FetchEntry(); } } return !finished; } void WordFormEnumerator_File3::FetchEntry(void) { if( !finished ) { while( icur_entry<(CastSizeToInt(entries->entry.size())-1) ) { icur_entry++; icur_form=UNKNOWN; const SG_Entry &e = entries->GetWordEntry(icur_entry); for( lem::Container::size_type k=0; k<words.size(); ++k ) { const lem::UCString &word = words[k]; if( e.GetMinLen()>word.length() || e.GetMaxLen()<word.length() ) { // не подходит по длине. continue; } // в этой статье может быть такая форма? if( !e.GetRoot().empty() && !word.eq_begi(e.GetRoot()) ) { // корень не подходит. continue; } // предварительные проверки прошли, теперь пройдемся по формам статьи до первого попадания. for( lem::Container::size_type i=0; i<e.forms().size(); ++i ) { imatched_word=words.find(e.forms()[i].name()); if( imatched_word!=UNKNOWN ) { // нашли и статью и форму в ней. icur_form = CastSizeToInt(i); return; } } } } finished=true; } return; } int WordFormEnumerator_File3::GetEntryKey(void) { LEM_CHECKIT_Z(!finished); LEM_CHECKIT_Z(icur_entry!=UNKNOWN); return entries->GetWordEntry(icur_entry).GetKey(); } int WordFormEnumerator_File3::GetFormIndex(void) { LEM_CHECKIT_Z(!finished); LEM_CHECKIT_Z(icur_form!=UNKNOWN); return icur_form; } float WordFormEnumerator_File3::GetValue(void) { return 1.0F; } int WordFormEnumerator_File3::GetMatchedWordIndex(void) { return imatched_word; }
809dd700ab13b5e72d72c59684c8a6765eccdc0f
c37d94eaedb6d0277b0e44740705e5e1a5d56454
/桌面开发(1) Windows/c++/lesson11 graphic1/TestView.cpp
664398df43c189c60f10300977c350deca70f5b4
[]
no_license
15831944/blogs
6d4e9c5111f06b268b30a7275d9cc6375b5f0108
1fa6a94d6b6a0b3d000fc3bfce13ac9f87deab64
refs/heads/master
2022-01-06T23:44:05.536952
2018-10-13T02:15:10
2018-10-13T02:15:10
null
0
0
null
null
null
null
GB18030
C++
false
false
3,995
cpp
TestView.cpp
// TestView.cpp : CTestView 类的实现 // #include "stdafx.h" // SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 // ATL 项目中进行定义,并允许与该项目共享文档代码。 #ifndef SHARED_HANDLERS #include "Test.h" #endif #include "TestDoc.h" #include "TestView.h" #include "Graph.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CTestView IMPLEMENT_DYNCREATE(CTestView, CView) BEGIN_MESSAGE_MAP(CTestView, CView) ON_COMMAND(IDM_DOT, &CTestView::OnDot) ON_COMMAND(IDM_LINE, &CTestView::OnLine) ON_COMMAND(IDM_RECT, &CTestView::OnRect) ON_COMMAND(IDM_ELLIPSE, &CTestView::OnEllipse) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_PAINT() END_MESSAGE_MAP() // CTestView 构造/析构 CTestView::CTestView() : m_nDrawType(0) , m_ptOrigin(0) { // TODO: 在此处添加构造代码 } CTestView::~CTestView() { } BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: 在此处通过修改 // CREATESTRUCT cs 来修改窗口类或样式 return CView::PreCreateWindow(cs); } // CTestView 绘制 // 虚函数, 在 OnPaint 函数中被调用, 响应 WM_PAINT 消息 void CTestView::OnDraw(CDC* pDC) { CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: 在此处为本机数据添加绘制代码 // 将保存的图形对象进行重绘 CBrush *pBrush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); pDC->SelectObject(pBrush); for (int i = 0; i < m_ptrArray.GetSize(); i++) { switch (((CGraph *)m_ptrArray.GetAt(i))->m_nDrawType) { case 1: pDC->SetPixel(((CGraph *)m_ptrArray.GetAt(i))->m_ptEnd, RGB(0, 0, 0)); break; case 2: pDC->MoveTo(((CGraph *)m_ptrArray.GetAt(i))->m_ptOrigin); pDC->LineTo(((CGraph *)m_ptrArray.GetAt(i))->m_ptEnd); break; case 3: pDC->Rectangle(CRect(((CGraph *)m_ptrArray.GetAt(i))->m_ptOrigin, ((CGraph *)m_ptrArray.GetAt(i))->m_ptEnd)); break; case 4: pDC->Ellipse(CRect(((CGraph *)m_ptrArray.GetAt(i))->m_ptOrigin, ((CGraph *)m_ptrArray.GetAt(i))->m_ptEnd)); break; default: break; } } } // CTestView 诊断 #ifdef _DEBUG void CTestView::AssertValid() const { CView::AssertValid(); } void CTestView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CTestDoc* CTestView::GetDocument() const // 非调试版本是内联的 { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc))); return (CTestDoc*)m_pDocument; } #endif //_DEBUG // CTestView 消息处理程序 void CTestView::OnDot() { // TODO: 在此添加命令处理程序代码 m_nDrawType = 1; } void CTestView::OnLine() { // TODO: 在此添加命令处理程序代码 m_nDrawType = 2; } void CTestView::OnRect() { // TODO: 在此添加命令处理程序代码 m_nDrawType = 3; } void CTestView::OnEllipse() { // TODO: 在此添加命令处理程序代码 m_nDrawType = 4; } void CTestView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 m_ptOrigin = point; CView::OnLButtonDown(nFlags, point); } void CTestView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CClientDC dc(this); CBrush *pBrush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); dc.SelectObject(pBrush); switch (m_nDrawType) { case 1: dc.SetPixel(point, RGB(0, 0, 0)); break; case 2: dc.MoveTo(m_ptOrigin); dc.LineTo(point); break; case 3: dc.Rectangle(CRect(m_ptOrigin, point)); break; case 4: dc.Ellipse(CRect(m_ptOrigin, point)); break; default: break; } /* 图形的保存 */ // CGraph graph(m_nDrawType, m_ptOrigin, point); // m_ptrArray.Add(&graph); CGraph *pGraph = new CGraph(m_nDrawType, m_ptOrigin, point); // 没有销毁 m_ptrArray.Add(pGraph); CView::OnLButtonUp(nFlags, point); } void CTestView::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CView::OnPaint() }
7d44ae4ee1f78526f8a568abf2c3dcb2cb070c26
a4938fcfa0eee008c023a03e13b6e0c65c48ae10
/AISDI/liniowe/asd.cc
5e1c15c15c2ace19d9a1b2cc91c96bcaa632578d
[]
no_license
tom3097/EiTI-Projects
2a62a427c757e1868ae7b6f16df1330389dc7027
9a8872dff97599d498f8145395a5c28cc14c0214
refs/heads/master
2021-01-10T02:39:02.806879
2016-01-23T15:01:31
2016-01-23T15:01:31
44,069,632
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
11,111
cc
asd.cc
/** @file asd.cc Plik do modyfikacji w ramach cwiczenia z AISDI. Zawiera niekompletne implementacje metod klasy ListMap, oraz mape podobna koncepcyjnie do tej z cwicznia 1 (SmallMap) zaimplementowana w jescze bardziej szczatkowy sposob. Jest tez prosta funkcja testujaca (void test()), ktora jest wolana w funkcji main. Mozna w niej zaimplementowac wlasne testy. NALEZY ZMODYFIKOWAC I UZUPELNIC CIALA METOD KLASY LISTMAP. @author Pawel Cichocki, Michal Nowacki @date last revision - 2006.01.06 Michal Nowacki: wersja polska - 2005.11.17 Michal Nowacki: constructor - 2005.11.04 Pawel Cichocki: copied comments from the header - 2005.11.03 Pawel Cichocki: const_iterator done properly now - 2005.10.27 Pawel Cichocki: cosmetic changes - 2005.10.26 Michal Nowacki: removed some method bodies - 2005.10.25 Pawel Cichocki: wrote it COPYRIGHT: Copyright (c) 2005 Instytut Informatyki, Politechnika Warszawska ALL RIGHTS RESERVED *******************************************************************************/ #include <assert.h> #include <algorithm> #include <iostream> #ifdef _SUNOS #include "/materialy/AISDI/liniowe/ListMap.h" #else #include "ListMap.h" #endif ////////////////////////////////////////////////////////////////////////////// // ListMap and ListMap::iterator methods ////////////////////////////////////////////////////////////////////////////// ListMap::ListMap() { //tworzy straznika, jego key ustawia na 0 - licznik elem. w liscie // wskazniki na siebie, jest pierwszym elementem // internal data pointer jako wskazanie na siebie // wykorzystywane do odnalezienia straznika std::pair<int,std::string> listGuard(0,"listGuard"); //first = new Node(listGuard, first, first); first = new Node(listGuard, NULL, NULL); first->prev = first; first->next = first; first->internalDataPointer = NULL; }; ListMap::ListMap( const ListMap& m ) { ///@todo Zaimplementować metode const_iterator i, k; // i-iterator, k- koncowy i = m.begin(); k = m.end(); first = new ListNode(*i, NULL, NULL); for(; i!=k; i++) unsafe_insert(*i); }; ListMap::~ListMap() { clear(); delete first; }; // Wstawienie elementu do mapy. // @returns Para, której komponent bool jest równy true gdy wstawienie zostało // dokonane, równy false gdy element identyfikowany przez klucz // już istniał w mapie. Iterator ustawiony jest na ten wstawiony // lub istniejący już w mapie element. std::pair<ListMap::iterator, bool> ListMap::insert(const std::pair<Key, Val>& entry) { ///@todo Uzupełnić kod iterator i; i = find(entry.first); if( i!= end()) //cos znalazl return std::make_pair(i, (bool)false); else { i = unsafe_insert(entry); return std::make_pair(i, (bool)true); } } // Wstawienie elementu do mapy. // Matoda zakłada, że w mapie nie występuje element identyfikowany przez key ListMap::iterator ListMap::unsafe_insert(const std::pair<Key, Val>& entry) { ///@todo Uzupełnić kod Node* temp; temp = new Node(entry, first, first->prev); first->prev->next = temp; first = temp; first->next->prev = first; int help = 1; first->internalDataPointer = &help; //key straznika zwiekszamy o 1 (end()->first)++; return iterator(first); } // Zwraca iterator addresujący element w mapie dla którego klucz jest równy // szukanemu kluczowi lub element za ostatnim gdy szukanego klucza brak w mapie. ListMap::iterator ListMap::find(const Key& k) { ///@todo Zaimplementować metode iterator i; i = begin(); for(; i != end(); ++i) if(i->first == k) return i; return end(); } ListMap::const_iterator ListMap::find(const Key& k) const { ///@todo Zaimplementować metode const_iterator i; i = begin(); for(; i != end(); ++i) if(i->first == k) return i; return end(); } // Udostępnia wartość powiązaną z kluczem key. Wstawia element do mapy jeśli // nie istniał. // @returns Referencje do wartości powiązanej z kluczem. ListMap::Val& ListMap::operator[](const Key& k) { ///@todo Zaimplementować metode iterator i; i = find(k); if( i == end()) { std::pair<int, std::string> new_insert(k, "new"); i = unsafe_insert(new_insert); } return i->second; } // Sprawdzenie czy mapa jest pusta. bool ListMap::empty( ) const { const_iterator k; k = end(); if( k->first == 0) //w key straznika mam liczbe elementow return true; else return false; } // Zwraca ilość elementów w mapie. ListMap::size_type ListMap::size( ) const { return (end()->first); } // Zwraza ilość elementów skojarzonych z kluczem key. ListMap::size_type ListMap::count(const Key& _Key) const { ///@todo Zaimplementować metode const_iterator i; i = find(_Key); if (i != end()) return 1; else return 0; // this is not a multimap } // Usuwa element z mapy. // @returns iterator adresujący pierwszy element za usuwanym. ListMap::iterator ListMap::erase(ListMap::iterator i) { ///@todo Zaimplementować metode iterator next; next = i; if(empty()) return i; // pusty wiec nic nie usuwam else { next++; next.node->prev = i.node->prev; i.node->prev->next = next.node; delete i.node; (end()->first)--; return next; } } // Usuwa zakres elementów z mapy. // Zakres jest zdefiniowany poprzez iteratory first i last // first jest określa pierwszy element do usunięcia, a last określa element // po ostatnim usuniętym elemencie. // @returns iterator adresujący pierwszy element za usuwanym. ListMap::iterator ListMap::erase(ListMap::iterator f, ListMap::iterator l) { ///@todo Zaimplementować metode iterator temp; temp = f; while (temp != l) temp = erase(temp); return l; } // Usuwa element z mapy. // @returns Ilość usuniętych elementów. // (nie jest to multimapa, więć może być to wartość 1 lub 0 ) ListMap::size_type ListMap::erase(const Key& key) { ///@todo Zaimplementować metode iterator i; i = find(key); if(i == end())return 0; else { erase(i); return 1; } } // Usunięcie wszystkich elementów z mapy. void ListMap::clear( ) { ///@todo Zaimplementować metode erase(begin(), end()); } // Porównanie strukturalne map. // Czy reprezentacja danych jest identyczna. // Zwraca true jeśli wewnętrzne struktury map są identyczne. bool ListMap::struct_eq(const ListMap& another) const { ///@todo Zaimplementować metode const_iterator i, a, i_end; a = another.begin(); i = begin(); i_end = end(); if (size() != another.size()) return false; else for (; i != i_end; ++i, ++a) { if ((a->first) != (i->first)) return false; if ((a->second) != (i->second)) return false; } return true; } // Porównanie informacyjne map. // Czy informacje trzymane w mapach są identyczne. // Zwraca true jeśli mapy zwierają takie same pary klucz-wartość. bool ListMap::info_eq(const ListMap& another) const { ///@todo Zaimplementować metode const_iterator i, a, i_end, a_end, temp; i = begin(); a = another.begin(); i_end = end(); a_end = another.end(); if (size() != another.size()) return false; else for (; i != i_end; ++i) { temp = another.find(i->first); if (temp == a_end) return false; } return true; } // preincrementacja ListMap::const_iterator& ListMap::const_iterator::operator++() { ///@todo Zaimplementować metode if (node->internalDataPointer == NULL) return *this; node = node->next; return *this; } // postincrementacja ListMap::const_iterator ListMap::const_iterator::operator++(int) { ///@todo Zaimplementować metode const_iterator i; i = *this; ++*this; return i; } ListMap::const_iterator& ListMap::const_iterator::operator--() { ///@todo Zaimplementować metode if (node->prev->internalDataPointer == NULL) return *this; node = node->prev; return *this; } // postincrementacja ListMap::const_iterator ListMap::const_iterator::operator--(int) { ///@todo Zaimplementować metode const_iterator i; i = *this; --*this; return i; } /// Zwraca iterator addresujący pierwszy element w mapie. ListMap::iterator ListMap::begin() { ///@todo Zaimplementować metode return iterator(first); } /// Zwraca iterator addresujący pierwszy element w mapie. ListMap::const_iterator ListMap::begin() const { ///@todo Zaimplementować metode return iterator(first); } /// Zwraca iterator addresujący element za ostatnim w mapie. ListMap::iterator ListMap::end() { ///@todo Zaimplementować metode return iterator(first->prev); } /// Zwraca iterator addresujący element za ostatnim w mapie. ListMap::const_iterator ListMap::end() const { ///@todo Zaimplementować metode return iterator(first->prev); } ////////////////////////////////////////////////////////////////////////////// // SmallMap ////////////////////////////////////////////////////////////////////////////// /// Przykład map'y z implementacją podobną do std::map. /// To jest jedynie przykład!!! /// Normalnie implementacja powinna opierać się o drzewo lub tablicę haszującą. template <class Key, class Val> class SmallMap { std::pair<Key, Val> tab[2]; int isOcupied[2]; public: SmallMap() { for(unsigned i=0; i<2; ++i) { isOcupied[i]=0; } } typedef std::pair<Key, Val>* iterator; ///< Każdy wskaźnik jest też iteratorem. iterator begin() { return tab; } iterator end() { return tab+2; } Val& operator[](const Key& k) { static Val val; for(unsigned i=0; i<2; ++i) { if(isOcupied[i]&&tab[i].first==k) return tab[i].second; } // create for(unsigned i=0; i<2; ++i) { if(!isOcupied[i]) { tab[i].first=k; isOcupied[i]=1; return tab[i].second; } } //std::cout<<"Out of space! You should not put more than two Key-Value pairs into the SmallMap.\n"; std::cerr<<"Out of space! You should not put more than two Key-Value pairs into the SmallMap.\n"; //assert(0); return val; // Mało sensowne, ale to jest tylko przykłąd } }; ////////////////////////////////////////////////////////////////////////////// // Testy ////////////////////////////////////////////////////////////////////////////// /// Funckcja pomocnicza do wypisania elementów. void print(const std::pair<int, std::string>& p) { std::cout<<p.first<<", "<<p.second<<std::endl; } #include <map> /// Testy użytkownika void test() { // A typedef used by the test. typedef std::map<int, std::string> TEST_MAP; //typedef SmallMap<int, std::string> TEST_MAP; //typedef ListMap TEST_MAP; std::cout << "Testy uzytkownika" << std::endl; TEST_MAP m; m[2] = "Merry"; m[4] = "Jane"; m[8] = "Korwin"; m[4] = "Magdalena"; TEST_MAP n=m; for_each(m.begin(), m.end(), print ); for_each(n.begin(), n.end(), print ); //system("PAUSE"); //assert(0); }
97f2c7d9f3ac742b0f800032c5385adfdf8d880d
d053b471a9173df602d4bd7d52546cd588e48925
/Лабораторная 11/lab11_5.cpp
603cc1776bafc2cd15df4c32fe6cfd911787e1fa
[]
no_license
OR0KA/-
c82b6b9344d8d67de8311ff42ec383ef4f69a053
fce282867ef3f4372e9f1729c19279f85a8a7dc3
refs/heads/master
2020-07-28T00:37:34.311395
2019-12-18T00:41:37
2019-12-18T00:41:37
209,257,093
0
0
null
null
null
null
UTF-8
C++
false
false
466
cpp
lab11_5.cpp
//5. Даны целые положительные числа A и B. Найти их наибольший общий делитель (НОД), используя алгоритм Евклида // #include <iostream> using namespace std; int main() { setlocale(0, ""); int a, b; cout << "Введите a и b: " << endl; cin >> a >> b; while (a != b) { if (a > b) a = a - b; else b = b - a; } cout << "НОД: " << a; }
c19cc4eef9d0558eb968b9ca895f47ce3c52a87b
0660b138f6d145882d49a10d15a59b95084b8d34
/include/lgp/dicebag.hpp
dd2406897250a03baff347562827df18ce072c70
[]
no_license
burlingk/libgamepieces
9d59c3a5be0fcb0e6b19d1fb8f538cac71c331d9
b091a74cb5b92cf1091723147a6f5db3e3df96c2
refs/heads/master
2021-01-25T10:11:44.164016
2011-08-19T02:30:19
2011-08-19T02:30:19
1,541,608
1
0
null
null
null
null
UTF-8
C++
false
false
4,814
hpp
dicebag.hpp
/// \file lgp_dicebag.hpp /// \brief A set of functions to deal with randome numbers. /// \author Kenneth. M. Burling Jr. (a.k.a Emry) /// \version Alpha-0.001 /// /// copyright: Copyright &copy; 2008, 2009, 2010 K. M. Burling Jr.<br> /// All Rights Reserved /// /// Redistribution and use in source and binary forms, with or without modification, are permitted provided that /// the following conditions are met: /// /// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. /// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following /// disclaimer in the documentation and/or other materials provided with the distribution. /// * Neither the name of the libgamepieces project team, nor the names of its contributors may be used to endorse or /// promote products derived from this software without specific prior written permission. /// /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, /// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE /// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, /// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR /// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, /// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE /// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /// /// lgp_dicebag.hpp and lgp_dicebag.cpp are part of libegamepieces. They /// contain a handfull of basic functions for dealign with random numbers /// in an RPG related manner. They are designed to simulate a bag of dice. /// /// libgamepieces is a library of tools to help build an RPG that I want to create. /// /// File last updated 13:43 UTC on 13 Jan 2011 #ifndef LGP_DICEBAG_HPP_ #define LGP_DICEBAG_HPP_ #include <lgp/exceptions.hpp> /// \namespace lgp /// \brief The namespace used for holding components of the libgamepieces library. /// /// This namespace will be used to hold the parts of the libgamepieces library. Some /// of these parts will be in the form of functions, and others will be classes. namespace lgp { /// \brief a single generic die roll. /// /// Takes a single integer as the argument representing the number of sides that the die has. /// The return value is a number between 1 and sides, representing the number rolled on the die. /// This function represents a single unmodified die roll, and also serves as the core of the other /// dice related functions. int dX(int sides); /*throw(InvalidValueException)*/ /// \brief Nd100. Number defaults to 1, and mods defaults to 0. If you want to use a modifier /// though, you have to include number, even if it is just 1. /// /// /// example: d100(); returns 1d100 /// d100(2); returns 2d100 /// d100(1,10); returns 1d100 + 10 /// d100(,10); is a syntax error /// The same format is used for the other related functions. int d100(int number, int mods); /// \brief Nd30 int d30(int number, int mods); /// \brief Nd20 int d20(int number, int mods); /// \brief Nd12 int d12(int number, int mods); /// \brief Nd10 int d10(int number, int mods); /// \brief Nd8 int d8(int number, int mods); /// \brief Nd6 int d6(int number, int mods); /// \brief Nd4 int d4(int number, int mods); /// \brief Nd3 int d3(int number, int mods); /// \brief NdF /// /// dF() represents a roll of fudge dice. Each roll of a dF returns a value between -1 and +1 int dF(int dice); /*throw(InvalidValueException)*/ //Following are helper functions to make code more readable. /// \brief If the value is less than 1, it raises an exception. /// /// The parameters are so that the calling function can set it up and not have to manually type every /// line every time. Standard usage would be similar to: /// /// try{lessThanOneExceptionCheck(sides, "sides", "int dX(int)", "lgp_dicebag.cpp");} /// catch(InvalidValueException exception){throw;} /// /// assume sides = -3 /// this would set exception.getMessagbe() to return "Exception: Invalid value (-3) privided for sides in function 'int dX(int)' in file lgp_dicebag.cpp." /// } #endif /* LGP_DICEBAG_HPP_ */
dd573bd85bc31566a3bbc9eb025bfd2a82b50d01
2c4f22a7d84c4379f1f5c40065ef8fa8b677a806
/test/math/Vector4Tests.cpp
227b8d1f170ba8fe7e32505383e246998fb04c6c
[]
no_license
meuter/ray
1021cb45acb9289bb1996a9d28f9598c54ee7302
03a458c321debee14353760e0385ca8adfdc7eed
refs/heads/master
2021-01-23T22:32:17.488269
2018-10-28T15:46:14
2018-10-28T15:46:14
102,944,827
1
0
null
null
null
null
UTF-8
C++
false
false
12,053
cpp
Vector4Tests.cpp
#include <ray/math/Vector4.hpp> #include <gtest/gtest.h> #include <type_traits> #include <typeinfo> #include <ray/platform/Print.hpp> using namespace ray; using namespace math; using namespace platform; using f32 = float; using f64 = double; using i32 = int32_t; using u32 = uint32_t; using vec2 = Vector2<f32>; using dvec2 = Vector2<f64>; using ivec2 = Vector2<i32>; using uvec2 = Vector2<u32>; using vec3 = Vector3<f32>; using dvec3 = Vector3<f64>; using ivec3 = Vector3<i32>; using uvec3 = Vector3<u32>; using vec4 = Vector4<f32>; using dvec4 = Vector4<f64>; using ivec4 = Vector4<i32>; using uvec4 = Vector4<u32>; #define TEST_VECTOR4_COORDINATES_SWIZZLE2(vec, coord1, coord2, s1, s2, s3, s4, e1, e2)\ TEST(vec, coord_##coord1##coord2##_CanBeAccessedWithSwizzlingByGroupsOf2) {\ auto v = vec{s1,s2,s3,s4};\ EXPECT_EQ(v.coord1##coord2.x,e1);\ EXPECT_EQ(v.coord1##coord2.y,e2);\ } #define TEST_VECTOR4_COORDINATES_SWIZZLE3(vec, coord1, coord2, coord3, s1, s2, s3, s4, e1, e2, e3)\ TEST(vec, coord_##coord1##coord2##_CanBeAccessedWithSwizzlingByGroupsOf3) {\ auto v = vec{s1,s2,s3,s4};\ EXPECT_EQ(v.coord1##coord2##coord3.x,e1);\ EXPECT_EQ(v.coord1##coord2##coord3.y,e2);\ EXPECT_EQ(v.coord1##coord2##coord3.z,e3);\ } #define TEST_VECTOR4_COORDINATES(vec, scalar, coord1, coord2, coord3, coord4, s1, s2, s3, s4) \ TEST(vec, coord_##coord1##_IsScalar) { auto v = vec{s1, s2, s3, s4}; EXPECT_EQ(typeid(v.coord1), typeid(scalar)); }\ TEST(vec, coord_##coord2##_IsScalar) { auto v = vec{s1, s2, s3, s4}; EXPECT_EQ(typeid(v.coord2), typeid(scalar)); }\ TEST(vec, coord_##coord3##_IsScalar) { auto v = vec{s1, s2, s3, s4}; EXPECT_EQ(typeid(v.coord3), typeid(scalar)); }\ TEST(vec, coord_##coord4##_IsScalar) { auto v = vec{s1, s2, s3, s4}; EXPECT_EQ(typeid(v.coord4), typeid(scalar)); }\ TEST(vec, coord_##coord1##_CanBeAccessed) { auto v = vec{s1,s2,s3,s4}; EXPECT_EQ(v.coord1,s1); }\ TEST(vec, coord_##coord2##_CanBeAccessed) { auto v = vec{s1,s2,s3,s4}; EXPECT_EQ(v.coord2,s2); }\ TEST(vec, coord_##coord3##_CanBeAccessed) { auto v = vec{s1,s2,s3,s4}; EXPECT_EQ(v.coord3,s3); }\ TEST(vec, coord_##coord4##_CanBeAccessed) { auto v = vec{s1,s2,s3,s4}; EXPECT_EQ(v.coord4,s4); }\ TEST_VECTOR4_COORDINATES_SWIZZLE2(vec, coord1, coord2, s1, s2, s3, s4, s1, s2)\ TEST_VECTOR4_COORDINATES_SWIZZLE2(vec, coord2, coord3, s1, s2, s3, s4, s2, s3)\ TEST_VECTOR4_COORDINATES_SWIZZLE2(vec, coord3, coord4, s1, s2, s3, s4, s3, s4)\ TEST_VECTOR4_COORDINATES_SWIZZLE3(vec, coord1, coord2, coord3, s1, s2, s3, s4, s1, s2, s3)\ TEST_VECTOR4_COORDINATES_SWIZZLE3(vec, coord2, coord3, coord4, s1, s2, s3, s4, s2, s3, s4)\ #define TEST_VECTOR4_STRUCTURE(vec, scalar, s1, s2, s3,s4)\ TEST(vec, isPod) { EXPECT_TRUE(std::is_pod<vec>::value); }\ TEST(vec, arePacked) { EXPECT_EQ(sizeof(vec), 4*sizeof(scalar)); }\ TEST(vec, canBeDefaultConstructed) { vec v; (void)v; }\ TEST(vec, canBeConstructedFromOneScalar) {\ vec v(33); EXPECT_EQ(v.x,scalar(33)); EXPECT_EQ(v.y,scalar(33)); EXPECT_EQ(v.y,scalar(33));EXPECT_EQ(v.w,scalar(33)); }\ TEST(vec, canBeConstructedFromMultipleScalar) {\ vec v(33,34,35,36); EXPECT_EQ(v.x,scalar(33)); EXPECT_EQ(v.y,scalar(34)); EXPECT_EQ(v.z,scalar(35));EXPECT_EQ(v.w,scalar(36));}\ TEST(vec, canBeConstructedFrom1xVector2And2xScalar) {\ vec v(Vector2<scalar>{33,34},35,36); EXPECT_EQ(v.x,scalar(33)); EXPECT_EQ(v.y,scalar(34)); EXPECT_EQ(v.z,scalar(35));EXPECT_EQ(v.w,scalar(36));\ vec u(33,Vector2<scalar>{34,35},36); EXPECT_EQ(u.x,scalar(33)); EXPECT_EQ(u.y,scalar(34)); EXPECT_EQ(u.z,scalar(35));EXPECT_EQ(u.w,scalar(36));\ vec w(33,34,Vector2<scalar>{35,36}); EXPECT_EQ(w.x,scalar(33)); EXPECT_EQ(w.y,scalar(34)); EXPECT_EQ(w.z,scalar(35));EXPECT_EQ(w.w,scalar(36));\ }\ TEST(vec, canBeConstructedFrom2xVector2) {\ vec v(Vector2<scalar>{33,34},Vector2<scalar>{35,36}); EXPECT_EQ(v.x,scalar(33)); EXPECT_EQ(v.y,scalar(34)); EXPECT_EQ(v.z,scalar(35));EXPECT_EQ(v.w,scalar(36));\ }\ TEST(vec, canBeConstructedFrom1xVector3And1xScalar) {\ vec v(Vector3<scalar>{33,34,35},36); EXPECT_EQ(v.x,scalar(33)); EXPECT_EQ(v.y,scalar(34)); EXPECT_EQ(v.z,scalar(35));EXPECT_EQ(v.w,scalar(36));\ vec u(33,Vector3<scalar>{34,35,36}); EXPECT_EQ(u.x,scalar(33)); EXPECT_EQ(u.y,scalar(34)); EXPECT_EQ(u.z,scalar(35));EXPECT_EQ(u.w,scalar(36));\ }\ TEST(vec, canBeConstructedFrom1xVector4And) {\ vec v(Vector4<scalar>{33,34,35,36}); EXPECT_EQ(v.x,scalar(33)); EXPECT_EQ(v.y,scalar(34)); EXPECT_EQ(v.z,scalar(35));EXPECT_EQ(v.w,scalar(36));\ }\ TEST_VECTOR4_COORDINATES(vec, scalar, x, y, z, w, s1, s2, s3, s4)\ TEST_VECTOR4_COORDINATES(vec, scalar, r, g, b, a, s1, s2, s3, s4) #define EXPECT_VECTOR4_EQUAL(v1,v2) do {\ EXPECT_TRUE(v1 == v2);\ EXPECT_FALSE(v1 != v2);\ EXPECT_EQ(v1,v2);\ } while(0); #define EXPECT_VECTOR4_NOT_EQUAL(v1,v2) do {\ EXPECT_FALSE(v1 == v2);\ EXPECT_TRUE(v1 != v2);\ EXPECT_NE(v1,v2);\ } while(0) #define TEST_VECTOR4_COMPARISON_OP(vec, s1, s2, s3, s4, s5, s6)\ TEST(vec, canBeCompared)\ {\ auto v1234=vec{s1,s2,s3,s4}, v1234Prime=vec{s1,s2,s3,s4}, v1234Double=v1234;\ auto v5234=vec{s5,s2,s3,s4}, v1534=vec{s1,s5,s3,s4}, v1235=vec{s1,s2,s3,s5}, v1254=vec{s1,s2,s5,s4};\ auto v3456=vec{s3,s4,s5,s6};\ EXPECT_VECTOR4_EQUAL(v1234,v1234);\ EXPECT_VECTOR4_EQUAL(v1234Prime, v1234);\ EXPECT_VECTOR4_EQUAL(v1234, v1234Prime);\ EXPECT_VECTOR4_EQUAL(v1234Double, v1234);\ EXPECT_VECTOR4_EQUAL(v1234, v1234Double);\ EXPECT_VECTOR4_NOT_EQUAL(v1234,v3456);\ EXPECT_VECTOR4_NOT_EQUAL(v3456,v1234);\ EXPECT_VECTOR4_NOT_EQUAL(v5234,v1234);\ EXPECT_VECTOR4_NOT_EQUAL(v1234,v5234);\ EXPECT_VECTOR4_NOT_EQUAL(v1534,v1234);\ EXPECT_VECTOR4_NOT_EQUAL(v1234,v1534);\ EXPECT_VECTOR4_NOT_EQUAL(v1254,v1234);\ EXPECT_VECTOR4_NOT_EQUAL(v1234,v1254);\ EXPECT_VECTOR4_NOT_EQUAL(v1235,v1234);\ EXPECT_VECTOR4_NOT_EQUAL(v1234,v1235);\ } #define TEST_VECTOR4_ONE_BIN_OP(vec, x1, y1, z1, w1, x2, y2, z2, w2, op, opName)\ TEST(vec, canBe##opName##edTogether) {\ auto v1 = vec{x1,y1,z1,w1};\ auto v2 = vec{x2,y2,z2,w2};\ auto v3 = v1;\ v3 op ## = v2;\ EXPECT_EQ(v3.x, v1.x op v2.x);\ EXPECT_EQ(v3.y, v1.y op v2.y);\ EXPECT_EQ(v3.z, v1.z op v2.z);\ EXPECT_EQ(v3.w, v1.w op v2.w);\ auto v4 = v1 op v2;\ EXPECT_EQ(v4.x, v1.x op v2.x);\ EXPECT_EQ(v4.y, v1.y op v2.y);\ EXPECT_EQ(v4.z, v1.z op v2.z);\ EXPECT_EQ(v4.w, v1.w op v2.w);\ EXPECT_EQ(typeid(v1 op ivec4{1,1,1,1}), typeid(Vector4<decltype(v1.x op 1)>));\ EXPECT_EQ(typeid(ivec4{1,1,1,1} op v1), typeid(Vector4<decltype(1 op v1.x)>));\ EXPECT_EQ(typeid(v1 op vec4{1.0f,1.0f,1.0f,1.0f}), typeid(Vector4<decltype(v1.x op 1.0f)>));\ EXPECT_EQ(typeid(vec4{1.0f,1.0f,1.0f,1.0f} op v1), typeid(Vector4<decltype(1.0f op v1.x)>));\ EXPECT_EQ(typeid(v1 op uvec4{1u,1u,1u,1u}), typeid(Vector4<decltype(v1.x op 1u)>));\ EXPECT_EQ(typeid(uvec4{1u,1u,1u,1u} op v1), typeid(Vector4<decltype(1u op v1.x)>));\ EXPECT_EQ(typeid(v1 op dvec4{1.0,1.0,1.0,1.0}), typeid(Vector4<decltype(v1.x op 1.0)>));\ EXPECT_EQ(typeid(dvec4{1.0,1.0,1.0,1.0} op v1), typeid(Vector4<decltype(1.0 op v1.x)>));\ } #define TEST_VECTOR4_SCALED_BY_SCALAR(vec, s1, s2, s3, s4, f, op, opName)\ TEST(vec, canBe ## opName ## edByAndFromAScalar)\ {\ auto v1 = vec{s1,s1,s3,s4};\ auto v2 = v1;\ v2 op##= f;\ EXPECT_EQ(v2.x,v1.x op f);\ EXPECT_EQ(v2.y,v1.y op f);\ EXPECT_EQ(v2.z,v1.z op f);\ EXPECT_EQ(v2.w,v1.w op f);\ auto v3 = v1 op f;\ EXPECT_EQ(v3.x,v1.x op f);\ EXPECT_EQ(v3.y,v1.y op f);\ EXPECT_EQ(v3.z,v1.z op f);\ EXPECT_EQ(v3.w,v1.w op f);\ auto v4 = f op v1;\ EXPECT_EQ(v4.x,f op v1.x);\ EXPECT_EQ(v4.y,f op v1.y);\ EXPECT_EQ(v4.z,f op v1.z);\ EXPECT_EQ(v4.w,f op v1.w);\ EXPECT_EQ(typeid(v1 op 1), typeid(Vector4<decltype(v1.x op 1)>));\ EXPECT_EQ(typeid(1 op v1), typeid(Vector4<decltype(1 op v1.x)>));\ EXPECT_EQ(typeid(v1 op 1u), typeid(Vector4<decltype(v1.x op 1u)>));\ EXPECT_EQ(typeid(1u op v1), typeid(Vector4<decltype(1u op v1.x)>));\ EXPECT_EQ(typeid(v1 op 1.0f), typeid(Vector4<decltype(v1.x op 1.0f)>));\ EXPECT_EQ(typeid(1.0f op v1), typeid(Vector4<decltype(1.0f op v1.x)>));\ EXPECT_EQ(typeid(v1 op 1.0), typeid(Vector4<decltype(v1.x op 1.0)>));\ EXPECT_EQ(typeid(1.0 op v1), typeid(Vector4<decltype(1.0 op v1.x)>));\ } #define TEST_VECTOR4_NEGATION(vec, s1, s2, s3, s4)\ TEST(vec, canBeNegated)\ {\ auto v1 = vec{s1,s2,s3,s4};\ auto v2 = -v1;\ EXPECT_EQ(v2.x, -v1.x);\ EXPECT_EQ(v2.y, -v1.y);\ EXPECT_EQ(v2.z, -v1.z);\ EXPECT_EQ(v2.w, -v1.w);\ } #define TEST_VECTOR4_OPERATORS(vec, x1, y1, z1, w1, x2, y2, z2, w2)\ TEST_VECTOR4_COMPARISON_OP(vec, x1, y1, z1, x2, y2, z2)\ TEST_VECTOR4_ONE_BIN_OP(vec, x1, y1, z1, w1, x2, y2, z2, w2, +, Add)\ TEST_VECTOR4_ONE_BIN_OP(vec, x1, y1, z1, w1, x2, y2, z2, w2, -, Substract)\ TEST_VECTOR4_ONE_BIN_OP(vec, x1, y1, z1, w1, x2, y2, z2, w2, *, Multiply)\ TEST_VECTOR4_ONE_BIN_OP(vec, x1, y1, z1, w1, x2, y2, z2, w2, /, Divide)\ TEST_VECTOR4_SCALED_BY_SCALAR(vec, x1, y1, z1, w1, x2, *, Multiply)\ TEST_VECTOR4_SCALED_BY_SCALAR(vec, x1, y1, z1, w1, x2, /, Divide)\ #define TEST_VECTOR4_CAN_BE_PRINTED(vec, str, s1, s2, s3,s4)\ TEST(vec, canBePrinted) { EXPECT_EQ(str, fmt("%1%", vec{s1,s2,s3,s4})); } TEST_VECTOR4_STRUCTURE(vec4, f32, 5.0f, 1.0f, 7.0f, 2.3f) TEST_VECTOR4_OPERATORS(vec4, 1.2f, 2.5f, 0.2f, 5.3f, 6.8f, 1.9f, 20.5f, 10.3f) TEST_VECTOR4_NEGATION(vec4, 1.2f, 2.5f, 0.2f, 5.3f) TEST_VECTOR4_CAN_BE_PRINTED(vec4, "(1.2,3.5,5.5,4.4)", 1.2f, 3.5f, 5.5f, 4.4f) TEST_VECTOR4_STRUCTURE(dvec4, double, 5.0, 1.0, 7.0, 2.3) TEST_VECTOR4_OPERATORS(dvec4, 1.2, 2.5, 0.2, 5.3, 6.8, 1.9, 20.5, 10.3) TEST_VECTOR4_NEGATION(dvec4, 1.2, 2.5, 0.2, 5.3); TEST_VECTOR4_CAN_BE_PRINTED(dvec4, "(1.2,3.5,5.5,4.4)", 1.2, 3.5,5.5,4.4) TEST_VECTOR4_STRUCTURE(ivec4, i32, 5, 1, 7, 4) TEST_VECTOR4_OPERATORS(ivec4, 10, 25, 5, 53, 58, 3, 20, 10) TEST_VECTOR4_NEGATION(ivec4, 10, 25, 5, 53) TEST_VECTOR4_CAN_BE_PRINTED(ivec4, "(1,2,3,4)", 1, 2, 3,4) TEST_VECTOR4_STRUCTURE(uvec4, u32, 5u, 10u, 70u, 1u) TEST_VECTOR4_OPERATORS(uvec4, 10u, 25u, 5u, 53u, 58u, 3u, 20u, 10u) // NOTE(cme): no negation tests on unsigned TEST_VECTOR4_CAN_BE_PRINTED(uvec4, "(1,2,3,4)", 1u, 2u, 3u,4u) TEST(widest, worksOnVector4) { EXPECT_EQ(typeid(widest<ivec4,ivec4>),typeid(ivec4)); EXPECT_EQ(typeid(widest<ivec4,vec4>),typeid(vec4)); EXPECT_EQ(typeid(widest<ivec4,dvec4>),typeid(dvec4)); EXPECT_EQ(typeid(widest<ivec4,uvec4>),typeid(uvec4)); EXPECT_EQ(typeid(widest<vec4,ivec4>),typeid(vec4)); EXPECT_EQ(typeid(widest<vec4,vec4>),typeid(vec4)); EXPECT_EQ(typeid(widest<vec4,dvec4>),typeid(dvec4)); EXPECT_EQ(typeid(widest<vec4,uvec4>),typeid(vec4)); EXPECT_EQ(typeid(widest<uvec4,ivec4>),typeid(uvec4)); EXPECT_EQ(typeid(widest<uvec4,vec4>),typeid(vec4)); EXPECT_EQ(typeid(widest<uvec4,dvec4>),typeid(dvec4)); EXPECT_EQ(typeid(widest<uvec4,uvec4>),typeid(uvec4)); EXPECT_EQ(typeid(widest<dvec4,ivec4>),typeid(dvec4)); EXPECT_EQ(typeid(widest<dvec4,vec4>),typeid(dvec4)); EXPECT_EQ(typeid(widest<dvec4,dvec4>),typeid(dvec4)); EXPECT_EQ(typeid(widest<dvec4,uvec4>),typeid(dvec4)); } TEST(Vector4, constexpr_ness) { #if !defined(_MSC_VER) constexpr auto v = ivec4(1,0,0,0) + ivec4(0,1,0,0); static_assert(v == ivec4(1,1,0,0), "wrong"); #endif }
87ef6bd2c1dfaf90770a7204fee39ad4d62cf6dd
80b02bff8cfa850dc60497db67e9ff263f671be6
/proj/calc2dcmd/src/preview/mmImagePreviewOGL.cpp
117fc5c859460b4edf36887ec35285db7e9892a5
[ "MIT" ]
permissive
ogx/Calculation2D
68a3188e59d9842647af0e00c52fefe036b16d06
79f9d05986227e4677a8f88309c2eb6512a3de69
refs/heads/master
2016-08-03T05:06:23.720417
2015-03-26T12:45:07
2015-03-26T12:45:07
3,526,351
3
0
null
null
null
null
UTF-8
C++
false
false
18,942
cpp
mmImagePreviewOGL.cpp
//--------------------------------------------------------------------------- #include <preview/mmImagePreviewOGL.h> //gl, glu #include <mmError.h> #include <algorithm> #pragma comment ( lib, "opengl32.lib" ) #define GET_X_LPARAM( LPARAM ) static_cast<int>(LOWORD(LPARAM)) #define GET_Y_LPARAM( LPARAM ) static_cast<int>(HIWORD(LPARAM)) //--------------------------------------------------------------------------- GLfloat const mmImages::mmRGBPalette::_m_fBYR[] = {0.0f,0.0f,1.0f,0.0f, 1.0f,1.0f,0.0f,0.5f, 1.0f,0.0f,0.0f,1.0f, 1.0f,0.0f,1.0f}; GLfloat const mmImages::mmRGBPalette::_m_fBLUE[] = {1.0f,1.0f,1.0f,0.0f, 0.5f,0.7f,1.0f,0.5f, 0.0f,0.42f,1.0f,1.0f, 0.5f,0.5f,0.5f}; GLfloat const mmImages::mmRGBPalette::_m_fGRAYSCALE[] = {0.0f,0.0f,0.0f,0.0f, 0.5f,0.5f,0.5f,0.5f, 1.0f,1.0f,1.0f,1.0f, 1.0f,1.0f,0.0f}; GLfloat const mmImages::mmRGBPalette::_m_fTEMP[] = {0.0f,0.0f,1.0f,0.0f, 0.0f,1.0f,0.0f,0.25f, 0.5f,0.9f,0.0f,0.38f, 1.0f,0.0f,0.0f,0.5f, 1.0f,1.0f,0.0f,0.75f, 1.0f,1.0f,1.0f,1.0f, 1.0f,0.0f,1.0f}; mmImages::mmRGBPalette::mmRGBPalette( GLfloat const _p_fThresholds[], mmInt const p_iSize ) { Set( _p_fThresholds, p_iSize ); } //--------------------------------------------------------------------------- void mmImages::mmRGBPalette::Set( GLfloat const _p_fThresholds[], mmInt const p_iSize ) { GLfloat v_fDR(0.0), v_fDG(0.0), v_fDB(0.0); GLfloat v_fBottom(0.0), v_fTop(0.0); for( mmInt v_iI = 0; v_iI < p_iSize-1; ++v_iI ) { mmInt v_iBottom(static_cast<mmInt>(_p_fThresholds[v_iI*4+3] * 255.0f)); mmInt v_iTop(static_cast<mmInt>(_p_fThresholds[(v_iI+1)*4+3] * 255.0f)); if( v_iTop > 255 ) v_iTop = 255; _m_fPalette[v_iBottom*3] = _p_fThresholds[v_iI*4]; _m_fPalette[v_iBottom*3+1] = _p_fThresholds[v_iI*4+1]; _m_fPalette[v_iBottom*3+2] = _p_fThresholds[v_iI*4+2]; v_fDR = ( _p_fThresholds[(v_iI+1)*4] - _p_fThresholds[v_iI*4] ) / static_cast<GLfloat>((v_iTop-v_iBottom)); v_fDG = ( _p_fThresholds[(v_iI+1)*4+1] - _p_fThresholds[v_iI*4+1] ) / static_cast<GLfloat>((v_iTop-v_iBottom)); v_fDB = ( _p_fThresholds[(v_iI+1)*4+2] - _p_fThresholds[v_iI*4+2] ) / static_cast<GLfloat>((v_iTop-v_iBottom)); for( mmInt v_iJ = v_iBottom+1; v_iJ < v_iTop; ++v_iJ ) { _m_fPalette[v_iJ*3] = _m_fPalette[(v_iJ-1)*3] + v_fDR; _m_fPalette[v_iJ*3+1] = _m_fPalette[(v_iJ-1)*3+1] + v_fDG; _m_fPalette[v_iJ*3+2] = _m_fPalette[(v_iJ-1)*3+2] + v_fDB; } } m_sDefaultColor.fR = _p_fThresholds[p_iSize*4]; m_sDefaultColor.fG = _p_fThresholds[p_iSize*4+1]; m_sDefaultColor.fB = _p_fThresholds[p_iSize*4+2]; } //--------------------------------------------------------------------------- mmImages::mmImagePreviewOGLIMPL::mmImagePreviewOGLIMPL( wchar_t const _p_tcWindowTitle[] ): m_fPixelZoom(1.0f), _m_fPixels(NULL), m_iWidth(0), m_iHeight(0), m_iChannels(0), m_hWindow(NULL), m_hWindowDC(NULL), m_hWindowContext(NULL), m_bInitialized(false), m_bVisible(false), m_sPalette(mmRGBPalette::_m_fTEMP,6) { if( ! CreatePreviewWindow( _p_tcWindowTitle ) || ! InitializeDisplay() ) throw mmError(0); } //--------------------------------------------------------------------------- mmImages::mmImagePreviewOGLIMPL::~mmImagePreviewOGLIMPL( void ) { DeinitializeDisplay(); delete[] _m_fPixels; } //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::InitializeDisplay( void ) { if( m_bInitialized ) DeinitializeDisplay(); if( m_hWindow == NULL ) return false; if( ( m_hWindowDC = ::GetDC( m_hWindow ) ) == NULL ) return false; if( ! SetPixelFormatDescriptor( m_hWindowDC ) ) return false; if( ( m_hWindowContext = ::wglCreateContext( m_hWindowDC ) ) == NULL ) return false; if(::wglMakeCurrent( m_hWindowDC, m_hWindowContext ) != TRUE) return false; ::glClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); ::glClear( GL_COLOR_BUFFER_BIT ); ::glMatrixMode( GL_PROJECTION ); ::glLoadIdentity(); ::glOrtho( 0.0, 1.0, 0.0, 1.0, -1.0, 1.0 ); ::glMatrixMode( GL_MODELVIEW ); ::glLoadIdentity(); ::glPixelStorei( GL_PACK_ALIGNMENT, 1 ); ::glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); m_bInitialized = true; return true; } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::DeinitializeDisplay( void ) { if( m_bInitialized ) { HidePreviewWindow(); ::wglMakeCurrent( NULL, m_hWindowContext ); ::ReleaseDC( m_hWindow, m_hWindowDC ); m_hWindowDC = NULL; ::wglDeleteContext( m_hWindowContext ); m_hWindowContext = NULL; m_bInitialized = false; ::DestroyWindow( m_hWindow ); ::PostQuitMessage(0); } } //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::IsDisplayInitialized( void ) { return m_bInitialized; } //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::CreatePreviewWindow( wchar_t const _p_tcWindowTitle[] ) { WNDCLASS v_sWindowClass = {}; ::ZeroMemory( &v_sWindowClass, sizeof(v_sWindowClass) ); v_sWindowClass.style = CS_HREDRAW | CS_VREDRAW; v_sWindowClass.lpfnWndProc = &mmImagePreviewOGLIMPL::MsgRouter; v_sWindowClass.hInstance = ::GetModuleHandle(NULL); v_sWindowClass.hIcon = ::LoadIcon(NULL,IDI_APPLICATION); v_sWindowClass.hCursor = ::LoadCursor(NULL,IDC_ARROW); v_sWindowClass.hbrBackground = HBRUSH(COLOR_WINDOW); v_sWindowClass.lpszClassName = L"OGX2DPreviewWndClass"; ATOM v_sRegisteredClass = ::RegisterClass( &v_sWindowClass ); m_hWindow = NULL; ::SetLastError(ERROR_SUCCESS); if( v_sRegisteredClass != 0 ) m_hWindow = ::CreateWindow( L"OGX2DPreviewWndClass", _p_tcWindowTitle, WS_POPUPWINDOW, 10, 10, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, v_sWindowClass.hInstance, static_cast<LPVOID>(this) ); if(!m_hWindow) { DWORD err = ::GetLastError(); err = err; } return true; } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::ShowPreviewWindow( void ) { if( m_bInitialized ) { ::ShowWindow( m_hWindow, SW_SHOW ); m_bVisible = true; } } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::HidePreviewWindow( void ) { if( m_bInitialized ) { ::ShowWindow( m_hWindow, SW_HIDE ); m_bVisible = false; } } //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::IsPreviewWindowVisible( void ) { if( m_bInitialized ) return m_bVisible; else return false; } //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::ZoomIn( void ) { if( m_bInitialized && m_fPixelZoom > 0.1f ) { m_fPixelZoom *= 0.9f; ::glPixelZoom( m_fPixelZoom, m_fPixelZoom ); ResizeWindow( static_cast<int>(static_cast<GLfloat>(m_iWidth)*m_fPixelZoom), static_cast<int>(static_cast<GLfloat>(m_iHeight)*m_fPixelZoom) ); RepaintDisplay(); return true; } return false; } //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::ZoomOut( void ) { if( m_bInitialized && m_fPixelZoom < 10.0f ) { m_fPixelZoom /= 0.9f; ::glPixelZoom( m_fPixelZoom, m_fPixelZoom ); ResizeWindow( static_cast<int>(static_cast<GLfloat>(m_iWidth)*m_fPixelZoom), static_cast<int>(static_cast<GLfloat>(m_iHeight)*m_fPixelZoom) ); RepaintDisplay(); return true; } return false; } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::ResizeWindow( int p_iWidth, int p_iHeight ) { RECT v_sClientRect, v_sWindowRect; POINT v_sDiff; POINT v_sCursor; ::GetCursorPos(&v_sCursor); ::GetClientRect( m_hWindow, &v_sClientRect ); ::GetWindowRect( m_hWindow, &v_sWindowRect ); v_sDiff.x = (v_sWindowRect.right - v_sWindowRect.left) - v_sClientRect.right; v_sDiff.y = (v_sWindowRect.bottom - v_sWindowRect.top) - v_sClientRect.bottom; ::SetWindowPos( m_hWindow, NULL, v_sWindowRect.left, v_sWindowRect.top, p_iWidth + v_sDiff.x, p_iHeight + v_sDiff.y, 0); } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::ResetView( mmInt p_iWidth, mmInt p_iHeight ) { if( m_bInitialized ) { ResizeWindow( p_iWidth, p_iHeight ); ::glViewport( 0, 0, static_cast<GLint>(p_iWidth), static_cast<GLint>(p_iHeight)); m_fPixelZoom = 1.0f; ::glPixelZoom( 1.0f, 1.0f ); ::glRasterPos2i( 0, 0 ); } } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::RepaintDisplay( void ) { if( m_bInitialized && _m_fPixels != NULL && m_hWindowDC != NULL ) { ::glClear( GL_COLOR_BUFFER_BIT ); ::glDrawPixels( m_iWidth, m_iHeight, m_eDisplayMode, GL_FLOAT, _m_fPixels ); ::glFlush(); ::SwapBuffers( m_hWindowDC ); } } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::DisplayImage( mmImages::mmImageI * const p_psImage, bool p_bResetView ) { PrepareImageData(p_psImage); if( p_bResetView ) ResetView(m_iWidth, m_iHeight); RepaintDisplay(); } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::PrepareImageData( mmImages::mmImageI * const p_psImage) { m_iWidth = p_psImage->GetWidth(); m_iHeight = p_psImage->GetHeight(); m_iChannels = static_cast<mmInt>(p_psImage->GetPixelType()); if(m_iChannels == 1) { mmPixel8 * _v_sPixels = new mmPixel8[m_iWidth * m_iHeight]; p_psImage->GetRows(0, m_iHeight, _v_sPixels); delete[] _m_fPixels; _m_fPixels = new GLfloat[m_iWidth * m_iHeight * 3]; for( mmInt v_iY = 0; v_iY < m_iHeight; ++v_iY ) for( mmInt v_iX = 0; v_iX < m_iWidth; ++v_iX ) _m_fPixels[(m_iHeight - v_iY - 1) * m_iWidth + v_iX] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rI); delete[] _v_sPixels; m_eDisplayMode = GL_LUMINANCE; } else if(m_iChannels == 3) { mmPixel24 * _v_sPixels = new mmPixel24[m_iWidth * m_iHeight]; p_psImage->GetRows(0, m_iHeight, _v_sPixels); delete[] _m_fPixels; _m_fPixels = new GLfloat[m_iWidth * m_iHeight * 3]; for( mmInt v_iY = 0; v_iY < m_iHeight; ++v_iY ) for( mmInt v_iX = 0; v_iX < m_iWidth; ++v_iX ) { _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX) * 3] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rR); _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX) * 3 + 1] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rG); _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX) * 3 + 2] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rB); } delete[] _v_sPixels; m_eDisplayMode = GL_RGB; } else if(m_iChannels == 4) { mmPixel32 * _v_sPixels = new mmPixel32[m_iWidth * m_iHeight]; p_psImage->GetRows(0, m_iHeight, _v_sPixels); delete[] _m_fPixels; _m_fPixels = new GLfloat[m_iWidth * m_iHeight * 3]; for( mmInt v_iY = 0; v_iY < m_iHeight; ++v_iY ) for( mmInt v_iX = 0; v_iX < m_iWidth; ++v_iX ) { _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX) * 3] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rR * _v_sPixels[v_iY * m_iWidth + v_iX].rA + (1.0 - _v_sPixels[v_iY * m_iWidth + v_iX].rA)); _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX) * 3 + 1] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rG * _v_sPixels[v_iY * m_iWidth + v_iX].rA + (1.0 - _v_sPixels[v_iY * m_iWidth + v_iX].rA)); _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX) * 3 + 2] = static_cast<GLfloat>(_v_sPixels[v_iY * m_iWidth + v_iX].rB * _v_sPixels[v_iY * m_iWidth + v_iX].rA + (1.0 - _v_sPixels[v_iY * m_iWidth + v_iX].rA)); } delete[] _v_sPixels; m_eDisplayMode = GL_RGB; } } //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::DisplayDataLayer( mmImages::mmLayerI * const p_psLayer, bool p_bResetView ) { PrepareDataLayerData( p_psLayer ); if( p_bResetView ) ResetView( m_iWidth, m_iHeight ); RepaintDisplay(); }; //--------------------------------------------------------------------------- void mmImages::mmImagePreviewOGLIMPL::PrepareDataLayerData( mmImages::mmLayerI * const p_psLayer ) { m_iWidth = p_psLayer->GetWidth(); m_iHeight = p_psLayer->GetHeight(); mmReal * _v_rPixels = new mmReal[ m_iWidth*m_iHeight ]; p_psLayer->GetRows(0, m_iHeight, _v_rPixels); mmReal const v_rDefaultValue = p_psLayer->GetDefaultValue(); mmStats const v_sStats = p_psLayer->GetStats(); mmReal v_rDLScale = (( v_rDLScale = v_sStats.rMax - v_sStats.rMin ) != 0.0) ? v_rDLScale : 1.0; delete[] _m_fPixels; _m_fPixels = new GLfloat[ m_iWidth*m_iHeight*3 ]; mmReal v_rValue; mmInt v_iIndex; for( mmInt v_iY = 0; v_iY < m_iHeight; ++v_iY ) for( mmInt v_iX = 0; v_iX < m_iWidth; ++v_iX ) { v_rValue = _v_rPixels[m_iWidth*v_iY+v_iX]; if( ::fabs(v_rValue - v_rDefaultValue) < 1e-20 ) { _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX)*3] = m_sPalette.m_sDefaultColor.fR; _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX)*3+1] = m_sPalette.m_sDefaultColor.fG; _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX)*3+2] = m_sPalette.m_sDefaultColor.fB; } else { v_iIndex = static_cast<mmInt>((v_rValue - v_sStats.rMin) / v_rDLScale * 255.0); _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX)*3] = m_sPalette._m_fPalette[v_iIndex*3]; _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX)*3+1] = m_sPalette._m_fPalette[v_iIndex*3+1]; _m_fPixels[((m_iHeight-v_iY-1)*m_iWidth+v_iX)*3+2] = m_sPalette._m_fPalette[v_iIndex*3+2]; } } delete[] _v_rPixels; m_eDisplayMode = GL_RGB; }; //--------------------------------------------------------------------------- bool mmImages::mmImagePreviewOGLIMPL::SetPixelFormatDescriptor( HDC p_hDeviceContext ) { int v_iPixelFormat; PIXELFORMATDESCRIPTOR v_sPSD = { sizeof(PIXELFORMATDESCRIPTOR), 1, // version of this data structure - should be set to 1 PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, 0,0,0,0,0,0, 0,0, 0,0,0,0,0, 24, // depth of the Z-buffer 0,0, PFD_MAIN_PLANE, // PFD_MAIN_PLANE PFD_OVERLAY_PLANE PFD_UNDERLAY_PLANE 0,0,0,0 }; return ( v_iPixelFormat = ::ChoosePixelFormat( p_hDeviceContext, &v_sPSD ) ) != 0 && ::SetPixelFormat( p_hDeviceContext, v_iPixelFormat, &v_sPSD ) != 0; } //--------------------------------------------------------------------------- // DONE: figure out // http://msdn.microsoft.com/en-us/library/ms644898 //#define GWL_USERDATA (-21) LRESULT CALLBACK mmImages::mmImagePreviewOGLIMPL::MsgRouter( HWND p_hWindow, UINT p_uiMessage, WPARAM p_sWParam, LPARAM p_sLParam ) { mmImagePreviewOGLIMPL * _v_sPreview(NULL); if( p_uiMessage == WM_NCCREATE ) { _v_sPreview = reinterpret_cast<mmImagePreviewOGLIMPL*>( ((LPCREATESTRUCT) p_sLParam)->lpCreateParams ); ::SetWindowLong( p_hWindow, GWLP_USERDATA, reinterpret_cast<long>(_v_sPreview) ); } else _v_sPreview = reinterpret_cast<mmImagePreviewOGLIMPL*>( ::GetWindowLong( p_hWindow, GWLP_USERDATA ) ); _v_sPreview->m_hWindow = p_hWindow; if( _v_sPreview != NULL ) return _v_sPreview->WndProc( p_uiMessage, p_sWParam, p_sLParam ); else return ::DefWindowProc( p_hWindow, p_uiMessage, p_sWParam, p_sLParam ); } LRESULT CALLBACK mmImages::mmImagePreviewOGLIMPL::WndProc( UINT p_uiMessage, WPARAM p_sWParam, LPARAM p_sLParam ) { PAINTSTRUCT v_sPaintStruct; switch( p_uiMessage ) { case WM_C2DP_DISPLAY_IMAGE: { DisplayImage(reinterpret_cast<mmImageI*>(p_sWParam), p_sLParam != 0); return 0; } case WM_C2DP_DISPLAY_LAYER: { DisplayDataLayer(reinterpret_cast<mmLayerI*>(p_sWParam), p_sLParam != 0); return 0; } case WM_NCHITTEST: { LRESULT v_sHitTestResult; if( ( v_sHitTestResult = ::DefWindowProc( m_hWindow, p_uiMessage, p_sWParam, p_sLParam ) ) == HTCLIENT ) return HTCAPTION; else return v_sHitTestResult; } case WM_PAINT: { ::BeginPaint( m_hWindow, &v_sPaintStruct ); RepaintDisplay(); ::EndPaint( m_hWindow, &v_sPaintStruct ); return 0; } case WM_MOUSEWHEEL: { if( GET_WHEEL_DELTA_WPARAM(p_sWParam) < 0 ) ZoomOut(); else ZoomIn(); return 0; } case WM_LBUTTONDBLCLK: { ResetView( m_iWidth, m_iHeight ); RepaintDisplay(); return 0; } case WM_NCMBUTTONUP: { HidePreviewWindow(); return 0; } case WM_CLOSE: { HidePreviewWindow(); return 0; } } return ::DefWindowProc( m_hWindow, p_uiMessage, p_sWParam, p_sLParam ); } // --------------- WRAPPER -------------- mmImages::mmImagePreviewOGL::mmImagePreviewOGL( wchar_t const _p_tcWindowTitle[] ) : m_sTitle(_p_tcWindowTitle), m_bExit(false) { m_hPreviewThread = ::CreateThread(NULL, 0, &mmImagePreviewOGL::PreviewFunc, reinterpret_cast<LPVOID>(this), 0, NULL); } DWORD WINAPI mmImages::mmImagePreviewOGL::PreviewFunc(LPVOID p_psParam) { mmImagePreviewOGL * v_psInstance = reinterpret_cast<mmImagePreviewOGL*>(p_psParam); v_psInstance->m_psPreview = new mmImagePreviewOGLIMPL(v_psInstance->m_sTitle.c_str()); MSG v_sMessage; while(! v_psInstance->m_bExit) { while(::PeekMessageW(&v_sMessage, v_psInstance->m_psPreview->m_hWindow, 0, 0, PM_REMOVE)) { ::TranslateMessage(&v_sMessage); ::DispatchMessageW(&v_sMessage); } ::Sleep(10); } delete v_psInstance->m_psPreview; return 0; } mmImages::mmImagePreviewOGL::~mmImagePreviewOGL( void ) { m_bExit = true; ::WaitForSingleObject(m_hPreviewThread, INFINITE); } void mmImages::mmImagePreviewOGL::DisplayImage( mmImages::mmImageI * const p_psImage, bool p_bResetView) { ::SendMessage(m_psPreview->m_hWindow, WM_C2DP_DISPLAY_IMAGE, reinterpret_cast<WPARAM>(p_psImage), static_cast<LPARAM>(p_bResetView)); } void mmImages::mmImagePreviewOGL::DisplayDataLayer( mmImages::mmLayerI * const p_psLayer, bool p_bResetView) { ::SendMessage(m_psPreview->m_hWindow, WM_C2DP_DISPLAY_LAYER, reinterpret_cast<WPARAM>(p_psLayer), static_cast<LPARAM>(p_bResetView)); } void mmImages::mmImagePreviewOGL::ShowPreviewWindow( void ) { m_psPreview->ShowPreviewWindow(); } void mmImages::mmImagePreviewOGL::HidePreviewWindow( void ) { m_psPreview->HidePreviewWindow(); } bool mmImages::mmImagePreviewOGL::IsPreviewWindowVisible( void ) { return m_psPreview->IsPreviewWindowVisible(); } bool mmImages::mmImagePreviewOGL::ZoomIn( void ) { return m_psPreview->ZoomIn(); } bool mmImages::mmImagePreviewOGL::ZoomOut( void ) { return m_psPreview->ZoomOut(); }
f5adbff6595b29ceef262beacfc9970f2faea25b
1e5d25a8e0e31b78c4e979af55ee2ad64687c258
/Google/415 Add Strings/415 addStrings.cpp
3486dc8211aff439d606dd40bab1ca5982bfbf14
[]
no_license
charlenellll/LeetCodeSolution
ed02ee9b4059d6c1c6972af8cc56ea7bc85d401f
3b846bf4cc1817aaae9e4e392547ad9ccde04e76
refs/heads/master
2021-01-01T16:18:58.440351
2019-11-19T15:48:04
2019-11-19T15:48:04
97,808,314
2
0
null
null
null
null
UTF-8
C++
false
false
698
cpp
415 addStrings.cpp
// O(max(m,n)) time, O(1) space // 4ms, beats 99.32% class Solution { public: string addStrings(string num1, string num2) { string res = ""; int m = num1.length() - 1, n = num2.length() - 1; int rest = 0; for(int i = 0; i <= max(m, n); i++){ int sum = 0; if( i <= m && i <= n ) sum = (num1[m-i]-'0') + (num2[n-i] - '0') + rest; if( i > m ) sum = num2[n-i]-'0' + rest; if( i > n ) sum = num1[m-i]-'0' + rest; rest = sum / 10; sum = sum % 10; res += '0'+sum; } if( rest != 0 ) res += '0'+rest; reverse(res.begin(), res.end()); return res; } };
6960aad39ec0c15ca9fd67f3cd503b1fd6f5fdda
fb7960d4abcf79c96d2c5671607393fecba79bd3
/XMLFileWithIncomes.cpp
edd273c718ed967e235da0016134c63c128867ad
[]
no_license
Adamall123/console-financial-app
39ce99baa74858b36edb8c4d3ed3239dcba80f8a
c1ef551800e58fdc1484a2ccd31c39aef8f4d1b6
refs/heads/master
2023-03-03T01:25:22.503661
2020-12-15T13:33:04
2020-12-15T13:33:04
321,360,399
0
0
null
2023-02-28T02:29:22
2020-12-14T13:44:16
C++
UTF-8
C++
false
false
3,077
cpp
XMLFileWithIncomes.cpp
#include "XMLFileWithIncomes.h" void XMLFileWithIncomes::addIncomeToXMLFile(Income income) { CMarkup xml; bool fileExists = xml.Load("incomes.xml"); if(!fileExists) { xml.SetDoc("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); xml.AddElem( "Incomes" ); } xml.FindElem(); xml.IntoElem(); xml.AddElem( "Income" ); xml.IntoElem(); xml.AddElem( "IncomeID", income.getIncomeID() ); xml.AddElem( "UserID", income.getUserId() ); string date = AuxiliaryMethods::convertFromIntToString(income.getDate()); xml.AddElem( "Date", DateMethods::addDashesInDate(date) ); //here it must be changed again with pattern from int to string with '-' xml.AddElem( "Item", income.getItem() ); xml.AddElem( "Amount", AuxiliaryMethods::convertFromFloatToString(income.getAmount()) ); xml.Save( "incomes.xml" ); } vector <Income> XMLFileWithIncomes::loadIncomesFromXMLFile() { Income income; string strDate=""; vector <Income> incomes; CMarkup xml; bool fileExists = xml.Load("incomes.xml"); if(fileExists) { xml.ResetPos(); // top of document xml.FindElem(); // incomes element is root xml.IntoElem(); // inside incomes while ( xml.FindElem("Income") ) { xml.IntoElem(); xml.FindElem( "IncomeID" ); income.setIncomeID(AuxiliaryMethods::convertFromStringToInt(MCD_2PCSZ(xml.GetData()))); xml.FindElem( "UserID"); income.setUserID(AuxiliaryMethods::convertFromStringToInt(MCD_2PCSZ(xml.GetData()))); xml.FindElem( "Date"); //changing from string to int without '-' strDate = MCD_2PCSZ(xml.GetData()); income.setDate(AuxiliaryMethods::convertFromStringToInt(DateMethods::disposeOfDashesInDate(strDate))); xml.FindElem( "Item"); income.setItem(xml.GetData()); xml.FindElem( "Amount"); income.setAmount(AuxiliaryMethods::convertFromStringToFloat(MCD_2PCSZ(xml.GetData()))); incomes.push_back(income); xml.OutOfElem(); } } //temporary solution - loading to vector data from logged in user vector <Income> incomesFromLoggedInUser; for (int i = 0; i < incomes.size(); i++) if (incomes[i].getUserId() == ID_LOGGED_IN_USER) incomesFromLoggedInUser.push_back(incomes[i]); return incomesFromLoggedInUser; } int XMLFileWithIncomes::returnLastIncomeId() { Income income; CMarkup xml; bool fileExists = xml.Load("incomes.xml"); if(fileExists) { xml.ResetPos(); // top of document xml.FindElem(); // incomes element is root xml.IntoElem(); // inside incomes while ( xml.FindElem("Income") ) { xml.IntoElem(); xml.FindElem( "IncomeID" ); idFromLastIncome = AuxiliaryMethods::convertFromStringToInt(MCD_2PCSZ(xml.GetData())); //after a while, when on last element than assign xml.OutOfElem(); } return idFromLastIncome; } else return 0; }
1157db561ce6f48853a339089ebd27f104161622
85ef9b1c0b13af144a0382c8be00f5a3ac5ab025
/leetcode/set_mismatch.cpp
f6b3aa8f61d3f71d32152bdf24b357801e0041fe
[]
no_license
MonsieurWilson/cpplearn
bdc44826ff5c20ba039933e5d4b699d5794e3415
0c59da95e8e853661998e997944fa44f68881ed6
refs/heads/master
2020-04-04T17:54:11.477183
2019-01-19T15:37:07
2019-01-19T15:37:07
156,141,305
0
0
null
null
null
null
UTF-8
C++
false
false
2,457
cpp
set_mismatch.cpp
/** * Copyright(C), 2018 * Name: set_mismatch * Author: Wilson Lan * Description: * The set S originally contains numbers from 1 to n. But unfortunately, * due to the data error, one of the numbers in the set got duplicated to * another number in the set, which results in repetition of one number * and loss of another number. * * Given an array nums representing the data status of this set after the * error. Your task is to firstly find the number occurs twice and then * find the number that is missing. Return them in the form of an array. */ class Solution { public: vector<int> findErrorNums(vector<int> &nums) { int dupelem, misselem; dupelem = misselem = 1; for (int n : nums) { if (nums[abs(n)-1] < 0) { dupelem = abs(n); } else { nums[abs(n)-1] *= -1; } } for (int i = 0; i < nums.size(); ++i) { if (nums[i] > 0) { misselem = i + 1; break; } } return {dupelem, misselem}; } vector<int> findErrorNumsXOR(vector<int> &nums) { // Calculate the xor of duplicate and missing elements. int dupxormiss = 0; for (int n : nums) { dupxormiss ^= n; } for (int i = 1; i <= nums.size(); ++i) { dupxormiss ^= i; } // Seperate into two parts and calculate xor1, xor2. // xor1 and xor2 must be duplicate and missing elements. int rightmostbit = dupxormiss & ~(dupxormiss - 1); int xor1 = 0, xor2 = 0; for (int n : nums) { if (n & rightmostbit) { xor1 ^= n; } else { xor2 ^= n; } } for (int i = 1; i <= nums.size(); ++i) { if (i & rightmostbit) { xor1 ^= i; } else { xor2 ^= i; } } // Find which one is the element of set. auto pos = find(nums.begin(), nums.end(), xor1); if (pos == nums.end()) { return {xor2, xor1}; } else { return {xor1, xor2}; } } };
e664cc6a0cb8a37d0355665ffd9243a935f670c2
2741e8174e6042f2e264ab15f3c69f7b7abf3152
/Common Bathroom/bathroom.h
b7a0381fa7877237d270cc84c2e19090506d3ad3
[]
no_license
yaPhilya/Algorithms
d2267ea60130476f72683a5d5353303d5da3ef52
7e143bddfc4160d31921a73adda674bcf9ae0fcf
refs/heads/master
2021-01-17T06:44:23.605791
2017-05-18T22:18:23
2017-05-18T22:18:23
59,145,329
0
0
null
null
null
null
UTF-8
C++
false
false
1,295
h
bathroom.h
// // Created by philipp on 09.12.16. // #include <mutex> #include <condition_variable> #include <atomic> class bathroom { public: bathroom() { manFlag_.store(false); girlFlag_.store(false); counter_ = 0; } void enter_male() { std::unique_lock<std::mutex> lock(mutex_); while(girlFlag_.load()) { waiter_.wait(lock); } manFlag_.store(true); counter_++; lock.unlock(); } void leave_male() { std::lock_guard<std::mutex> lock(mutex_); --counter_; if (counter_ == 0){ manFlag_.store(false); } waiter_.notify_all(); } void enter_female() { std::unique_lock<std::mutex> lock(mutex_); while (manFlag_.load()) { waiter_.wait(lock); } girlFlag_.store(true); counter_++; lock.unlock(); } void leave_female() { std::lock_guard<std::mutex> lock(mutex_); --counter_; if (counter_ == 0){ girlFlag_.store(false); } waiter_.notify_all(); } private: std::atomic<bool> manFlag_; std::atomic<bool> girlFlag_; std::condition_variable waiter_; std::mutex mutex_; std::size_t counter_; };
2e489f0e3c39efb154afd8185ab171be8f4ee8a3
064d096b2764285235abc09e162c76654ea8a1e0
/game/interactible_screen.hpp
26084c5e7b5021b413a0f5592f6deb144a7e088a
[]
no_license
bdajeje/IsoRPG
972753576af7c3bfd007eb893d5164a7d1729238
7bc9c23eb506100365ae1a906e48630bd468de0e
refs/heads/master
2021-03-27T18:56:10.727056
2017-03-07T02:54:22
2017-03-07T02:54:22
78,490,484
0
0
null
null
null
null
UTF-8
C++
false
false
1,663
hpp
interactible_screen.hpp
#ifndef INTERACTIBLESCREEN_HPP #define INTERACTIBLESCREEN_HPP #include "graphics/drawable.hpp" #include "graphics/screen.hpp" #include "graphics/sprite.hpp" #include "game/events/handler.hpp" namespace game { class InteractibleScreen : public graphics::Screen, public events::Handler { struct HoverFuncs { HoverFuncs() {} HoverFuncs(std::function<void()> focus, std::function<void()> unfocus) : _focus {focus} , _unfocus {unfocus} {} std::function<void()> _focus; std::function<void()> _unfocus; }; public: virtual ~InteractibleScreen() = default; virtual void update(const sf::Time& time) override; virtual events::EventAction handleEvents(const sf::Event& event) override; /*! Called every time the screen is shown on top of others */ virtual void show() {} protected: void addClickable(graphics::DrawableSP clickable, std::function<void()> func); void addHoverable(graphics::DrawableSP hoverable); void addHoverable(graphics::DrawableSP hoverable, std::function<void()> focus, std::function<void()> unfocus); void addEventHandler(HandlerSP handler) { _event_handlers.push_back(handler); } bool hovered(int x, int y) noexcept; bool clicked(int x, int y) const noexcept; void unhoverCurrent(); private: std::map<graphics::DrawableSP, std::function<void()>> _clickables; std::map<graphics::DrawableSP, HoverFuncs> _hoverables; std::vector<HandlerSP> _event_handlers; graphics::DrawableSP _current_hover; }; using InteractibleScreenSP = std::shared_ptr<InteractibleScreen>; } #endif // INTERACTIBLESCREEN_HPP
1a6c13e21a17ae6973e57ba246b355ef1ae5d453
efc1446f8788c0bb8b4decc0960a61b760e0ec02
/PEProLicenseFix/Main.cpp
a4d23f645ae5b39372d1ae7262fcaa26ad47c243
[]
no_license
gregshutt/pe-pro-license-fix
62c6d57eb2af2c171a30ce9221741c15908209c0
7205a0b8cf0788dc247f4589e506b1223e38c259
refs/heads/master
2020-03-28T19:11:42.560107
2018-09-16T02:07:42
2018-09-16T02:07:42
148,953,272
0
0
null
null
null
null
UTF-8
C++
false
false
2,235
cpp
Main.cpp
#include <stdio.h> #include <Windows.h> int readSector(const wchar_t* disk, char* buffer, unsigned int sector) { DWORD dwRead; HANDLE hDisk = CreateFile(disk, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0); if (hDisk == INVALID_HANDLE_VALUE) { CloseHandle(hDisk); fprintf(stderr, "Could not open disk %ls: 0x%x\n", disk, GetLastError()); return(-1); } if (SetFilePointer(hDisk, sector * 512, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) { CloseHandle(hDisk); return(-1); } if (ReadFile(hDisk, buffer, 512, &dwRead, NULL) == FALSE) { CloseHandle(hDisk); return(-1); } if (dwRead != 512) { CloseHandle(hDisk); return(-1); } CloseHandle(hDisk); return(0); } int writeSector(const wchar_t* disk, char* buffer, unsigned int sector) { DWORD dwWritten; HANDLE hDisk = CreateFile(disk, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); if (hDisk == INVALID_HANDLE_VALUE) { CloseHandle(hDisk); fprintf(stderr, "Could not open disk %ls: 0x%x\n", disk, GetLastError()); return(-1); } if (SetFilePointer(hDisk, sector * 512, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) { CloseHandle(hDisk); return(-1); } if (WriteFile(hDisk, buffer, 512, &dwWritten, NULL) == FALSE) { CloseHandle(hDisk); return(-1); } if (dwWritten != 512) { CloseHandle(hDisk); return(-1); } CloseHandle(hDisk); return(0); } int main() { char buffer[512]; // read sector 0 printf("Checking sector 0..."); if (readSector(L"\\\\.\\PhysicalDrive0", buffer, 0) != 0) { fprintf(stderr, "Could not read first sector"); exit(1); } printf("done.\n"); // read sector 60 printf("Checking for license sector..."); if (readSector(L"\\\\.\\PhysicalDrive0", buffer, 60) != 0) { fprintf(stderr, "Could not read first sector"); exit(1); } UINT32 magic = buffer[511] << 24 | buffer[510] << 16 | buffer[509] << 8 | buffer[508]; if (magic == 0x0045561D) { printf("found.\n"); } else { printf("not found. Are you sure PE Pro is installed? (Expected 0x0045561D, got 0x%0x)\n", magic); exit(0); } memset(buffer, 0, sizeof(buffer)); printf("Clearing license..."); if (writeSector(L"\\\\.\\PhysicalDrive0", buffer, 60) != 0) { printf("failed.\n"); } else { printf("succeeded.\n"); } }
2f22ffbe0b36393d6bd45052e5fe56f541c869a1
2e4bb545151fccfde585598182a3d687f4cafe52
/lightweaver-gui/MainWindow.h
3f3ff53ce38b050588aa83e847ccfcfdb6da76dd
[]
no_license
tiltit/lightweaver
a228869ae1a985f0d4430d7efee91ba00c7854cb
246b313c7140852b6a3e74ebcf6c76b909f20ed8
refs/heads/master
2020-05-15T18:56:02.366912
2014-05-20T10:42:41
2014-05-20T10:42:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,366
h
MainWindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QColor> #include <QString> #include <QVector> #include "ui_ui-main-window.h" #include "motorcontrol.h" class MainWindow : public QMainWindow, private Ui::MainWindow { Q_OBJECT public: MainWindow(QMainWindow *parent = 0); private: MotorControl motorControl; void colorImage(); void colorStripes(); void lineWorld(); void lineWorldColor(); void perfectImage(); void colorLinesFull(); private slots: void onOpenDeviceButtonClicked(); void onColorWheelColorChange(QColor); void onMotorControlGotNewLine(QString line); void onSendCommandsButtonClicked(); void onM1StepClockwiseButtonClicked(); void onM1StepCounterclockwiseButtonClicked(); void onM2StepClockwiseButtonClicked(); void onM2StepCounterclockwiseButtonClicked(); void onReleaseMotor1Button(); void onReleaseMotor2Button(); void actionColorImageTriggered(); void actionColorStripesTriggered(); void actionLineWorldColorTriggered(); void actionLineWorldTriggered(); void actionPerfectImageTriggered(); void actionColorLinesFullTriggered(); void onMotorControlCommandQueueDequeued(int queueSize); void onFlushCommandsButtonClick(); void onToggleShutterButtonClicked(); QVector<QColor*>* computeGoldenRatioColors(double startHue,double saturation, double value, int size); }; #endif
42c39b6717d16ae2ffcce3da380d2e2630c1c80c
d7c238248b0c783bda83a32ad9067397b683a2ed
/TEst/PreferencialTaxDlg.cpp
bc11502128b92bc42902101eb709c286407afcf3
[]
no_license
ahmdsaf/CPP_MFC_Xml_Serialization
8ea6fe02dbce895712d2b520c550bf50fb9f8091
2726973fe2851f902800c8ae47044682670fafbc
refs/heads/master
2023-03-23T08:56:51.404426
2018-08-01T19:48:27
2018-08-01T19:48:27
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
78,996
cpp
PreferencialTaxDlg.cpp
// PreferencialTaxesDlg.cpp // #include "stdafx.h" #include "bfrofC.h" #include "CSCmnClientTemplates.h" #include "FormViewDlg.h" #include "PreferencialTaxes.h" #include "PreferencialTaxDlg.h" #include "RpcBfrof.h" #include "BlkSumAccStr.h" #include "ExtListCtrl.h" #include "CodeNameChooseDlg.h" #include "TaxAutomationStructs.h" #include "TopDetStr.h" #include "TaxAutomationStructs.h" #include "PreferencialDealTypeC.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define MIN_DATE 18900101 #define MAX_PERCENT 100 #define ID_ADD_EVENT 1 #define ID_DELETE_EVENT 2 #define ID_ADD_TAX 3 #define ID_DELETE_TAX 4 #define ID_WM_DEAL_TYPE_CHANGED WM_USER + 1001 ACCSYScEXP int StoreSelDetValueFromComboX( CComboBox& cb, long& value ); ACCSYScEXP void LoadDetInComboX( WORD wCode, BYTE byDetOrNom, long curvalue, CComboBox& cb, BOOL fNamesOnly/*=FALSE*/ ); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CPreferencialTaxSheet::DoXmlSerialization() { _bstr_t bstrBuf; CSXMLSerializer oXmlSerializer; CPreferencialTaxFullRec oFullRecBuffer; oFullRecBuffer.Copy( *m_pBuf ); if( !oFullRecBuffer.SerializeXML( oXmlSerializer ) ) return; if( !oXmlSerializer.GetXML( bstrBuf ) ) return; CXmlEditDlg oDlgXmlEditor; oDlgXmlEditor.m_bstr = bstrBuf; if( oDlgXmlEditor.DoModal() != IDOK ) return; bstrBuf = oDlgXmlEditor.m_bstr; CPreferencialTaxFullRec oFullRecBuff2; CSXMLSerializer oXmlDeserializer; if( !oFullRecBuff2.DeserializeXML( oXmlDeserializer, &bstrBuf, NULL ) ) return; m_pBuf->Copy( oFullRecBuff2 ); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #pragma region MainPage ///////////////////////////////////////////////////////////////////////////// // CPreferencialTaxMainPage BEGIN_LANG_WND( CPreferencialTaxMainPage ) WND( WND_TITLE, MSG_BASE_DATA ), WND( IDC_RDB_MONTHS, MSG_NUMBER_MONTHS ), WND( IDC_RDB_DAYS, MSG_NUMBER_OF_DAYS ), WND( IDC_CHK_DEPENDS_ON_DATE_OPEN, MSG_DEPENDS_ON_DEAL_OPEN_DATE ), WND( IDC_RDB_DEPENDS_ON, MSG_DEPENDS_ON ), WND( IDC_RDB_EVENT_COUNT, MSG_NUMBER_EVENTS ), WND( IDC_RDB_PERCENT, MSG_PERCENT ), WND( IDC_RDB_SOLID_SUM, MSG_FIXED_SUM ), WND( IDC_BTN_ADD, MSG_ACCSYSC_1797 ), WND( IDC_BTN_DEL, MSG_ACCSYSC_1798 ), WND( IDC_GRB_PREF_CONDITIONS, MSG_PREFERENCE_CONDITIONS ), WND( IDC_STT_CODE, MSG_ACCSYSC_1509 ), WND( IDC_STT_PREF_TAX_NAME, MSG_ACCSYSC_2141 ), WND( IDC_GRB_PREF_MAIN_DATA, MSG_PREFERENCE_MAIN_DATA ), WND( IDC_STT_PREF_STATUS, MSG_ACCSYSC_2140 ), WND( IDC_STT_TERM_OF_ACTION, MSG_TERM_OF_ACTIVITY ), WND( IDC_STT_PERIODICITY, MSG_CYCLE ), WND( IDC_STT_TERM_FROM, MSG_FROM_SHORT ), WND( IDC_STT_TERM_TO, MSG_UNTIL ), WND( IDC_STT_DATE_OPEN_FROM, MSG_FROM_ACC ), WND( IDC_STT_DATE_OPEN_TO, MSG_UNTIL ), WND( IDC_STT_SUM_OVER, MSG_SUM_OVER ), WND( IDC_STT_EVENT_COUNT_FROM, MSG_FROM_ACC ), WND( IDC_STT_EVENT_COUNT_TO, MSG_UNTIL ), WND( IDC_GRB_PREF_PLAN_BY_EVENTS, MSG_EVENT_PREFERENCE_PLAN ), WND( IDC_STT_DEAL_TYPE, MSG_DEAL_TYPE_2 ), WND( IDC_STT_PREF_SYSTEM, MSG_SERVICE_SYSTEM ), WND( IDC_RDB_NO_DEPENDANCY, MSG_NO_ADDITIONAL_PREFERENCE_CONDITIONS ), WND( IDC_GRB_GRATIS_SUM_PERIOD, MSG_GRATIS_SUM_AND_PERIOD ), WND( IDC_CHK_GRATIS_SUM_VALIDITY, MSG_GRATIS_SUM_VALIDITY_MONTHS ), WND( IDC_STT_GRATIS_SUM, MSG_GRATIS_SUM_AMMOUNT_IN_LV ), WND( IDC_RDB_DEAL_SERVICE_COMB, MSG_DEAL_SERVICE_COMBINATION ), END_LANG_WND() IMPLEMENT_DYNAMIC( CPreferencialTaxMainPage, CBasePropertyPage ) CPreferencialTaxMainPage::CPreferencialTaxMainPage( CPreferencialTaxFullRec & recPrefTax , const short sDlgMode, CWnd* pParent ) : CBasePropertyPage( CPreferencialTaxMainPage::IDD, GetHISTANCEBfrofCDLL() ) , m_eDlgMode( (ePrefTaxDlgMode)sDlgMode ) { m_pBuf = &recPrefTax; m_nCode = 0; m_nRdbDaysMonths = -1; m_nRdbBalanceNumEvents = -1; m_nRdbPercentSolidSum = -1; m_nGratisMonths = 0; m_nNumMonths = 0; m_nNumDays = 0; m_nNumEventsFrom = 0; m_nNumEventsTo =0; } CPreferencialTaxMainPage::~CPreferencialTaxMainPage() { } BEGIN_MESSAGE_MAP( CPreferencialTaxMainPage, CBasePropertyPage ) ON_EN_KILLFOCUS( IDC_EDB_TERM_FROM, &CPreferencialTaxMainPage::OnEnKillfocusEdbTermFrom ) ON_EN_KILLFOCUS( IDC_EDB_MONTHS, &CPreferencialTaxMainPage::OnEnKillfocusEdbMonths ) ON_EN_KILLFOCUS( IDC_EDB_DAYS, &CPreferencialTaxMainPage::OnEnKillfocusEdbDays ) ON_BN_CLICKED( IDC_RDB_MONTHS, &CPreferencialTaxMainPage::OnBnClickedRdbMonths ) ON_BN_CLICKED( IDC_RDB_DAYS, &CPreferencialTaxMainPage::OnBnClickedRdbMonths ) ON_BN_CLICKED( IDC_CHK_DEPENDS_ON_DATE_OPEN, &CPreferencialTaxMainPage::OnBnClickedChkDependsOnDateOpen ) ON_EN_KILLFOCUS( IDC_EDB_DATE_OPEN_TO, &CPreferencialTaxMainPage::OnEnKillfocusEdbDateOpenTo ) ON_BN_CLICKED( IDC_RDB_DEPENDS_ON, &CPreferencialTaxMainPage::OnBnClickedRdbDependsOn ) ON_BN_CLICKED( IDC_RDB_EVENT_COUNT, &CPreferencialTaxMainPage::OnBnClickedRdbDependsOn ) ON_BN_CLICKED( IDC_RDB_NO_DEPENDANCY, &CPreferencialTaxMainPage::OnBnClickedRdbDependsOn ) ON_BN_CLICKED( IDC_RDB_DEAL_SERVICE_COMB, &CPreferencialTaxMainPage::OnBnClickedRdbDependsOnDealTypeService ) ON_BN_CLICKED( IDC_RDB_PERCENT, &CPreferencialTaxMainPage::OnBnClickedRdbPercent ) ON_BN_CLICKED( IDC_RDB_SOLID_SUM, &CPreferencialTaxMainPage::OnBnClickedRdbPercent ) ON_BN_CLICKED( IDC_BTN_ADD, &CPreferencialTaxMainPage::OnBnClickedAdd ) ON_BN_CLICKED( IDC_BTN_DEL, &CPreferencialTaxMainPage::OnBnClickedDel ) ON_CBN_SELCHANGE( IDC_CMB_DEAL_TYPE, &CPreferencialTaxMainPage::OnCbnDealTypeSelChange ) ON_LBN_SELCHANGE( IDC_LSB_PREF_SYSTEM, &CPreferencialTaxMainPage::OnLbsProcSystemSelChange) ON_BN_CLICKED( IDC_CHK_GRATIS_SUM_VALIDITY, &CPreferencialTaxMainPage::OnBnClickedChkGratisSumValidity ) END_MESSAGE_MAP() bool CPreferencialTaxMainPage::Control() { if( !UpdateData() ) return false; if( !m_pBuf ) return false; LDATE lMaxDate = MAX_DATE; m_edbName.GetWindowText( m_pBuf->m_recPrefTax.m_szPreferenceName, sizeof( m_pBuf->m_recPrefTax.m_szPreferenceName )-1 ) ; if( strlen( m_pBuf->m_recPrefTax.m_szPreferenceName ) <= 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_ACCSYSC_2141 ) ) ); return false; }// if long lSel = -1; lSel = m_cmbDealType.GetCurSel(); if( lSel < 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_DEAL_TYPE_3 ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_nDealType = m_cmbDealType.GetItemData( lSel ); if( m_pBuf->m_recPrefTax.m_nDealType < 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_DEAL_TYPE_3 ) ) ); return false; }// if // Обслужваща система BOOL bHasChoosenSystem = FALSE; CSNomMsgIDCode oProcSystem( g_arrProcessingSystem, _countof( g_arrProcessingSystem ) ); CSCmnRecsArray<long> arrProcSystems; for( INT_PTR i = 0, nCnt = oProcSystem.GetSize(); i < nCnt; i++ ) { if( ( i == nCnt - 1 ) && oProcSystem.LastIsEmpty() ) break; int nCode = oProcSystem.GetCodeByIndex( i ); if( nCode == (int)eUndefinedProcessingSystem ) continue; if( m_pBuf->m_recPrefTax.CheckProcessingSystemBit( nCode ) ) { bHasChoosenSystem = TRUE; break; }// if }// for if( !bHasChoosenSystem ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_SERVICE_SYSTEM ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_fDateValidFrom = (LDATE)m_edbDateActiveFrom.GetDate(); if( ( m_eDlgMode == eAdd || m_eDlgMode == eAddNoStdDog ) && ( (LDATE)m_pBuf->m_recPrefTax.m_fDateValidFrom < CUR_DATE || (LDATE)m_pBuf->m_recPrefTax.m_fDateValidFrom > lMaxDate ) ) { CSMsg::Log( eScreen, MSG_DATE_BEGIN_BEFORE_CURRENT ); return false; }// if m_pBuf->m_recPrefTax.m_fDateValidTo = (LDATE)m_edbDateActiveTo.GetDate(); if( (LDATE)m_pBuf->m_recPrefTax.m_fDateValidTo < (LDATE)m_pBuf->m_recPrefTax.m_fDateValidFrom || (LDATE)m_pBuf->m_recPrefTax.m_fDateValidTo > lMaxDate ) { CSMsg::Log( eScreen, MSG_END_DATE_ACTIVE_SMALLER_THAN_BEGIN_DATE ); return false; }// if if( m_pBuf->m_recPrefTax.m_sPreferenceStatus != (short)eStsDeactivated ) { if( CUR_DATE <(LDATE)m_pBuf->m_recPrefTax.m_fDateValidFrom ) m_pBuf->m_recPrefTax.m_sPreferenceStatus = (short)eStsWaiting; else if( CUR_DATE > (LDATE)m_pBuf->m_recPrefTax.m_fDateValidTo ) m_pBuf->m_recPrefTax.m_sPreferenceStatus = (short)eStsInactive; else if( CUR_DATE >= (LDATE)m_pBuf->m_recPrefTax.m_fDateValidFrom && CUR_DATE <= (LDATE)m_pBuf->m_recPrefTax.m_fDateValidTo ) m_pBuf->m_recPrefTax.m_sPreferenceStatus = (short)eStsActive; }// else if( m_nRdbDaysMonths != (int)eMonthsPeriod && m_nRdbDaysMonths != (int)eDaysPeriod ) { CSMsg::Log( eScreen, MSG_CHOOSE_OPTION_COUNT_MONTHS_DAYS ); return false; }// if if( m_nRdbDaysMonths == (int)eMonthsPeriod ) { if( m_nNumMonths <= 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_NUMBER_MONTHS ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_nNumMonths = m_nNumMonths; m_pBuf->m_recPrefTax.m_nNumDays = 0; }// if else if( m_nRdbDaysMonths == (int)eDaysPeriod ) { if( m_nNumDays <= 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_DAYS_COUNT_EMPL ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_nNumMonths = 0; m_pBuf->m_recPrefTax.m_nNumDays = m_nNumDays; }// else if m_pBuf->m_recPrefTax.m_sPeriodType = m_nRdbDaysMonths; // Периодичност lSel = m_cmbPeriodicity.GetCurSel(); if( lSel < 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_PERIODICAL ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_sPeriodicity = (short)m_cmbPeriodicity.GetItemData( lSel ); if( m_pBuf->m_recPrefTax.m_sPeriodicity <= 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_PERIODICAL ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_Hdr.SetBit( STS_DEPENDS_ON_DATE_OPEN, m_chbDependsOnDealOpenDate.GetCheck() > 0 ); if( m_pBuf->m_recPrefTax.m_nDealType == KCK_DEALS && m_chbGratisSumValidity.GetCheck() > 0 ) { if( m_nGratisMonths <= 0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_GRATIS_SUM_VALIDITY_MONTHS ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_nGratisMonths = m_nGratisMonths; if( m_edbGratisSum.GetSum() <= 0.0 ) { CSMsg::Log( eScreen, MSG_PLEASE_FILL_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_GRATIS_SUM_VALUE ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_fGratisSumBgn = m_edbGratisSum.GetSum(); }// if if( m_chbGratisSumValidity.GetCheck() <= 0 ) { m_pBuf->m_recPrefTax.m_nGratisMonths = 0; m_pBuf->m_recPrefTax.m_fGratisSumBgn = 0; }// if if( m_chbDependsOnDealOpenDate.GetCheck() > 0 ) { m_pBuf->m_recPrefTax.m_fDateOpenFrom = (LDATE)m_edbDateDealFrom.GetDate(); if( (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenFrom < MIN_DATE || (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenFrom > lMaxDate ) { CSMsg::Log( eScreen, MSG_INCORRECT_DATE_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_DATE_OPEN_DEAL_FROM ) ) ); return false; }// if m_pBuf->m_recPrefTax.m_fDateOpenTo = (LDATE)m_edbDateDealTo.GetDate(); if( (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenTo < MIN_DATE || (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenTo > lMaxDate ) { CSMsg::Log( eScreen, MSG_INCORRECT_DATE_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_DATE_OPEN_DEAL_TO ) ) ); return false; }// if if( (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenFrom > (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenTo ) { CSMsg::Log( eScreen, MSG_DATE_DEAL_OPEN_TO_SMALLER_DATE_FROM ); return false; }// if }// if else { m_pBuf->m_recPrefTax.m_fDateOpenFrom.Clear(); m_pBuf->m_recPrefTax.m_fDateOpenTo.Clear(); }// else if( m_nRdbBalanceNumEvents != (short)eBalanceTurnover && m_nRdbBalanceNumEvents != (short)eEventsCount && m_nRdbBalanceNumEvents != (short)eNoDependancy && m_nRdbBalanceNumEvents != (short)eDealService ) { CSMsg::Log( eScreen, MSG_CHOOSE_OPTION_DEPENDS_ON_OR_EVENT_COUNT ); return false; }// if if( m_pBuf->m_arrPlan.GetCount() <= 0 && m_pBuf->m_recPrefTax.m_fGratisSumBgn <= 0 ) { CSMsg::Log( eScreen, MSG_NO_PREF_PLAN ); return false; }// if // Събития и такси PREFERENCIAL_EVENTS_TAXES * pPrefEvent = NULL; if( m_pBuf->m_arrEventsTaxes.GetCount() <= 0 ) { CSMsg::Log( eScreen, MSG_NO_EVENTS_AND_TAXES_ADDED ); return FALSE; }// if for( int i = 0; i < m_pBuf->m_arrEventsTaxes.GetCount(); i++ ) { pPrefEvent = m_pBuf->m_arrEventsTaxes.GetAt( i ); if ( pPrefEvent->m_lTaxCode > 0 ) continue; if( !m_pBuf->m_arrEventsTaxes.EventHasTaxes( pPrefEvent->m_lEventCode ) ) { CString strName; GetSheet()->GetEventName( pPrefEvent->m_lEventCode, strName ); CSMsg::Log( eScreen, MSG_FOR_EVENT_THERE_ARE_NO_TAXES, &MSGKEY( "0", strName ) ); return FALSE; }// if }// for if( m_eDlgMode != eAddNoStdDog && m_eDlgMode!= eEditConditionsOnly && m_eDlgMode != eAddKlientska && !m_pBuf->IsIndividual() && !m_pBuf->IsKlientskaPref() && m_pBuf->m_arrTaxesToStdDeals.GetCount() <= 0 && ( m_pBuf->m_recPrefTax.m_nDealType == RAZPL_DEALS || m_pBuf->m_recPrefTax.m_nDealType == DEPOS_DEALS || m_pBuf->m_recPrefTax.m_nDealType == WLOG_DEALS || m_pBuf->m_recPrefTax.m_nDealType == KCK_DEALS ) ) { CSMsg::Log( eScreen, MSG_PR_TAX_NO_STD ); return false; }//if return true; } void CPreferencialTaxMainPage::DoDataExchange( CDataExchange* pDX ) { CBasePropertyPage::DoDataExchange( pDX ); // Код на преференциална такса DDX_Control( pDX, IDC_EDB_CODE, m_edbCode ); DDX_Text( pDX, IDC_EDB_CODE, m_nCode ); // Име на преференциалната такса DDX_Control( pDX, IDC_EDB_NAME, m_edbName ); // Статус - активна, неактивна, деактивирана или чакаща DDX_Control( pDX, IDC_EDB_STATUS, m_edbStatus ); // Тип на сделка DDX_Control( pDX, IDC_CMB_DEAL_TYPE, m_cmbDealType ); // Обслужваща система DDX_Control( pDX, IDC_LSB_PREF_SYSTEM, m_chlbProcessingSystem ); // Срок на действие от DDX_EditDate( pDX, IDC_EDB_TERM_FROM, m_edbDateActiveFrom ); // Срок на действие до DDX_EditDate( pDX, IDC_EDB_TERM_TO, m_edbDateActiveTo ); // Радиобутони Брой месеци / Брой дни DDX_Control( pDX, IDC_RDB_MONTHS, m_rdbMohtns ); DDX_Control( pDX, IDC_RDB_DAYS, m_rdbDays ); // Брой месеци DDX_Control( pDX, IDC_EDB_MONTHS, m_edbNumMonths ); DDX_Text( pDX, IDC_EDB_MONTHS, m_nNumMonths ); // Брой дни DDX_Control( pDX, IDC_EDB_DAYS, m_edbNumDays ); DDX_Text( pDX, IDC_EDB_DAYS, m_nNumDays ); // Периодичност DDX_Control( pDX, IDC_CMB_PERIODICITY, m_cmbPeriodicity ); // Зависи от дата на откриване на сделката DDX_Control( pDX, IDC_CHK_DEPENDS_ON_DATE_OPEN, m_chbDependsOnDealOpenDate ); // Дата на откриване на сделката от DDX_EditDate( pDX, IDC_EDB_DATE_OPEN_FROM, m_edbDateDealFrom ); // Дата на откриване на сделката до DDX_EditDate( pDX, IDC_EDB_DATE_OPEN_TO, m_edbDateDealTo ); // Гратисна сума // Брой месеци за валидност на гратисната сума DDX_Control( pDX, IDC_CHK_GRATIS_SUM_VALIDITY, m_chbGratisSumValidity ); DDX_Control( pDX, IDC_EDB_GRATIS_MONTHS, m_edbGratisMonths ); DDX_Text( pDX, IDC_EDB_GRATIS_MONTHS, m_nGratisMonths ); // Размер на гратисната сума DDX_Control( pDX, IDC_EDB_GRATIS_SUM, m_edbGratisSum ); // Радиобутони Зависи от салдо / брой събития / комбинация от сделка и услуга DDX_Control( pDX, IDC_RDB_DEPENDS_ON, m_rdbBalance ); DDX_Control( pDX, IDC_RDB_EVENT_COUNT, m_rdbNumEvents ); DDX_Control( pDX, IDC_RDB_DEAL_SERVICE_COMB, m_rdbDealTypeService ); DDX_Control( pDX, IDC_RDB_NO_DEPENDANCY, m_rdbNoDependancy ); // Зависи от DDX_Control( pDX, IDC_CMB_DEPENDS_ON, m_cmbDependsOn ); // Комбинация от зделка и услуга DDX_Control( pDX, IDC_CMB_DEAL_SERVICE_COMB, m_cmbDealTypeService ); // Сума над DDX_SumEdit( pDX, IDC_EDB_SUM_OVER, m_edbSumOver ); // Брой събития от DDX_Control( pDX, IDC_EDB_EVENT_COUNT_FROM, m_edbNumEventsFrom ); DDX_Text( pDX, IDC_EDB_EVENT_COUNT_FROM, m_nNumEventsFrom ); // Брой събития до DDX_Control( pDX, IDC_EDB_EVENT_COUNT_TO, m_edbNumEventsТо ); DDX_Text( pDX, IDC_EDB_EVENT_COUNT_TO, m_nNumEventsTo ); // Радиобутони процент / твърда сума DDX_Control( pDX, IDC_RDB_PERCENT, m_rdbPercent ); DDX_Control( pDX, IDC_RDB_SOLID_SUM, m_rdbSolidSum ); // Процент DDX_SumEdit( pDX, IDC_EDB_PERCENT, m_edbPercent ); // Твърда сума DDX_SumEdit( pDX, IDC_EDB_SOLID_SUM, m_edbSolidSum ); // Добавяне DDX_Control( pDX, IDC_BTN_ADD, m_btnAdd ); // Изтриване DDX_Control( pDX, IDC_BTN_DEL, m_btnDelete ); // Преференциален план по събития DDX_Control( pDX, IDC_LSB_PREF_EVENT_PLAN, m_lstPlan ); } BOOL CPreferencialTaxMainPage::OnInitDialog() { CBasePropertyPage::OnInitDialog(); m_edbCode.EnableWindow( FALSE ); m_edbStatus.EnableWindow( FALSE ); m_edbNumDays.EnableWindow( FALSE ); m_edbNumMonths.EnableWindow( FALSE ); m_edbDateDealFrom.EnableWindow( FALSE ); m_edbDateDealTo.EnableWindow( FALSE ); m_cmbDependsOn.EnableWindow( FALSE ); m_edbSumOver.EnableWindow( FALSE ); m_edbNumEventsFrom.EnableWindow( FALSE ); m_edbNumEventsТо.EnableWindow( FALSE ); m_edbPercent.EnableWindow( FALSE ); m_edbSolidSum.EnableWindow( FALSE ); m_chbGratisSumValidity.EnableWindow( TRUE ); m_edbGratisMonths.EnableWindow( FALSE ); m_edbGratisSum.EnableWindow( FALSE ); m_edbGratisSum.SetSum( 0.0 ); m_edbDateActiveTo.EnableWindow( FALSE ); m_cmbDealType.EnableWindow( m_eDlgMode == eEditFull || ( m_eDlgMode == eAdd && m_pBuf->m_recPrefTax.m_nDealType <= 0 ) ); WORD wCol = 0; m_lstPlan.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_SUM_PERCENT ), LVCFMT_RIGHT, m_lstPlan.GetStringWidth("#############"), wCol ); m_lstPlan.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_DEPENDS_ON ), LVCFMT_LEFT, m_lstPlan.GetStringWidth("################"), wCol ); m_lstPlan.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_SUM_OVER ), LVCFMT_RIGHT, m_lstPlan.GetStringWidth("##########"), wCol ); m_lstPlan.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_EVENTS_FROM ), LVCFMT_RIGHT, m_lstPlan.GetStringWidth("###########"), wCol ); m_lstPlan.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_UNTIL ), LVCFMT_RIGHT, m_lstPlan.GetStringWidth("##########"), wCol ); DWORD dwStyleEx = m_lstPlan.GetExtendedStyle(); dwStyleEx |= LVS_EX_FULLROWSELECT; m_lstPlan.SetExtendedStyle( dwStyleEx ); if( m_eDlgMode == eView || m_eDlgMode == eViewNoDeactivate || m_eDlgMode == eEditDatesOnly || m_eDlgMode == eEditConditionsOnly ) EnableControls( FALSE ); if( !LoadData() ) { CSMsg::Log( eScreen, MSG_ERR_LOAD_PREFERENCE_DATA ); return FALSE; }// if return TRUE; } BOOL CPreferencialTaxMainPage::OnApply() { if( !Control() ) return FALSE; return TRUE; } void CPreferencialTaxMainPage::EnableControls( const BOOL bEnable ) { BOOL bEditDatesOnly = ( m_eDlgMode == eEditDatesOnly ); m_edbCode.EnableWindow( FALSE ); m_edbName.EnableWindow( bEnable ); m_edbStatus.EnableWindow( FALSE ); m_chlbProcessingSystem.EnableWindow( bEnable ); m_cmbDealType.EnableWindow( bEnable ); m_edbDateActiveFrom.EnableWindow( bEnable || ( m_eDlgMode == eEditConditionsOnly && m_pBuf->m_recPrefTax.IsKlientskaPref() ) || ( m_eDlgMode == eEditConditionsOnly && m_pBuf->m_recPrefTax.IsIndividual() ) ); m_edbDateActiveTo.EnableWindow( bEnable ); m_rdbMohtns.EnableWindow( bEnable ); m_rdbDays.EnableWindow( bEnable ); m_edbNumMonths.EnableWindow( bEnable || ( bEditDatesOnly && m_pBuf->m_recPrefTax.m_sPeriodType == (short)eMonthsPeriod ) ); m_edbNumDays.EnableWindow( bEnable || ( bEditDatesOnly && m_pBuf->m_recPrefTax.m_sPeriodType == (short)eDaysPeriod ) ); m_chbGratisSumValidity.EnableWindow( ( bEnable || ( m_eDlgMode == eEditConditionsOnly && m_pBuf->m_recPrefTax.m_nDealType == KCK_DEALS ) ) && m_pBuf->m_arrPlan.GetCount() <= 0 ); m_cmbPeriodicity.EnableWindow( bEnable ); m_chbDependsOnDealOpenDate.EnableWindow( bEnable ); m_edbDateDealFrom.EnableWindow( bEnable ); m_edbDateDealTo.EnableWindow( bEnable || ( bEditDatesOnly && m_pBuf->m_recPrefTax.m_Hdr.CheckBit( STS_DEPENDS_ON_DATE_OPEN ) == (short)eDaysPeriod ) ); m_rdbBalance.EnableWindow( bEnable ); m_rdbNumEvents.EnableWindow( bEnable ); m_cmbDependsOn.EnableWindow( bEnable ); m_rdbNoDependancy.EnableWindow( bEnable ); m_edbSumOver.EnableWindow( bEnable ); m_edbNumEventsFrom.EnableWindow( bEnable ); m_edbNumEventsТо.EnableWindow( bEnable ); m_rdbDealTypeService.EnableWindow( bEnable ); m_cmbDealTypeService.EnableWindow( bEnable ); m_rdbPercent.EnableWindow( m_eDlgMode == eEditConditionsOnly ); m_rdbSolidSum.EnableWindow( m_eDlgMode == eEditConditionsOnly ); m_edbPercent.EnableWindow( m_eDlgMode == eEditConditionsOnly ); m_edbSolidSum.EnableWindow( m_eDlgMode == eEditConditionsOnly ); m_btnAdd.EnableWindow( m_eDlgMode == eEditConditionsOnly ); m_btnDelete.EnableWindow( m_eDlgMode == eEditConditionsOnly ); } void CPreferencialTaxMainPage::OnLbsProcSystemSelChange() { if( !m_pBuf ) return; for( int i=0; i< m_chlbProcessingSystem.GetCount(); i++ ) { if( m_chlbProcessingSystem.GetItemData( i ) < 0 ) continue; m_pBuf->m_recPrefTax.SetProcessingSystemBit( m_chlbProcessingSystem.GetItemData( i ) , m_chlbProcessingSystem.GetCheck( i ) > 0 ); }// for } void CPreferencialTaxMainPage::OnCbnDealTypeSelChange() { if( !m_pBuf ) return; long lDealType = 0; StoreSelDetValueFromComboX( m_cmbDealType, lDealType ); if( m_pBuf->m_recPrefTax.m_nDealType != lDealType && m_pBuf->m_arrEventsTaxes.GetCount() > 0 ) if( !CSMsg::Question( "При смяна на типа сделка ще бъдат премахнати всички събития! Сигурни ли сте?" ) ) { int nIndex =-1; for( int i = 0; i< m_cmbDealType.GetCount(); i++ ) { if( m_pBuf->m_recPrefTax.m_nDealType == m_cmbDealType.GetItemData( i ) ) { m_cmbDealType.SetCurSel( i ); break; }// if }// for return; }// if if( lDealType < 0 ) return; m_pBuf->m_recPrefTax.m_nDealType = lDealType; m_chbGratisSumValidity.EnableWindow( m_pBuf->m_recPrefTax.m_nDealType == KCK_DEALS && m_pBuf->m_arrPlan.GetCount() <= 0 ); int nCurSel = m_cmbDealType.GetCurSel(); if( nCurSel != CB_ERR && (m_cmbDealType.GetItemData( nCurSel ) == RAZPL_DEALS) ) { m_rdbDealTypeService.ShowWindow( SW_SHOW ); m_cmbDealTypeService.ShowWindow( SW_SHOW ); } else if ( m_rdbDealTypeService.GetCheck() == BST_CHECKED ) { m_rdbDealTypeService.ShowWindow( SW_HIDE ); m_cmbDealTypeService.ShowWindow( SW_HIDE ); m_pBuf->m_arrPlan.Release(); LoadPlan(); } else { m_rdbDealTypeService.ShowWindow( SW_HIDE ); m_cmbDealTypeService.ShowWindow( SW_HIDE ); } if( m_pBuf->m_recPrefTax.m_nDealType == RAZPL_DEALS && m_cmbDealTypeService.IsWindowVisible() ) LoadDealTypeBankServiceCombinationsInCombo( m_pBuf->m_recPrefTax.m_nDealType ); OnBnClickedRdbDependsOn(); OnBnClickedChkGratisSumValidity(); GetParent()->PostMessage( ID_WM_DEAL_TYPE_CHANGED, (WPARAM)lDealType ); } void CPreferencialTaxMainPage::OnBnClickedChkGratisSumValidity() { if( !m_pBuf ) return; BOOL bEnable = m_chbGratisSumValidity.GetCheck() > 0; if( m_pBuf->m_recPrefTax.m_nDealType != KCK_DEALS ) { m_edbGratisMonths.EnableWindow( FALSE ); m_nGratisMonths = 0; UpdateData( FALSE ); m_edbGratisSum.EnableWindow( FALSE ); m_edbGratisSum.SetSum( 0.0 ); m_chbGratisSumValidity.SetCheck( FALSE ); bEnable = FALSE; }// if BOOL bEnableGratisControls = ( m_eDlgMode != eView && m_eDlgMode != eViewNoDeactivate && m_eDlgMode != eEditDatesOnly ); m_edbGratisMonths.EnableWindow( bEnable && bEnableGratisControls ); m_edbGratisSum.EnableWindow( bEnable && bEnableGratisControls ); BOOL bEnableDependanceControls = m_eDlgMode != eView && m_eDlgMode != eViewNoDeactivate && m_eDlgMode != eEditDatesOnly; m_rdbBalance.EnableWindow( !bEnable && bEnableDependanceControls ); m_rdbNumEvents.EnableWindow( !bEnable && bEnableDependanceControls); m_rdbNoDependancy.EnableWindow( !bEnable && bEnableDependanceControls ); m_btnAdd.EnableWindow( !bEnable && bEnableDependanceControls ); m_btnDelete.EnableWindow( !bEnable && bEnableDependanceControls ); m_rdbPercent.EnableWindow( !bEnable && bEnableDependanceControls ); m_rdbSolidSum.EnableWindow( !bEnable && bEnableDependanceControls ); if( bEnable ) { m_edbPercent.EnableWindow( FALSE ); m_edbSolidSum.EnableWindow( FALSE ); }// if else { if( m_rdbPercent.GetCheck() > 0 ) m_edbPercent.EnableWindow( bEnableDependanceControls ); if( m_rdbSolidSum.GetCheck() > 0 ) m_edbSolidSum.EnableWindow( bEnableDependanceControls ); }// else LoadPlan(); } bool CPreferencialTaxMainPage::LoadData() { if( !m_pBuf ) return false; CSNomMsgIDCode oStatuses( g_arrPreferenceTaxStatus, _countof( g_arrPreferenceTaxStatus ) ); LoadDetInComboX( DIALS, NOM, m_pBuf->m_recPrefTax.m_nDealType, m_cmbDealType, FALSE ); if( !LoadProcessingSystem() ) return false; if( m_pBuf->m_recPrefTax.IsIndividual() ) { CString strDealType = "", strCaption = ""; for( int i =0; i< m_arrDealTypes.GetCount(); i++ ) if( m_arrDealTypes.GetAt( i )->lCode == m_pBuf->m_recPrefToDeal.m_lDealType ) { strDealType = m_arrDealTypes.GetAt( i )->szName; break; }// if CSMsg::GetMsgUsrLang( strCaption, MSG_PREFERENCIAL_TAX_TO_DEAL_TYPE_NUMBER, &MSGKEY("0", strDealType ), &MSGKEY("1", m_pBuf->m_recPrefToDeal.m_lDealNum ) ); if( GetParent() ) GetParent()->SetWindowText( strCaption ); }// if // Ако мода е добавяне на клиеткса преференция if( m_eDlgMode == eAddKlientska ) { m_edbName.SetWindowText( m_pBuf->m_recPrefTax.m_szPreferenceName ); m_edbDateActiveFrom.SetDate( CUR_DATE ); m_edbDateActiveTo.SetDate( CUR_DATE ); m_edbDateDealFrom.SetDate( CUR_DATE ); m_edbDateDealTo.SetDate( CUR_DATE ); m_rdbPercent.SetCheck( TRUE ); m_rdbMohtns.SetCheck( TRUE ); m_rdbNoDependancy.SetCheck( TRUE ); UpdateData( TRUE ); m_edbSolidSum.SetSum( 0.0 ); m_edbSumOver.SetSum( 0.0 ); m_edbPercent.SetSum( 0.0 ); m_edbStatus.SetWindowText( oStatuses.GetMsgUserLang( eStsWaiting ) ); OnBnClickedRdbMonths(); OnBnClickedChkDependsOnDateOpen(); OnBnClickedRdbDependsOn(); OnBnClickedRdbPercent(); if ( !LoadPeriodicities() ) return false; if( !LoadBalanceTurnover() ) return false; OnCbnDealTypeSelChange(); return true; }//if if( m_eDlgMode == eAdd ) { m_edbDateActiveFrom.SetDate( CUR_DATE ); m_edbDateActiveTo.SetDate( CUR_DATE ); m_edbDateDealFrom.SetDate( CUR_DATE ); m_edbDateDealTo.SetDate( CUR_DATE ); m_rdbPercent.SetCheck( TRUE ); m_rdbMohtns.SetCheck( TRUE ); m_rdbNoDependancy.SetCheck( TRUE ); UpdateData( TRUE ); OnBnClickedRdbMonths(); OnBnClickedRdbPercent(); OnBnClickedRdbDependsOn(); m_edbSolidSum.SetSum( 0.0 ); m_edbSumOver.SetSum( 0.0 ); m_edbPercent.SetSum( 0.0 ); m_edbStatus.SetWindowText( oStatuses.GetMsgUserLang( eStsWaiting ) ); if ( !LoadPeriodicities() ) return false; if( !LoadBalanceTurnover() ) return false; m_rdbDealTypeService.ShowWindow( SW_HIDE ); m_cmbDealTypeService.ShowWindow( SW_HIDE ); return true; }// if if( m_eDlgMode != eAdd ) { if( m_pBuf->m_recPrefTax.m_sPeriodType == eMonthsPeriod ) { m_rdbMohtns.SetCheck( BST_CHECKED ); } else { m_rdbDays.SetCheck( BST_CHECKED ); } } if ( m_eDlgMode == eAdd || m_eDlgMode == eAddNoStdDog ) return false; m_nCode = m_pBuf->m_recPrefTax.m_lCode; m_nRdbDaysMonths = m_pBuf->m_recPrefTax.m_sPeriodType; m_nNumMonths = m_pBuf->m_recPrefTax.m_nNumMonths; m_nNumDays = m_pBuf->m_recPrefTax.m_nNumDays; if( m_pBuf->m_arrPlan.GetCount() > 0 ) m_nRdbBalanceNumEvents = m_pBuf->m_arrPlan.GetAt(0)->m_sDependType; if( m_pBuf->m_recPrefTax.m_sPreferenceStatus == (short)eStsDeactivated ) { CString strSts; strSts.Format( "%s %s %s", oStatuses.GetMsgUserLang( m_pBuf->m_recPrefTax.m_sPreferenceStatus ) , CSMsg::GetMsgUsrLang( MSG_FROM ) , m_pBuf->m_recPrefTax.m_iniDeactivate.inic ); m_edbStatus.SetWindowText( strSts ); }// if else m_edbStatus.SetWindowText( oStatuses.GetMsgUserLang( m_pBuf->m_recPrefTax.m_sPreferenceStatus ) ); m_edbName.SetWindowText( m_pBuf->m_recPrefTax.m_szPreferenceName ); m_edbDateActiveFrom.SetDate( (LDATE)m_pBuf->m_recPrefTax.m_fDateValidFrom ); if( m_eDlgMode == eEditConditionsOnly && m_pBuf->m_recPrefTax.IsIndividual() ) m_edbDateActiveFrom.SetDate( CUR_DATE ); m_edbDateActiveTo.SetDate( (LDATE)m_pBuf->m_recPrefTax.m_fDateValidTo ); m_chbDependsOnDealOpenDate.SetCheck( m_pBuf->m_recPrefTax.m_Hdr.CheckBit( STS_DEPENDS_ON_DATE_OPEN ) ); m_edbDateDealFrom.SetDate( (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenFrom ); m_edbDateDealTo.SetDate( (LDATE)m_pBuf->m_recPrefTax.m_fDateOpenTo ); m_nGratisMonths = m_pBuf->m_recPrefTax.m_nGratisMonths; m_edbGratisSum.SetSum( m_pBuf->m_recPrefTax.m_fGratisSumBgn ); m_chbGratisSumValidity.SetCheck( m_pBuf->m_recPrefTax.m_fGratisSumBgn > 0 ); UpdateData( FALSE ); OnBnClickedRdbMonths(); OnBnClickedChkDependsOnDateOpen(); OnBnClickedRdbDependsOn(); OnBnClickedRdbPercent(); if ( !LoadPlan() ) return false; if ( !LoadPeriodicities( m_pBuf->m_recPrefTax.m_sPeriodicity ) ) return false; short sBalanceTurnover = 0; if( m_pBuf->m_arrPlan.GetCount() > 0 ) sBalanceTurnover = m_pBuf->m_arrPlan.GetAt( 0 )->m_sBalanceTurnoverType; if( !LoadBalanceTurnover( sBalanceTurnover ) ) return false; if ( m_eDlgMode != eView && m_eDlgMode != eViewNoDeactivate ) OnBnClickedChkGratisSumValidity(); OnCbnDealTypeSelChange( ); return true; } /************************************************************************/ /* Зарежда комбинациите м/у типове зделки и банкови услуги за тип зделка /************************************************************************/ bool CPreferencialTaxMainPage::LoadDealTypeBankServiceCombinationsInCombo( const long& lDealType ) { if( lDealType <= 0 ) return false; CCSPreferencialDealTypeC oPrefDealTypes; if( !oPrefDealTypes.LoadAllInCombo_ByDealType( lDealType, m_cmbDealTypeService ) ) return false; return true; } bool CPreferencialTaxMainPage::LoadPeriodicities( const short sPeriodicity ) { CSNomMsgIDCode oPeriodicities( g_arrPreferenceTaxPeriodicity, _countof( g_arrPreferenceTaxPeriodicity ) ); oPeriodicities.LoadInCombo( m_cmbPeriodicity, sPeriodicity ); if( sPeriodicity == (short)eDayly ) m_cmbPeriodicity.EnableWindow( FALSE ); return true; } bool CPreferencialTaxMainPage::LoadProcessingSystem() { m_chlbProcessingSystem.ResetContent(); CSNomMsgIDCode oProcSystem( g_arrProcessingSystem, _countof( g_arrProcessingSystem ) ); CSCmnRecsArray<long> arrProcSystems; int nItem = 0; for( INT_PTR i = 0, nCnt = oProcSystem.GetSize(); i < nCnt; i++ ) { if( ( i == nCnt - 1 ) && oProcSystem.LastIsEmpty() ) break; int nCode = oProcSystem.GetCodeByIndex( i ); if( nCode == (int)eUndefinedProcessingSystem ) continue; nItem = m_chlbProcessingSystem.AddString( oProcSystem.GetMsgUserLangByIndex( i ) ); m_chlbProcessingSystem.SetItemData( nItem, nCode ); m_chlbProcessingSystem.SetCheck( nItem, m_pBuf->m_recPrefTax.CheckProcessingSystemBit( nCode ) ); }// for return true; } bool CPreferencialTaxMainPage::LoadBalanceTurnover( const short sBalanceTurnoverType ) { CSNomMsgIDCode oBalTurnover( g_arrPreferenceTaxBalanceTurnover, _countof( g_arrPreferenceTaxBalanceTurnover ) ); oBalTurnover.LoadInCombo( m_cmbDependsOn, sBalanceTurnoverType ); return true; } bool CPreferencialTaxMainPage::LoadPlan() { CCSPreferencialDealTypeC oPrefHelper; m_lstPlan.DeleteAllItems(); CString strBuf = ""; int nSubItem = 1; m_pBuf->m_arrPlan.SetCompFunction( PREFERENCIAL_PLANS::compareByEventCountSumOver ); m_pBuf->m_arrPlan.QSort(); CSNomMsgIDCode oBalanceTurnover( g_arrPreferenceTaxBalanceTurnover, _countof( g_arrPreferenceTaxBalanceTurnover ) ); if( m_pBuf->m_arrPlan.GetCount() > 0 ) { if( m_pBuf->m_arrPlan.GetAt( 0 )->m_sDependType == (short)eBalanceTurnover ) { m_edbSumOver.EnableWindow( m_eDlgMode == eAdd || m_eDlgMode == eEditFull || m_eDlgMode == eEditNoDealType || m_eDlgMode == eEditConditionsOnly || m_eDlgMode == eAddKlientska || m_eDlgMode == eEditKlientska ); m_rdbBalance.SetCheck( TRUE ); }// if if( m_pBuf->m_arrPlan.GetAt( 0 )->m_sDependType == (short)eEventsCount ) { m_edbNumEventsFrom.EnableWindow( m_eDlgMode == eAdd || m_eDlgMode == eEditFull || m_eDlgMode == eEditNoDealType || m_eDlgMode == eEditConditionsOnly || m_eDlgMode == eAddKlientska || m_eDlgMode == eEditKlientska ); m_edbNumEventsТо.EnableWindow( m_eDlgMode == eAdd || m_eDlgMode == eEditFull || m_eDlgMode == eEditNoDealType || m_eDlgMode == eEditConditionsOnly || m_eDlgMode == eAddKlientska || m_eDlgMode == eEditKlientska ); m_rdbNumEvents.SetCheck( TRUE ); }// if if( m_pBuf->m_arrPlan.GetAt( 0 )->m_sDependType == (short)eDealService ) { m_cmbDealTypeService.EnableWindow( m_eDlgMode == eAdd || m_eDlgMode == eEditFull || m_eDlgMode == eEditNoDealType || m_eDlgMode == eEditConditionsOnly || m_eDlgMode == eAddKlientska || m_eDlgMode == eEditKlientska ); m_rdbDealTypeService.SetCheck( BST_CHECKED ); oPrefHelper.LoadAllInCombo_ByDealType( m_pBuf->m_recPrefTax.m_nDealType, m_cmbDealTypeService ); CCSPreferencialDealTypeC::SelectInCombo_ByCode( m_pBuf->m_arrPlan.GetAt(0)->m_nPrefDealTypeCode, m_cmbDealTypeService ); } if( m_pBuf->m_arrPlan.GetAt( 0 )->m_sDependType == (short)eNoDependancy ) { m_rdbNoDependancy.SetCheck( TRUE ); } UpdateData( TRUE ); }// if else { m_rdbSolidSum.SetCheck( FALSE ); m_rdbPercent.SetCheck( TRUE ); m_rdbNumEvents.SetCheck( FALSE ); m_rdbBalance.SetCheck( FALSE ); m_rdbNoDependancy.SetCheck( TRUE ); UpdateData( TRUE ); OnBnClickedRdbPercent(); OnBnClickedRdbDependsOn(); }// else BOOL bEnableDependanceControls = ( m_pBuf->m_arrPlan.GetCount() <= 0 ) && m_eDlgMode != eView && m_eDlgMode != eViewNoDeactivate && m_eDlgMode != eEditDatesOnly && m_chbGratisSumValidity.GetCheck() <= 0; m_rdbBalance.EnableWindow( bEnableDependanceControls ); m_rdbNumEvents.EnableWindow( bEnableDependanceControls ); m_rdbNoDependancy.EnableWindow( bEnableDependanceControls ); m_cmbDependsOn.EnableWindow( bEnableDependanceControls && m_rdbBalance.GetCheck() > 0 ); m_rdbDealTypeService.EnableWindow( bEnableDependanceControls ); PREFERENCIAL_DEAL_TYPE recPrefDealType; for( INT_PTR i = 0, nCount = m_pBuf->m_arrPlan.GetCount() ; i < nCount ; i++ ) { nSubItem = 1; PREFERENCIAL_PLANS *pItem = m_pBuf->m_arrPlan.GetAt( i ); if( !pItem ) return false; if( pItem->m_sPreferenceType == (short)ePercent ) strBuf.Format( "%.2f %%", pItem->m_fPercent ); else strBuf.Format( "%.2f ", pItem->m_fSumSolid ); // Сума/процент int nLCIndex = m_lstPlan.InsertItem( m_lstPlan.GetItemCount(), strBuf ); strBuf = ""; if( pItem->m_sDependType == (short)eBalanceTurnover ) { strBuf = oBalanceTurnover.GetMsgUserLang( pItem->m_sBalanceTurnoverType ); } else if ( pItem->m_sDependType == (short)eDealService ) { if( !oPrefHelper.LoadRecord( pItem->m_nPrefDealTypeCode, recPrefDealType ) ) return false; strBuf.Format( _T("%d.%s"), recPrefDealType.nCode, recPrefDealType.szPrefName ); } // Зависи от m_lstPlan.SetItemText( nLCIndex, nSubItem++, strBuf ); strBuf = ""; if( pItem->m_sDependType == (short)eBalanceTurnover ) strBuf.Format( "%.2f", pItem->m_fSumOver ); // Сума над m_lstPlan.SetItemText( nLCIndex, nSubItem++, strBuf ); strBuf = ""; if( pItem->m_sDependType == (short)eEventsCount ) strBuf.Format( "%d", pItem->m_nEventCountFrom ); // Събития от m_lstPlan.SetItemText( nLCIndex, nSubItem++, strBuf ); strBuf = ""; if( pItem->m_sDependType == (short)eEventsCount ) strBuf.Format( "%d", pItem->m_nEventCountTo ); // Събития до m_lstPlan.SetItemText( nLCIndex, nSubItem++, strBuf ); }// for return true; } void CPreferencialTaxMainPage::OnBnClickedAdd() { if( !m_pBuf ) return; UpdateData( TRUE ); long lBalTurnover = 0; // Дали е избрана опция от радиобутоните брой събития/зависи от if( m_nRdbBalanceNumEvents != (short)eEventsCount && m_nRdbBalanceNumEvents != (short)eBalanceTurnover && m_nRdbBalanceNumEvents != (short)eNoDependancy && m_nRdbBalanceNumEvents != (short)eDealService ) { CSMsg::Log( eScreen, MSG_CHOOSE_OPTION_DEPENDS_ON_OR_EVENT_COUNT ); return; }// if // За избрана опция 'Без допълнителни условия за преференцията' не може да имаме повече от един елемент if( m_nRdbBalanceNumEvents == (short)eNoDependancy && m_pBuf->m_arrPlan.GetCount() > 0 ) { CSMsg::Log( eScreen, MSG_FOR_OPTION_NO_DEPENDENCY_CANT_HAVE_MORE_THAN_ONE_INPLAN ); return; }// if // Дали е избрана опция от радиобутоните сума/процент if( m_nRdbPercentSolidSum != (short)eSolidSum && m_nRdbPercentSolidSum != (short)ePercent ) { CSMsg::Log( eScreen, MSG_CHOOSE_OPTION_PERCENT_OR_SOLID_SUM ); return; }// if // Ако е брой събития, проверяваме дали брой 'от' е if( m_nRdbBalanceNumEvents == (short)eEventsCount ) { if( m_nNumEventsFrom != m_pBuf->m_arrPlan.GetMaxEventCountTo() +1 ) { CSMsg::Log( eScreen, MSG_INNCORECT_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_NUMBER_EVENTS_FROM ) ) ); m_nNumEventsFrom = m_pBuf->m_arrPlan.GetMaxEventCountTo() + 1; m_edbNumEventsFrom.SetFocus(); UpdateData( FALSE ); return; }//if if( m_nNumEventsFrom > m_nNumEventsTo ) { CSMsg::Log( eScreen, MSG_NUM_EVENTS_TO_SMALLER_THAN_FROM ); m_nNumEventsTo = m_nNumEventsFrom +1; m_edbNumEventsТо.SetFocus(); UpdateData( FALSE ); return; }// if }// if // Ако е по салдо/оборот, проверяваме дали е сума над е по-голяма от последната за салдо или оборот if( m_nRdbBalanceNumEvents == (short)eBalanceTurnover ) { if( StoreSelDetValueFromComboX( m_cmbDependsOn, lBalTurnover ) == CB_ERR || lBalTurnover <= 0 ) { CSMsg::Log( eScreen, MSG_INNCORECT_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_DEPENDS_ON ) ) ); m_cmbDependsOn.SetFocus(); return; }// if if( m_edbSumOver.GetSum() <= m_pBuf->m_arrPlan.GetMaxSumOver( (short)lBalTurnover ) ) { CSNomMsgIDCode oBalanceTurnover( g_arrPreferenceTaxBalanceTurnover, _countof( g_arrPreferenceTaxBalanceTurnover ) ); CString strType = ""; strType = oBalanceTurnover.GetMsgUserLang( (short)lBalTurnover ); CSMsg::Log( eScreen, MSG_SUM_OVER_FOR_TYPE_MUST_BE_BIGGER_THAN_LAST, &MSGKEY( "0", strType ), &MSGKEY( "1", strType ) ); m_edbSumOver.SetFocus(); return; }// if }// if // Ако е избрано 'Комбинация м/у зделка и услуга' проверяваме дали имаме валидна селекция // и при опит за добавяне дали избраният елемент вече не е добавен if( m_nRdbBalanceNumEvents == (short)eDealService ) { int nCurSel = m_cmbDealTypeService.GetCurSel(); if( nCurSel == CB_ERR ) { m_cmbDealTypeService.SetFocus(); return; } // if if( m_cmbDealTypeService.GetItemData( nCurSel ) <= 0 ) { m_cmbDealTypeService.SetFocus(); return; } // if int nPrefDealTypeCode = (int)m_cmbDealTypeService.GetItemData( m_cmbDealTypeService.GetCurSel() ); if( m_pBuf->m_arrPlan.GetCount() > 0 ) { for( int i = 0; i < m_pBuf->m_arrPlan.GetCount() > 0; i++ ) { PREFERENCIAL_PLANS *pRec = m_pBuf->m_arrPlan.GetAt( i ); if( pRec == NULL ) continue; if( pRec->m_nPrefDealTypeCode == nPrefDealTypeCode ) { CSMsg::Log( eScreen, MSG_PREF_PLAN_HAS_COMBINATION ); return; } // if } // for } // if } // if // Ако е сума, проверяваме дали е по-голяма от нула if( m_nRdbPercentSolidSum == (short)eSolidSum ) { if( m_edbSolidSum.GetSum() < 0.0 ) { CSMsg::Log( eScreen, MSG_INNCORECT_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_FIXED_SUM ) ) ); m_edbSolidSum.SetFocus(); return; }// if }// if // Ако е процент, проверяваме дали е по-голям от нула if( m_nRdbPercentSolidSum == (short)ePercent ) { if( m_edbPercent.GetSum() < 0.0 ) { CSMsg::Log( eScreen, MSG_INNCORECT_VALUE_IN_FIELD, &MSGKEY( "0", CSMsg::GetMsgUsrLang( MSG_PERCENT ) ) ); m_edbPercent.SetFocus(); return; }// if }// if // Създаваме нов елемент PREFERENCIAL_PLANS *pNewItem = new PREFERENCIAL_PLANS(); if( !pNewItem ) return; pNewItem->m_lCode = 0; pNewItem->m_lPreferenceCode = m_pBuf->m_recPrefTax.m_lCode; pNewItem->m_sDependType = m_nRdbBalanceNumEvents; if( m_nRdbBalanceNumEvents == (short)eEventsCount ) { pNewItem->m_nEventCountFrom = m_nNumEventsFrom; pNewItem->m_nEventCountTo = m_nNumEventsTo; m_nNumEventsFrom = m_nNumEventsTo +1; m_nNumEventsTo = m_nNumEventsFrom; }// if if( m_nRdbBalanceNumEvents == (short)eBalanceTurnover ) { pNewItem->m_sBalanceTurnoverType = (short)lBalTurnover; pNewItem->m_fSumOver = m_edbSumOver.GetSum(); }// if if( m_nRdbBalanceNumEvents == (short)eDealService ) { pNewItem->m_nPrefDealTypeCode = (int)m_cmbDealTypeService.GetItemData( m_cmbDealTypeService.GetCurSel() ); } pNewItem->m_sPreferenceType = m_nRdbPercentSolidSum; if( m_nRdbPercentSolidSum == (short)eSolidSum ) pNewItem->m_fSumSolid = m_edbSolidSum.GetSum(); if( m_nRdbPercentSolidSum == (short)ePercent ) pNewItem->m_fPercent = m_edbPercent.GetSum(); m_pBuf->m_arrPlan.Add( pNewItem ); if( m_pBuf->m_arrPlan.GetCount() > 0 ) { m_chbGratisSumValidity.EnableWindow( FALSE ); m_edbGratisMonths.SetWindowText( "0" ); m_edbGratisSum.SetSum( 0.0 ); }// if LoadPlan(); UpdateData( FALSE ); } void CPreferencialTaxMainPage::OnBnClickedDel() { if( !m_pBuf ) return; int nSelection = GetSelected( m_lstPlan ); if( nSelection == LB_ERR || AfxMessageBox( CSMsg::GetMsgUsrLang( MSG_BFROFC_3681 ), MB_ICONQUESTION|MB_YESNO ) != IDYES ) return; PREFERENCIAL_PLANS *pItem = m_pBuf->m_arrPlan.GetAt( nSelection ); delete pItem; m_pBuf->m_arrPlan.RemoveAt( nSelection ); if( m_pBuf->m_arrPlan.GetCount() <= 0 && m_eDlgMode != eView && m_eDlgMode != eViewNoDeactivate && m_eDlgMode != eEditDatesOnly && m_pBuf->m_recPrefTax.m_nDealType == KCK_DEALS ) { m_chbGratisSumValidity.EnableWindow( TRUE ); }// if LoadPlan(); } void CPreferencialTaxMainPage::CalculateEndDate() { UpdateData( TRUE ); LDATE lBeginDate = 0, lEndDate = 0; if( m_chbDependsOnDealOpenDate.GetCheck() > 0 ) lBeginDate = m_edbDateDealTo.GetDate(); else lBeginDate = m_edbDateActiveFrom.GetDate(); if( lBeginDate <= MIN_DATE ) return; if( m_nRdbDaysMonths != (int)eDaysPeriod && m_nRdbDaysMonths != (int)eMonthsPeriod ) return; if( m_nRdbDaysMonths == (int)eDaysPeriod ) { LoadPeriodicities((short)eDayly ); lEndDate = korldat( lBeginDate, m_nNumDays, LIHWA_365_365 ); }// if else if( m_nRdbDaysMonths == (int)eMonthsPeriod ) { m_cmbPeriodicity.EnableWindow( m_eDlgMode == eEditFull || m_eDlgMode == eEditNoDealType || m_eDlgMode == eAdd || m_eDlgMode == eAddNoStdDog || m_eDlgMode == eAddKlientska || m_eDlgMode == eEditKlientska ); lEndDate = korlmnt( lBeginDate, m_nNumMonths, LIHWA_365_365 ); }// else m_edbDateActiveTo.SetDate( lEndDate ); } void CPreferencialTaxMainPage::OnEnKillfocusEdbTermFrom() { CalculateEndDate(); } void CPreferencialTaxMainPage::OnEnKillfocusEdbMonths() { CalculateEndDate(); } void CPreferencialTaxMainPage::OnEnKillfocusEdbDays() { CalculateEndDate(); } void CPreferencialTaxMainPage::OnBnClickedRdbMonths() { if( m_eDlgMode == eView || m_eDlgMode == eViewNoDeactivate || m_eDlgMode == eEditConditionsOnly ) return; if( m_rdbMohtns.GetCheck() > 0 ) { m_nRdbDaysMonths = eMonthsPeriod; } else if ( m_rdbDays.GetCheck() > 0 ) { m_nRdbDaysMonths = eDaysPeriod; } m_edbNumMonths.EnableWindow( m_rdbMohtns.GetCheck() > 0 ); m_edbNumDays.EnableWindow( m_rdbDays.GetCheck() > 0 ); CalculateEndDate(); } void CPreferencialTaxMainPage::OnBnClickedChkDependsOnDateOpen() { if( m_eDlgMode == eView || m_eDlgMode == eViewNoDeactivate ) return; if( m_eDlgMode != eEditDatesOnly ) { m_edbDateDealFrom.EnableWindow( m_chbDependsOnDealOpenDate.GetCheck() > 0 ); m_edbDateDealTo.EnableWindow( m_chbDependsOnDealOpenDate.GetCheck() > 0 ); } CalculateEndDate(); } void CPreferencialTaxMainPage::OnEnKillfocusEdbDateOpenTo() { CalculateEndDate(); } void CPreferencialTaxMainPage::OnBnClickedRdbDependsOn() { if( m_eDlgMode == eView || m_eDlgMode == eViewNoDeactivate || m_eDlgMode == eEditDatesOnly ) return; if( m_pBuf->m_arrPlan.GetCount() <= 0 ) m_cmbDependsOn.EnableWindow( m_rdbBalance.GetCheck() > 0 ); m_edbSumOver.EnableWindow( m_rdbBalance.GetCheck() > 0 ); m_edbNumEventsFrom.EnableWindow( m_rdbNumEvents.GetCheck() > 0 ); m_edbNumEventsТо.EnableWindow( m_rdbNumEvents.GetCheck() > 0 ); m_rdbDealTypeService.SetCheck( BST_UNCHECKED ); m_cmbDealTypeService.EnableWindow( m_rdbDealTypeService.GetCheck() > 0 ); if( m_rdbNoDependancy.GetCheck() > 0 && m_pBuf->m_arrPlan.GetCount() <= 0 ) { m_pBuf->m_arrPlan.Release(); m_lstPlan.DeleteAllItems(); }// if if ( m_rdbBalance.GetCheck() > 0 ) { m_nRdbBalanceNumEvents = eBalanceTurnover; } else if ( m_rdbNumEvents.GetCheck() > 0 ) { m_nRdbBalanceNumEvents = eEventsCount; } else if( m_rdbNoDependancy.GetCheck() > 0 ) { m_nRdbBalanceNumEvents = eNoDependancy; } } void CPreferencialTaxMainPage::OnBnClickedRdbDependsOnDealTypeService() { if( m_eDlgMode == eView || m_eDlgMode == eViewNoDeactivate || m_eDlgMode == eEditDatesOnly ) return; m_rdbBalance.SetCheck( BST_UNCHECKED ); m_rdbNumEvents.SetCheck( BST_UNCHECKED ); m_rdbNoDependancy.SetCheck( BST_UNCHECKED ); if( m_pBuf->m_arrPlan.GetCount() <= 0 ) m_cmbDependsOn.EnableWindow( m_rdbBalance.GetCheck() > 0 ); m_edbSumOver.EnableWindow( m_rdbBalance.GetCheck() > 0 ); m_edbNumEventsFrom.EnableWindow( m_rdbNumEvents.GetCheck() > 0 ); m_edbNumEventsТо.EnableWindow( m_rdbNumEvents.GetCheck() > 0 ); if( m_rdbNoDependancy.GetCheck() > 0 && m_pBuf->m_arrPlan.GetCount() <= 0 ) { m_pBuf->m_arrPlan.Release(); m_lstPlan.DeleteAllItems(); }// if m_cmbDealTypeService.EnableWindow( m_rdbDealTypeService.GetCheck() > 0 ); if( m_rdbDealTypeService.GetCheck() > 0 ) { m_nRdbBalanceNumEvents = eDealService; } LoadDealTypeBankServiceCombinationsInCombo( m_pBuf->m_recPrefTax.m_nDealType ); } void CPreferencialTaxMainPage::OnBnClickedRdbPercent() { if( m_eDlgMode == eView || m_eDlgMode == eViewNoDeactivate || m_eDlgMode == eEditDatesOnly ) return; if( m_rdbPercent.GetCheck() > 0 ) { m_nRdbPercentSolidSum = ePercent; } else if ( m_rdbSolidSum.GetCheck() > 0 ) { m_nRdbPercentSolidSum = eSolidSum; } m_edbPercent.EnableWindow( m_rdbPercent.GetCheck() > 0 && m_chbGratisSumValidity.GetCheck() <= 0 ); m_edbSolidSum.EnableWindow( m_rdbSolidSum.GetCheck() > 0 && m_chbGratisSumValidity.GetCheck() <= 0 ); } #pragma endregion MainPage ////////////////////////////////////////////////////////////////////////////////////////////////// // CPreferencialTaxEventsTaxesPage BEGIN_LANG_WND( CPreferencialTaxEventsTaxesPage ) WND( WND_TITLE, MSG_EVENTS_AND_TAXES ), WND( IDC_STT_EVENTS_AND_TAXES_BY_PREF, MSG_PREFERENCE_TAXES_AND_EVENTS ), END_LANG_WND() IMPLEMENT_DYNAMIC( CPreferencialTaxEventsTaxesPage, CBasePropertyPage ) CPreferencialTaxEventsTaxesPage::CPreferencialTaxEventsTaxesPage( CPreferencialTaxFullRec & recPrefTax, const short sDlgMode, long lSelStdDogCode /*= NO_DETCODE*/, CWnd* pParent ) : CBasePropertyPage( CPreferencialTaxEventsTaxesPage::IDD, GetHISTANCEBfrofCDLL() ) , m_eDlgMode( (ePrefTaxDlgMode)sDlgMode ) { m_pBuf = &recPrefTax; m_arrEvents.SetCompFunction( CODE_NAME::compByCode ); m_lSelStdDogCode = lSelStdDogCode; } CPreferencialTaxEventsTaxesPage::~CPreferencialTaxEventsTaxesPage() { } void CPreferencialTaxEventsTaxesPage::DoDataExchange( CDataExchange* pDX ) { CBasePropertyPage::DoDataExchange( pDX ); DDX_Control( pDX, IDC_TREE_EVENTS_TAXES, m_treeEventsTaxes ); } BEGIN_MESSAGE_MAP( CPreferencialTaxEventsTaxesPage, CBasePropertyPage ) ON_NOTIFY( NM_RCLICK, IDC_TREE_EVENTS_TAXES, OnNMRclickTree ) ON_COMMAND( ID_ADD_EVENT, &CPreferencialTaxEventsTaxesPage::OnTreeAddEvent ) ON_COMMAND( ID_DELETE_EVENT,&CPreferencialTaxEventsTaxesPage::OnTreeRemoveEvent ) ON_COMMAND( ID_ADD_TAX, &CPreferencialTaxEventsTaxesPage::OnTreeAddTax ) ON_COMMAND( ID_DELETE_TAX, &CPreferencialTaxEventsTaxesPage::OnTreeRemoveTax ) ON_MESSAGE( ID_WM_DEAL_TYPE_CHANGED, OnDealTypeChanged ) END_MESSAGE_MAP() LRESULT CPreferencialTaxEventsTaxesPage::OnDealTypeChanged( WPARAM wParam, LPARAM lParam ) { if( !m_pBuf ) return FALSE; m_pBuf->m_arrEventsTaxes.Release(); m_treeEventsTaxes.DeleteAllItems(); return TRUE; } BOOL CPreferencialTaxEventsTaxesPage::OnInitDialog() { CBasePropertyPage::OnInitDialog(); if( !LoadTree() ) { CSMsg::Log( eScreen, MSG_ERR_VISUALIZE_EVENTS_TAXES ); m_treeEventsTaxes.EnableWindow( FALSE ); }// if return TRUE; } bool CPreferencialTaxEventsTaxesPage::LoadTree() { if( !m_pBuf ) return false; HTREEITEM hTreeItem = NULL; PREFERENCIAL_EVENTS_TAXES *pItem = NULL; CString strEventName, strBuf; m_treeEventsTaxes.DeleteAllItems(); for( int i = 0; i < m_pBuf->m_arrEventsTaxes.GetCount(); i ++ ) { pItem = m_pBuf->m_arrEventsTaxes.GetAt( i ); if( !pItem ) continue; if( pItem->m_lTaxCode > 0 ) continue; if( !GetSheet()->GetEventName( pItem->m_lEventCode, strEventName ) ) continue; strBuf.Format( " %06d %s ", pItem->m_lEventCode, strEventName ); hTreeItem = m_treeEventsTaxes.InsertItem( strBuf ); m_treeEventsTaxes.SetItemData( hTreeItem, (DWORD_PTR)pItem ); if( !LoadTaxes( hTreeItem, pItem->m_lEventCode ) ) return false; }// for return true; } bool CPreferencialTaxEventsTaxesPage::LoadTaxes( HTREEITEM hParentItem, const long lEventCode ) { PREFERENCIAL_EVENTS_TAXES *pItem = NULL; CString strTaxName = "", strBuf = ""; HTREEITEM hTreeItem = NULL; for( int i = 0; i < m_pBuf->m_arrEventsTaxes.GetCount(); i ++ ) { pItem = m_pBuf->m_arrEventsTaxes.GetAt( i ); if( !pItem ) continue; if( pItem->m_lTaxCode <= 0 ) continue; if( pItem->m_lEventCode != lEventCode ) continue; if( !GetTaxName( pItem->m_lTaxCode, strTaxName ) ) return false; strBuf.Format( " %06d %s ", pItem->m_lTaxCode, strTaxName ); hTreeItem = m_treeEventsTaxes.InsertItem( strBuf, hParentItem ); m_treeEventsTaxes.SetItemData( hTreeItem, (DWORD_PTR)pItem ); }// for return true; } bool CPreferencialTaxEventsTaxesPage::GetTaxName( long lTaxCode, CString & strName ) { if( !fnCallRpc( CParameterT< long >( lTaxCode ) , RPC_BFROF_GET_TAX_NAME_BY_CODE , CParameterT< CString >( strName ) ) ) return false; return true; } bool CPreferencialTaxEventsTaxesPage::GetTaxName( const long lTaxCode, const CSCmnRecsArray< CODE_NAME > & arrTaxesCodeNames, CString & strName ) { strName = ""; for( int i = 0; i < arrTaxesCodeNames.GetCount(); i++ ) if( arrTaxesCodeNames.GetAt( i )->lCode == lTaxCode ) { strName = arrTaxesCodeNames.GetAt( i )->szName; break; }// if return strName != ""; } void CPreferencialTaxEventsTaxesPage::OnNMRclickTree( NMHDR* pNMHDR, LRESULT* pResult ) { if ( m_eDlgMode != eEditFull && m_eDlgMode != eEditNoDealType && m_eDlgMode != eAdd && m_eDlgMode != eAddKlientska && m_eDlgMode != eEditKlientska ) return; CPoint pos; GetCursorPos( &pos ); m_treeEventsTaxes.ScreenToClient( &pos ); HTREEITEM hSelectedItem = m_treeEventsTaxes.HitTest( pos ); if ( !hSelectedItem ) { GetCursorPos( &pos ); CMenu menu; menu.CreatePopupMenu(); menu.AppendMenu( MF_STRING, ID_ADD_EVENT, CSMsg::GetMsgUsrLang( MSG_ADD_EVENT_TYPE ) ); menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON, pos.x, pos.y, this ); return; }// if m_treeEventsTaxes.SelectItem( hSelectedItem ); m_treeEventsTaxes.ClientToScreen( &pos ); CMenu menu; menu.CreatePopupMenu(); // Избрано е тип събитие if( m_treeEventsTaxes.GetParentItem( hSelectedItem ) == NULL ) { menu.AppendMenu( MF_STRING, ID_ADD_EVENT, CSMsg::GetMsgUsrLang( MSG_ADD_EVENT_TYPE ) ); menu.AppendMenu( MF_STRING, ID_DELETE_EVENT, CSMsg::GetMsgUsrLang( MSG_BFROFC_3055 ) ); menu.AppendMenu( MF_SEPARATOR ); menu.AppendMenu( MF_STRING, ID_ADD_TAX, CSMsg::GetMsgUsrLang( MSG_ADD_TAX ) ); }//if else // Избрана е такса { menu.AppendMenu( MF_STRING, ID_DELETE_TAX, CSMsg::GetMsgUsrLang( MSG_BFROFC_3055 ) ); }// else menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON, pos.x, pos.y, this ); } void CPreferencialTaxEventsTaxesPage::OnTreeAddEvent() { if( !m_pBuf ) return; CSCmnRecsArray< CODE_NAME > arrEvents; BOOL bIsInList = FALSE; for( int i = 0; i < GetSheet()->m_arrEvents.GetCount(); i++ ) { bIsInList = FALSE; for( int j =0; j < m_pBuf->m_arrEventsTaxes.GetCount(); j++ ) { if( m_pBuf->m_arrEventsTaxes.GetAt( j )->m_lTaxCode > 0 ) continue; if( m_pBuf->m_arrEventsTaxes.GetAt( j )->m_lEventCode == GetSheet()->m_arrEvents.GetAt( i )->lCode ) { bIsInList = TRUE; break; }// if }// for if( bIsInList ) continue; CODE_NAME * pCodeName = new CODE_NAME(); pCodeName->lCode = GetSheet()->m_arrEvents.GetAt( i )->lCode; ourstrncpy( pCodeName->szName, GetSheet()->m_arrEvents.GetAt( i )->szName, sizeof( pCodeName->szName ) - 1 ); arrEvents.Add( pCodeName ); }// for if( arrEvents.GetCount() <= 0 ) { CSMsg::GetMsgUsrLang( MSG_ERR_LOAD_EVENTS_OR_ALL_ADDED ); return; }// if CCodeNameChooseDlg oDlg( arrEvents, CSMsg::GetMsgUsrLang( MSG_CHOOSE_EVENTS ), TRUE ); if( oDlg.DoModal() != IDOK ) return; CInt64Array arrSelectedEventCodes; oDlg.GetSelectedCodes( arrSelectedEventCodes ); if( arrSelectedEventCodes.GetSize() <= 0 ) return; HTREEITEM hTreeItem = NULL; CString strName = "", strBuf = ""; for( int i = 0; i < arrSelectedEventCodes.GetSize(); i++ ) { if( !GetSheet()->GetEventName( (long)arrSelectedEventCodes.GetAt( i ), strName ) ) break; PREFERENCIAL_EVENTS_TAXES * pNewItem = new PREFERENCIAL_EVENTS_TAXES(); pNewItem->m_lPreferenceCode = m_pBuf->m_recPrefTax.m_lCode; pNewItem->m_lEventCode = (long)arrSelectedEventCodes.GetAt( i ); m_pBuf->m_arrEventsTaxes.Add( pNewItem ); strBuf.Format( " %06d %s ",pNewItem->m_lEventCode , strName ); hTreeItem = m_treeEventsTaxes.InsertItem( strBuf ); m_treeEventsTaxes.SetItemData( hTreeItem, (DWORD_PTR)pNewItem ); }// for } bool CPreferencialTaxEventsTaxesPage::LoadTaxesForKlietskaPref( long lEventCode, long lDealType, long lDealNum, bool bStandartTaxesOnly, CSCmnRecsArray< CODE_NAME > & arrTaxesCodeNames ) { long lRet = 0; CRpcBufArray arrIn, arrOut; CSNomMsgIDCode oProcSystem( g_arrProcessingSystem, _countof( g_arrProcessingSystem ) ); CSCmnRecsArray<long> arrProcSystems; for( INT_PTR i = 0, nCnt = oProcSystem.GetSize(); i < nCnt; i++ ) { if( ( i == nCnt - 1 ) && oProcSystem.LastIsEmpty() ) break; int nCode = oProcSystem.GetCodeByIndex( i ); if( nCode == (int)eUndefinedProcessingSystem ) continue; if( m_pBuf->m_recPrefTax.CheckProcessingSystemBit( nCode ) ) { arrProcSystems.Add( new long( (long)nCode ) ); }// if }// for arrIn << lEventCode << lDealType << lDealNum << bStandartTaxesOnly ; arrProcSystems.Serialize( arrIn ); try { lRet = RPCBfrofCDispatchHandler( MyHandle(), RPCSYS( RPC_BFROF_GET_TAXES_NAME_CODES_BY_DEALTYPE_AND_CODE ), &arrIn, &arrOut ); } // try catch(...) { glShowErrMsg( APP_CLIENTTYPE, NULL, "CPreferencialTaxEventsTaxesPage::LoadTaxesForKlietskaPref", NULL ); lRet = 0; } // catch if( lRet <= 0 ) return false; for( int i = 0, nCount = arrOut.GetCnt(); i < nCount ; i++ ) { long lSize = 0; CODE_NAME *pBuf = (CODE_NAME*)arrOut.GetAt( i, lSize ); ASSERT( lSize == sizeof( CODE_NAME ) ); CODE_NAME * pNewItem = new CODE_NAME(); *pNewItem = *pBuf; arrTaxesCodeNames.Add( pNewItem ); } // for return true; } bool CPreferencialTaxEventsTaxesPage::LoadTaxes( const long lEventType, const bool bStandartTaxesOnly/*=true*/, CSCmnRecsArray< CODE_NAME > & arrTaxesCodeNames ) { long lRet = 0; CRpcBufArray arrIn, arrOut; CSNomMsgIDCode oProcSystem( g_arrProcessingSystem, _countof( g_arrProcessingSystem ) ); CSCmnRecsArray<long> arrProcSystems; for( INT_PTR i = 0, nCnt = oProcSystem.GetSize(); i < nCnt; i++ ) { if( ( i == nCnt - 1 ) && oProcSystem.LastIsEmpty() ) break; int nCode = oProcSystem.GetCodeByIndex( i ); if( nCode == (int)eUndefinedProcessingSystem ) continue; if( m_pBuf->m_recPrefTax.CheckProcessingSystemBit( nCode ) ) { arrProcSystems.Add( new long( (long)nCode ) ); }// if }// for arrIn << lEventType << (long)m_pBuf->m_recPrefTax.m_nDealType << m_pBuf->m_recPrefTax.m_lCode << m_lSelStdDogCode << bStandartTaxesOnly ; m_pBuf->m_arrTaxesToStdDeals.Serialize( arrIn ); arrProcSystems.Serialize( arrIn ); try { lRet = RPCBfrofCDispatchHandler( MyHandle(), RPCSYS( RPC_BFROF_GET_TAXES_NAME_CODES_BYEVENT_TYPE ), &arrIn, &arrOut ); } // try catch(...) { glShowErrMsg( APP_CLIENTTYPE, NULL, "CPreferencialTaxEventsTaxesPage::LoadEventsByDealType", NULL ); lRet = 0; } // catch if( lRet <= 0 ) return false; for( int i = 0, nCount = arrOut.GetCnt(); i < nCount ; i++ ) { long lSize = 0; CODE_NAME *pBuf = (CODE_NAME*)arrOut.GetAt( i, lSize ); ASSERT( lSize == sizeof( CODE_NAME ) ); CODE_NAME * pNewItem = new CODE_NAME(); *pNewItem = *pBuf; arrTaxesCodeNames.Add( pNewItem ); } // for return true; } void CPreferencialTaxEventsTaxesPage::OnTreeRemoveEvent() { HTREEITEM hSelectedItem = m_treeEventsTaxes.GetSelectedItem(); if ( hSelectedItem == NULL ) return; if( m_treeEventsTaxes.GetParentItem( hSelectedItem ) != NULL ) return; RemoveItem( hSelectedItem ); } void CPreferencialTaxEventsTaxesPage::OnTreeAddTax() { HTREEITEM hSelectedItem = m_treeEventsTaxes.GetSelectedItem(); if ( hSelectedItem == NULL ) return; if( m_treeEventsTaxes.GetParentItem( hSelectedItem ) != NULL ) return; PREFERENCIAL_EVENTS_TAXES *pEvent = (PREFERENCIAL_EVENTS_TAXES*)m_treeEventsTaxes.GetItemData( hSelectedItem ); if( !pEvent || pEvent->m_lTaxCode > 0 || pEvent->m_lEventCode <= 0 ) return; CSCmnRecsArray<CODE_NAME> arrTaxes; CSCmnRecsArray<CODE_NAME> arrTaxesFiltered; if( m_pBuf->m_recPrefTax.IsKlientskaPref() ) { if( !LoadTaxesForKlietskaPref( pEvent->m_lEventCode, m_pBuf->m_recPrefTax.m_nDealType, m_pBuf->m_recPrefToDeal.m_lDealNum, false, arrTaxes ) ) return; } else { if( !LoadTaxes( pEvent->m_lEventCode, m_pBuf->m_recPrefTax.m_nDealType != KCK_DEALS, arrTaxes ) ) return; }//else BOOL bIsInList = FALSE; for( int i = 0; i < arrTaxes.GetCount(); i++ ) { bIsInList = FALSE; for( int j =0; j < m_pBuf->m_arrEventsTaxes.GetCount(); j++ ) if( m_pBuf->m_arrEventsTaxes.GetAt( j )->m_lTaxCode == arrTaxes.GetAt( i )->lCode ) { bIsInList = TRUE; break; }// if if( bIsInList ) continue; CODE_NAME * pCodeName = new CODE_NAME(); pCodeName->lCode = arrTaxes.GetAt( i )->lCode; ourstrncpy( pCodeName->szName, arrTaxes.GetAt( i )->szName, sizeof( pCodeName->szName ) - 1 ); arrTaxesFiltered.Add( pCodeName ); }// for arrTaxesFiltered.SetCompFunction( CODE_NAME::compByCode ); arrTaxesFiltered.QSort(); CCodeNameChooseDlg oDlg( arrTaxesFiltered, CSMsg::GetMsgUsrLang( MSG_CHOOSE_TAXES ), TRUE ); if( oDlg.DoModal() != IDOK ) return; CInt64Array arrSelectedTax; oDlg.GetSelectedCodes( arrSelectedTax ); if( arrSelectedTax.GetSize() <= 0 ) return; HTREEITEM hInsertedItem = NULL; CString strName = "", strBuf = ""; for( int i = 0; i < arrSelectedTax.GetSize(); i++ ) { PREFERENCIAL_EVENTS_TAXES * pNewItem = new PREFERENCIAL_EVENTS_TAXES(); pNewItem->m_lPreferenceCode = m_pBuf->m_recPrefTax.m_lCode; pNewItem->m_lEventCode = pEvent->m_lEventCode; pNewItem->m_lTaxCode = (long)arrSelectedTax.GetAt( i ); m_pBuf->m_arrEventsTaxes.Add( pNewItem ); GetTaxName( pNewItem->m_lTaxCode, arrTaxesFiltered, strName ); strBuf.Format( " %06d %s ",pNewItem->m_lTaxCode , strName ); hInsertedItem = m_treeEventsTaxes.InsertItem( strBuf, hSelectedItem ); m_treeEventsTaxes.SetItemData( hInsertedItem, (DWORD_PTR)pNewItem ); }// for } void CPreferencialTaxEventsTaxesPage::OnTreeRemoveTax() { HTREEITEM hSelectedItem = m_treeEventsTaxes.GetSelectedItem(); if ( hSelectedItem == NULL ) return; if( m_treeEventsTaxes.GetParentItem( hSelectedItem ) == NULL ) return; RemoveItem( hSelectedItem ); } void CPreferencialTaxEventsTaxesPage::RemoveItem( const HTREEITEM hSelectedItem ) { PREFERENCIAL_EVENTS_TAXES *pItem = (PREFERENCIAL_EVENTS_TAXES*)m_treeEventsTaxes.GetItemData( hSelectedItem ); if( !pItem ) return; if( !m_pBuf ) return; long lEventCode = 0; for ( int i = 0; i < m_pBuf->m_arrEventsTaxes.GetCount(); i++) { PREFERENCIAL_EVENTS_TAXES* pEvtTax = m_pBuf->m_arrEventsTaxes[i]; if ( pEvtTax == pItem ) { // Ако е събитие, махаме таксите от масива if( pEvtTax->m_lTaxCode <= 0 ) lEventCode = pEvtTax->m_lEventCode; m_pBuf->m_arrEventsTaxes.RemoveAt(i); delete pEvtTax; m_treeEventsTaxes.DeleteItem( hSelectedItem ); break; }// if }// for // Ако е събитие, махаме таксите от масива if( lEventCode > 0 ) for ( int i = m_pBuf->m_arrEventsTaxes.GetCount() - 1; i >=0 ; i-- ) { if( m_pBuf->m_arrEventsTaxes.GetAt( i ) == NULL ) break; if( m_pBuf->m_arrEventsTaxes.GetAt( i )->m_lEventCode == lEventCode ) { delete m_pBuf->m_arrEventsTaxes.GetAt( i ); m_pBuf->m_arrEventsTaxes.RemoveAt( i ); }// if }// for } ////////////////////////////////////////////////////////////////////////////////////////////////// // CPreferencialTaxEventsTaxesPage BEGIN_LANG_WND( CPreferencialTaxStgDogsPage ) WND( WND_TITLE, MSG_ASSIGN_TO_STG_DOGS ), WND( IDC_BTN_ADD_STD_DOGS, MSG_BFROFC_3054 ), WND( IDC_BTN_DEL_STD_DOG, MSG_BFROFC_3055 ), END_LANG_WND() IMPLEMENT_DYNAMIC( CPreferencialTaxStgDogsPage, CBasePropertyPage ) CPreferencialTaxStgDogsPage::CPreferencialTaxStgDogsPage( CPreferencialTaxFullRec & recPrefTax , const short sPrefTaxDlgMode/*ePrefTaxDlgMode*/ , CWnd* pParent/* = NULL */ , const BOOL bEditStdDogs/* = TRUE*/) : CBasePropertyPage( CPreferencialTaxStgDogsPage::IDD, GetHISTANCEBfrofCDLL() ) , m_eDlgMode( (ePrefTaxDlgMode)sPrefTaxDlgMode ) , m_bEditStdDogs( bEditStdDogs ) { m_pBuf = &recPrefTax; m_arrStdDogs.SetCompFunction( CODE_NAME::compByCode ); m_pBuf->m_arrTaxesToStdDeals.SetCompFunction( PREFERENCIAL_TAXES_TO_STD_DEALS::compByDealCode ); } CPreferencialTaxStgDogsPage::~CPreferencialTaxStgDogsPage() { } void CPreferencialTaxStgDogsPage::DoDataExchange( CDataExchange* pDX ) { CBasePropertyPage::DoDataExchange( pDX ); DDX_Control( pDX, IDC_LST_STD_DOGS, m_listStdDogs ); DDX_Control( pDX, IDC_BTN_ADD_STD_DOGS, m_btnAdd ); DDX_Control( pDX, IDC_BTN_DEL_STD_DOG, m_btnDel ); } BEGIN_MESSAGE_MAP( CPreferencialTaxStgDogsPage, CBasePropertyPage ) ON_BN_CLICKED( IDC_BTN_ADD_STD_DOGS, &CPreferencialTaxStgDogsPage::OnBnClickedAddStdDogs ) ON_BN_CLICKED( IDC_BTN_DEL_STD_DOG, &CPreferencialTaxStgDogsPage::OnBnClickedDelStdDog ) ON_MESSAGE( ID_WM_DEAL_TYPE_CHANGED, OnDealTypeChanged ) END_MESSAGE_MAP() void CPreferencialTaxStgDogsPage::OnBnClickedAddStdDogs() { if( !EnsureStdDogs() ) return; CSCmnRecsArray< CODE_NAME > arrStdDogs; BOOL bIsInList = FALSE; for( int i = 0; i < m_arrStdDogs.GetCount(); i++ ) { bIsInList = FALSE; for( int j = 0; j < m_pBuf->m_arrTaxesToStdDeals.GetCount(); j++ ) { if( m_pBuf->m_arrTaxesToStdDeals.GetAt( j )->m_lStdDogCode == m_arrStdDogs.GetAt( i )->lCode ) { bIsInList = TRUE; break; }// if }// for if( bIsInList ) continue; CODE_NAME * pCodeName = new CODE_NAME(); pCodeName->lCode = m_arrStdDogs.GetAt( i )->lCode; ourstrncpy( pCodeName->szName, m_arrStdDogs.GetAt( i )->szName, sizeof( pCodeName->szName ) - 1 ); arrStdDogs.Add( pCodeName ); }// for CCodeNameChooseDlg oDlg( arrStdDogs, CSMsg::GetMsgUsrLang( MSG_CHOOSE_STD_DOGS ), TRUE ); if( oDlg.DoModal() != IDOK ) return; CInt64Array arrSelectedStdDogCodes; oDlg.GetSelectedCodes( arrSelectedStdDogCodes ); if( arrSelectedStdDogCodes.GetSize() <= 0 ) return; int nSubItem = 1; CString strName = "", strBuf = ""; for( int i = 0; i < arrSelectedStdDogCodes.GetSize(); i++ ) { if( !GetStdDogName( (long)arrSelectedStdDogCodes.GetAt( i ), strName ) ) break; PREFERENCIAL_TAXES_TO_STD_DEALS * pNewItem = new PREFERENCIAL_TAXES_TO_STD_DEALS(); pNewItem->m_lPreferencialTaxCode = m_pBuf->m_recPrefTax.m_lCode; pNewItem->m_lStdDogCode = (long)arrSelectedStdDogCodes.GetAt( i ); pNewItem->m_lDealType = (long)m_pBuf->m_recPrefTax.m_nDealType; m_pBuf->m_arrTaxesToStdDeals.Add( pNewItem ); strBuf.Format( "%6.6d",pNewItem->m_lStdDogCode ); int nLCIndex = m_listStdDogs.InsertItem( m_listStdDogs.GetItemCount(), strBuf ); nSubItem = 1; // Име m_listStdDogs.SetItemText( nLCIndex, nSubItem++, strName ); m_listStdDogs.SetItemData( nLCIndex, (DWORD_PTR)pNewItem ); }// for } void CPreferencialTaxStgDogsPage::OnBnClickedDelStdDog() { POSITION pos = m_listStdDogs.GetFirstSelectedItemPosition(); if( pos == NULL) return; CInt64Array arrIndexes; for( UINT i = 0; i < m_listStdDogs.GetSelectedCount(); i++ ) arrIndexes.Add( m_listStdDogs.GetNextSelectedItem( pos ) ); for( int i = 0; i < arrIndexes.GetSize(); i++ ) { if( arrIndexes.GetAt( i ) == LB_ERR ) return; PREFERENCIAL_TAXES_TO_STD_DEALS *pItem = (PREFERENCIAL_TAXES_TO_STD_DEALS*)m_listStdDogs.GetItemData( (int)arrIndexes.GetAt( i ) ); for( int j=0; j < m_pBuf->m_arrTaxesToStdDeals.GetCount(); j++ ) if( pItem == m_pBuf->m_arrTaxesToStdDeals.GetAt( j ) ) { delete pItem; m_pBuf->m_arrTaxesToStdDeals.RemoveAt( j ); } }// for LoadList(); } LRESULT CPreferencialTaxStgDogsPage::OnDealTypeChanged( WPARAM wParam, LPARAM lParam ) { if( !m_pBuf ) return FALSE; m_pBuf->m_arrTaxesToStdDeals.Release(); m_listStdDogs.DeleteAllItems(); long lDealType = (long)wParam; m_arrStdDogs.Release(); LoadStdDogsByDealType( lDealType, m_arrStdDogs ); m_arrStdDogs.QSort(); return TRUE; } BOOL CPreferencialTaxStgDogsPage::OnInitDialog() { CBasePropertyPage::OnInitDialog(); WORD wCol = 0; m_listStdDogs.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_FOREIGN_EXC_TRANS_SHOW_HIST_CODE ), LVCFMT_RIGHT, m_listStdDogs.GetStringWidth("#########"), wCol ); m_listStdDogs.InsertColumn( wCol++, CSMsg::GetMsgUsrLang( MSG_STD_DO_NAME ), LVCFMT_LEFT, m_listStdDogs.GetStringWidth("########################################"), wCol ); DWORD dwStyleEx = m_listStdDogs.GetExtendedStyle(); dwStyleEx |= LVS_EX_FULLROWSELECT; m_listStdDogs.SetExtendedStyle( dwStyleEx ); if( ( m_eDlgMode != eAdd && m_eDlgMode != eEditFull && m_eDlgMode != eEditNoDealType ) || !m_bEditStdDogs ) { m_btnAdd.EnableWindow( FALSE ); m_btnDel.EnableWindow( FALSE ); }// if if( !LoadList() ) { CSMsg::Log( eScreen, MSG_ERR_VISUALIZE_EVENTS_TAXES ); m_btnAdd.EnableWindow( FALSE ); m_btnDel.EnableWindow( FALSE ); }// if return TRUE; } bool CPreferencialTaxStgDogsPage::EnsureStdDogs() { if( m_arrStdDogs.GetCount() > 0 ) return true; if( !LoadStdDogsByDealType( m_pBuf->m_recPrefTax.m_nDealType, m_arrStdDogs ) ) return false; return true; } bool CPreferencialTaxStgDogsPage::LoadStdDogsByDealType( const long lDealType, CSCmnRecsArray < CODE_NAME > & arrStdDogs ) { WORD wNom = 0; switch ( lDealType ) { case RAZPL_DEALS: wNom = NOM_STD_DOG_RAZPL; break; case DEPOS_DEALS: wNom = NOM_STD_DOG_DEPOS; break; case WLOG_DEALS: wNom = NOM_STD_DOG_WLOGS; break; case KCK_DEALS: wNom = NOM_INV_BROKERAGE_CONTRACT_TYPE; break; }// switch if( wNom <= 0 ) return false; DetInArray oArr( wNom, NOM ); oArr.MkArray(); for( int i = 0, nCount = oArr.GetCount(); i < nCount ; i++ ) { CODE_NAME *pBuf = new CODE_NAME(); pBuf->lCode = oArr.GetCode( i ); ourstrncpy( pBuf->szName, (LPCTSTR)oArr.GetName( i ), sizeof( pBuf->szName ) ); arrStdDogs.Add( pBuf ); } // for return true; } bool CPreferencialTaxStgDogsPage::GetStdDogName( const long lStdDogCode, CString &strName ) { strName = ""; if( !EnsureStdDogs() ) return false; for( int i =0; i < m_arrStdDogs.GetCount(); i++ ) if( m_arrStdDogs.GetAt( i )->lCode == lStdDogCode ) { strName = m_arrStdDogs.GetAt( i )->szName; break; }//if return strName != ""; } bool CPreferencialTaxStgDogsPage::LoadList() { if( !m_pBuf ) return false; m_pBuf->m_arrTaxesToStdDeals.QSort(); m_listStdDogs.DeleteAllItems(); PREFERENCIAL_TAXES_TO_STD_DEALS *pItem = NULL; CString strBuf = ""; int nSubItem =1; for( int i = 0; i < m_pBuf->m_arrTaxesToStdDeals.GetCount(); i ++ ) { pItem = m_pBuf->m_arrTaxesToStdDeals.GetAt( i ); if( !pItem ) continue; strBuf.Format( "%6.6d", pItem->m_lStdDogCode ); int nLCIndex = m_listStdDogs.InsertItem( m_listStdDogs.GetItemCount(), strBuf ); strBuf = ""; if( !GetStdDogName( pItem->m_lStdDogCode, strBuf ) ) continue; nSubItem = 1; // Име m_listStdDogs.SetItemText( nLCIndex, nSubItem++, strBuf ); m_listStdDogs.SetItemData( nLCIndex, (DWORD_PTR)pItem ); }// for return true; } #pragma region Sheet ////////////////////////////////////////////////////////////////////////////////////////////////// // CPreferencialTaxSheet IMPLEMENT_DYNAMIC( CPreferencialTaxSheet, PrShComm ) CPreferencialTaxSheet::CPreferencialTaxSheet( CPreferencialTaxFullRec &oBuf , const short sDlgMode/*ePrefTaxDlgMode*/ , long lSelStdDogCode /*= NO_DETCODE*/ , CWnd* pParent/* = NULL*/, UINT iSelectPage /* = 0*/ ) :PrShComm( CSMsg::GetMsgUsrLang( MSG_PREFERENCIAL_TAX_DATA ) , pParent, iSelectPage ) , m_oMainPage( oBuf, sDlgMode, this ) , m_oEventsTaxesPage( oBuf, sDlgMode, lSelStdDogCode, this ) , m_eMode( (ePrefTaxDlgMode)sDlgMode ) { m_pBuf = &oBuf; AddPage( &m_oMainPage ); AddPage( &m_oEventsTaxesPage ); m_arrEvents.SetCompFunction( CODE_NAME::compByCode ); if( oBuf.m_recPrefTax.m_nDealType > 0 ) { LoadEventsByDealType( oBuf.m_recPrefTax.m_nDealType, m_arrEvents ); m_arrEvents.QSort(); } } BEGIN_MESSAGE_MAP( CPreferencialTaxSheet, PrShComm ) ON_MESSAGE( ID_WM_DEAL_TYPE_CHANGED, OnDealTypeChanged ) END_MESSAGE_MAP() BOOL CPreferencialTaxSheet::OnInitDialog() { PrShComm::OnInitDialog(); if( !m_pBuf ) return FALSE; CPropertyPage* parent = GetActivePage(); if( !parent ) return TRUE; BOOL bDisableDeactivate = ( m_eMode != eView || ( m_pBuf->m_recPrefTax.m_sPreferenceStatus != (short)eStsActive && m_pBuf->m_recPrefTax.m_sPreferenceStatus != (short)eStsWaiting ) ); m_DsblCtrl.VirtEnableCtrl( parent, IDC_BTN_DEACTIVATE , !bDisableDeactivate ); return TRUE; } LRESULT CPreferencialTaxSheet::OnDealTypeChanged( WPARAM wParam, LPARAM lParam ) { m_arrEvents.Release(); long lDealType = (long)wParam; LoadEventsByDealType( lDealType, m_arrEvents ); m_arrEvents.QSort(); if( IsWindow( m_oEventsTaxesPage.GetSafeHwnd() ) ) m_oEventsTaxesPage.PostMessage( ID_WM_DEAL_TYPE_CHANGED, wParam, lParam ); return TRUE; } bool CPreferencialTaxSheet::LoadEventsByDealType( long lDealType, CSCmnRecsArray < CODE_NAME > & arrEvents ) { long lRet = 0; CRpcBufArray arrIn, arrOut; arrIn << lDealType; try { lRet = RPCBfrofCDispatchHandler( MyHandle(), RPCSYS( RPC_BFROF_GET_EVENTS_NAME_CODES_BY_DEALTYPE ), &arrIn, &arrOut ); } // try catch(...) { glShowErrMsg( APP_CLIENTTYPE, NULL, "CPreferencialTaxEventsTaxesPage::LoadEventsByDealType", NULL ); lRet = 0; } // catch if( lRet <= 0 ) return false; for( int i = 0, nCount = arrOut.GetCnt(); i < nCount ; i++ ) { long lSize = 0; CODE_NAME *pBuf = (CODE_NAME*)arrOut.GetAt( i, lSize ); ASSERT( lSize == sizeof( CODE_NAME ) ); arrEvents.Add( (CODE_NAME*)memcpy( new CODE_NAME, pBuf, sizeof( CODE_NAME ) ) ); } // for return true; } void CPreferencialTaxSheet::AddIfNeed( CAPT_ID*& p_it, int& newcnt ) { int nOldSize = newcnt; newcnt += 3; CAPT_ID *lp = new CAPT_ID[newcnt]; memcpy( lp, p_it, sizeof( CAPT_ID ) * nOldSize ); delete [] p_it; p_it = lp; // Първия правим история на корекциите p_it[ IND_BUT_EDIT ].capt = (char*)gl_MSG( MSG_HIST_ACC ); p_it[ IND_BUT_EDIT ].id = IDC_BTN_TAX_HIST; p_it[ IND_BUT_EDIT ].style = WS_CHILD | WS_VISIBLE; // Вторият деактивиране p_it[ IND_BUT_WRITE ].capt = (char*)gl_MSG( MSG_CSSAFEBOX_4200 ); p_it[ IND_BUT_WRITE ].id = IDC_BTN_DEACTIVATE; p_it[ IND_BUT_WRITE ].style = WS_CHILD | WS_VISIBLE ; // Скриваме третия p_it[ IND_BUT_REJECT ].style &= ~WS_VISIBLE; // Предпоследния да е запис p_it[ nOldSize ].pCB = &m_btnОк; p_it[ nOldSize ].capt = (char*)gl_MSG( MSG_SAFE ); p_it[ nOldSize ].id = IDOK; p_it[ nOldSize ].style = WS_CHILD | WS_VISIBLE; if( m_eMode == eView || m_eMode == eViewNoDeactivate ) p_it[ nOldSize ].style |= WS_DISABLED; nOldSize++; // Последния му задаваме да е Отказ p_it[ nOldSize ].pCB = &m_btnExit; p_it[ nOldSize ].capt = (char*)gl_MSG( MSG_CANCEL_AMP_1 ); p_it[ nOldSize ].id = IDCANCEL; p_it[ nOldSize ].style = WS_CHILD | WS_VISIBLE; nOldSize++; char * pszSeriazlization = new char [MAX_PATH]; ourstrncpy( pszSeriazlization, "XML serialization", MAX_PATH-1 ); p_it[ nOldSize ].pCB = &m_btnXmlSerialize; p_it[ nOldSize ].capt = pszSeriazlization; p_it[ nOldSize ].id = IDC_BTN_PREF_XML; p_it[ nOldSize ].style = WS_CHILD | WS_VISIBLE; } bool CPreferencialTaxSheet::GetEventName( const long lEventCode, CString & strName ) { strName = ""; for( int i=0; i< m_arrEvents.GetCount(); i++ ) if( m_arrEvents.GetAt( i )->lCode == lEventCode ) { strName = m_arrEvents.GetAt( i )->szName; break; }// if return strName != ""; } BOOL CPreferencialTaxSheet::OnCommand( WPARAM wParam, LPARAM lParam ) { WORD wNotifyCode = HIWORD( wParam ); // notification code UINT nID = LOWORD( wParam ); // item, control, or accelerator identifier if( wNotifyCode == BN_CLICKED ) { switch( nID ) { case IDC_BTN_TAX_HIST: ShowHistorySql( ePreferencialTaxes, GetString( "%ld", m_pBuf->m_recPrefTax.GetKeyValue() ) ); break; case IDC_BTN_DEACTIVATE: DeactivatePreferencialTax(); break; case IDC_BTN_PREF_XML: DoXmlSerialization(); } // switch } // if return PrShComm::OnCommand( wParam, lParam ); } void CPreferencialTaxSheet::DeactivatePreferencialTax() { if( !m_pBuf ) return; if( m_pBuf->m_recPrefTax.IsKlientskaPref() && !pGetUser()->GetAccess( ACCESS_Deactivate_Klientska_Preference, TRUE ) ) return; m_pBuf->m_recPrefTax.m_sPreferenceStatus = (short)eStsDeactivated; m_pBuf->m_recPrefTax.m_fDeactivateDate = CUR_DATE; m_pBuf->m_recPrefTax.m_iniDeactivate = *pGetUserIni(); EndDialog( IDOK ); } #pragma endregion Sheet /////////////////////////////////////////////////////////////////////////////////////////////////// // CPreferencialTaxSheetStdDogAssign IMPLEMENT_DYNAMIC( CPreferencialTaxSheetStdDogAssign, CPreferencialTaxSheet ) CPreferencialTaxSheetStdDogAssign::CPreferencialTaxSheetStdDogAssign( CPreferencialTaxFullRec &oBuf , const short sPrefTaxDlgMode/*ePrefTaxDlgMode*/ , CWnd* pParent/* = NULL*/, UINT iSelectPage /*= 0*/ , const BOOL bEditStdDogs /*= TRUE*/) :CPreferencialTaxSheet( oBuf, sPrefTaxDlgMode, NO_DETCODE, pParent, iSelectPage ) , m_oStdDogsPage( oBuf, sPrefTaxDlgMode, this , bEditStdDogs ) { if( !oBuf.m_recPrefTax.IsIndividual() && !oBuf.m_recPrefTax.IsKlientskaPref() ) AddPage( &m_oStdDogsPage ); } LRESULT CPreferencialTaxSheetStdDogAssign::OnDealTypeChanged( WPARAM wParam, LPARAM lParam ) { CPreferencialTaxSheet::OnDealTypeChanged( wParam, lParam ); if( IsWindow( m_oStdDogsPage.GetSafeHwnd() ) ) m_oStdDogsPage.PostMessage( ID_WM_DEAL_TYPE_CHANGED, wParam, lParam ); return TRUE; } CXmlEditDlg::CXmlEditDlg( CWnd* pParent /*=NULL*/ ) : CBaseDialog( CXmlEditDlg::IDD, GetHISTANCEBfrofCDLL(), pParent ) { } void CXmlEditDlg::DoDataExchange(CDataExchange* pDX) { CBaseDialog::DoDataExchange(pDX); DDX_Control( pDX, IDC_XML_EDIT_EDB_XML, m_edbXml ); } BOOL CXmlEditDlg::OnInitDialog() { CBaseDialog::OnInitDialog(); CString strBuf; strBuf = (LPCTSTR)m_bstr; m_edbXml.SetWindowText( strBuf ); return TRUE; } void CXmlEditDlg::OnOK() { CString strBuf; m_edbXml.GetWindowText( strBuf ); m_bstr = strBuf; __super::OnOK(); }
9cd0c94e2c6c38540827bbb7e1f5e591bd00c139
25cbe9daccb3e0e89b940e1092334104f86899fa
/CodeChef/Long Challenge/JULY2019/CHFM.cpp
7c96287e2fa4dd21a91f442ba8c428e19ff021ca
[]
no_license
Anmol-Sri/Competitive-Programming
c6806527e95f41cba36b5ed670332ab365dfe0e8
1d028a841bb0d6c8118b55a5bc219677ec475e3f
refs/heads/master
2020-04-26T08:49:05.642461
2020-01-16T17:39:50
2020-01-16T17:39:50
173,435,283
1
0
null
null
null
null
UTF-8
C++
false
false
594
cpp
CHFM.cpp
#include<stdio.h> #include<iostream> #include<bits/stdc++.h> using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); int arr[n]; long long int sum=0; for(int i=0;i<n;i++){ scanf("%d",&arr[i]); sum+=arr[i]; } double mean=(double)sum/n; if((mean*(n-1))-(long long int)(mean*(n-1)) != 0 ){ printf("Impossible\n"); continue; } long long int val=(sum)-(long long int)((n-1)*mean); int i; for(i=0;i<n;i++){ if(arr[i]==val){ printf("%d\n",(i+1)); break; } } if(i==n) printf("Impossible\n"); } return 0; }
42cac39d81b88846c7d1b986388a9386ce5b4dae
d0d6c9f7968cf2169924b6894b5bd1e439551664
/tests/load-test.cpp
9b745a533a605afe3cf35589245161a1e8f803e7
[]
no_license
ahtamaral/catalogo-filmes-cpp
cb0a346d2734d79c95a6b16090975b68d9a29e8c
991a3f481bfdec041be07c9d1c362076632be5eb
refs/heads/master
2023-07-22T13:11:30.525886
2021-09-03T19:26:05
2021-09-03T19:26:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,057
cpp
load-test.cpp
#include <iostream> #include "../include/catalogo.h" using namespace std; int main(int argc, char* argv[]) { string nomeArquivo = "../data/catalogo.txt"; Catalogo catalogo(nomeArquivo); Filme f; string op; cout << catalogo; cout << "Inserir filme? [s/n]: "; getline(cin, op); Filme removido; while (op == "s"){ cin >> f; catalogo += f; cout << catalogo; cout << "Inserir filme? [s/n]: "; getline(cin, op); } string novaProdutora; string novaNota; Filme* fPtr; cout << "Alterar filme por nome: "; getline(cin, op); fPtr = catalogo(op); if(fPtr == NULL) cout << "Este filme nao existe no catalogo." << endl; else cout << *fPtr; cout << "Nova Produtora: "; getline(cin, novaProdutora); cout << "Nova nota: "; getline(cin, novaNota); fPtr = catalogo(op, novaProdutora, stod(novaNota)); if(fPtr == NULL) cout << "Este filme nao existe no catalogo." << endl; else cout << *fPtr; return 0; }
cf31b79cb76c43ada3ebb9bb5e7c4ba655f2efd6
9d1ccdb0dad890fa479bd2288fffb5839a87f55c
/Game/src/Game.cpp
2452e5a9deb0d9ff25f0058d6d7d118f3a93cf16
[]
no_license
RobbAP/Assignment03_Qbert
2b3cd12ebbf61f44e7af3cb40267f301f24bf6f9
c559447c06e1834c8dfb06eb3d5e1e8ec945a08e
refs/heads/master
2016-09-06T17:02:40.050915
2015-03-27T03:56:04
2015-03-27T03:56:04
32,966,455
0
0
null
null
null
null
UTF-8
C++
false
false
11,751
cpp
Game.cpp
#include "Game.h" #include <GameObject.h> #include <SDL.h> #include <math.h> #include <SDL_image.h> #include <SDL_opengl.h> #include <InputManager.h> #include <SDL_mixer.h> #include <Cameras/Camera.h> #include <Cameras/PerspectiveCamera.h> #include <Cameras/OrthographicCamera.h> // Initializing our static member pointer. GameEngine* GameEngine::_instance = nullptr; // Sound files to load char* deathWav = "../Game/player_death.wav"; char* scoreWav = "../Game/score_sound.wav"; char* gameOverWav = "../Game/game_over.wav"; char* levelWav = "../Game/new_level.wav"; char* moveWav = "../Game/player_move.wav"; /* * */ GameEngine* GameEngine::CreateInstance() { if (_instance == nullptr) { _instance = new Game(); } return _instance; } /* * Constructor */ Game::Game() : GameEngine() { } /* * Game destructor */ Game::~Game() { closeGameMedia(); } /* * Game Initialize Implementation function */ void Game::InitializeImpl() { SDL_SetWindowTitle(_window, "QBert -~- Lives: 0 Score: 0"); deathSound = NULL; scoreSound = NULL; gameOverSound = NULL; levelSound = NULL; moveSound = NULL; if (SDL_Init(SDL_INIT_AUDIO) < 0) { printf("Failed to initialize the audio"); } if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { printf("SDL_mixer could not be initialized!"); } loadGameMedia(); level = 1; lives = 5; float _gridWidth = 7.0f; float _gridHeight = 7.0f; int cube = 0; //testing purposes int offSetY = 0; // pyramid shape instead of bipyramid float nearPlane = 0.01f; float farPlane = 100.0f; Vector4 position(3.25f, 2.5f, 2.5f, 0.0f); Vector4 lookAt = Vector4::Normalize(Vector4::Difference(Vector4(0.0f, 0.0f, 0.0f, 0.0f), position)); Vector4 up(0.0f, 0.0f, 0.0f, 0.0f); //_camera = new PerspectiveCamera(100.0f, 1.0f, nearPlane, farPlane, position, lookAt, up); _camera = new OrthographicCamera(-8.0f, 8.0f, 8.0f, -8.0f, nearPlane, farPlane, position, lookAt, up); //Spawn player _playerPos = Vector3(0, 1, 0); _player.SetPosition(_playerPos); _objects.push_back(&_player); //Spawn Enemy for (int i = 0; i < 3; i++) { int random = rand() % 2; if (random == 0) { _ball[i].SetPosition(Vector3(1, 0, 0)); } else { _ball[i].SetPosition(Vector3(0, 0, 1)); } _objects.push_back(&_ball[i]); // Increase difficulty by decreasing the spawn delay on the enemies by 0.1 second per level _ball[i].SetSpawnDelay((i + 1) * (3.0f - (0.1f * level))); _ball[i].SetIsLive(false); } //Creating our grid. newCube = new Cube[28](); for (int gridX = 0; gridX < _gridWidth; gridX++) { for (int gridZ = 0; gridZ < _gridHeight - offSetY; gridZ++) { //World coordinates. float worldX = gridX; float worldY = -(gridX + gridZ); float worldZ = gridZ; //printf("Cube%d location: Z:%f, X:%f, Y:%f\n", cube + 1, worldZ, worldX, worldY); - Prints the location of each cube in the world //Setting position based on world coordinates. newCube[cube].GetTransform().position = Vector3(worldX, worldY, worldZ); _objects.push_back(&newCube[cube]); cube++; } offSetY++; } for (auto itr = _objects.begin(); itr != _objects.end(); itr++) { (*itr)->Initialize(_graphicsObject); } } /* * Game's update implementation function */ void Game::UpdateImpl(float dt) { char title[50] = "QBert - ~ - Lives: "; char lifeCount[10]; char levelCount[10]; int j = 0; char playAgain = NULL; bool again = false; _playerPos = _player.GetPosition(); //Player Interactions with world tiles if (_player.GetPlayerMoved()) { for (int i = 0; i < 28; i++) { if(_playerPos.x == newCube[i].GetTransform().position.x && _playerPos.y == newCube[i].GetTransform().position.y + 1 && _playerPos.z == newCube[i].GetTransform().position.z) { if (newCube[i].GetIsTouched() == false) Mix_PlayChannel(-1, scoreSound, 0); newCube[i].SetIsTouched(true); break; } } } //Player Interactions with borders if (_playerPos.y > 1 || _playerPos.y < -5 || _playerPos.z < 0 || _playerPos.x < 0) { // Death Sound Mix_PlayChannel(-1, deathSound, 0); lives--; _playerPos.x = 0; _playerPos.y = 1; _playerPos.z = 0; _player.Reset(); for (int j = 0; j < 3; j++) { _ball[j].Reset(); _ball[j].SetSpawnDelay((j + 1)*3.0f); } } //Player to Obstacle Interactions for (int i = 0; i < 3; i++) { if (_ball[i].GetIsLive()) { if (V3Collision(_ball[i].GetPosition(), _playerPos)) { // Death Sound Mix_PlayChannel(-1, deathSound, 0); lives--; _playerPos.x = 0; _playerPos.y = 1; _playerPos.z = 0; _player.Reset(); for (int j = 0; j < 3; j++) { _ball[j].Reset(); _ball[j].SetSpawnDelay((j + 1)*3.0f); } break; } } } // If the player runs out of lives, prompt them if they would like to play again if (lives < 1) { again = false; _player.Reset(); for (int i = 0; i < 28; i++) { newCube[i].Reset(); } for (int j = 0; j < 3; j++) { _ball[j].Reset(); _ball[j].SetSpawnDelay((j + 1)*3.0f); } _player.Reset(); _playerPos.x = 0; _playerPos.y = 1; _playerPos.z = 0; j = 0; level = 1; printf("Game Over! Would you like to play again? [Y/N]\n"); // Get user input to see if they want to play again while (again == false) { fflush(stdin); fflush(stdout); scanf("%c", &playAgain); if (playAgain == 'Y' || playAgain == 'y') { lives = 5; again = true; } else if (playAgain == 'N' || playAgain == 'n') { exit(EXIT_SUCCESS); } else { printf("Would you like to play again? [Y/N]\n"); scanf("%c", &playAgain); } } } // Check if a player touches a new tile for (int i = 0; i < 28; i++) { if (newCube[i].GetIsTouched()) { j++; } else { break; } } // If the player has lit up all tiles then proceed to the next level if (j == 28) { level++; for (int i = 0; i < 28; i++) { newCube[i].Reset(); } for (int j = 0; j < 3; j++) { _ball[j].Reset(); _ball[j].SetSpawnDelay((j + 1)*3.0f); } _player.Reset(); _playerPos.x = 0; _playerPos.y = 1; _playerPos.z = 0; j = 0; Mix_PlayChannel(-1, levelSound, 0); } InputManager *im = InputManager::GetInstance(); im->Update(dt); // Get user input for moving the player if (im->GetKeyState(SDLK_UP, SDL_KEYUP) == true) //up right { // move up grid 1 space towards upper right _playerPos.x = _player.GetPosition().x; _playerPos.y = _player.GetPosition().y + 1.0f; _playerPos.z = _player.GetPosition().z - 1.0f; _player.SetPlayerMoved(true); Mix_PlayChannel(-1, moveSound, 0); } else if (im->GetKeyState(SDLK_DOWN, SDL_KEYUP) == true) // down left { // move down grid 1 space towards lower left _playerPos.x = _player.GetPosition().x; _playerPos.y = _player.GetPosition().y - 1.0f; _playerPos.z = _player.GetPosition().z + 1.0f; _player.SetPlayerMoved(true); Mix_PlayChannel(-1, moveSound, 0); } else if (im->GetKeyState(SDLK_LEFT, SDL_KEYUP) == true) //up left { // move up grid 1 space towards upper left _playerPos.x = _player.GetPosition().x - 1.0f; _playerPos.y = _player.GetPosition().y + 1.0f; _playerPos.z = _player.GetPosition().z; _player.SetPlayerMoved(true); Mix_PlayChannel(-1, moveSound, 0); } else if (im->GetKeyState(SDLK_RIGHT, SDL_KEYUP) == true) // downright { // move down grid 1 space towards lower right _playerPos.x = _player.GetPosition().x + 1.0f; _playerPos.y = _player.GetPosition().y - 1.0f; _playerPos.z = _player.GetPosition().z; _player.SetPlayerMoved(true); Mix_PlayChannel(-1, moveSound, 0); } // Prints the position of the player cube //printf("X:%f,Y:%f,Z:%f\n", _player.GetPosition().x, _player.GetPosition().y, _player.GetPosition().z); _player.SetPosition(_playerPos); for (auto itr = _objects.begin(); itr != _objects.end(); itr++) { (*itr)->Update(dt); } // Cap levels at 30 if (level > 30) level = 30; // Update title bar _itoa_s(lives, lifeCount, 10); _itoa_s(level, levelCount, 10); strcat_s(title, lifeCount); strcat_s(title, " Level: "); strcat_s(title, levelCount); SDL_SetWindowTitle(_window, title); } /* * Game's draw function */ void Game::DrawImpl(Graphics *graphics, float dt) { std::vector<GameObject *> renderOrder = _objects; glPushMatrix(); CalculateCameraViewpoint(); for (auto itr = renderOrder.begin(); itr != renderOrder.end(); itr++) { (*itr)->Draw(graphics, _camera->GetProjectionMatrix(), dt); } glPopMatrix(); } /* * */ void Game::CalculateDrawOrder(std::vector<GameObject *>& drawOrder) { // SUPER HACK GARBAGE ALGO. drawOrder.clear(); auto objectsCopy = _objects; auto farthestEntry = objectsCopy.begin(); while (objectsCopy.size() > 0) { bool entryFound = true; for (auto itr = objectsCopy.begin(); itr != objectsCopy.end(); itr++) { if (farthestEntry != itr) { if ((*itr)->GetTransform().position.y < (*farthestEntry)->GetTransform().position.y) { entryFound = false; farthestEntry = itr; break; } } } if (entryFound) { GameObject *farthest = *farthestEntry; drawOrder.push_back(farthest); objectsCopy.erase(farthestEntry); farthestEntry = objectsCopy.begin(); } } } /* * Sets up the camera's viewpoint into the game world */ void Game::CalculateCameraViewpoint() { Vector4 xAxis(1.0f, 0.0f, 0.0f, 0.0f); Vector4 yAxis(0.0f, 1.0f, 0.0f, 0.0f); Vector4 zAxis(0.0f, 0.0f, 1.0f, 0.0f); Vector3 cameraVector(_camera->GetLookAtVector().x, _camera->GetLookAtVector().y, _camera->GetLookAtVector().z); Vector3 lookAtVector(0.0f, 0.0f, -1.0f); Vector3 cross = Vector3::Normalize(Vector3::Cross(cameraVector, lookAtVector)); float dot = MathUtils::ToDegrees(Vector3::Dot(lookAtVector, cameraVector)); glRotatef(cross.x * dot, 1.0f, 0.0f, 0.0f); glRotatef(cross.y * dot, 0.0f, 1.0f, 0.0f); glRotatef(cross.z * dot, 0.0f, 0.0f, 1.0f); glTranslatef(-_camera->GetPosition().x, -_camera->GetPosition().y, -_camera->GetPosition().z); } /* * Checks if two vector3's are occupying the same cube */ bool Game::V3Collision(Vector3 object1, Vector3 object2) { if(object1.x == object2.x && object1.y == object2.y && object1.z == object2.z) { return true; } else { return false; } } /* * Loads the sound files used by the game */ bool Game::loadGameMedia() { //Loading success flag bool success = true; //Load sound effects deathSound = Mix_LoadWAV(deathWav); scoreSound = Mix_LoadWAV(scoreWav); gameOverSound = Mix_LoadWAV(gameOverWav); levelSound = Mix_LoadWAV(levelWav); moveSound = Mix_LoadWAV(moveWav); if (deathSound == NULL) { printf("Failed to load Death sound effect! SDL_mixer Error: %s\n", Mix_GetError()); success = false; } else if (scoreSound == NULL) { printf("Failed to load the Score sound effect! SDL_mixer Error: %s\n", Mix_GetError()); success = false; } else if (gameOverSound == NULL) { printf("Failed to load the Game Over sound effect! SDL_mixer Error: %s\n", Mix_GetError()); success = false; } else if (levelSound == NULL) { printf("Failed to load the Next Level sound effect! SDL_mixer Error: %s\n", Mix_GetError()); success = false; } else if (moveSound == NULL) { printf("Failed to load the PLAYER MOVEMENT sound effect! SDL_mixer Error: %s\n", Mix_GetError()); success = false; } return success; } /* * Cleans up & frees memory for the sound files used for the game */ void Game::closeGameMedia() { //Free the sound effects Mix_FreeChunk(deathSound); Mix_FreeChunk(scoreSound); Mix_FreeChunk(gameOverSound); Mix_FreeChunk(levelSound); Mix_FreeChunk(moveSound); deathSound = NULL; scoreSound = NULL; gameOverSound = NULL; levelSound = NULL; moveSound == NULL; //Quit SDL mixer Mix_Quit(); }
320698dfa1075ccaed2d039d5cce7ca1afa939c7
65e621ced8332044aa390422d26981c42eb4eab4
/BuilderPattern/BuilderPattern.cpp
41c1081793d60849b64e36207f97d37269af41dc
[]
no_license
adem0zer/designpatterns
b0c48bfba93fbd15c5bdba5d26939b48ed8143df
cb886d8cca3202443ca33e77302644539a77fb15
refs/heads/master
2022-11-26T15:56:40.765542
2020-08-04T08:26:45
2020-08-04T08:26:45
284,920,738
1
0
null
null
null
null
UTF-8
C++
false
false
4,885
cpp
BuilderPattern.cpp
#include <iostream> using namespace std; class ComputerParts{ public: virtual void setMainBoard(const string &MainBoard) = 0; virtual void setRam(const string &Ram) = 0; virtual void setProcessor(const string &Processor) = 0; virtual void setGPU(const string &GPU) = 0; virtual void setMemory(const string &Memory) = 0; virtual void setDisplayScreen(const string &DisplayScreen) = 0; virtual void setKeyboard(const string &Keyboard) = 0; }; class Computer : public ComputerParts{ private: string MainBoard; string Ram; string Processor; string GPU; string Memory; string DisplayScreen; string Keyboard; public: void setMainBoard(const string &mainBoard) { MainBoard = mainBoard; } void setRam(const string &ram) { Ram = ram; } void setProcessor(const string &processor) { Processor = processor; } void setGPU(const string &gpu) { GPU = gpu; } void setMemory(const string &memory) { Memory = memory; } void setDisplayScreen(const string &displayScreen) { DisplayScreen = displayScreen; } void setKeyboard(const string &keyboard) { Keyboard = keyboard; } }; class ComputerBuilder{ public: virtual void buildMainBoard() = 0; virtual void buildRam() = 0; virtual void buildProcessor() = 0; virtual void buildGPU() = 0; virtual void buildMemory() = 0; virtual void buildDisplayScreen() = 0; virtual void buildKeyboard() = 0; virtual Computer* getComputer() = 0; }; class MonsterAbraA5_V15_4 : public ComputerBuilder{ private: Computer *computer; public: MonsterAbraA5_V15_4(){ computer = new Computer(); } void buildMainBoard(){ computer->setMainBoard("Mobile Intel® HM370 Chipset"); } void buildRam(){ computer->setRam("8GB (1x8GB) DDR4L 1.2V 2666MHz SODIMM"); } void buildProcessor(){ computer->setProcessor("Intel® Coffee Lake Core™ i7-9750H 6C/12T; 12MB L3; 8GT/s; 2.6GHz > 4.5GHz; 45W; 14nm"); } void buildGPU(){ computer->setGPU("3GB GDDR5 nVIDIA® GeForce® GTX1050 DX12 (2019 Sürümü)"); } void buildMemory(){ computer->setMemory("240GB M.2 SSD Sata 3 (Okuma: 550 MB/s - Yazma: 510 MB/s)"); } void buildDisplayScreen(){ computer->setDisplayScreen("15,6\" FHD 1920x1080 IPS Mat LED Ekran"); } void buildKeyboard(){ computer->setKeyboard("RGB 4 Bölge Aydınlatmalı Klavye (Türkçe Q)"); } Computer* getComputer(){ return this->computer; } }; class MonsterAbraA7_V11_1 : public ComputerBuilder{ private: Computer* computer; public: MonsterAbraA7_V11_1(){ computer = new Computer(); } void buildMainBoard(){ computer->setMainBoard("Mobile Intel® HM370 Chipset"); } void buildRam(){ computer->setRam("8GB (1x8GB) DDR4L 1.2V 2666MHz SODIMM"); } void buildProcessor(){ computer->setProcessor("Intel® Coffee Lake Core™ i7-9750H 6C/12T; 12MB L3; 8GT/s; 2.6GHz > 4.5GHz; 45W; 14nm"); } void buildGPU(){ computer->setGPU("4GB GDDR5 nVIDIA® GeForce® GTX1650 128-Bit DX12"); } void buildMemory(){ computer->setMemory("240GB M.2 SSD Sata 3 (Okuma: 550 MB/s - Yazma: 510 MB/s)"); } void buildDisplayScreen(){ computer->setDisplayScreen("17,3\" FHD 1920x1080 Mat LED Ekran"); } void buildKeyboard(){ computer->setKeyboard("RGB 4 Bölge Aydınlatmalı Klavye (Türkçe Q)"); } Computer* getComputer(){ return computer; } }; class Monster{ private: ComputerBuilder* computerBuilder; public: Monster(ComputerBuilder *computerBuilder) : computerBuilder(computerBuilder) {} Computer* getComputer(){ return computerBuilder->getComputer(); } void createComputer(){ computerBuilder->buildMainBoard(); computerBuilder->buildRam(); computerBuilder->buildProcessor(); computerBuilder->buildGPU(); computerBuilder->buildMemory(); computerBuilder->buildDisplayScreen(); computerBuilder->buildKeyboard(); } }; int main() { ComputerBuilder *abraA5 = new MonsterAbraA5_V15_4(); ComputerBuilder *abraA7 = new MonsterAbraA7_V11_1(); Monster *m1 = new Monster(abraA5); Monster *m2 = new Monster(abraA7); m1->createComputer(); Computer *cmpA5 = m1->getComputer(); cout << "Abra A5: " << cmpA5 << endl; m2->createComputer(); Computer *cmpA7 = m2->getComputer(); cout << "Abra A7: " << cmpA7 << endl; return 0; }
23a2030286274c13624d0b30b64387d57bea8098
eefb6c2f62b23d7e1be0a25b014d52db94a2c15b
/testMySql/main.cpp
69ede06a0a6a4b980c412c2ac73028b416b35cb3
[]
no_license
lycchang/cncMMI
120e4f447ffd56eb3b32762644bd35dc08b95b43
c095f43467deb6fd4f0fcf95fe45640ce952f874
refs/heads/master
2022-04-01T12:52:29.751693
2017-08-30T01:41:34
2017-08-30T01:41:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,419
cpp
main.cpp
#include "widget.h" #include <QApplication> #include <mysql.h> #include <QDebug> struct table_info { char plugin[32]; char object[32]; int addr; char dataArea[3]; int dataType; char rw[3]; }; int main(int argc, char *argv[]) { QApplication a(argc, argv); const char user[] = "root"; const char pswd[] = "123456"; const char host[] = "10.0.11.57"; const char table[] = "test";//mysql中数据库名称 const char table1[] = "select plugin,object,addr,dataArea,dataType,rw from pluginObjectAddrs";//plugin,object,addr,dataArea,dataType,rw char value1[] = "insert into pluginObjectAddrs values('1','2',3,'4*',0,'6',null,null);"; char query[] = "select * from pluginObjectAddrs where object like 'labelCoordExValueX'"; MYSQL myCont; MYSQL_RES *result = NULL; MYSQL_ROW sql_row; int res; mysql_init(&myCont); char value = 1; mysql_options(&myCont,MYSQL_OPT_RECONNECT,(char*)&value); if (mysql_real_connect(&myCont, host, user, pswd, table, 0, NULL, 0)) { /* res = mysql_real_query(&myCont, value1, strlen(value1)); if (!res) { qDebug("insert data success!\n"); } */ res = mysql_query(&myCont, query); //res = mysql_query(&myCont, table1);//查询 if (!res) { result = mysql_store_result(&myCont); if (result) { struct table_info info; memset(&info, 0, sizeof(table_info)); while (sql_row = mysql_fetch_row(result))//获取具体的数据 { strcpy(info.plugin, sql_row[0]); strcpy(info.object, sql_row[1]); info.addr = atoi(sql_row[2]); strcpy(info.dataArea, sql_row[3]); info.dataType = atoi(sql_row[4]); strcpy(info.rw, sql_row[5]); qDebug("info:%s,%s,%d,%s,%d,%s...\n", info.plugin, info.object, info.addr, info.dataArea, info.dataType, info.rw); } } } else { //cout << "query sql failed!" << endl; } } else { // cout << "connect failed!" << endl; } if (result != NULL) mysql_free_result(result); mysql_close(&myCont); system("pause"); return 0; }
abf3f1d43e6754f0d12057ad960dc85cb42d9c49
25bc26013521a32dc06b2c4790f84f8d92e6b710
/linux/md5_sha1/main.cc
c2be870e38ad48c24f4f31381b5047f55671afd7
[ "Apache-2.0" ]
permissive
yangaofeng/x_socket
1fb3c0dc2fbe3b1ac4f3fb1724132e49b9160da1
cc0c6a385a3750237c1e44d352164436187b2c9b
refs/heads/master
2022-11-13T05:50:48.461843
2022-11-09T10:08:43
2022-11-09T10:08:43
28,037,900
0
0
null
null
null
null
UTF-8
C++
false
false
1,103
cc
main.cc
// main.cc (2015-06-01) // Yan Gaofeng (yangaofeng@360.cn) #include <iostream> #include <string.h> #include "crypto.h" using namespace std; int main(int argc, char *argv[]) { char buf[] = "hello world"; const char *filename = "main.cc"; cout << "string: " << buf << endl; cout << "filename: " << filename << endl; std::string hexmd5; md5(buf, strlen(buf), &hexmd5); cout << "string md5: " << hexmd5 << endl; md5_file(filename, &hexmd5); cout << "file md5: " << hexmd5 << endl; std::string hexsha1; sha1(buf, strlen(buf), &hexsha1); cout << "string sha1: " << hexsha1 << endl; sha1_file(filename, &hexsha1); cout << "file sha1: " << hexsha1 << endl; uint8_t bin[4] = {8, 9, 10, 11}; std::string hex_str; bin2hex(bin, 4, &hex_str); cout << "8, 9, 10, 11 hex string: " << hex_str << endl; std::string ori_bin; hex2bin(hex_str.data(), hex_str.size(), &ori_bin); cout << "8, 9, 10, 11 ori string: "; for (int i = 0; i < 4; i++) { cout << (int)ori_bin[i] << " "; } cout << endl; return 0; }
d0ad2649ee6615d17f0e1bee227f53cdc7fe2174
394b16f94033cdeee1eb8f609ce5339638dc87d8
/strifeEngine/src/engine/helloWorld/HelloWorld.h
76d1d5cc92ad2a09fe0d040f9af6b8ed4226e74d
[]
no_license
dtrajko/strifeEngine
31c73331f62a6bcb12cad68b2c352226a23cfbf1
40f51d920f7441b5d4079d141988ed4d1c6e3ebe
refs/heads/master
2020-04-01T06:11:55.249846
2020-02-02T21:18:32
2020-02-02T21:18:32
152,936,701
0
0
null
null
null
null
UTF-8
C++
false
false
609
h
HelloWorld.h
#pragma once #include "../interfaces/IGameLogic.h" #include "../interfaces/IScene.h" #include "../../engine/graph/Input.h" #include "../helloWorld/Scene.h" using namespace engine::interfaces; using namespace engine::graph; using namespace engine::helloWorld; class engine::helloWorld::Scene; namespace engine { namespace helloWorld { class HelloWorld : public IGameLogic { public: HelloWorld(); void init(Window * window); void update(float interval, Window * window); void render(Window * window); void cleanUp(); virtual ~HelloWorld(); public: IScene* scene; }; } }
664e954751a2f6fdd7ff2bbc19f05b175857e01f
b2263008c8d6159b3a2253ec237eb7dc71e2e4b2
/libs/Flow/source/Flow/SystemBase.cpp
6bb8754aa8f9d40d475587e0abf25436588e17d3
[]
no_license
mckelley3v/BlackBox
32daa66cbccd2b47577854b887bf51af8a5bbab9
005339363962347c6aa484403db04c08fe0469c7
refs/heads/master
2021-01-23T14:03:45.035245
2017-08-27T19:26:21
2017-08-27T19:26:21
23,777,405
0
0
null
2014-11-06T16:20:07
2014-09-08T02:51:51
C++
UTF-8
C++
false
false
18,325
cpp
SystemBase.cpp
#include "Flow/System.hpp" #include "Flow/SystemGraph.hpp" #include "Flow/TypeManager.hpp" #include "Flow/Verify.hpp" #include "m1/dictionary.hpp" #include <stdexcept> #include <cassert> // ===================================================================================================================== namespace { using ComponentPtrs = std::vector<std::unique_ptr<Flow::Component>>; using ComponentDefinitionPtrDict = m1::dictionary<Flow::ComponentDefinition const*>; } // namespace // ===================================================================================================================== // construct components in topological order, gathering inputs from dependencies static ComponentPtrs MakeSystemComponents(Flow::TypeManager const &type_manager, Flow::SystemDefinition const &definition, Flow::ComponentInputConnectionPtrsDict const &input_connection_ptrs_dict); // --------------------------------------------------------------------------------------------------------------------- // create a dictionary from each component's instance name to the component's definition // note: includes an entry for System::In and System::Out static ComponentDefinitionPtrDict MakeComponentInstanceDefinitionPtrDict(Flow::TypeManager const &type_manager, Flow::SystemDefinition const &definition); // --------------------------------------------------------------------------------------------------------------------- // gather all the inputs for node from available_inputs into a single dictionary // to be passed to the node's MakeInstanceFunc static Flow::ComponentInputConnectionPtrsDict ResolveNodeInputs(Flow::TypeManager const &type_manager, Flow::SystemNode const &node, ComponentDefinitionPtrDict const &component_instance_definition_ptr_dict, m1::dictionary<Flow::ComponentInputConnectionPtrsDict> const &available_inputs_dict); // --------------------------------------------------------------------------------------------------------------------- // search a component's definition for an input port with the given name, return that port's type name static char const* FindInputPortTypeName(Flow::ComponentDefinition const * const node_definition_ptr, std::string const &port_name); // --------------------------------------------------------------------------------------------------------------------- // search a component's definition for an output port with the given name, return that port's type name static char const* FindOutputPortTypeName(Flow::ComponentDefinition const * const node_definition_ptr, std::string const &port_name); // --------------------------------------------------------------------------------------------------------------------- // construct corresponding inputs for each output so component's outputs can be easily found and connected static Flow::ComponentInputConnectionPtrsDict MirrorComponentOutputs(Flow::ComponentOutputPortDict const &output_port_dict); // --------------------------------------------------------------------------------------------------------------------- // construct dictionary of system outputs to initialize System's base Component with static Flow::ComponentOutputConnectionPtrDict MakeSystemOutputDict(Flow::SystemDefinition const &definition, ComponentPtrs const &component_ptrs); // ===================================================================================================================== Flow::SystemBase::SystemBase(TypeManager const &type_manager, SystemDefinition const &definition, ComponentInputConnectionPtrsDict const &input_connection_ptrs_dict) : m_ComponentPtrs(MakeSystemComponents(type_manager, definition, input_connection_ptrs_dict)) , m_OutputConnectionPtrDict(MakeSystemOutputDict(definition, m_ComponentPtrs)) { } // --------------------------------------------------------------------------------------------------------------------- Flow::SystemBase::~SystemBase() { // destroy in reverse dependency order while(!m_ComponentPtrs.empty()) { m_ComponentPtrs.pop_back(); } } // --------------------------------------------------------------------------------------------------------------------- Flow::SystemBase::ComponentPtrs const& Flow::SystemBase::GetComponentPtrs() const { return m_ComponentPtrs; } // --------------------------------------------------------------------------------------------------------------------- Flow::ComponentOutputConnectionPtrDict& Flow::SystemBase::OutputConnectionPtrDict() { return m_OutputConnectionPtrDict; } // ===================================================================================================================== ComponentPtrs MakeSystemComponents(Flow::TypeManager const &type_manager, Flow::SystemDefinition const &definition, Flow::ComponentInputConnectionPtrsDict const &input_connection_ptrs_dict) { using namespace Flow; std::vector<std::unique_ptr<Component>> result; result.reserve(definition.ComponentInstances.size()); // create graph of node definitions and connections between them SystemGraph const system_graph = MakeSystemGraph(definition, input_connection_ptrs_dict); // topographically sort nodes std::vector<SystemNode const*> const sorted_node_ptrs = SortSystemGraph(system_graph); assert(sorted_node_ptrs.size() == definition.ComponentInstances.size()); // dictionary from component instance name to input connection dictionary created from the component's outputs // note: adds a special entry for System::In m1::dictionary<ComponentInputConnectionPtrsDict> available_inputs_dict; //available_inputs_dict.reserve(sorted_node_ptrs.size() + 1); available_inputs_dict[System::In] = input_connection_ptrs_dict; // dictionary from component instance name to definition ptr // used to validate connection type safety ComponentDefinitionPtrDict const component_instance_definition_ptr_dict = MakeComponentInstanceDefinitionPtrDict(type_manager, definition); // construct components in topological order // gather available inputs/outputs as new components are added for(SystemNode const *node_ptr : sorted_node_ptrs) { assert(node_ptr != nullptr); assert(node_ptr->InstancePtr != nullptr); assert(!node_ptr->InstancePtr->InstanceName.empty()); FLOW_VERIFY(node_ptr->InstancePtr->InstanceName != System::In, std::runtime_error("Component name must not be a reserved name")); FLOW_VERIFY(node_ptr->InstancePtr->InstanceName != System::Out, std::runtime_error("Component name must not be a reserved name")); SystemNode const &node = *node_ptr; std::string const &node_instance_name = node.InstancePtr->InstanceName; FLOW_VERIFY(available_inputs_dict.find(node_instance_name) == available_inputs_dict.end(), std::runtime_error("Duplicate component name detected")); // gather inputs to create component for this node (topological sort should insure they are available) ComponentInputConnectionPtrsDict node_input_connection_ptrs_dict = ResolveNodeInputs(type_manager, node, component_instance_definition_ptr_dict, available_inputs_dict); // create node std::string const &node_definition_name = node.InstancePtr->DefinitionName; Component::InstanceData * const node_instance_data_ptr = node.InstancePtr->InstanceDataPtr.get(); std::unique_ptr<Component> node_component_ptr = type_manager.MakeSystemComponent(node_definition_name, node_instance_name, std::move(node_input_connection_ptrs_dict), node_instance_data_ptr); FLOW_VERIFY(node_component_ptr != nullptr, std::runtime_error("Unable to create component")); // for each output port, add to available_inputs_dict available_inputs_dict.emplace(std::piecewise_construct, std::forward_as_tuple(node_instance_name), std::forward_as_tuple(MirrorComponentOutputs(node_component_ptr->GetOutputPortDict()))); result.push_back(std::move(node_component_ptr)); } return result; } // --------------------------------------------------------------------------------------------------------------------- ComponentDefinitionPtrDict MakeComponentInstanceDefinitionPtrDict(Flow::TypeManager const &type_manager, Flow::SystemDefinition const &definition) { using namespace Flow; ComponentDefinitionPtrDict result; //result.reserve(definition.ComponentInstances.size() + 2); ComponentDefinition const * const system_definition_ptr = type_manager.FindComponentDefinition(definition.Interface.Name); result[System::In] = system_definition_ptr; result[System::Out] = system_definition_ptr; for(SystemComponentInstance const &component_instance : definition.ComponentInstances) { assert(!component_instance.DefinitionName.empty()); assert(!component_instance.InstanceName.empty()); result[component_instance.InstanceName] = type_manager.FindComponentDefinition(component_instance.DefinitionName); } return result; } // --------------------------------------------------------------------------------------------------------------------- Flow::ComponentInputConnectionPtrsDict ResolveNodeInputs(Flow::TypeManager const &type_manager, Flow::SystemNode const &node, ComponentDefinitionPtrDict const &component_instance_definition_ptr_dict, m1::dictionary<Flow::ComponentInputConnectionPtrsDict> const &available_inputs_dict) { using namespace Flow; std::string const &node_instance_name = node.InstancePtr->InstanceName; ComponentDefinition const * const node_definition_ptr = component_instance_definition_ptr_dict.at(node_instance_name); FLOW_VERIFY(node_definition_ptr != nullptr, std::runtime_error("Invalid definition name for component")); ComponentInputConnectionPtrsDict result; //result.reserve(node.InputEdgePtrs.size()); // for each node source edge // look up source component/port in available_inputs // append to result at connected slot name for(SystemEdge const * const input_edge_ptr : node.InputEdgePtrs) { assert(input_edge_ptr != nullptr); SystemEdge const &input_edge = *input_edge_ptr; // get port name input is connected to assert(input_edge.ConnectionPtr != nullptr); assert(input_edge.ConnectionPtr->TargetPort.ComponentInstanceName == node_instance_name); std::string const &target_component_port_name = input_edge.ConnectionPtr->TargetPort.PortName; char const * const target_component_port_type_name = FindInputPortTypeName(node_definition_ptr, target_component_port_name); assert(target_component_port_type_name != nullptr); // get component and port name input is connected from assert(node.InstancePtr != nullptr); std::string const &source_component_instance_name = input_edge.ConnectionPtr->SourcePort.ComponentInstanceName; std::string const &source_component_port_name = input_edge.ConnectionPtr->SourcePort.PortName; ComponentDefinition const * const source_component_definition_ptr = component_instance_definition_ptr_dict.at(source_component_instance_name); char const * const source_component_port_type_name = FindOutputPortTypeName(source_component_definition_ptr, source_component_port_name); assert(source_component_port_type_name != nullptr); // verify that connection is between valid types FLOW_VERIFY(type_manager.IsConnectionValid(source_component_port_type_name, target_component_port_type_name), std::runtime_error("Invalid connection specified for port input/output types")); // find port dictionary for input component (must exist) ComponentInputConnectionPtrsDict const &input_component_dict = available_inputs_dict.at(source_component_instance_name); // find port (must exist) std::vector<m1::const_any_ptr> const &input_port_ptrs = input_component_dict.at(source_component_port_name); // copy port's connection ptrs std::vector<m1::const_any_ptr> &result_port_ptrs = result[target_component_port_name]; result_port_ptrs.insert(result_port_ptrs.end(), input_port_ptrs.begin(), input_port_ptrs.end()); } return result; } // --------------------------------------------------------------------------------------------------------------------- char const* FindInputPortTypeName(Flow::ComponentDefinition const * const node_definition_ptr, std::string const &port_name) { using namespace Flow; for(InputPortDefinition const &input_port : node_definition_ptr->InputPorts) { if(input_port.PortName == port_name) { return input_port.TypeName.c_str(); } } return nullptr; } // --------------------------------------------------------------------------------------------------------------------- char const* FindOutputPortTypeName(Flow::ComponentDefinition const * const node_definition_ptr, std::string const &port_name) { using namespace Flow; for(OutputPortDefinition const &output_port : node_definition_ptr->OutputPorts) { if(output_port.PortName == port_name) { return output_port.TypeName.c_str(); } } return nullptr; } // --------------------------------------------------------------------------------------------------------------------- Flow::ComponentInputConnectionPtrsDict MirrorComponentOutputs(Flow::ComponentOutputPortDict const &output_port_dict) { using namespace Flow; // for each output, copy connection as input ComponentInputConnectionPtrsDict result; //result.reserve(output_port_dict.size()); for(ComponentOutputPortDict::value_type const &output_port_nvp : output_port_dict) { OutputPort const &node_component_output_port = output_port_nvp.second; FLOW_VERIFY(result.find(node_component_output_port.GetPortName()) == result.end(), std::runtime_error("Duplicate component output port detected")); result[node_component_output_port.GetPortName()].push_back(node_component_output_port.GetConnectionPtr()); } return result; } // --------------------------------------------------------------------------------------------------------------------- /*static*/ Flow::ComponentOutputConnectionPtrDict MakeSystemOutputDict(Flow::SystemDefinition const &definition, ComponentPtrs const &component_ptrs) { using namespace Flow; // first index all the nodes by name so this isn't a O(N^2) algorithm // TODO - consider if this can this be constructed in MakeSystemComponents m1::dictionary<Component const*> component_ptr_dict; //component_ptr_dict.reserve(component_ptrs.size()); for(std::unique_ptr<Component> const &component_ptr : component_ptrs) { assert(component_ptr != nullptr); component_ptr_dict[component_ptr->GetInstanceName()] = component_ptr.get(); } ComponentOutputConnectionPtrDict result; //result.reserve(definition.Interface.OutputPorts.size()); // for each connection to System::Out // copy the pointer that is assigned to connect to it for(SystemConnection const &connection : definition.Connections) { std::string const &target_component_instance_name = connection.TargetPort.ComponentInstanceName; assert(!target_component_instance_name.empty()); if(target_component_instance_name == System::Out) { std::string const &target_component_port_name = connection.TargetPort.PortName; assert(!target_component_port_name.empty()); std::string const &source_component_instance_name = connection.SourcePort.ComponentInstanceName; assert(!source_component_instance_name.empty()); std::string const &source_component_port_name = connection.SourcePort.PortName; assert(!source_component_port_name.empty()); Component const *source_component_ptr = component_ptr_dict.at(source_component_instance_name); assert(source_component_ptr != nullptr); OutputPort const &system_output_port = source_component_ptr->GetOutputPortDict().at(source_component_port_name); result[target_component_port_name] = system_output_port.GetConnectionPtr(); } } return result; } // =====================================================================================================================
46a2717d5a63d4cd170351e476be5d7ff27ca6ed
878dadb550891e94bc49f2e314e8baa359a00640
/drzewo/src/element.cpp
9e668d9f1ffd3ea88123afc9207297e1e8f46f40
[]
no_license
218502/PAMSI
52893226a55e8de94208383fa87a37b0590ba822
1440960bb6d70747cad00a1bc6c19834eef35537
refs/heads/master
2021-01-17T07:12:24.502395
2016-06-10T11:40:09
2016-06-10T11:40:09
52,606,239
0
2
null
2016-04-01T13:21:44
2016-02-26T13:28:48
C++
UTF-8
C++
false
false
22
cpp
element.cpp
#include "element.hh"
f7a650aa8d75fd811c8d6fc2451adcc37cc478b3
9dda90ced50dae365b36855c2133fcf118d22b04
/snakePros/snake1/Snake1.cpp
0577da54e3d2e0a8b43f48b211458c68156f1236
[]
no_license
qingsen/consolePros
fbd5c8f25de1be16cc3db308d44a50f51e62bc2f
53548d6caf2f1bb488fd1be945fe16d8668f2749
refs/heads/master
2021-01-10T04:52:13.572836
2016-01-09T11:16:34
2016-01-09T11:16:34
49,318,762
0
0
null
null
null
null
UTF-8
C++
false
false
3,621
cpp
Snake1.cpp
// Snake1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "Mappoint.h" #include "Sprite.h" #include "windows.h" #include "conio.h" #include "string.h" char key='s'; char oldkey; int snakelength=1; char slook[]="●"; char flook[]="★"; char wall[]="■"; char flor[]=" "; char map[10][10][3]; char map1[10][10][3]={ "■","■","■","■","■","■","■","■","■","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■"," "," "," "," "," "," "," "," ","■", "■","■","■","■","■","■","■","■","■","■", }; Sprite snakehead(Mappoint(3,3),slook); Sprite food(Mappoint(5,6),flook); Sprite snakebody[50]; void intokey(); //按键输入 void judge(int &x,int &y);//按键处理 void snakemove(); //蛇移动处理 void changemap();//修改地图 void printfmap(); //打印地图 bool gameover();//游戏结束判断 bool foodisbody(); //判断随机生成的食物是否在蛇的身上 int _tmain(int argc, _TCHAR* argv[]) { snakebody[0]=snakehead; while(!gameover()) { changemap(); printfmap(); Sleep(600); intokey(); } system("CLS"); printf(" GAME OVER"); while(1); return 0; } //按键输入 void intokey() { key=kbhit()==1?getch():key; switch(key) { case 'w': judge(--snakehead.position.row,snakehead.position.col);break; case 's': judge(++snakehead.position.row,snakehead.position.col);break; case 'a': judge(snakehead.position.row,--snakehead.position.col);break; case 'd': judge(snakehead.position.row,++snakehead.position.col);break; default: key=oldkey,intokey();break; } } //按键处理 void judge(int &x,int &y) { if (strcmp(map[snakehead.position.row][snakehead.position.col],flook)==0) { snakebody[snakelength++]=food; food.setposition(); while (foodisbody()) { food.setposition(); } snakemove(); } if (strcmp(map[snakehead.position.row][snakehead.position.col],flor)==0) { snakemove(); } if (snakehead.position.row==snakebody[1].position.row&&snakehead.position.col==snakebody[1].position.col) { snakehead=snakebody[0]; key=oldkey; intokey(); } oldkey=key; } //蛇移动处理 void snakemove() { if (snakelength>1) { for (int i=snakelength-1;i>0;i--) { snakebody[i]=snakebody[i-1]; } } snakebody[0]=snakehead; } //修改地图 void changemap() { for (int i=0;i<10;i++) { for (int j=0;j<10;j++) { strcpy(map[i][j],map1[i][j]); } } strcpy(map[food.position.row][food.position.col],flook); for (int i=0;i<snakelength;i++) { strcpy(map[snakebody[i].position.row][snakebody[i].position.col],slook); } } //打印地图 void printfmap() { system("CLS"); printf(" Score:%d\n",snakelength-1); for (int i=0;i<10;i++) { for(int j=0;j<10;j++) { printf("%s",map[i][j]); } printf("\n"); } } //游戏结束判断 bool gameover() { if (strcmp(map[snakehead.position.row][snakehead.position.col],wall)==0||strcmp(map[snakehead.position.row][snakehead.position.col],slook)==0) { return 1; } else { return 0; } } //判断随机生成的食物是否在蛇的身上 bool foodisbody() { if (strcmp(map[food.position.row][food.position.col],slook)==0) { return 1; } else { return 0; } }
c7b931812717b9886b60c03117d48bb6ebd5dac3
382a4dacbf7d6e6da096ddac660ba7a40af350cf
/src/drive/gps/Air530.cpp
fcccab35ffdf5855b6643f8aa8b0be2aea469ccd
[ "MIT" ]
permissive
Xinyuan-LilyGO/TTGO_TWatch_Library
84b1a580ad931caac7407bf110fde5b9248be3c4
6a07f3762a4d11c8e5c0c2d6f9340ee4fdaa5fcb
refs/heads/master
2023-08-18T15:36:22.029944
2023-07-03T01:27:29
2023-07-03T01:27:29
202,286,916
776
293
MIT
2023-08-31T05:18:44
2019-08-14T06:17:29
C
UTF-8
C++
false
false
13,410
cpp
Air530.cpp
///////////////////////////////////////////////////////////////// /* MIT License Copyright (c) 2020 lewis he Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Air530.cpp - Arduino library for Air530 gps module. Created by Lewis he on December 28, 2020. github:https://github.com/lewisxhe/Air530_Library */ ///////////////////////////////////////////////////////////////// #include "Air530.h" #define _LOOP_TO_TIMEOUT(func) do{ \ uint32_t start = millis() + 500;\ while (millis() < start ){ \ func; \ } \ } while (0); /** * @brief Air530 * @param *ser: uart stream * @param wakeupPin: Wake-up pin * @retval None */ Air530::Air530(Stream *ser, uint8_t wakeupPin) { stream = ser; wakeup_pin = wakeupPin; if (wakeup_pin > 0) { pinMode(wakeup_pin, OUTPUT); } wakeup(); } Air530::~Air530() { stream = nullptr; } /** * @brief restart * @note System restart command * @param mode: See Air530_RestartMode * @retval None */ void Air530::restart(Air530_RestartMode mode) { sendCmd("$PGKC030,%d,1", mode); } /** * @brief erase * @note Erase auxiliary positioning data in flash * @retval None */ void Air530::erase(void) { sendCmd("$PGKC040*2B"); } /** * @brief sleep * @note Set Air530 to sleep * @retval None */ void Air530::sleep(void) { sendCmd("$PGKC051,0*37"); } /** * @brief stop * @note Set Air530 to stop * @retval None */ void Air530::stop(void) { sendCmd("$PGKC051,1*36"); } /** * @brief wakeup * @note wakeup Air530 * @retval None */ void Air530::wakeup(void) { if (wakeup_pin > 0) { digitalWrite(wakeup_pin, HIGH); delay(60); digitalWrite(wakeup_pin, LOW); delay(200); digitalWrite(wakeup_pin, HIGH); } } /** * @brief setNormalMode * @note Normal operation mode * @retval None */ void Air530::setNormalMode(void) { sendCmd("$PGKC105,0*37"); } /** * @brief setCycleTrackingMode * @note Cycle ultra-low power tracking mode, need to pull up WAKE to wake up * @param runMillis: Running time (ms) * @param sleepMillis: Sleep time (ms) * @retval None */ void Air530::setCycleTrackingMode(uint32_t runMillis, uint32_t sleepMillis) { //TODO:Unknown error parameter sendCmd("$PGKC105,1,%u,%u", runMillis, sleepMillis); } /** * @brief setCycleLowPowerMode * @note Cycle low power mode * @param runMillis: Running time (ms) * @param sleepMillis: Sleep time (ms) * @retval None */ void Air530::setCycleLowPowerMode(uint32_t runMillis, uint32_t sleepMillis) { //TODO:Unknown error parameter sendCmd("$PGKC105,2,%u,%u", runMillis, sleepMillis); } /** * @brief setTrackingMode * @note Ultra-low power tracking mode, need to pull up WAKE to wake up * @retval None */ void Air530::setTrackingMode(void) { sendCmd("$PGKC105,4*33"); } /** * @brief setAutoLowPowerMode * @note Automatic low power consumption mode, can wake up via serial port * @retval None */ void Air530::setAutoLowPowerMode(void) { sendCmd("$PGKC105,8*3F"); } /** * @brief setAutoTrackingMode * @note Automatic ultra-low power tracking mode, need to pull up WAKE to wake up * @retval None */ void Air530::setAutoTrackingMode(void) { sendCmd("$PGKC105,9*3E"); } /** * @brief enableQZSS_NMEA * @note Enable QZSS NMEA format output * @retval None */ void Air530::enableQZSS_NMEA(void) { sendCmd("$PGKC113,0*30"); } /** * @brief disableQZSS_NMEA * @note Disable QZSS NMEA format output * @retval None */ void Air530::disableQZSS_NMEA(void) { sendCmd("$PGKC113,1*31"); } /** * @brief enableQZSS * @note Enable QZSS function * @retval None */ void Air530::enableQZSS(void) { sendCmd("$PGKC114,0*37"); } /** * @brief disableQZSS * @note Disable QZSS function * @retval None */ void Air530::disableQZSS(void) { sendCmd("$PGKC114,1*36"); } /** * @brief setSearchMode * @note Command: 115 Set search mode * @param gps: true is GPS on , false is GPS off * @param glonass: true is Glonass on,false is Glonass off * @param beidou: true is Beidou on,false is Beidou off * @param galieo: true is Galieo on,false is Galieo off * @retval None */ void Air530::setSearchMode(bool gps, bool glonass, bool beidou, bool galieo) { sendCmd("$PGKC115,%u,%u,%u,%u", gps, glonass, beidou, galieo); } /** * @brief setNMEABaud * @note Set NMEA output baud rate * @param baud: 9600,19200,38400,57600,115200,921600 * @retval None */ void Air530::setNMEABaud(uint32_t baud) { (void)baud; // TODO: Don't change } /** * @brief setBaud * @note Set NMEA serial port parameters * @param baud: 9600,19200,38400,57600,115200,921600 * @retval None */ void Air530::setBaud(uint32_t baud) { sendCmd("$PGKC147,%u", baud); } /** * @brief setPPS * @note PPS settings * @param mode: see Air530_1PPS_Mode * @param ppsWidth: PPS pulse width (ms), the requirement is less than 999 * @param ppsPeriod: PPS period (ms), which must be greater than the PPS pulse width * @retval */ bool Air530::setPPS(Air530_1PPS_Mode mode, uint16_t ppsWidth, uint16_t ppsPeriod) { if (ppsWidth >= 999) { ppsWidth = 998; } if (ppsWidth < ppsPeriod) { return false; } sendCmd("$PGKC161,%u,%u,%u", mode, ppsWidth, ppsPeriod); return true; } /** * @brief get NMEA Interval * @note NMEA message interval * @retval NMEA Interval(millisecond) */ uint32_t Air530::getNMEAInterval(void) { sendCmd("$PGKC201*2C"); _LOOP_TO_TIMEOUT( while (stream->available()) { if (stream->read() == '$') { if (!stream->readStringUntil(',').startsWith("PGKC202")) { break; } else { return stream->readStringUntil('*').toInt(); } } }); return 0; } /** * @brief setInterval * @note Configure the interval for outputting NMEA messages (in ms) * @param ms: millisecond * @retval None */ void Air530::setNMEAInterval(uint16_t ms) { if (ms < 200) { ms = 200; } if (ms > 10000) { ms = 10000; } sendCmd("$PGKC101,%u", ms); } /** * @brief enableSBAS * @note Turn on SBAS function * @retval None */ void Air530::enableSBAS(void) { sendCmd("$PGKC239,0*3B"); } /** * @brief disableSBAS * @note Turn off SBAS function * @retval None */ void Air530::disableSBAS(void) { sendCmd("$PGKC239,1*3A"); } /** * @brief getSBASEnable * @note Query whether SBAS is enabled * @retval true is enable ,false is disable */ bool Air530::getSBASEnable(void) { sendCmd("$PGKC240*29"); _LOOP_TO_TIMEOUT( while (stream->available()) { if (stream->read() == '$') { if (!stream->readStringUntil(',').startsWith("PGKC241")) { break; } else { return stream->readStringUntil('*').toInt(); } } }); return false; } /** * @brief setNMEAStatement * @note Set NMEA sentence output enable * @param gll: GLL false off , true on * @param rmc: RMC false off , true on * @param vtg: VTG false off , true on * @param gga: GGA false off , true on * @param gsa: GSA false off , true on * @param gsv: GSV false off , true on * @param grs: GRS false off , true on * @param gst: GST false off , true on * @retval None */ void Air530::setNMEAStatement(bool gll, bool rmc, bool vtg, bool gga, bool gsa, bool gsv, bool grs, bool gst) { sendCmd("$PGKC242,%d,%d,%d,%d,%d,%d,%d,%d,0,0,0,0,0,0,0,0,0,0,0", gll, rmc, vtg, gga, gsa, gsv, grs, gst); } /** * @brief disableNMEAOutput * @note Disable NMEA Output * @retval None */ void Air530::disableNMEAOutput(void) { setNMEAStatement(false, false, false, false, false, false, false, false); } /** * @brief enableNMEAOutput * @note Enable NMEA Output * @retval None */ void Air530::enableNMEAOutput(void) { setNMEAStatement(true, true, true, true, true, true, true, true); } // Command: 243 // Command: 244 /** * @brief setDateTime * @note Set RTC time * @param year: * @param month:1~12 * @param day: 1~31 * @param hour: 0~23 * @param min: 0~59 * @param sec: 0~59 * @retval None */ void Air530::setDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) { sendCmd("$PGKC278,%u,%u,%u,%u,%u,%u", year, month, day, hour, min, sec); } /** * @brief getDateTime * @note * @param &year: * @param &month: * @param &day: * @param &hour: * @param &min: * @param &sec: * @retval None */ bool Air530::getDateTime(uint16_t &year, uint8_t &month, uint8_t &day, uint8_t &hour, uint8_t &min, uint8_t &sec) { sendCmd("$PGKC279*23"); _LOOP_TO_TIMEOUT( while (stream->available()) { if (stream->read() == '$') { if (!stream->readStringUntil(',').startsWith("PGKC280")) { break; } else { year = stream->readStringUntil(',').toInt(); month = stream->readStringUntil(',').toInt(); day = stream->readStringUntil(',').toInt(); hour = stream->readStringUntil(',').toInt(); min = stream->readStringUntil(',').toInt(); sec = stream->readStringUntil('*').toInt(); return true; } } }); return false; } //Command: 284 Set speed threshold //Command: 356 Set HDOP threshold //Command: 357 Get HDOP threshold /** * @brief getSoftVersion * @note Query the version number of the current software * @retval version */ const char *Air530::getSoftVersion(void) { sendCmd("$PGKC462*2F"); _LOOP_TO_TIMEOUT( while (stream->available()) { if (stream->read() == '$') { if (!stream->readStringUntil(',').startsWith("PGKC463")) { break; } else { return stream->readStringUntil(',').c_str(); } } }); return "None"; } /** * @brief setProbablyLoaction * @note Set approximate location information and time information to speed up positioning * @example: setProbablyLoaction(28.166450,120.389700,0,2017,3,15,12,0,0) * @retval None */ void Air530::setProbablyLoaction(float lat, float lng, uint16_t altitude, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) { sendCmd("$PGKC639,%f,%f,%u,%u,%u,%u,%u,%u,%u", lat, lng, altitude, year, month, day, hour, min, sec); } /** * @brief process * @note Processing sentences * @retval True is running ,False is abnormal */ bool Air530::process(/*Stream *serial = nullptr*/void) { if (!stream)return false; while (stream->available()) { char r = stream->read(); // if (serial) { // serial->write(r); // } encode(r); } if (charsProcessed() < 10) { // Serial.println(F("WARNING: No GPS data. Check wiring.")); return false; } return true; } bool Air530::sendCmd(const char *format, ...) { va_list args; va_start(args, format); int err = vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); if (err < 0) { return false; } uint8_t checksum = buffer[1]; int i = 2; while (buffer[i] != '\0') { checksum ^= buffer[i++]; } while (stream->available()) { stream->flush(); } stream->write(buffer); stream->write("*"); stream->println(checksum, HEX); return true; }
43bbbdb3d247dc14ac779474146f0445d77b2e5b
3981364051f2551ecc2bd61c6e7a1106f05433fb
/femflip2/src/fvmfluid2.h
e15e14df470e03f44f8cca9dc1c59eca104d9983
[]
no_license
PtrMan/FemFlip
936b485df08a4348c97d5b81dac7df973e89e602
219fe31281167d90b5502ca1ac1df409fb69acd7
refs/heads/master
2021-01-22T03:14:09.557907
2017-02-06T16:25:16
2017-02-06T16:25:16
81,106,711
8
4
null
null
null
null
UTF-8
C++
false
false
2,414
h
fvmfluid2.h
/* * fvmfluid2.h * * Created by Ryoichi Ando on 12/27/11 * Email: and@verygood.aid.design.kyushu-u.ac.jp * */ #include "pcgsolver/sparse_matrix.h" #include "fluid2.h" #include "umesher2.h" #include "bccmesher2.h" #ifndef _FVMFLUID2_H #define _FVMFLUID2_H class fvmfluid2 : public fluid2 { public: fvmfluid2(); // 1st step: setup simulation configuration. You have to call them in defined order. virtual void init( uint gn, const levelset2 *hint ); virtual void setParameter( int name, FLOAT64 value ); virtual void setTimestep( FLOAT64 dt ); virtual void setupSolidLevelset( const levelset2 *solid ); virtual void setupFluidLevelset( const levelset2 *fluid ); virtual void getSamplePoints( std::vector<vec2d> &pos ); virtual void setupVelocity( const std::vector<vec2d> &vel, const std::vector<bool> &mapped ); // 2nd step: project virtual void project(); // 3rd step: retrieve information virtual vec2d getPressureGradient( vec2d p ) const; virtual vec2d getVelocity( vec2d p ) const; virtual FLOAT64 getDivergence( vec2d p ) const; // Render variables virtual void render( int name, vec2d mousePos=vec2d() ) const; virtual const mesher2 *getMesh() const { return &g; } protected: typedef struct _facet2 { vec2d center; vec2d normal; FLOAT64 velocity; FLOAT64 gradient; FLOAT64 fraction; bool mapped; } facet2; std::vector<facet2> facets; typedef struct _cell2 { FLOAT64 pressure; FLOAT64 divergence; FLOAT64 solidVolume; FLOAT64 solidLS; FLOAT64 fluidLS; vec2d velocity; vec2d gradient; bool mapped; } cell2; std::vector<cell2> cells; typedef struct _node2 { vec2d velocity; vec2d gradient; bool mapped; FLOAT64 fluidLS; FLOAT64 solidLS; FLOAT64 volume; } node2; std::vector<node2> nodes; umesher2 g; // Mesh geometry uint gn; // Base resolution FLOAT64 dx; FLOAT64 dt; FLOAT64 extrapolate_dist; const levelset2 *solid; const levelset2 *fluid; bool variation; uint surf_order; SparseMatrix<FLOAT64> LhsMatrix; SparseMatrix<FLOAT64> RhsMatrix; void initMesh(const levelset2 *hint); protected: void buildMatrix(); void computeElementVelocity( const mesher2 &g, const std::vector<facet2> &facets, std::vector<cell2> &cells, int kind ); void extrapolate(const mesher2 &g, std::vector<node2> &nodes, int kind); vec2d getVector( vec2d p, uint kind ) const; void resample( uint type, uint kind ); }; #endif
666a2a661452a7dd583fe78a887e4a2a903def9c
4e8155af1d02233dd73e73e46f619aaff30742aa
/3D_Projection/OpenGL_Test.cpp
51655c12be4c2d53da4f61431326a31fdfcfd093
[]
no_license
luoxz-ai/AR_Chess
da0cefa19df3e5e3a82264a2a8f8b5e7df6dc5e0
31f3b6c5e824663b2ba108ef7000bcd98584a022
refs/heads/master
2021-07-15T14:16:33.074817
2017-10-13T17:25:38
2017-10-13T17:25:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
20,944
cpp
OpenGL_Test.cpp
///* // * opticalFlow.cpp // * OpenCVTries1 // * // * Created by Roy Shilkrot on 11/3/10. // * Copyright 2010. All rights reserved. // * // */ // #include <vector> #include <opencv2/highgui.hpp> #include <opencv2/aruco/charuco.hpp> #include <opencv2/opencv.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> #include <opencv/cxcore.hpp> #include <opencv2/core.hpp> #include <GL/glew.h> #include <GL/glut.h> #include <GL/freeglut.h> #include <glm/glm.hpp> #define MARK_SIZE 0.18 using namespace std; using namespace cv; using namespace aruco; using namespace glm; //String camera = "/dev/v4l/by-id/usb-Etron_Technology__Inc._USB2.0_Camera-video-index0"; String camera = "/dev/v4l/by-id/usb-046d_C922_Pro_Stream_Webcam_808791DF-video-index0"; String param_file = "logicool_params_1400x1050_3.yml"; String out_name = "full_chess_board.avi"; // Black pawns' IDs and indices if found int black_pawns[8] = {8, 9, 10, 11, 12, 13, 14 ,15}; int black_pawns_i[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; // Black queen and king's IDs and indices if found int black_queen = 3; int black_queen_i = -1; int black_king = 4; int black_king_i = -1; // Black rooks' IDs and indices if found int black_rooks[2] = {0, 7}; int black_rooks_i[2] = {-1, -1}; // Black knights' IDs and indices if found int black_knights[2] = {1, 6}; int black_knights_i[2] = {-1, -1}; // Black bishops' IDs and indices if found int black_bishops[2] = {2, 5}; int black_bishops_i[2] = {-1, -1}; // White pawns' IDs and indices if found int white_pawns[8] = {16, 17, 18, 19, 20, 21, 22, 23}; int white_pawns_i[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; // White queen and king's IDs and indices if found int white_queen = 27; int white_queen_i = -1; int white_king = 28; int white_king_i = -1; // White rooks' IDs and indices if found int white_rooks[2] = {24, 31}; int white_rooks_i[2] = {-1, -1}; // White knights' IDs and indices if found int white_knights[2] = {25, 30}; int white_knights_i[2] = {-1, -1}; // White bishops' IDs and indices if found int white_bishops[2] = {26, 29}; int white_bishops_i[2] = {-1, -1}; // For displaying functions GLuint textID; float width; float height; // For chess pieces // Each pieces' extrinsic matrix GLfloat black_pawns_glMatrix[8][16]; GLfloat black_rooks_glMatrix[8][16]; GLfloat black_knights_glMatrix[8][16]; GLfloat black_bishops_glMatrix[8][16]; GLfloat black_queen_glMatrix[16]; GLfloat black_king_glMatrix[16]; GLfloat white_pawns_glMatrix[8][16]; GLfloat white_rooks_glMatrix[8][16]; GLfloat white_knights_glMatrix[8][16]; GLfloat white_bishops_glMatrix[8][16]; GLfloat white_queen_glMatrix[16]; GLfloat white_king_glMatrix[16]; // Each pieces' vertex values vector<vec3> pawn; vector<vec3> pawn_norms; vector<vec3> knight; vector<vec3> knight_norms; vector<vec3> rook; vector<vec3> rook_norms; vector<vec3> bishop; vector<vec3> bishop_norms; vector<vec3> king; vector<vec3> king_norms; vector<vec3> queen; vector<vec3> queen_norms; static bool readCameraParameters(string filename, Mat &camMatrix, Mat &distCoeffs) { FileStorage fs(filename, FileStorage::READ); if(!fs.isOpened()) return false; fs["camera_matrix"] >> camMatrix; fs["distortion_coefficients"] >> distCoeffs; return true; } void loadGLArrayOfMatrix (int size, int id_i[], GLfloat (&glMatrix)[8][16], vector<Vec3d> r_vecs, vector<Vec3d> t_vecs){ for (int i = 0; i < size; i ++){ if (id_i[i] >= 0){ Mat rot_3d(3,3,CV_32FC1); Vec3d temp_rot = r_vecs[id_i[i]]; // Flip x and y rotation... I think //temp_rot[0] = -temp_rot[0]; //temp_rot[1] = -temp_rot[1]; // Apply Rodrigues to convert from 2d rotational vector to 3d matrix Rodrigues(temp_rot, rot_3d); // Place rotation matrix into the correct transformation matrix positions for (int j = 0; j < 3; j ++) { for (int k = 0; k < 3; k ++){ glMatrix[i][j*4+k] = -rot_3d.at<double>(j,k); } } // Place translation vector into correct transformation matrix positions Vec3d temp_vec = t_vecs[id_i[i]]; double x = temp_vec[0]; double y = -temp_vec[1]; // -y since OpenCV and OpenGL have opposite y directions double z = -temp_vec[2]; // Same with z glMatrix[i][12] = x; glMatrix[i][13] = y; glMatrix[i][14] = z; } } } void loadGLMatrix(int id_i, GLfloat(& glMatrix)[16], vector<Vec3d> r_vecs, vector<Vec3d> t_vecs){ if (id_i >= 0){ Mat rot_3d(3,3,CV_32FC1); Vec3d temp_rot = r_vecs[id_i]; //temp_rot[0] = -temp_rot[0]; //temp_rot[1] = -temp_rot[1]; Rodrigues(temp_rot, rot_3d); // Place into glMatrix for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++){ glMatrix[i*4+j] = -rot_3d.at<double>(i,j); } } // Translating Vec3d test = t_vecs[id_i]; double x = test[0]; double y = -test[1]; double z = -test[2]; glMatrix[12] = x; glMatrix[13] = y; glMatrix[14] = z; } } // Reset array indices for each piece // This is so that pieces do not stay // on image when its respective marker // ID cannot be found void resetIndices(){ for (int i = 0; i < 8; i ++){ black_pawns_i[i] = -1; white_pawns_i[i] = -1; } for (int i = 0; i < 2; i ++){ black_rooks_i[i] = -1; black_bishops_i[i] = -1; black_knights_i[i] = -1; white_rooks_i[i] = -1; white_bishops_i[i] = -1; white_knights_i[i] = -1; } black_king_i = -1; white_king_i = -1; black_queen_i = -1; white_queen_i = -1; } // Sets up the extrinsic matrices void initMatrices(){ for (int i = 0; i < 16; i ++){ if (i == 0 || i == 5 || i == 10 || i == 15){ black_queen_glMatrix[i] = 1; black_king_glMatrix[i] = 1; white_queen_glMatrix[i] = 1; white_king_glMatrix[i] = 1; } else{ black_queen_glMatrix[i] = 0; black_king_glMatrix[i] = 0; white_queen_glMatrix[i] = 0; white_king_glMatrix[i] = 0; } } for (int i = 0; i < 8; i ++){ for(int j = 0; j < 16; j ++){ if (j == 0 || j == 5 || j == 10 || j == 15){ black_pawns_glMatrix[i][j] = 1; black_rooks_glMatrix[i][j] = 1; black_knights_glMatrix[i][j] = 1; black_bishops_glMatrix[i][j] = 1; white_pawns_glMatrix[i][j] = 1; white_rooks_glMatrix[i][j] = 1; white_knights_glMatrix[i][j] = 1; white_bishops_glMatrix[i][j] = 1; } else{ black_pawns_glMatrix[i][j] = 0; black_rooks_glMatrix[i][j] = 0; black_knights_glMatrix[i][j] = 0; black_bishops_glMatrix[i][j] = 0; white_pawns_glMatrix[i][j] = 0; white_rooks_glMatrix[i][j] = 0; white_knights_glMatrix[i][j] = 0; white_bishops_glMatrix[i][j] = 0; } } } } // Draw the background image // In our case, it is the camera // feed from OpenCV void drawBackground(){ // Start Ortho glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 1, 0, 1, -1.0f, 1.0f); glDisable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Draw 2D background glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textID); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glEnd(); glDisable(GL_TEXTURE_2D); // End Ortho glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f); } // Draws one chess piece // used for drawing the Kings and Queens void drawPiece(int id_i, GLfloat glMatrix[16], vector<vec3> vecs, vec3 color) { glColor3f(color.x, color.y, color.z); if(id_i >= 0){ glLoadIdentity(); glLoadMatrixf(glMatrix); glBegin(GL_TRIANGLES); for(int i = 0; i < vecs.size(); i ++){ glVertex3f(vecs[i].x, vecs[i].y, vecs[i].z); } glEnd(); glLineWidth(1.5f); glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); for (int i = 0; i < vecs.size(); i ++){ glVertex3f(vecs[i].x, vecs[i].y, vecs[i].z); } glEnd(); } } // Draws multiple pieces at once // used for drawing the pawns, knights, rooks, and bishops // ele = number of elements to draw // id_i[] = array of each piece's index storing whether the piece has been spotted or not // glMatrix[][16] = the array of matrices that contain the extrinsic matrix values for transformation // vecs = vector of triangle points to draw actual piece // color = color used to glColor3f void drawPieces(int ele, int id_i[], GLfloat glMatrix[][16], vector<vec3> vecs, vec3 color) { for (int i = 0; i < ele; i ++){ if(id_i[i] >= 0){ /*for (int j = 0; j < 16; j ++){ if (j % 4 == 0) cout << endl; cout << glMatrix[i][j] << ", "; } cout << "=============================================" << endl;*/ glColor3f(color.x, color.y, color.z); glLoadIdentity(); glLoadMatrixf(glMatrix[i]); glBegin(GL_TRIANGLES); for(int j = 0; j < vecs.size(); j ++) glVertex3f(vecs[j].x, vecs[j].y, vecs[j].z); glEnd(); glLineWidth(1.5f); glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); for (int j = 0; j < vecs.size(); j ++){ glVertex3f(vecs[j].x, vecs[j].y, vecs[j].z); } glEnd(); } } } // Load vertex values of object bool loadOBJ(const char * path, vector<vec3> & out_vertices, vector<vec3> & out_normals) { printf("Loading OBJ file %s...\n", path); vector<unsigned int> vertexIndices, normalIndices; vector<vec3> temp_vertices; vector<vec3> temp_normals; FILE * file = fopen(path, "r"); if( file == NULL ){ cout << "Cannot Open:" << path << endl; return false; } while(1){ char lineHeader[128]; // read the first word of the line int res = fscanf(file, "%s", lineHeader); if (res == EOF) break; // EOF = End Of File. Quit the loop. if ( strcmp( lineHeader, "v" ) == 0 ){ vec3 vertex; fscanf(file, "%f %f %f\n", &vertex.x, &vertex.y, &vertex.z); temp_vertices.push_back(vertex); }else if ( strcmp( lineHeader, "vn" ) == 0 ){ glm::vec3 normal; fscanf(file, "%f %f %f\n", &normal.x, &normal.y, &normal.z ); temp_normals.push_back(normal); }else if ( strcmp( lineHeader, "f" ) == 0 ){ unsigned int vertexIndex[3], normalIndex[3]; int matches = fscanf(file, "%d//%d %d//%d %d//%d\n", &vertexIndex[0], &normalIndex[0], &vertexIndex[1], &normalIndex[1], &vertexIndex[2], &normalIndex[2]); vertexIndices.push_back(vertexIndex[0]); vertexIndices.push_back(vertexIndex[1]); vertexIndices.push_back(vertexIndex[2]); normalIndices.push_back(normalIndex[0]); normalIndices.push_back(normalIndex[1]); normalIndices.push_back(normalIndex[2]); }else{ // Probably a comment, eat up the rest of the line char stupidBuffer[1000]; fgets(stupidBuffer, 1000, file); } } // For each vertex of each triangle for( unsigned int i=0; i<vertexIndices.size(); i++ ){ // Get the indices of its attributes unsigned int vertexIndex = vertexIndices[i]; unsigned int normalIndex = normalIndices[i]; // Get the attributes thanks to the indexblack_pawns vec3 vertex = temp_vertices[ vertexIndex-1 ]; glm::vec3 normal = temp_normals[ normalIndex-1 ]; // Put the attributes in buffers out_vertices.push_back(vertex); out_normals.push_back(normal); } return true; } // Display callback function // Draws background and pieces void display (void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear color and depth buffers glColor3f(1.0f, 1.0f, 1.0f); drawBackground(); // Draw all the pieces glMatrixMode(GL_MODELVIEW); // Black pieces drawPiece(black_king_i, black_king_glMatrix, king, vec3(0.2f, 0.2f, 0.2f)); drawPiece(black_queen_i, black_queen_glMatrix, queen, vec3(0.2f, 0.2f, 0.2f)); drawPieces(8, black_pawns_i, black_pawns_glMatrix, pawn, vec3(0.2f, 0.2f, 0.2f)); drawPieces(2, black_knights_i, black_knights_glMatrix, knight, vec3(0.2f, 0.2f, 0.2f)); drawPieces(2, black_bishops_i, black_bishops_glMatrix, bishop, vec3(0.2f, 0.2f, 0.2f)); drawPieces(2, black_rooks_i, black_rooks_glMatrix, rook, vec3(0.2f, 0.2f, 0.2f)); // White pieces drawPiece(white_king_i, white_king_glMatrix, king, vec3(0.8f, 0.8f, 0.8f)); drawPiece(white_queen_i, white_queen_glMatrix, queen, vec3(0.8f, 0.8f, 0.8f)); drawPieces(8, white_pawns_i, white_pawns_glMatrix, pawn, vec3(0.8f, 0.8f, 0.8f)); drawPieces(2, white_knights_i, white_knights_glMatrix, knight, vec3(0.8f, 0.8f, 0.8f)); drawPieces(2, white_bishops_i, white_bishops_glMatrix, bishop, vec3(0.8f, 0.8f, 0.8f)); drawPieces(2, white_rooks_i, white_rooks_glMatrix, rook, vec3(0.8f, 0.8f, 0.8f)); glutSwapBuffers(); // Swap the front and back frame buffers (double buffering) } // Reshapes window when scaled and sets perspective void reshape(GLsizei width, GLsizei height) { // Compute aspect ratio of the new window if (height == 0) // To prevent divide by 0 height = 1; GLfloat aspect = (GLfloat)width / (GLfloat)height; // Set the viewport to cover the new window glViewport(0, 0, width, height); // Set the aspect ratio of the clipping volume to match the viewport glMatrixMode(GL_PROJECTION); // To operate on the Projection matrix glLoadIdentity(); // Reset // Enable perspective projection with fovy, aspect, zNear and zFar gluPerspective(45.0f, aspect, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); } // Binds an image to a texture to use as background void bindTexture(Mat img){ glGenTextures(1, &textID); glBindTexture(GL_TEXTURE_2D, textID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, // Type of texture 0, // Pyramid level (for mip-mapping) - 0 is the top level GL_RGB, // Internal colour format to convert to img.cols, // Image width img.rows, // Image height 0, // Border width in pixels (can either be 1 or 0) GL_BGR, // Input image format (i.e. GL_RGB, GL_RGBA, GL_BGR etc.) GL_UNSIGNED_BYTE, // Image data type img.data); // The actual image data itself } // Init Glut things void initGlut(){ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(width, height); glutInitWindowPosition(320,240); glutCreateWindow("Glut Window"); glutDisplayFunc(display); glutReshapeFunc(reshape); } // Initialize OpenGL Graphics void initGL() { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque glClearDepth(1.0f); // Set background depth to farthest glEnable(GL_DEPTH_TEST); // Enable depth testing for z-culling glDepthFunc(GL_LEQUAL); // Set the type of depth-test glShadeModel(GL_SMOOTH); // Enable smooth shading glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Nice perspective corrections } int main(int argc, char** argv) { VideoCapture cap; //VideoWriter video(out_name, CV_FOURCC('M','J','P','G'), 10, Size(width, height), true); Mat frame, img, gl_img; float rvecs_z[32][10]; double rvecs_y[32][10]; double rvecs_x[32][10]; // Open camera //cap.open(camera); cap.open(camera); if (!cap.isOpened()) { cout << "CAMERA?!" << endl; return -1; } cap.set(CV_CAP_PROP_FRAME_WIDTH, 1400); cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1050); width = cap.get(CV_CAP_PROP_FRAME_WIDTH); height = cap.get(CV_CAP_PROP_FRAME_HEIGHT); cout << "WIDTH: " << width << " HEIGHT: " << height << endl; // Dictionary of markers Ptr<Dictionary> dictionary = getPredefinedDictionary(DICT_4X4_50); // Initialize functions for glut, glew, GL glutInit(&argc, argv); initGlut(); glewInit(); initGL(); // Opening Chess Object Files loadOBJ("Chess_Pieces/Pawn/Pawn.obj", pawn, pawn_norms); loadOBJ("Chess_Pieces/Knight/Knight.obj", knight, knight_norms); loadOBJ("Chess_Pieces/Rook/Rook.obj", rook, rook_norms); loadOBJ("Chess_Pieces/Bishop/Bishop.obj", bishop, bishop_norms); loadOBJ("Chess_Pieces/King/King.obj", king, king_norms); loadOBJ("Chess_Pieces/Queen/Queen.obj", queen, queen_norms); // Camera Parameters for drawing axis Mat camMatrix, distCoeffs; bool read = readCameraParameters(param_file, camMatrix, distCoeffs); if (!read){ cerr << "Invalid camera file" << endl; return 0; } // Init extrinsic matrices of each chess piece to be diagonal initMatrices(); while(1){ // Main processing function of glut glutMainLoopEvent(); // Grab frame cap >> frame; frame.copyTo(img); // Detect and draw Markers vector<int> markerIds; vector<vector<Point2f>> markerCorners; Ptr<DetectorParameters> params = DetectorParameters::create(); params->cornerRefinementMethod = CORNER_REFINE_CONTOUR; detectMarkers(img, dictionary, markerCorners, markerIds, params); if (markerIds.size() > 0){ drawDetectedMarkers(img, markerCorners, markerIds); for (int i = 0; i < markerIds.size(); i ++){ // Find ID of 8 black pawns (8 - 16) for (int j = 0; j < 8; j ++){ if (black_pawns[j] == markerIds[i]){ black_pawns_i[j] = i; } } // Find ID of 2 black rooks for (int j = 0; j < 2; j ++){ if (black_rooks[j] == markerIds[i]){ black_rooks_i[j] = i; } } // Find ID of 2 black knights for (int j = 0; j < 2; j ++){ if (black_knights[j] == markerIds[i]){ black_knights_i[j] = i; } } // Find ID of 2 black bishops for (int j = 0; j < 2; j ++){ if (black_bishops[j] == markerIds[i]){ black_bishops_i[j] = i; } } // Find ID of black King if (markerIds[i] == black_king){ black_king_i = i; } // Find ID of black Queen if (markerIds[i] == black_queen){ black_queen_i = i; } // Find ID of 8 white pawns for (int j = 0; j < 8; j ++){ if (white_pawns[j] == markerIds[i]){ white_pawns_i[j] = i; } } // Find ID of 2 white rooks for (int j = 0; j < 2; j ++){ if (white_rooks[j] == markerIds[i]){ white_rooks_i[j] = i; } } // Find ID of 2 white knights for (int j = 0; j < 2; j ++){ if (white_knights[j] == markerIds[i]){ white_knights_i[j] = i; } } // Find ID of 2 white bishops for (int j = 0; j < 2; j ++){ if (white_bishops[j] == markerIds[i]){ white_bishops_i[j] = i; } } // Find ID of white King if (markerIds[i] == white_king){ white_king_i = i; } // Find ID of white Queen if (markerIds[i] == white_queen){ white_queen_i = i; } } // Estimate and draw all poses vector<Vec3d> rvecs, tvecs; estimatePoseSingleMarkers(markerCorners, MARK_SIZE, camMatrix, distCoeffs, rvecs, tvecs); // Average rvec's x rotation to get rid of the z axix flipping randomly /*for (int i = 0; i < markerIds.size(); i ++){ double total = 0; int markerID = markerIds[i]; for (int j = 0; j < 9; j ++){ rvecs_z[markerID][j] = rvecs_z[markerID][j+1]; total += rvecs_z[markerID][j]; } rvecs_z[markerID][10] = rvecs[i][1]; total += rvecs_z[markerID][10]; double avg = total / 10.0; cout << "ID: " << markerID << "\tRAW: " << rvecs[i][2] << "\tAVG: " << avg << endl; rvecs[i][1] = avg; }*/ for (int i = 0; i < markerIds.size(); i ++) drawAxis(img, camMatrix, distCoeffs, rvecs[i], tvecs[i], MARK_SIZE); // Black Pawns loadGLArrayOfMatrix(8, black_pawns_i, black_pawns_glMatrix, rvecs, tvecs); // Black Rooks loadGLArrayOfMatrix(2, black_rooks_i, black_rooks_glMatrix, rvecs, tvecs); // Black Knights loadGLArrayOfMatrix(2, black_knights_i, black_knights_glMatrix, rvecs, tvecs); // Black Bishops loadGLArrayOfMatrix(2, black_bishops_i, black_bishops_glMatrix, rvecs, tvecs); // Black Queen loadGLMatrix(black_queen_i, black_queen_glMatrix, rvecs, tvecs); // Black King loadGLMatrix(black_king_i, black_king_glMatrix, rvecs, tvecs); // White Pawns loadGLArrayOfMatrix(8, white_pawns_i, white_pawns_glMatrix, rvecs, tvecs); // White Rooks loadGLArrayOfMatrix(2, white_rooks_i, white_rooks_glMatrix, rvecs, tvecs); // White Knights loadGLArrayOfMatrix(2, white_knights_i, white_knights_glMatrix, rvecs, tvecs); // White Bishops loadGLArrayOfMatrix(2, white_bishops_i, white_bishops_glMatrix, rvecs, tvecs); // White Queen loadGLMatrix(white_queen_i, white_queen_glMatrix, rvecs, tvecs); // White King loadGLMatrix(white_king_i, white_king_glMatrix, rvecs, tvecs); } // Bind camera frame to texture image for GL to display as background // flip image since GL displays a flipped image flip(img, gl_img, 0); bindTexture(gl_img); display(); imshow("camera", img); int key = waitKey(10); switch(key){ case 'q': exit(1); case 27: exit(1); default: break; } // Reset arrays that hold the indices of pieces resetIndices(); // Reset transformation matrices initMatrices(); cout << "==================================================================" << endl; } }
3ac978bc4157686dd266449b887ab62fa0b9e271
ec64118889b66820893a51e3bd62c9af651a0bae
/100517/J.cpp
c03e616cb5ca24bd60f8799d76dd3744c8f7ab45
[]
no_license
ferambot/Heuristics-CodeForces-GYM
e237309bb84bc09afbefefe408985e8a9dfa8a0b
6600d929b24d4d540c921a2995a138c180b2acdf
refs/heads/master
2018-05-18T22:14:29.665971
2016-06-13T05:52:41
2016-06-13T05:52:41
61,010,468
0
0
null
2016-06-13T05:52:42
2016-06-13T05:52:42
null
UTF-8
C++
false
false
2,630
cpp
J.cpp
//karanaggarwal #include<bits/stdc++.h> using namespace std; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); } #else #define trace(...) #endif #define si(x) scanf("%d",&x) #define F first #define S second #define PB push_back #define MP make_pair #define REP(i,a,b) for(int i = (int)a; i < (int)b; i++) #define all(v) (v).begin(),(v).end() typedef long long LL; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<PII> VPII; const int mod = 1000000007; inline void add(int &x, int y){x+=y; if(x>=mod)x-=mod; if(x<0)x+=mod;} inline int mul(int x, int y){ return ((LL)x * y)%mod;} int gcd(int a, int b){ if(b)return gcd(b,a%b); return a;} int power(int a ,int p){int ret = 1; while(p){if(p&1)ret=mul(ret,a); a=mul(a,a); p/=2;}return ret;} int phi(int n){ int ret=n; int i = 2; if(n%i==0){ ret-=ret/i; while(n%i==0)n/=i;} for(i=3; i*i<=n; i++)if(n%i==0){ ret-=ret/i; while(n%i==0)n/=i;} if(n>1)ret-=ret/n;return ret; } #ifdef ONLINE_JUDGE FILE *fin = freopen("jubilee.in","r",stdin); FILE *fout = freopen("jubilee.out","w",stdout); #endif int V[301]; int G[301]; int process(int x, int y){ return 6-(x+y); } int main() { while(1) { int N; si(N); if(N==0)return 0; if(N<=3) { cout<<1<<endl; for(int i = 0; i<N; i++) cout<<1<<" "; cout<<endl; for(int i = 0; i<N; i++) cout<<1<<" "; cout<<endl; continue; } if(N<=6) { cout<<2<<endl; int i = 0; for(;i<3;i++) cout<<"1 "; for(;i<N;i++) cout<<"2 "; cout<<endl; for(int i = 0; i<N; i++) cout<<(i%2)+1<<" "; cout<<endl; continue; } int i = 0; int c = 0; if(N%3==1) { V[i++] = ++c; c%=2; V[i++] = ++c; c%=2; V[i++] = ++c; c%=2; V[i++] = ++c; c%=2; } while(i<N) { V[i++] = ++c; c%=3; } for(int i = 0; i<N; i++) G[i] = process(V[i],V[(i+1)%N]); cout<<3<<endl; for(int i =0; i<N; i++) cout<<V[i]<<" "; cout<<endl; for(int i =0; i<N; i++) cout<<G[i]<<" "; cout<<endl; } return 0; }
ce0d8cb68709387b3095145aff7cb8996e3ff68e
3839bf85e06352f84911a65b6db9eff9a62f1ae4
/devsoundextensions/ciextnfactoryplugins/ciplatformmsghndlrplugin/src/ciplatformmsghndlrplugin.cpp
14ae1415f5cf7dd707bf06aa67a3e32ff4eb97e3
[]
no_license
SymbianSource/oss.FCL.sf.os.mmaudio
8891725edbe3d5b81ef646197260e74d16838da1
a39c075cce88671b23d13598fda2f7cbf008f3bb
refs/heads/master
2021-06-07T22:01:56.400545
2010-11-02T12:28:51
2010-11-02T12:28:51
72,878,426
0
0
null
null
null
null
UTF-8
C++
false
false
6,864
cpp
ciplatformmsghndlrplugin.cpp
/* * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Class definition of plugin implementing message handler * interface. * */ // Include files #include "ciplatformmsghndlrplugin.h" #include "ciplatformmsghndlrplugin.hrh" #include "citraces.h" #include <ecom.h> #include <CustomInterfaceBuilder.h> #include <CustomInterfaceCustomCommandParser.h> #define RET_ERR_IF_ERR(s) if(s!=KErrNone) return s // --------------------------------------------------------------------------- // Constructs and returns an application object. // --------------------------------------------------------------------------- // MCIMsgHndlrIntfc* CCIPlatformMsgHndlrPlugin::NewL() { DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::NewL")); CCIPlatformMsgHndlrPlugin* self = new (ELeave) CCIPlatformMsgHndlrPlugin; CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); MCIMsgHndlrIntfc* ptr = static_cast<MCIMsgHndlrIntfc*>(self); return ptr; } // --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // CCIPlatformMsgHndlrPlugin::~CCIPlatformMsgHndlrPlugin() { // No Impl } // --------------------------------------------------------------------------- // Called by framework when plugin is constructed // --------------------------------------------------------------------------- // TInt CCIPlatformMsgHndlrPlugin::Initialize( MCustomInterface& aCustomInterface, TUid aDestructorKey ) { TInt status(KErrNone); iMCustomInterface = &aCustomInterface; iDestructorKey = aDestructorKey; iCIFWObjectsInitialized = EFalse; return status; } // --------------------------------------------------------------------------- // Called by framework when it needs to know plugin implementation uid // --------------------------------------------------------------------------- // TUid CCIPlatformMsgHndlrPlugin::ImplementationUid() { TUid implId = {KUidCCIPlatformMsgHndlrPlugin}; return implId; } // --------------------------------------------------------------------------- // Called by framework forwarding request to handle aMessage // --------------------------------------------------------------------------- // TBool CCIPlatformMsgHndlrPlugin::HandleMessage( const RMmfIpcMessage& aMessage ) { DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::HandleMessage")); TBool handled(EFalse); // Initialize Custom Interface Framework Objects if not done already if (!iCIFWObjectsInitialized) { TRAPD( status, InitializeCIFWObjectsL()); if ( status != KErrNone ) { aMessage.Complete(status); handled = ETrue; } } // Get the destination info from the client into TMMFMessage. TMMFMessage message(aMessage); TRAPD(status, message.FetchDestinationL()); if(status != KErrNone) DEB_TRACE1(_L("CI* CCIPlatformMsgHndlrPlugin::HandleMessage status:%d"),status); // Check if Custom Command Parser manager can handle the message... if (!handled) { handled = iCustomCommandParserManager->HandleRequest(message); } // Check if the aMessage is for one of the MMF Objects if (!handled) { CMMFObject* object = NULL; // Try to find MMFObject that handles this request TInt status = iMMFObjectContainer->FindMMFObject(message.Destination(), object); // If found, give message to the MMFObject if ( KErrNone == status ) { object->HandleRequest(message); handled = ETrue; } } return handled; } // --------------------------------------------------------------------------- // Called by framework when plugin is to be deleted // --------------------------------------------------------------------------- // void CCIPlatformMsgHndlrPlugin::Close() { DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::Close")); iMCustomInterface = NULL; delete iCustomCommandParserManager; iCustomCommandParserManager = NULL; delete iMMFObjectContainer; iMMFObjectContainer = NULL; iCIFWObjectsInitialized = EFalse; REComSession::DestroyedImplementation(iDestructorKey); delete this; } // --------------------------------------------------------------------------- // Called by framework to get handle to custom interface builder // --------------------------------------------------------------------------- // const TMMFMessageDestination& CCIPlatformMsgHndlrPlugin::GetCustomInterfaceBuilderL() { // return the handle return iCustomInterfaceBuilder->Handle(); } // --------------------------------------------------------------------------- // Constructor // --------------------------------------------------------------------------- // CCIPlatformMsgHndlrPlugin::CCIPlatformMsgHndlrPlugin() :iMCustomInterface(NULL), iCIFWObjectsInitialized(EFalse), iMMFObjectContainer(NULL), iCustomCommandParserManager(NULL), iCustomInterfaceBuilder(NULL) { // No Impl } // --------------------------------------------------------------------------- // Second phase constructor // --------------------------------------------------------------------------- // void CCIPlatformMsgHndlrPlugin::ConstructL() { // No Impl } // --------------------------------------------------------------------------- // Initializes objects required for Custom Interface Framework. // --------------------------------------------------------------------------- // void CCIPlatformMsgHndlrPlugin::InitializeCIFWObjectsL() { DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::InitializeCIFWObjectsL")); iMMFObjectContainer = new(ELeave) CMMFObjectContainer; iCustomCommandParserManager = CMMFCustomCommandParserManager::NewL(); CCustomInterfaceCustomCommandParser* ciccParser = CCustomInterfaceCustomCommandParser::NewL(*this); CleanupStack::PushL( ciccParser ); iCustomCommandParserManager->AddCustomCommandParserL(*ciccParser); CleanupStack::Pop( ciccParser ); iCustomInterfaceBuilder = CCustomInterfaceBuilder::NewL( *iMMFObjectContainer, *iMCustomInterface); iMMFObjectContainer->AddMMFObject(*iCustomInterfaceBuilder); iCIFWObjectsInitialized = ETrue; }
fa813433f52cd830a543d1897523cbdd12e2c2d4
98b1e51f55fe389379b0db00365402359309186a
/homework_6/problem_2/100x100/0.525/T
bfd89b3ff5da66491ccf8a64a466dd9009a51872
[]
no_license
taddyb/597-009
f14c0e75a03ae2fd741905c4c0bc92440d10adda
5f67e7d3910e3ec115fb3f3dc89a21dcc9a1b927
refs/heads/main
2023-01-23T08:14:47.028429
2020-12-03T13:24:27
2020-12-03T13:24:27
311,713,551
1
0
null
null
null
null
UTF-8
C++
false
false
88,967
T
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 8 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.525"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 1 0 0 0]; internalField nonuniform List<scalar> 10000 ( 50 4.65083 -4.65066 -1.17959 1.17882 0.450754 -0.448478 -0.220647 0.215573 0.129799 -0.120281 -0.0889922 0.0731887 0.0692099 -0.0453631 -0.0588394 0.0256978 0.0522364 -0.00961919 -0.0461222 -0.00446027 0.0384227 0.0164297 -0.0280367 -0.0251239 0.0149845 0.0289205 -0.000609479 -0.0265101 -0.0124701 0.0178087 0.0209349 -0.00471752 -0.0219742 -0.00876718 0.014869 0.0175769 -0.0022041 -0.017767 -0.0103334 0.00907278 0.0162551 0.00384837 -0.012103 -0.0131615 0.000546732 0.0126557 0.0102325 -0.00284799 -0.0119897 -0.00820037 0.00351475 0.0108663 0.00716593 -0.00300708 -0.00956524 -0.0069051 0.0016569 0.00803412 0.00701779 0.000266247 -0.00606788 -0.00698222 -0.00240404 0.0035216 0.00623246 0.0041795 -0.000563306 -0.004375 -0.00483842 -0.00213392 0.0015569 0.00381603 0.00352002 0.00126115 -0.00136342 -0.00285395 -0.00263721 -0.0011311 0.000653266 0.00182931 0.00194843 0.00122348 0.000103009 -0.000791909 -0.00123197 -0.00106596 -0.00061159 6.76019e-06 0.000411933 0.000644139 0.000567217 0.000381751 0.000110169 -0.000123174 -0.000243467 -0.000333362 -0.000233282 -0.000230954 -1.01792e-05 95.3492 49.9999 10.481 -4.65011 -2.80898 1.1769 1.11964 -0.443924 -0.565791 0.206745 0.338922 -0.105337 -0.231411 0.050336 0.173706 -0.0132669 -0.13743 -0.0159671 0.109041 0.0403049 -0.0815072 -0.0591748 0.0516347 0.0701586 -0.0193621 -0.0703502 -0.012426 0.0579207 0.0384341 -0.0338065 -0.0524178 0.00293272 0.0497229 0.0259539 -0.030315 -0.0426526 0.000828164 0.0399933 0.0263054 -0.0187281 -0.0377925 -0.0104224 0.0271895 0.0306999 -0.000890165 -0.029191 -0.0234025 0.00718893 0.0279024 0.0180509 -0.00948354 -0.0254088 -0.0151263 0.00892203 0.0226116 0.0142527 -0.00632932 -0.01954 -0.0146297 0.0022695 0.0157379 0.0151708 0.00263515 -0.0106956 -0.0145926 -0.00734057 0.00438876 0.0117394 0.0102594 0.0021731 -0.00630989 -0.00976677 -0.00684719 -0.000302807 0.00547935 0.00738509 0.00505007 0.000484249 -0.00357478 -0.00520214 -0.004134 -0.00139227 0.00139596 0.00307628 0.00313637 0.00202718 0.000362426 -0.000977637 -0.00173246 -0.0016632 -0.00116503 -0.000389807 0.000233761 0.000658271 0.000779176 0.000683283 0.000482154 0.000204837 2.59417e-05 -0.000219804 104.651 89.519 49.9998 12.1103 -4.64897 -3.47779 1.17346 1.46481 -0.436526 -0.775182 0.1935 0.48202 -0.0843319 -0.337162 0.0200235 0.254243 0.0269926 -0.196877 -0.065256 0.147578 0.0955489 -0.0979448 -0.114859 0.0455764 0.118712 0.00685428 -0.103513 -0.0523758 0.0691503 0.0815524 -0.0212464 -0.0859372 -0.0282317 0.0627115 0.0634072 -0.018715 -0.070479 -0.0290037 0.0455943 0.0586148 -0.000289831 -0.0545532 -0.0408866 0.0189683 0.0529468 0.0253643 -0.0280241 -0.0472756 -0.0150389 0.0304228 0.0413865 0.0100496 -0.0287264 -0.0367567 -0.00942091 0.0243968 0.0332747 0.0118651 -0.0179813 -0.0298882 -0.0158847 0.00969293 0.0251197 0.019582 -0.000169171 -0.017716 -0.0206523 -0.00883537 0.00761915 0.0170655 0.0143741 0.00305378 -0.0086117 -0.0136092 -0.010137 -0.00158919 0.006494 0.00992407 0.00783883 0.00232797 -0.0032583 -0.00635617 -0.00608292 -0.00337081 0.000151376 0.0027901 0.0038512 0.00323263 0.00174637 9.63066e-06 -0.00118786 -0.00174922 -0.00161625 -0.00109871 -0.000499517 6.34677e-05 0.000339028 0.000491359 0.000473295 0.000351356 101.18 104.65 87.8897 49.9997 12.7791 -4.64704 -3.82308 1.16809 1.67465 -0.425751 -0.919288 0.175245 0.589594 -0.056759 -0.420538 -0.0179465 0.317604 0.0750147 -0.240205 -0.120873 0.169128 0.153729 -0.0963759 -0.16812 0.0220034 0.158213 0.0471741 -0.121308 -0.0994514 0.061327 0.122006 0.00908446 -0.106733 -0.06979 0.0565842 0.0992154 0.0109603 -0.0844843 -0.0673019 0.0313528 0.0847841 0.033266 -0.0535044 -0.0722191 -0.00761366 0.060768 0.0574808 -0.00751928 -0.0597263 -0.0459133 0.0137189 0.0550294 0.0390465 -0.0132987 -0.0488712 -0.0362968 0.00812966 0.0415495 0.0359692 0.000333939 -0.0323146 -0.0356716 -0.0104328 0.0203711 0.0326504 0.0196067 -0.00608208 -0.0246421 -0.0242994 -0.00792868 0.0115094 0.0212672 0.0168361 0.00311843 -0.0104162 -0.0161879 -0.0124246 -0.0028387 0.00655801 0.0111734 0.00974133 0.00422838 -0.00205742 -0.00616926 -0.00697544 -0.00486404 -0.00150501 0.00164863 0.00335126 0.00359613 0.00253499 0.00111097 -0.000281499 -0.00109425 -0.00131628 -0.00117742 -0.000615762 -0.000344661 0.000147656 0.000132165 98.821 102.809 104.65 87.2209 49.9995 13.1245 -4.64412 -4.03333 1.16042 1.8198 -0.411097 -1.02887 0.151456 0.676262 -0.0222442 -0.48865 -0.0635511 0.367046 0.130088 -0.268706 -0.181162 0.174289 0.212161 -0.0777732 -0.215511 -0.0168097 0.185211 0.0974624 -0.121525 -0.147829 0.0348928 0.153493 0.0531614 -0.110212 -0.114542 0.0308941 0.125302 0.0537339 -0.0794905 -0.105042 -0.00156074 0.0961553 0.073955 -0.0319351 -0.0938372 -0.0465051 0.0483459 0.0840731 0.0281267 -0.0528553 -0.0737328 -0.0191491 0.0499926 0.0654855 0.0178768 -0.0423715 -0.0591717 -0.0220255 0.0310044 0.0529577 0.0289211 -0.0163253 -0.0442639 -0.0351831 -0.000473521 0.0309302 0.0367401 0.0162341 -0.0129361 -0.0300606 -0.025739 -0.00589745 0.0148858 0.024052 0.0181994 0.00316075 -0.011248 -0.0175428 -0.0140157 -0.00434547 0.00562413 0.0111797 0.0108356 0.00600978 -0.000170753 -0.00496731 -0.00676046 -0.00576417 -0.00296015 1.79889e-05 0.00227375 0.00308831 0.00284992 0.00173892 0.000584464 -0.000426817 -0.000997182 -0.000976644 -0.000978091 -0.000242048 99.5494 98.8226 103.478 104.648 86.8755 49.9992 13.335 -4.64001 -4.17934 1.15009 1.93125 -0.3921 -1.11884 0.121685 0.749458 0.0194446 -0.545044 -0.116543 0.403999 0.191205 -0.282821 -0.244155 0.163467 0.267966 -0.0434229 -0.253712 -0.0679751 0.196916 0.153008 -0.103242 -0.191628 -0.00797746 0.170666 0.105382 -0.0939462 -0.154791 -0.0118998 0.135009 0.102255 -0.0536897 -0.133012 -0.048004 0.0869992 0.111712 0.00787271 -0.0970946 -0.0878302 0.0153897 0.0945947 0.0694829 -0.0246268 -0.0868107 -0.0588381 0.0236045 0.0771006 0.0548502 -0.0152532 -0.0658269 -0.0548177 0.00176798 0.0516988 0.0549832 0.0143746 -0.033323 -0.0509957 -0.0292767 0.0110832 0.0391818 0.0373912 0.0110869 -0.0190925 -0.0334852 -0.0256712 -0.00383304 0.0170753 0.0254662 0.0189526 0.00368727 -0.0109003 -0.0177016 -0.0150593 -0.00612267 0.00370099 0.0100386 0.0109718 0.00752034 0.00199883 -0.00286534 -0.00562225 -0.00575459 -0.00409159 -0.00157588 0.000633685 0.00208969 0.00246295 0.0022 0.00132483 0.00056992 -0.000209828 -0.000716668 100.449 98.8804 98.8257 103.823 104.646 86.6649 49.9989 13.4815 -4.63452 -4.29223 1.13675 2.02413 -0.368331 -1.19693 0.0855672 0.813042 0.0683919 -0.591379 -0.176453 0.428917 0.257077 -0.28262 -0.307634 0.13718 0.318198 0.00492357 -0.279713 -0.128002 0.191402 0.208732 -0.0669432 -0.225316 -0.0635081 0.169612 0.159085 -0.0579432 -0.183226 -0.0667217 0.124012 0.147856 -0.0089623 -0.143363 -0.0997316 0.0556652 0.136407 0.0590249 -0.077315 -0.120171 -0.0326133 0.0822089 0.104355 0.0202819 -0.0771222 -0.0924747 -0.0192549 0.0657544 0.0840355 0.0261852 -0.0493388 -0.0761947 -0.0373186 0.0281789 0.0650162 0.0478993 -0.00361849 -0.0470497 -0.0520254 -0.0201072 0.0217885 0.0442681 0.0355151 0.00570726 -0.0236069 -0.0350162 -0.0248428 -0.00246505 0.0177992 0.025629 0.0193755 0.00484537 -0.00931726 -0.0166852 -0.0153851 -0.0079877 0.00109928 0.00771663 0.0100451 0.00817949 0.0040742 -0.000389789 -0.00346727 -0.00470117 -0.00421809 -0.00269922 -0.00101972 0.000453015 0.0012539 0.00148639 0.00148512 0.000894361 100.221 100.445 98.5351 98.8305 104.034 104.642 86.5183 49.9985 13.5952 -4.62748 -4.38729 1.12007 2.10642 -0.339404 -1.26731 0.0428225 0.868962 0.124533 -0.628266 -0.242591 0.441752 0.326171 -0.268101 -0.369203 0.0962312 0.359966 0.06499 -0.290996 -0.192886 0.167764 0.25946 -0.01454 -0.244118 -0.126595 0.148225 0.207192 -0.00468411 -0.193787 -0.126481 0.0909567 0.181802 0.0493366 -0.130976 -0.146795 0.00502697 0.1399 0.111327 -0.0350206 -0.133247 -0.085512 0.0458008 0.121048 0.0714667 -0.0429984 -0.107576 -0.0672878 0.0305918 0.09293 0.0691169 -0.0112586 -0.0749018 -0.0717776 -0.0120775 0.0510295 0.0691704 0.0345 -0.0211454 -0.0557872 -0.0484986 -0.0100146 0.0301443 0.0463418 0.0323056 0.00121095 -0.0261416 -0.0350145 -0.0238276 -0.00211149 0.0170417 0.0246899 0.0194633 0.00651547 -0.00675775 -0.014487 -0.01484 -0.00934746 -0.0017394 0.00474967 0.00789471 0.00775242 0.00509419 0.00178132 -0.00115523 -0.00279681 -0.00311816 -0.00265768 -0.00142836 -0.000708273 0.000297648 0.000412602 99.7841 100.566 100.438 98.325 98.8376 104.18 104.637 86.4045 49.9981 13.6915 -4.6187 -4.47269 1.09974 2.18257 -0.304971 -1.33222 -0.00674305 0.918085 0.187652 -0.655726 -0.314063 0.442234 0.396743 -0.239363 -0.42637 0.0418035 0.390574 0.133981 -0.28568 -0.258264 0.126222 0.300227 0.0507176 -0.24439 -0.191198 0.106434 0.2429 0.0610941 -0.182403 -0.182925 0.0377209 0.196576 0.113104 -0.094407 -0.179247 -0.0578735 0.117768 0.153286 0.0239185 -0.120395 -0.130741 -0.00938604 0.111597 0.115398 0.0099335 -0.0959926 -0.106003 -0.0211087 0.0746554 0.0984184 0.0382829 -0.0472402 -0.0870501 -0.0555644 0.0146319 0.0666629 0.0652369 0.0184081 -0.0355144 -0.0595049 -0.0422806 -0.000864565 0.0355833 0.0460983 0.0288466 -0.0017786 -0.0267403 -0.0339079 -0.0229423 -0.00282435 0.0150147 0.0227524 0.0191824 0.00830796 -0.00354379 -0.0114767 -0.0132668 -0.00997424 -0.00400795 0.00163482 0.00532619 0.00622581 0.00516345 0.00279303 0.000571884 -0.00120837 -0.0020058 -0.00187912 -0.00166484 -0.000395795 99.8703 99.7925 100.776 100.427 98.1796 98.8472 104.293 104.631 86.3082 49.9977 13.7786 -4.608 -4.55307 1.07545 2.2551 -0.264727 -1.39283 -0.0632348 0.960634 0.257387 -0.67345 -0.389781 0.430038 0.466876 -0.196722 -0.476627 -0.0244882 0.407634 0.208635 -0.262653 -0.319596 0.0681512 0.326579 0.124417 -0.223922 -0.250813 0.0462672 0.260367 0.132839 -0.147531 -0.227628 -0.0307146 0.187005 0.172621 -0.0363002 -0.188877 -0.122911 0.0703671 0.174407 0.0892384 -0.0803327 -0.156186 -0.0726385 0.0741424 0.138943 0.0698306 -0.0567129 -0.122041 -0.0756726 0.0307822 0.101876 0.0836081 0.000860305 -0.0743168 -0.085714 -0.0328356 0.0378466 0.0741768 0.0558788 0.00281817 -0.0454959 -0.0592208 -0.035233 0.00617907 0.0381693 0.0443649 0.025897 -0.00300162 -0.0256272 -0.0319761 -0.022329 -0.00442494 0.011875 0.0199895 0.0183167 0.0100234 -0.000179769 -0.00780621 -0.0109564 -0.00961399 -0.00564079 -0.00101882 0.00255179 0.00436357 0.00437642 0.00337261 0.00161555 0.000375106 -0.000917171 -0.00132614 100.121 99.6609 99.8052 100.92 100.413 98.0677 98.8598 104.388 104.623 86.2209 49.9972 13.8613 -4.59521 -4.63117 1.04691 2.32547 -0.218408 -1.44966 -0.126667 0.996448 0.333226 -0.680964 -0.468479 0.404904 0.53453 -0.140788 -0.517536 -0.100584 0.40919 0.285311 -0.221664 -0.37238 -0.00393966 0.334874 0.201241 -0.182165 -0.298996 -0.0282528 0.255323 0.20281 -0.0904516 -0.253039 -0.106778 0.151125 0.217938 0.0368062 -0.170726 -0.178518 0.00308512 0.16739 0.148153 -0.0178382 -0.153071 -0.129985 0.0139056 0.132948 0.121451 0.00321884 -0.107382 -0.116838 -0.0284294 0.0746861 0.108628 0.055171 -0.0344455 -0.0892708 -0.0741276 -0.00891005 0.054825 0.0746961 0.044103 -0.010118 -0.0510301 -0.0563317 -0.0287732 0.0105983 0.0382835 0.0417733 0.0238391 -0.00252554 -0.0229772 -0.0293489 -0.0217571 -0.00669703 0.00795592 0.016253 0.0167521 0.011055 0.00312133 -0.00392347 -0.00773957 -0.00822189 -0.00618848 -0.00296156 -0.000145789 0.00203143 0.00272628 0.00267892 0.00218062 0.00098413 100.089 100.106 99.5173 99.8229 101.03 100.395 97.9744 98.8757 104.474 104.614 86.1381 49.9966 13.9424 -4.58016 -4.70866 1.01386 2.39446 -0.165798 -1.50278 -0.196958 1.02513 0.414512 -0.677737 -0.54873 0.366715 0.597589 -0.0725104 -0.54682 -0.183998 0.393823 0.360109 -0.16339 -0.412388 -0.086495 0.322552 0.275302 -0.120343 -0.329917 -0.111383 0.225586 0.262853 -0.0152662 -0.253475 -0.181165 0.0906624 0.240375 0.115268 -0.124161 -0.213673 -0.074304 0.129842 0.187855 0.0568031 -0.11829 -0.167326 -0.0575162 0.0950537 0.1501 0.070003 -0.0622912 -0.130656 -0.0865703 0.0218208 0.102532 0.097608 0.0213871 -0.0618897 -0.0926203 -0.0568449 0.0122418 0.0649321 0.0703571 0.0324268 -0.0193651 -0.0527669 -0.0521187 -0.0237375 0.0124036 0.0363686 0.0387053 0.0225978 -0.000613667 -0.0191108 -0.0258742 -0.0209337 -0.00893134 0.00353052 0.0119035 0.0139879 0.0111217 0.00533747 -0.000241345 -0.0042801 -0.00577296 -0.00521117 -0.00366302 -0.00130832 -0.000151047 0.00138598 0.00113193 99.9263 100.232 100.086 99.4091 99.8461 101.121 100.372 97.8914 98.8952 104.555 104.602 86.0568 49.996 14.0237 -4.56268 -4.78658 0.976041 2.46246 -0.106727 -1.55205 -0.273934 1.04615 0.500452 -0.663256 -0.628978 0.31556 0.653919 0.00679952 -0.562453 -0.271866 0.360745 0.429025 -0.0894508 -0.435906 -0.175078 0.288355 0.340546 -0.0414486 -0.338891 -0.196113 0.171387 0.305274 0.0714152 -0.225944 -0.243977 0.0110253 0.233921 0.18767 -0.0532992 -0.219916 -0.149158 0.0651495 0.198207 0.129615 -0.0556028 -0.173847 -0.124538 0.0309184 0.145758 0.126467 0.00400028 -0.110098 -0.125888 -0.0427525 0.0641119 0.112533 0.0750121 -0.0106835 -0.0792105 -0.0871905 -0.0381563 0.028433 0.0689906 0.0634408 0.0225394 -0.0247761 -0.0516154 -0.0475414 -0.0203994 0.0118943 0.032916 0.0352389 0.0219381 0.00213478 -0.0142953 -0.0217191 -0.0193191 -0.0107313 -0.000479171 0.00715884 0.0106371 0.00974795 0.00646319 0.00210979 -0.00120286 -0.0033862 -0.00380154 -0.00309454 -0.00223111 -0.000239039 99.9307 99.9487 100.338 100.059 99.3217 99.8753 101.2 100.344 97.8146 98.9186 104.634 104.588 85.9752 49.9954 14.1065 -4.54262 -4.86556 0.933213 2.52961 -0.0410737 -1.59711 -0.357329 1.05891 0.590125 -0.637081 -0.707565 0.251763 0.701431 0.0954724 -0.562743 -0.361023 0.309864 0.48812 -0.00237257 -0.439955 -0.264599 0.232461 0.391181 0.0499215 -0.322839 -0.274756 0.0954726 0.323687 0.161102 -0.170672 -0.285991 -0.0792245 0.196302 0.242509 0.0333598 -0.193028 -0.208113 -0.0177669 0.174027 0.185677 0.0246868 -0.144849 -0.171158 -0.0466121 0.106186 0.15668 0.0753137 -0.0577843 -0.1329 -0.100041 0.0029419 0.0926176 0.107575 0.0476954 -0.036562 -0.0869266 -0.0766023 -0.0212312 0.0390366 0.0685073 0.0558419 0.0152879 -0.0267119 -0.0484628 -0.0431119 -0.0187 0.00959526 0.0282277 0.0314416 0.0213241 0.00532053 -0.00913127 -0.0167831 -0.0169678 -0.011423 -0.00387926 0.00280866 0.00672686 0.00761115 0.00618564 0.00372631 0.000947623 -0.00070211 -0.00222506 -0.002153 100.046 99.8255 99.9787 100.423 100.025 99.2475 99.9109 101.271 100.31 97.7412 98.9462 104.712 104.572 85.8922 49.9947 14.1914 -4.5198 -4.94598 0.885152 2.59585 0.03124 -1.63753 -0.446787 1.06278 0.682494 -0.598879 -0.782757 0.175908 0.738135 0.191499 -0.546398 -0.448094 0.241815 0.533684 0.0944951 -0.422477 -0.349584 0.156539 0.422093 0.147842 -0.280614 -0.339607 0.00296735 0.313757 0.244271 -0.0912612 -0.299879 -0.169346 0.129547 0.269956 0.124021 -0.134041 -0.239456 -0.105764 0.116489 0.212203 0.107537 -0.0832851 -0.184814 -0.120247 0.0380887 0.150463 0.132705 0.0141184 -0.102932 -0.131895 -0.0631559 0.041973 0.106422 0.0928274 0.0212638 -0.05444 -0.0871573 -0.0641746 -0.00789191 0.0444581 0.065074 0.0488054 0.0108758 -0.0258047 -0.0439228 -0.0390227 -0.0181793 0.00596245 0.0227339 0.0269929 0.0204473 0.00803754 -0.00383237 -0.0115971 -0.0134106 -0.0108635 -0.00582761 -0.000705879 0.00275816 0.00471178 0.00432802 0.00354982 0.00203443 0.000556629 100.059 100.014 99.7441 100.016 100.492 99.9831 99.1829 99.9532 101.337 100.27 97.6698 98.9783 104.79 104.553 85.807 49.994 14.279 -4.49408 -5.02806 0.83165 2.66099 0.110245 -1.67277 -0.541863 1.05715 0.776414 -0.548453 -0.852777 0.0888516 0.762187 0.292556 -0.512589 -0.529583 0.157976 0.562403 0.197091 -0.382489 -0.424464 0.0637153 0.429239 0.245435 -0.213205 -0.383623 -0.0989777 0.273762 0.31135 0.00552037 -0.281254 -0.247708 0.0399882 0.263448 0.205239 -0.0494338 -0.235315 -0.183624 0.0333442 0.201333 0.176082 0.000352249 -0.159619 -0.172232 -0.0439952 0.106554 0.159641 0.0868463 -0.042132 -0.126875 -0.113539 -0.0245878 0.0700032 0.107952 0.0736814 -0.000711768 -0.0645182 -0.0825319 -0.0523542 0.00117595 0.0456261 0.059976 0.0429792 0.00900258 -0.0226853 -0.0384955 -0.0350665 -0.0183855 0.00181376 0.0166343 0.0221578 0.0185596 0.0100187 0.00033927 -0.00639093 -0.00961597 -0.0087899 -0.00604144 -0.00256717 0.00066982 0.00181359 0.00319878 0.00167041 99.9738 100.139 99.974 99.6796 100.062 100.549 99.9343 99.1257 100.002 101.399 100.225 97.5997 99.0151 104.87 104.531 85.719 49.9932 14.3698 -4.46528 -5.11188 0.772514 2.72476 0.19592 -1.70225 -0.64202 1.04143 0.870639 -0.485773 -0.915831 -0.00826151 0.77195 0.396038 -0.461007 -0.601989 0.0604687 0.571522 0.300792 -0.320197 -0.4839 -0.0415311 0.409992 0.335328 -0.123796 -0.401095 -0.201728 0.204961 0.353765 0.110302 -0.229428 -0.303267 -0.0623016 0.220917 0.263917 0.0495257 -0.193346 -0.236714 -0.0620707 0.152126 0.215109 0.0898155 -0.0982584 -0.188687 -0.120853 0.0335977 0.146805 0.140063 0.0336635 -0.0843116 -0.131366 -0.085983 0.00905418 0.0863388 0.101134 0.0544753 -0.0166156 -0.0681181 -0.0754052 -0.0426064 0.00608108 0.0435174 0.0540971 0.0384435 0.00922857 -0.0180322 -0.0323368 -0.0311679 -0.0186349 -0.00252172 0.010629 0.0168047 0.0161872 0.0106191 0.00377451 -0.00246382 -0.00568957 -0.00695111 -0.00544871 -0.00353809 -0.00125018 0.00116215 99.9473 100.015 100.199 99.9258 99.629 100.115 100.597 99.8781 99.0752 100.059 101.457 100.173 97.5303 99.0569 104.952 104.507 85.6279 49.9924 14.4638 -4.43326 -5.19745 0.707572 2.78683 0.288192 -1.72537 -0.746632 1.01512 0.96384 -0.410995 -0.970153 -0.114003 0.766056 0.499118 -0.391915 -0.661931 -0.0478861 0.559012 0.400608 -0.237066 -0.523115 -0.153578 0.363428 0.410199 -0.0176526 -0.388261 -0.295902 0.111675 0.364971 0.212032 -0.147792 -0.327102 -0.164659 0.145458 0.289427 0.148295 -0.117591 -0.253768 -0.153004 0.0713164 0.214487 0.16632 -0.012035 -0.163359 -0.173211 -0.0514267 0.0952751 0.15772 0.103077 -0.0152787 -0.109426 -0.12169 -0.0564614 0.0343764 0.0926358 0.089913 0.0380021 -0.0263075 -0.0668869 -0.0674648 -0.0354469 0.00734959 0.0389951 0.0477187 0.0349392 0.0107938 -0.0121855 -0.0256096 -0.0266887 -0.0185826 -0.00632879 0.00454376 0.0111681 0.0126753 0.0102426 0.00590888 0.0014803 -0.0020514 -0.00346509 -0.0045743 -0.00321387 100.01 99.8895 100.065 100.244 99.8704 99.5908 100.175 100.635 99.8147 99.0311 100.122 101.512 100.114 97.4618 99.104 105.035 104.48 85.5334 49.9915 14.5614 -4.39787 -5.28471 0.636671 2.8468 0.386936 -1.74153 -0.854992 0.977756 1.05463 -0.324475 -1.01404 -0.226677 0.743459 0.598822 -0.306161 -0.706287 -0.163648 0.5237 0.491425 -0.135806 -0.53823 -0.265971 0.290501 0.463359 0.098199 -0.343778 -0.372248 0.00104207 0.341341 0.299184 -0.0436682 -0.313781 -0.25346 0.0452438 0.27551 0.231286 -0.0182453 -0.229277 -0.22236 -0.0275079 0.171781 0.212675 0.0811962 -0.0997785 -0.18682 -0.127268 0.0169828 0.133189 0.145484 0.0601857 -0.0532602 -0.119037 -0.104066 -0.03001 0.0506703 0.0915913 0.0774244 0.0255417 -0.0305578 -0.0623958 -0.0596088 -0.030683 0.00593034 0.0327202 0.0409233 0.0315917 0.0128497 -0.0061316 -0.0181711 -0.0214319 -0.0168823 -0.00885329 -0.000422683 0.00538983 0.00784723 0.00780805 0.00530972 0.00333546 0.000688772 -0.000470222 100.047 99.9598 99.8499 100.121 100.273 99.8085 99.5646 100.242 100.664 99.7445 98.9937 100.193 101.563 100.049 97.3939 99.1565 105.12 104.449 85.4354 49.9906 14.6626 -4.35896 -5.37356 0.559672 2.90427 0.491983 -1.75011 -0.966324 0.929006 1.14157 -0.226765 -1.04591 -0.344352 0.703467 0.692105 -0.205179 -0.732313 -0.282871 0.465356 0.568248 -0.0202769 -0.526532 -0.37181 0.194062 0.489301 0.215465 -0.268979 -0.422545 -0.117564 0.282724 0.361103 0.0723771 -0.262302 -0.316009 -0.0673981 0.221546 0.284436 0.0897852 -0.164882 -0.256067 -0.126317 0.0932482 0.217335 0.160955 -0.0109349 -0.156522 -0.174067 -0.0681687 0.0717792 0.147603 0.119289 0.0201573 -0.0781322 -0.11713 -0.0839357 -0.00931384 0.0589378 0.086013 0.0657538 0.0173035 -0.030605 -0.0559493 -0.0523135 -0.0276609 0.0028571 0.0256692 0.0337732 0.0280436 0.0140867 -0.000732726 -0.0115167 -0.015465 -0.0141245 -0.00870423 -0.00319027 0.00179266 0.00430566 0.004508 0.00431971 0.00127434 100.004 100.083 99.9038 99.8273 100.182 100.288 99.7416 99.5505 100.315 100.683 99.6679 98.9633 100.27 101.61 99.9767 97.327 99.2147 105.207 104.415 85.3336 49.9896 14.7675 -4.31638 -5.46387 0.476447 2.95878 0.603119 -1.75053 -1.07978 0.868612 1.22321 -0.118619 -1.06427 -0.464881 0.645769 0.775917 -0.0909626 -0.737738 -0.40123 0.384739 0.626431 0.104655 -0.486676 -0.46414 0.0787593 0.484155 0.32517 -0.167885 -0.440408 -0.23334 0.192652 0.389242 0.187634 -0.176455 -0.342312 -0.177554 0.132944 0.297571 0.189204 -0.0694254 -0.245907 -0.206059 -0.00709106 0.177209 0.208808 0.0835456 -0.0878874 -0.178731 -0.137666 -0.0105419 0.10771 0.143732 0.0879734 -0.0118829 -0.0909039 -0.108254 -0.0651908 0.00474401 0.0608956 0.078174 0.0560916 0.0129153 -0.0275505 -0.0485457 -0.0457281 -0.0259807 -0.00101561 0.0184074 0.0268368 0.0242802 0.0147332 0.00331101 -0.00578038 -0.0107083 -0.0108741 -0.0087087 -0.00407714 -0.00108617 0.00246664 0.0034876 99.9608 100.06 100.1 99.8445 99.8213 100.247 100.289 99.6711 99.5489 100.392 100.692 99.5855 98.9405 100.354 101.652 99.8978 97.2613 99.2788 105.295 104.378 85.2281 49.9886 14.8763 -4.26996 -5.55547 0.386886 3.00987 0.720077 -1.74221 -1.19443 0.796432 1.29806 -0.000998283 -1.06782 -0.585918 0.570471 0.847277 0.033942 -0.72087 -0.514135 0.283631 0.661905 0.233288 -0.418848 -0.536368 -0.0491417 0.44607 0.418304 -0.0470589 -0.42198 -0.334992 0.0782203 0.378248 0.288598 -0.0646626 -0.326581 -0.269656 0.0207097 0.26624 0.263054 0.0421732 -0.191363 -0.250297 -0.109909 0.09873 0.212579 0.161703 0.00372493 -0.13851 -0.172293 -0.0912856 0.0363817 0.125268 0.128516 0.058144 -0.0340338 -0.0941313 -0.0962329 -0.0500207 0.0124625 0.0581594 0.069484 0.0486681 0.0118103 -0.0222154 -0.0403484 -0.0396407 -0.0249571 -0.00546358 0.0110218 0.0196584 0.020077 0.01469 0.00662206 -0.000399313 -0.0055297 -0.00736956 -0.006925 -0.00584852 -0.00253635 99.9835 99.9468 100.117 100.1 99.7845 99.8315 100.312 100.275 99.5987 99.5601 100.472 100.69 99.4981 98.926 100.444 101.689 99.8121 97.1972 99.3488 105.386 104.337 85.1187 49.9875 14.9889 -4.21957 -5.64818 0.290903 3.05703 0.84253 -1.7246 -1.30928 0.712454 1.36464 0.124913 -1.05545 -0.704957 0.478132 0.903365 0.166471 -0.680713 -0.616905 0.164853 0.671429 0.359319 -0.324886 -0.58271 -0.182056 0.375525 0.486543 0.0847517 -0.366507 -0.411829 -0.0503746 0.326843 0.362544 0.0607214 -0.268376 -0.329685 -0.0997743 0.192914 0.297643 0.151115 -0.10033 -0.248683 -0.194189 -0.00281593 0.169614 0.20433 0.0962962 -0.0624541 -0.161592 -0.147379 -0.0458203 0.0688611 0.128252 0.108317 0.0336312 -0.0467043 -0.0906984 -0.0836489 -0.0390249 0.0148711 0.0521284 0.0603872 0.0429194 0.0127451 -0.0152935 -0.0314657 -0.0329387 -0.023525 -0.0090769 0.0037933 0.0121532 0.014409 0.01227 0.0079596 0.00261289 -0.00022074 -0.00336589 -0.00278137 100.029 99.9285 99.9525 100.171 100.081 99.727 99.8576 100.375 100.247 99.5265 99.5845 100.554 100.677 99.4067 98.9203 100.541 101.721 99.7195 97.135 99.425 105.478 104.293 85.0054 49.9864 15.1053 -4.16506 -5.74177 0.18844 3.09977 0.9701 -1.6972 -1.4233 0.616809 1.4215 0.257727 -1.02629 -0.819388 0.369784 0.941634 0.303126 -0.617054 -0.704973 0.032194 0.652828 0.476176 -0.208287 -0.598663 -0.311551 0.275472 0.523036 0.217264 -0.276664 -0.454956 -0.180746 0.238306 0.399241 0.184788 -0.173111 -0.347467 -0.210911 0.0871231 0.285315 0.238022 0.0117946 -0.199669 -0.241805 -0.106178 0.0882112 0.200188 0.166614 0.0302277 -0.107686 -0.162337 -0.11428 -0.00795914 0.0872757 0.121601 0.0878692 0.0158545 -0.0515924 -0.0832703 -0.0719139 -0.031798 0.0135542 0.0440907 0.0511944 0.0378523 0.0142998 -0.00833198 -0.022449 -0.0258125 -0.0203925 -0.0108762 -0.000850207 0.00562424 0.00924107 0.00842011 0.00637562 0.00343911 -0.000282718 100.026 100.02 99.8784 99.9762 100.221 100.046 99.6747 99.8988 100.435 100.204 99.4565 99.6222 100.637 100.652 99.3123 98.9243 100.642 101.746 99.6203 97.0752 99.5076 105.571 104.244 84.8882 49.9853 15.2257 -4.1063 -5.83605 0.0794458 3.13761 1.10237 -1.65957 -1.53538 0.50976 1.46727 0.395885 -0.979746 -0.926569 0.246902 0.959896 0.440085 -0.530494 -0.774087 -0.109736 0.605151 0.577386 -0.0740595 -0.581366 -0.428928 0.151221 0.523067 0.339533 -0.158463 -0.458312 -0.299616 0.120323 0.392409 0.291995 -0.0515682 -0.318464 -0.295674 -0.0358431 0.226163 0.286687 0.124919 -0.11125 -0.241796 -0.188995 -0.0140353 0.149298 0.196711 0.115462 -0.0250067 -0.131753 -0.148559 -0.0810697 0.0194779 0.0942513 0.109938 0.0700971 0.00474999 -0.0508102 -0.0738914 -0.0618202 -0.0275343 0.00985902 0.035317 0.0422524 0.0331982 0.0155971 -0.00229309 -0.0144087 -0.0191108 -0.0167838 -0.0108867 -0.0040272 0.00202025 0.0044923 0.00687712 0.00460307 99.9844 100.072 99.9938 99.8373 100.016 100.261 99.9973 99.6309 99.9541 100.487 100.148 99.3909 99.6733 100.718 100.615 99.216 98.9384 100.748 101.765 99.5145 97.0182 99.5965 105.666 104.191 84.767 49.984 15.35 -4.04313 -5.93079 -0.0361186 3.17004 1.23889 -1.61129 -1.64443 0.391692 1.50063 0.537664 -0.915491 -1.02386 0.111384 0.956367 0.573295 -0.422446 -0.820462 -0.255665 0.52874 0.656891 0.0715053 -0.529824 -0.525783 0.0101402 0.484491 0.440844 -0.0208292 -0.419371 -0.394172 -0.0157282 0.340611 0.368138 0.0813984 -0.244596 -0.340242 -0.157271 0.128211 0.287097 0.21803 0.000500492 -0.192794 -0.2328 -0.114333 0.0629384 0.178489 0.170895 0.0640184 -0.0643142 -0.138597 -0.127818 -0.0528149 0.0363485 0.0930456 0.0966556 0.0564094 -0.000535963 -0.0460055 -0.0638528 -0.0533492 -0.0256436 0.00482782 0.0261199 0.0337386 0.0286011 0.0164518 0.00297076 -0.00751173 -0.0122898 -0.0132664 -0.00948888 -0.00610411 -0.00159429 0.00142035 99.9702 100.012 100.107 99.9525 99.8087 100.068 100.288 99.9357 99.5982 100.022 100.531 100.079 99.3318 99.7376 100.796 100.565 99.1191 98.9633 100.859 101.776 99.4025 96.9645 99.692 105.762 104.134 84.6418 49.9828 15.4782 -3.9754 -6.02572 -0.158276 3.19654 1.37914 -1.55201 -1.74926 0.263133 1.52033 0.681175 -0.833486 -1.10864 -0.0344501 0.929731 0.698549 -0.295148 -0.840925 -0.3998 0.425298 0.709342 0.221063 -0.445072 -0.59453 -0.138708 0.408044 0.51157 0.124991 -0.339563 -0.453356 -0.155774 0.247669 0.402125 0.208565 -0.134297 -0.336147 -0.257737 0.00644212 0.237387 0.272941 0.114207 -0.10358 -0.226984 -0.189572 -0.0387445 0.115796 0.181497 0.134787 0.0205895 -0.0874553 -0.133631 -0.105809 -0.0318055 0.0440616 0.086475 0.0837045 0.0467975 -0.00116792 -0.0384986 -0.0533615 -0.0460121 -0.0247865 -0.00097564 0.017103 0.024812 0.0236498 0.0157655 0.0067126 -0.00154177 -0.00664518 -0.00759954 -0.00817609 -0.00378134 100.001 99.9399 100.053 100.126 99.9005 99.7957 100.13 100.301 99.8646 99.5793 100.1 100.562 99.9976 99.2815 99.8144 100.869 100.502 99.0228 98.9995 100.973 101.778 99.2843 96.9146 99.7941 105.859 104.073 84.5126 49.9814 15.6103 -3.90296 -6.1206 -0.287017 3.21659 1.52256 -1.48142 -1.84868 0.124777 1.52524 0.82437 -0.734033 -1.17839 -0.187859 0.879235 0.8116 -0.151679 -0.833108 -0.536024 0.297951 0.730455 0.36653 -0.330314 -0.628993 -0.285068 0.297554 0.544087 0.266241 -0.224496 -0.469179 -0.284385 0.122668 0.387662 0.312466 -0.00184927 -0.282004 -0.32018 -0.119191 0.144817 0.277957 0.207046 0.00798884 -0.171703 -0.221629 -0.130982 0.0242614 0.144029 0.167185 0.0977982 -0.0111833 -0.097043 -0.121906 -0.0859912 -0.0181654 0.0446616 0.0767432 0.0717105 0.0404113 0.00118375 -0.0293511 -0.0426132 -0.0387696 -0.0238105 -0.0059394 0.00859611 0.0165299 0.0172944 0.0141535 0.00734865 0.0027638 -0.00256334 -0.0042041 100.028 99.9605 99.9277 100.102 100.127 99.8427 99.8005 100.198 100.297 99.7872 99.5763 100.186 100.58 99.9067 99.2421 99.9029 100.936 100.427 98.9287 99.0472 101.089 101.772 99.1603 96.869 99.9028 105.956 104.007 84.3794 49.98 15.7463 -3.82567 -6.21515 -0.422302 3.22969 1.66853 -1.39932 -1.94147 -0.0225246 1.51436 0.965086 -0.617795 -1.23077 -0.34574 0.804772 0.908333 0.00410073 -0.795636 -0.658187 0.151202 0.717366 0.499556 -0.190891 -0.625008 -0.418235 0.159877 0.533686 0.389831 -0.083718 -0.437931 -0.386579 -0.0207856 0.324561 0.377991 0.134378 -0.184362 -0.33314 -0.2271 0.0251012 0.230865 0.25968 0.118413 -0.0786988 -0.202438 -0.19074 -0.0722579 0.0688752 0.152204 0.144223 0.0657935 -0.0311115 -0.0967486 -0.107367 -0.0698378 -0.0108446 0.0404674 0.0653226 0.060832 0.035844 0.00495458 -0.0199 -0.0319484 -0.0311513 -0.0218944 -0.00892993 0.00165354 0.00924194 0.0112676 0.0101917 0.00794361 0.00269247 100.013 100.036 99.9156 99.9353 100.153 100.109 99.7843 99.8241 100.266 100.274 99.7073 99.5907 100.277 100.582 99.8077 99.2154 100.002 100.993 100.339 98.8383 99.107 101.207 101.757 99.031 96.8281 100.018 106.054 103.937 84.2422 49.9786 15.8862 -3.74341 -6.30909 -0.564082 3.23537 1.8164 -1.30557 -2.02645 -0.177786 1.4869 1.1011 -0.485779 -1.26372 -0.504721 0.706897 0.984926 0.167687 -0.728228 -0.760421 -0.00926718 0.668877 0.612062 -0.0339998 -0.580856 -0.527929 0.00444073 0.479186 0.48368 0.0701407 -0.360853 -0.44976 -0.166174 0.219087 0.394833 0.254728 -0.0569487 -0.293134 -0.298186 -0.100458 0.139816 0.260815 0.204008 0.0312907 -0.136454 -0.203243 -0.148528 -0.0228967 0.0950586 0.146757 0.119372 0.0414598 -0.0408721 -0.0901881 -0.0925585 -0.0576846 -0.00816247 0.0333208 0.053577 0.0506966 0.032344 0.00841846 -0.0110338 -0.0222322 -0.0235381 -0.0183583 -0.0104566 -0.00160289 0.00259847 0.00732863 0.00551838 99.9813 100.055 100.023 99.873 99.9624 100.199 100.072 99.7307 99.8664 100.331 100.233 99.6288 99.6235 100.37 100.567 99.7032 99.2033 100.111 101.04 100.24 98.7529 99.1789 101.325 101.731 98.8966 96.7927 100.14 106.151 103.862 84.1011 49.9771 16.0301 -3.65602 -6.40217 -0.712302 3.23312 1.96549 -1.20008 -2.10242 -0.339903 1.44217 1.23014 -0.339306 -1.27542 -0.661227 0.586809 1.03796 0.334076 -0.631715 -0.837379 -0.176831 0.585538 0.696701 0.131714 -0.497428 -0.605072 -0.15746 0.383121 0.537886 0.22258 -0.244117 -0.465242 -0.296078 0.0832459 0.359044 0.341217 0.0814419 -0.205329 -0.319312 -0.209021 0.0216675 0.209585 0.246237 0.133564 -0.039311 -0.165649 -0.184929 -0.106024 0.0129705 0.105918 0.133767 0.0969053 0.0253371 -0.0427896 -0.0800599 -0.0788973 -0.0490513 -0.00878212 0.0247725 0.0419494 0.0415931 0.0288189 0.0116597 -0.00423209 -0.013207 -0.0172332 -0.0141828 -0.0100449 -0.00454579 0.00114943 99.9782 99.9965 100.09 99.9915 99.8394 100.007 100.235 100.017 99.687 99.9263 100.387 100.173 99.556 99.675 100.461 100.534 99.5956 99.2073 100.227 101.076 100.13 98.6741 99.2629 101.443 101.695 98.7576 96.763 100.269 106.249 103.781 83.9559 49.9755 16.1778 -3.56333 -6.49408 -0.866889 3.22247 2.11508 -1.08284 -2.16818 -0.507632 1.37969 1.3499 -0.180029 -1.26438 -0.811515 0.44636 1.06448 0.497852 -0.508069 -0.884434 -0.34413 0.469711 0.747244 0.296548 -0.378288 -0.64242 -0.313377 0.2517 0.54564 0.358468 -0.0984055 -0.429304 -0.394113 -0.0664857 0.273723 0.380045 0.209572 -0.0829246 -0.285562 -0.280154 -0.101006 0.115773 0.235479 0.204752 0.0657988 -0.0875068 -0.172139 -0.15767 -0.0699369 0.0350208 0.105582 0.117637 0.0788242 0.016499 -0.0389175 -0.0680236 -0.0664866 -0.0429785 -0.0114253 0.0156024 0.0304383 0.0328556 0.0250377 0.0135574 0.00204154 -0.00656584 -0.0093215 -0.0116988 -0.00687088 100.005 99.9477 100.029 100.112 99.9453 99.8205 100.065 100.256 99.9491 99.6582 100.001 100.43 100.097 99.4929 99.7446 100.547 100.482 99.4879 99.2285 100.348 101.097 100.01 98.6035 99.3592 101.559 101.649 98.6146 96.7397 100.405 106.346 103.696 83.8066 49.9739 16.3295 -3.4652 -6.58451 -1.02773 3.20292 2.26437 -0.953938 -2.22254 -0.679568 1.29916 1.45805 -0.00995988 -1.22947 -0.951718 0.288108 1.06219 0.653309 -0.360468 -0.897944 -0.503307 0.325644 0.759021 0.450203 -0.229716 -0.63525 -0.450547 0.0946422 0.504111 0.463432 0.0617847 -0.34403 -0.446942 -0.210855 0.149187 0.363902 0.306782 0.0543516 -0.201685 -0.299664 -0.203794 -0.00142487 0.173619 0.228037 0.153037 0.0108586 -0.114019 -0.163548 -0.12893 -0.0430829 0.0452814 0.0978325 0.101038 0.0650444 0.0132686 -0.0314659 -0.0547442 -0.0548675 -0.0376897 -0.014328 0.00668842 0.0197518 0.0230769 0.0206995 0.0122581 0.00624193 -0.00123073 -0.00424915 100.023 99.973 99.9335 100.073 100.117 99.8902 99.8206 100.131 100.258 99.8717 99.648 100.088 100.456 100.006 99.4436 99.831 100.624 100.412 99.3832 99.2678 100.474 101.103 99.8807 98.5426 99.4673 101.672 101.591 98.468 96.7234 100.548 106.443 103.605 83.6534 49.9722 16.4851 -3.3615 -6.67313 -1.19468 3.17403 2.41254 -0.813561 -2.26438 -0.854167 1.20054 1.55229 0.168541 -1.17006 -1.07799 0.115298 1.02955 0.794678 -0.193285 -0.875563 -0.646411 0.159422 0.729425 0.58248 -0.0604996 -0.582039 -0.557028 -0.0754162 0.415168 0.525566 0.21951 -0.21763 -0.446424 -0.330387 0.00206065 0.293804 0.356682 0.183308 -0.082058 -0.263139 -0.265669 -0.117028 0.0746029 0.198087 0.200734 0.103257 -0.0275728 -0.123196 -0.146873 -0.103223 -0.0254522 0.046718 0.0859538 0.0852103 0.0547688 0.0131798 -0.0222496 -0.0417581 -0.0432539 -0.0326078 -0.0153083 -0.000413462 0.0109442 0.0150394 0.0139743 0.0117334 0.00390158 100.009 100.032 99.9333 99.9395 100.12 100.1 99.833 99.8422 100.2 100.237 99.7903 99.6594 100.181 100.463 99.9049 99.4116 99.9321 100.689 100.324 99.2847 99.3255 100.6 101.093 99.744 98.4928 99.587 101.782 101.521 98.3186 96.7144 100.697 106.538 103.509 83.4962 49.9704 16.6446 -3.25208 -6.75965 -1.36758 3.13537 2.55874 -0.661995 -2.29263 -1.02979 1.08404 1.63047 0.352839 -1.08601 -1.18662 -0.068236 0.965969 0.9164 -0.0119146 -0.816445 -0.76588 -0.021341 0.658209 0.684073 0.118652 -0.484785 -0.622913 -0.244065 0.285442 0.536997 0.357408 -0.0636558 -0.391081 -0.408393 -0.147142 0.179328 0.350403 0.281706 0.0519126 -0.1773 -0.274018 -0.206254 -0.0388613 0.122797 0.197763 0.165577 0.0624262 -0.0501603 -0.12035 -0.127452 -0.082585 -0.0157642 0.0422819 0.0722697 0.0708215 0.0470396 0.014632 -0.0130224 -0.0296014 -0.0329366 -0.0265786 -0.0161854 -0.00365676 0.00277493 0.00991674 0.0085519 99.9841 100.045 100.02 99.8949 99.9662 100.164 100.063 99.7812 99.8856 100.264 100.194 99.7113 99.694 100.276 100.446 99.7969 99.4 100.045 100.737 100.22 99.1955 99.4018 100.724 101.065 99.6012 98.4556 99.7178 101.886 101.44 98.1668 96.7133 100.852 106.633 103.408 83.3349 49.9685 16.808 -3.13679 -6.84376 -1.54627 3.08654 2.70212 -0.499591 -2.30629 -1.20472 0.95008 1.69056 0.54008 -0.977673 -1.27416 -0.258191 0.871736 1.01332 0.177434 -0.721277 -0.854914 -0.207897 0.547529 0.747201 0.295857 -0.348905 -0.6412 -0.396427 0.125731 0.494789 0.459699 0.100614 -0.286362 -0.433354 -0.27709 0.0370924 0.288097 0.332282 0.175956 -0.0584978 -0.227194 -0.250116 -0.140976 0.0208116 0.145996 0.182341 0.13111 0.0331672 -0.0595728 -0.110223 -0.108313 -0.0674393 -0.0120461 0.0340436 0.0580625 0.0577709 0.0405627 0.0168829 -0.00510074 -0.0178615 -0.0238144 -0.0200089 -0.0146499 -0.0072589 0.000408407 99.9813 99.9988 100.075 99.9891 99.8665 100.011 100.195 100.007 99.7421 99.9488 100.316 100.13 99.641 99.7517 100.367 100.406 99.6871 99.4109 100.167 100.767 100.101 99.1189 99.4961 100.845 101.02 99.4542 98.4323 99.859 101.984 101.347 98.0135 96.7207 101.015 106.725 103.3 83.1696 49.9666 16.9754 -3.01546 -6.92511 -1.73057 3.02711 2.84178 -0.326776 -2.30439 -1.37715 0.799314 1.73065 0.727186 -0.845877 -1.33739 -0.449835 0.748076 1.0808 0.367888 -0.592311 -0.907749 -0.390703 0.40192 0.766072 0.458733 -0.182985 -0.608403 -0.518329 -0.0498041 0.401362 0.513832 0.25597 -0.144158 -0.400481 -0.3685 -0.111521 0.179034 0.325602 0.267113 0.0702719 -0.134796 -0.239249 -0.208433 -0.0828829 0.059543 0.150263 0.159974 0.101972 0.0152095 -0.0592935 -0.0960301 -0.0909311 -0.0564588 -0.0125504 0.024328 0.0435292 0.0458616 0.0340687 0.0178669 0.00185891 -0.00981719 -0.0131259 -0.0161482 -0.00875247 100.003 99.9571 100.031 100.091 99.9434 99.8553 100.07 100.207 99.9365 99.7222 100.028 100.351 100.047 99.5857 99.831 100.447 100.341 99.5807 99.4459 100.292 100.775 99.9709 99.0577 99.6075 100.958 100.956 99.3049 98.424 100.01 102.074 101.241 97.8593 96.737 101.183 106.816 103.187 83.0002 49.9646 17.1466 -2.88793 -7.00335 -1.92026 2.95668 2.97674 -0.144096 -2.28604 -1.54514 0.632658 1.74898 0.910848 -0.692025 -1.37347 -0.638049 0.597225 1.11493 0.552053 -0.433443 -0.920007 -0.559787 0.22829 0.737403 0.595137 0.00153219 -0.525111 -0.59753 -0.224642 0.264681 0.512053 0.383301 0.0181644 -0.312817 -0.406959 -0.243237 0.0406996 0.262117 0.30792 0.183376 -0.016303 -0.176337 -0.22575 -0.162631 -0.0383567 0.0794752 0.142161 0.136167 0.0797887 0.00654127 -0.0525348 -0.080031 -0.0753186 -0.0484066 -0.0146743 0.0139152 0.030684 0.0335189 0.0287868 0.0159969 0.00715417 -0.00350084 -0.007562 100.019 99.972 99.9507 100.072 100.086 99.891 99.8662 100.134 100.196 99.8595 99.7262 100.117 100.362 99.9497 99.551 99.9289 100.512 100.255 99.4831 99.5054 100.418 100.76 99.8319 99.0149 99.7345 101.062 100.873 99.1553 98.4319 100.169 102.155 101.124 97.705 96.7627 101.358 106.905 103.068 82.8268 49.9625 17.3218 -2.75405 -7.07811 -2.11507 2.8749 3.10603 0.0477692 -2.25046 -1.70668 0.451342 1.74409 1.08759 -0.518128 -1.38008 -0.817455 0.422494 1.11278 0.722294 -0.250238 -0.889122 -0.705302 0.0357496 0.660962 0.694142 0.190996 -0.396396 -0.625143 -0.381398 0.0979275 0.452838 0.466096 0.179664 -0.181514 -0.385651 -0.33664 -0.103635 0.152885 0.290341 0.257799 0.102616 -0.0762663 -0.189621 -0.198817 -0.121338 -0.00882069 0.0849337 0.12701 0.114004 0.0640042 0.00455019 -0.0419487 -0.0636964 -0.0606917 -0.0420669 -0.0164143 0.00420275 0.0189643 0.0229537 0.020538 0.0162464 0.00537882 100.011 100.02 99.9369 99.9656 100.113 100.059 99.8413 99.9009 100.196 100.16 99.7836 99.7566 100.208 100.347 99.8448 99.5413 100.041 100.556 100.148 99.3997 99.5889 100.539 100.72 99.6879 98.9928 99.8753 101.153 100.772 99.0077 98.457 100.336 102.226 100.994 97.5514 96.7982 101.539 106.991 102.942 82.6493 49.9602 17.5009 -2.61368 -7.14904 -2.31471 2.78147 3.22864 0.248037 -2.197 -1.85973 0.256873 1.7148 1.25389 -0.326774 -1.35553 -0.982646 0.228196 1.07266 0.871149 -0.0497246 -0.814658 -0.818238 -0.164901 0.539833 0.747111 0.370668 -0.231646 -0.596872 -0.503804 -0.0817606 0.34156 0.493002 0.318768 -0.0245763 -0.307035 -0.376224 -0.229093 0.0179027 0.21805 0.278588 0.196062 0.0371573 -0.110291 -0.18369 -0.167709 -0.0887407 0.00755375 0.080348 0.108939 0.0942655 0.053408 0.00606639 -0.0296896 -0.0479805 -0.0472468 -0.0347832 -0.0181881 -0.000678543 0.00720257 0.0159928 0.011809 99.9901 100.041 100.001 99.9082 100.001 100.144 100.011 99.8036 99.9578 100.245 100.099 99.7178 99.8137 100.294 100.303 99.7395 99.5598 100.161 100.574 100.026 99.3356 99.6945 100.649 100.656 99.5427 98.9934 100.028 101.229 100.653 98.8643 98.4999 100.51 102.286 100.852 97.3995 96.8441 101.726 107.074 102.811 82.4677 49.958 17.684 -2.46667 -7.2158 -2.5189 2.6761 3.34363 0.45586 -2.12515 -2.00227 0.0509811 1.66027 1.40626 -0.121035 -1.29885 -1.12836 0.0194725 0.994171 0.991682 0.159955 -0.69837 -0.891008 -0.361889 0.380261 0.74846 0.526014 -0.0437695 -0.513578 -0.578568 -0.255274 0.189951 0.459516 0.416479 0.135885 -0.182574 -0.355272 -0.313966 -0.117935 0.105649 0.242282 0.244239 0.137471 -0.00849976 -0.123348 -0.166896 -0.138328 -0.0657181 0.0136455 0.0697826 0.0901703 0.0775931 0.0456183 0.00998078 -0.01896 -0.0325893 -0.0363585 -0.0269806 -0.0176338 -0.00568363 0.00409494 99.9823 100.011 100.06 99.9643 99.8951 100.051 100.156 99.9476 99.7864 100.032 100.274 100.018 99.6705 99.8947 100.365 100.232 99.6417 99.6078 100.282 100.564 99.8928 99.2953 99.8195 100.745 100.566 99.4008 99.0184 100.189 101.287 100.517 98.7276 98.5614 100.688 102.333 100.698 97.25 96.9007 101.919 107.154 102.672 82.282 49.9556 17.871 -2.31283 -7.27802 -2.72736 2.5585 3.44996 0.670314 -2.03447 -2.13227 -0.16439 1.57997 1.54124 0.0955703 -1.20973 -1.24957 -0.197821 0.878229 1.07769 0.369836 -0.544139 -0.91782 -0.543087 0.191308 0.696059 0.64377 0.151809 -0.381252 -0.596672 -0.403501 0.0148122 0.368551 0.458849 0.276764 -0.0309436 -0.276831 -0.343375 -0.229468 -0.024477 0.157219 0.237467 0.201796 0.0901727 -0.0351291 -0.121377 -0.145369 -0.113357 -0.0511386 0.0122831 0.0561676 0.0714449 0.0635003 0.0394044 0.0139244 -0.00826975 -0.0210939 -0.0229657 -0.0236623 -0.0114684 99.9959 99.9701 100.044 100.059 99.9197 99.9044 100.108 100.144 99.8778 99.7956 100.115 100.276 99.9244 99.6487 99.9944 100.414 100.136 99.5592 99.6845 100.397 100.524 99.7547 99.2823 99.9602 100.821 100.454 99.2664 99.0685 100.355 101.325 100.365 98.6 98.6416 100.87 102.366 100.533 97.1039 96.9685 102.117 107.23 102.527 82.0922 49.9531 18.062 -2.15197 -7.33528 -2.93973 2.42841 3.54658 0.890352 -1.92464 -2.24765 -0.387026 1.47366 1.65544 0.319039 -1.08862 -1.34156 -0.417147 0.727135 1.12395 0.570347 -0.357999 -0.895058 -0.696576 -0.0154327 0.591614 0.712928 0.338132 -0.210854 -0.55444 -0.509188 -0.163473 0.230496 0.438949 0.376961 0.124295 -0.153627 -0.311887 -0.295571 -0.146006 0.0421605 0.17828 0.215727 0.160974 0.0565652 -0.0460087 -0.110065 -0.122371 -0.0932654 -0.042421 0.0066331 0.0409888 0.0542156 0.0489479 0.0351279 0.0139075 0.00192283 -0.0123204 -0.013178 100.013 99.9664 99.9788 100.079 100.036 99.8777 99.9381 100.16 100.104 99.8119 99.8336 100.197 100.248 99.8262 99.6577 100.105 100.435 100.022 99.4996 99.7872 100.498 100.453 99.6184 99.2994 100.112 100.873 100.32 99.1442 99.1442 100.523 101.341 100.2 98.4839 98.7409 101.053 102.384 100.357 96.9622 97.0478 102.321 107.302 102.375 81.8982 49.9505 18.257 -1.98393 -7.38715 -3.15562 2.28561 3.63242 1.11478 -1.79553 -2.34633 -0.614414 1.34159 1.74559 0.544891 -0.936854 -1.40015 -0.63141 0.544737 1.12658 0.75169 -0.148122 -0.821806 -0.811449 -0.22634 0.441006 0.725943 0.498088 -0.0177904 -0.454535 -0.559149 -0.323111 0.0625802 0.358555 0.420828 0.258128 -0.00669439 -0.225358 -0.303713 -0.233948 -0.0771651 0.0817771 0.177539 0.186809 0.126648 0.0357608 -0.0458498 -0.0933655 -0.100521 -0.0761878 -0.0381141 0.000835393 0.0255258 0.0392677 0.0360691 0.0277813 0.0165918 0.00131136 100.014 100.001 99.9415 100.008 100.104 99.992 99.8496 99.9935 100.197 100.041 99.7609 99.8991 100.267 100.188 99.7343 99.6996 100.218 100.424 99.8962 99.4691 99.9112 100.578 100.354 99.4911 99.3477 100.268 100.898 100.168 99.0386 99.245 100.69 101.333 100.022 98.3817 98.8592 101.236 102.387 100.17 96.8258 97.1391 102.529 107.37 102.216 81.7 49.9478 18.456 -1.80855 -7.43323 -3.37458 2.12997 3.70641 1.34228 -1.64721 -2.42634 -0.843811 1.18449 1.80875 0.768299 -0.756739 -1.42197 -0.833245 0.336392 1.08343 0.904434 0.0755061 -0.700196 -0.878784 -0.426726 0.254163 0.679812 0.616231 0.179461 -0.306173 -0.546343 -0.443878 -0.113207 0.228501 0.401249 0.348597 0.138263 -0.100324 -0.25312 -0.270605 -0.174219 -0.0280857 0.0988713 0.16341 0.157094 0.100151 0.0253341 -0.0389371 -0.0741694 -0.0803867 -0.0619464 -0.0343945 -0.00660402 0.0151696 0.0221126 0.028957 0.0173127 99.9993 100.032 99.9721 99.9324 100.051 100.108 99.9353 99.8448 100.063 100.209 99.9606 99.7347 99.9863 100.314 100.102 99.6592 99.7735 100.322 100.377 99.7678 99.4722 100.05 100.631 100.229 99.3797 99.4273 100.424 100.893 100.003 98.9538 99.3699 100.851 101.301 99.8349 98.2959 98.996 101.418 102.373 99.9734 96.6957 97.2426 102.742 107.433 102.05 81.4977 49.9449 18.659 -1.62567 -7.47313 -3.59619 1.9614 3.76755 1.57149 -1.47995 -2.48586 -1.07232 1.00352 1.84237 0.984254 -0.551448 -1.4046 -1.01535 0.108756 0.994291 1.0201 0.301655 -0.535403 -0.892423 -0.602008 0.0443547 0.576583 0.680476 0.3613 -0.12429 -0.471056 -0.509994 -0.273234 0.0672432 0.32109 0.38084 0.255702 0.0392076 -0.155033 -0.249626 -0.227948 -0.124768 0.00151007 0.0998123 0.142094 0.129861 0.0806196 0.0215366 -0.0277433 -0.0559529 -0.0599043 -0.0511309 -0.0282264 -0.0128403 0.00603214 0.0128948 99.9858 100.026 100.031 99.9361 99.9457 100.098 100.087 99.8766 99.8684 100.136 100.19 99.8733 99.7403 100.086 100.332 99.9958 99.6106 99.8749 100.408 100.297 99.6465 99.5113 100.195 100.651 100.085 99.2911 99.5366 100.572 100.857 99.8277 98.8936 99.5172 101.002 101.242 99.6407 98.2286 99.1508 101.595 102.34 99.7675 96.5731 97.3587 102.96 107.491 101.877 81.2911 49.9419 18.8661 -1.43512 -7.50645 -3.82002 1.77982 3.81484 1.80099 -1.29412 -2.52314 -1.29693 0.800287 1.84429 1.18766 -0.324932 -1.34664 -1.1707 -0.130468 0.860865 1.09154 0.518431 -0.335378 -0.849425 -0.738775 -0.172799 0.423285 0.683336 0.509023 0.0720176 -0.341008 -0.512301 -0.395551 -0.101828 0.192855 0.349786 0.325004 0.166557 -0.0303816 -0.177327 -0.227899 -0.185846 -0.0886823 0.0154516 0.0898878 0.118819 0.105083 0.0673528 0.0201916 -0.0151205 -0.0391498 -0.0434431 -0.0371018 -0.0278759 -0.0075708 99.9886 99.9918 100.053 100.009 99.9058 99.9823 100.134 100.04 99.8289 99.9206 100.199 100.139 99.7918 99.7807 100.187 100.313 99.8796 99.596 99.9965 100.465 100.187 99.5425 99.5863 100.337 100.635 99.9267 99.2311 99.6726 100.706 100.787 99.6486 98.8614 99.6841 101.139 101.157 99.4424 98.1819 99.3228 101.767 102.29 99.5531 96.459 97.4876 103.181 107.544 101.695 81.0802 49.9389 19.0773 -1.23665 -7.53272 -4.04559 1.58514 3.84721 2.02925 -1.09029 -2.53655 -1.51447 0.57678 1.81277 1.37334 -0.0819103 -1.24771 -1.29271 -0.372674 0.686818 1.11329 0.71375 -0.110572 -0.750347 -0.825661 -0.380332 0.231551 0.622707 0.606608 0.261354 -0.170672 -0.449518 -0.462822 -0.253691 0.0368462 0.260989 0.334149 0.257491 0.0946823 -0.0708925 -0.176409 -0.198123 -0.149361 -0.065479 0.0181707 0.0737197 0.0953133 0.0841732 0.0557183 0.0232079 -0.00753725 -0.019841 -0.033347 -0.0231077 100.003 99.9685 100.017 100.067 99.9686 99.8933 100.036 100.15 99.9738 99.804 99.9957 100.239 100.061 99.7291 99.8541 100.275 100.257 99.7657 99.6201 100.128 100.487 100.055 99.465 99.6943 100.468 100.582 99.7631 99.2048 99.8305 100.82 100.686 99.4712 98.8598 99.8676 101.259 101.045 99.2434 98.1578 99.5108 101.93 102.22 99.3312 96.3543 97.6297 103.407 107.59 101.506 80.8649 49.9356 19.2926 -1.03006 -7.55144 -4.27236 1.37735 3.86361 2.25459 -0.869212 -2.52455 -1.72156 0.335521 1.74656 1.53609 0.172074 -1.10869 -1.37544 -0.608487 0.477885 1.08193 0.875865 0.126334 -0.599576 -0.854285 -0.561016 0.0171222 0.502517 0.642453 0.422046 0.0198533 -0.328931 -0.464872 -0.365103 -0.121481 0.130179 0.282143 0.294575 0.193885 0.0447533 -0.0877631 -0.160776 -0.166556 -0.120025 -0.0514549 0.0127012 0.0565218 0.0704332 0.0675266 0.0435333 0.0248277 0.00150234 -0.0119932 100.014 99.9796 99.9654 100.052 100.06 99.9215 99.9066 100.096 100.137 99.8997 99.8107 100.083 100.248 99.9635 99.6967 99.9538 100.339 100.167 99.6669 99.6835 100.258 100.469 99.9088 99.4219 99.83 100.577 100.491 99.6027 99.2156 100.005 100.907 100.555 99.3016 98.8907 100.064 101.356 100.909 99.0469 98.1579 99.7134 102.083 102.131 99.1029 96.2602 97.7851 103.635 107.631 101.309 80.6452 49.9322 19.512 -0.81517 -7.56212 -4.49971 1.15655 3.86302 2.47522 -0.631941 -2.48584 -1.91475 0.0795783 1.6451 1.67091 0.430726 -0.931839 -1.41399 -0.82812 0.241889 0.996668 0.994196 0.361017 -0.405519 -0.82036 -0.698922 -0.201212 0.333033 0.611244 0.534842 0.206938 -0.166226 -0.401038 -0.418628 -0.255639 -0.0187284 0.180106 0.271659 0.246836 0.142409 0.014848 -0.0871613 -0.138348 -0.135397 -0.0980094 -0.0423993 0.00397768 0.0386926 0.0510798 0.0468586 0.0399966 0.01453 100.009 100.011 99.9528 99.9842 100.084 100.028 99.8812 99.9475 100.149 100.092 99.8321 99.8522 100.168 100.219 99.8607 99.7022 100.069 100.368 100.051 99.5956 99.7827 100.373 100.41 99.7608 99.419 99.9855 100.655 100.367 99.4547 99.2652 100.188 100.962 100.397 99.146 98.955 100.268 101.428 100.748 98.8568 98.1836 99.9288 102.224 102.021 98.8693 96.1779 97.9539 103.866 107.664 101.104 80.4212 49.9285 19.7356 -0.59182 -7.56431 -4.72702 0.922912 3.84451 2.6893 -0.379764 -2.41944 -2.0906 -0.187516 1.50859 1.77321 0.687231 -0.720866 -1.40488 -1.02191 -0.0115807 0.859567 1.06021 0.578541 -0.180179 -0.724411 -0.781134 -0.403465 0.130077 0.515064 0.585714 0.366744 0.0165299 -0.280725 -0.406113 -0.343279 -0.158379 0.0489077 0.195764 0.243867 0.200761 0.105462 0.000825496 -0.075739 -0.112646 -0.108333 -0.0782472 -0.0404416 -0.000120618 0.0177849 0.0382398 0.0293941 99.9959 100.029 99.9886 99.9368 100.022 100.1 99.977 99.8613 100.01 100.179 100.021 99.7857 99.9251 100.237 100.153 99.7675 99.7488 100.185 100.355 99.9198 99.5617 99.9103 100.461 100.312 99.6229 99.4591 100.151 100.697 100.215 99.3281 99.3536 100.372 100.981 100.217 99.0107 99.0529 100.475 101.472 100.565 98.6767 98.236 100.155 102.35 101.891 98.6317 96.1084 98.1364 104.1 107.69 100.891 80.1926 49.9248 19.9634 -0.359808 -7.55755 -4.95369 0.676631 3.8072 2.89498 -0.114141 -2.3246 -2.24572 -0.46187 1.33794 1.83893 0.934474 -0.480751 -1.34619 -1.18076 -0.271617 0.675522 1.06802 0.764361 0.0616329 -0.571891 -0.799022 -0.570391 -0.086506 0.363339 0.56773 0.478432 0.193972 -0.121986 -0.330159 -0.369954 -0.26339 -0.0848819 0.0848047 0.18796 0.208873 0.161429 0.080285 -0.000608141 -0.0606652 -0.0840763 -0.0862111 -0.0599528 -0.0371969 -0.00868031 0.0116848 99.9874 100.017 100.033 99.955 99.9422 100.068 100.089 99.9178 99.8713 100.083 100.176 99.9352 99.7725 100.02 100.274 100.057 99.6991 99.8334 100.288 100.299 99.7885 99.5717 100.055 100.512 100.18 99.5073 99.5419 100.315 100.696 100.042 99.2314 99.4784 100.548 100.96 100.02 98.9014 99.1832 100.679 101.484 100.362 98.5105 98.3159 100.39 102.459 101.741 98.3915 96.0529 98.3327 104.335 107.708 100.669 79.9596 49.9208 20.1955 -0.118882 -7.54133 -5.17909 0.417915 3.7502 3.09034 0.163294 -2.20079 -2.37683 -0.739251 1.13475 1.86459 1.16516 -0.217677 -1.23764 -1.29646 -0.526392 0.452135 1.01478 0.905221 0.303187 -0.372984 -0.749151 -0.685299 -0.294674 0.172095 0.482231 0.526971 0.340982 0.0508205 -0.203959 -0.332027 -0.315239 -0.19405 -0.0365193 0.0953936 0.167491 0.171734 0.130694 0.0632128 0.00393116 -0.0422174 -0.062146 -0.0591171 -0.0536259 -0.0217008 99.9917 99.9896 100.043 100.016 99.9239 99.9725 100.107 100.05 99.8663 99.914 100.15 100.137 99.8505 99.799 100.121 100.271 99.9437 99.6681 99.9474 100.361 100.202 99.6723 99.6279 100.203 100.519 100.026 99.4251 99.6637 100.466 100.65 99.8573 99.1717 99.6354 100.708 100.9 99.8129 98.8234 99.3438 100.876 101.463 100.143 98.3618 98.4237 100.631 102.55 101.571 98.1501 96.0123 98.5427 104.571 107.718 100.438 79.7218 49.9167 20.432 0.131224 -7.51507 -5.40249 0.147029 3.67264 3.27334 0.450673 -2.04777 -2.48066 -1.01504 0.901374 1.84737 1.3719 0.0610117 -1.08074 -1.36202 -0.763533 0.199568 0.901083 0.990023 0.526819 -0.142131 -0.633884 -0.73573 -0.47235 -0.0375067 0.338992 0.5054 0.436422 0.21068 -0.048987 -0.237876 -0.30541 -0.25767 -0.141605 -0.0100552 0.0891275 0.139724 0.138584 0.103034 0.0568166 0.00486366 -0.018952 -0.0467022 -0.0376737 100.004 99.9735 100.011 100.057 99.9791 99.9098 100.022 100.126 99.9884 99.838 99.9837 100.195 100.065 99.7844 99.8647 100.212 100.224 99.8292 99.6822 100.077 100.393 100.075 99.5858 99.727 100.34 100.477 99.8603 99.3853 99.8173 100.592 100.559 99.6723 99.1546 99.8183 100.844 100.799 99.6029 98.7812 99.5314 101.058 101.407 99.9106 98.2344 98.5592 100.875 102.619 101.38 97.909 95.9879 98.7665 104.808 107.719 100.197 79.4794 49.9123 20.6728 0.390745 -7.47818 -5.62309 -0.135635 3.57367 3.44185 0.745822 -1.86563 -2.55406 -1.28423 0.641053 1.78531 1.5474 0.346821 -0.879017 -1.37212 -0.970598 -0.0696433 0.731293 1.01076 0.715061 0.10265 -0.461723 -0.71498 -0.599671 -0.241083 0.155536 0.416351 0.466036 0.332183 0.107768 -0.106232 -0.237286 -0.265072 -0.206548 -0.104439 -0.0019319 0.0755234 0.106559 0.11087 0.0785464 0.0496594 0.0136549 -0.0137564 100.011 99.9832 99.9713 100.043 100.05 99.9354 99.9227 100.079 100.113 99.9179 99.8441 100.067 100.204 99.9711 99.7522 99.9611 100.276 100.137 99.7317 99.7431 100.205 100.377 99.9308 99.5412 99.861 100.45 100.388 99.6986 99.3938 99.9926 100.682 100.428 99.4983 99.1836 100.019 100.947 100.66 99.3984 98.7784 99.7417 101.221 101.316 99.6696 98.1319 98.7221 101.12 102.665 101.17 97.67 95.9807 99.004 105.046 107.711 99.9478 79.2322 49.9077 20.918 0.659881 -7.43009 -5.84005 -0.429561 3.45261 3.59372 1.04628 -1.65493 -2.59418 -1.54153 0.357942 1.67757 1.68479 0.630346 -0.63812 -1.32365 -1.13585 -0.341098 0.513788 0.963574 0.852226 0.341021 -0.247162 -0.623613 -0.661623 -0.414011 -0.044386 0.272537 0.425635 0.396278 0.238082 0.0374777 -0.128062 -0.216867 -0.219652 -0.165865 -0.0791575 -0.00343853 0.0552429 0.0807643 0.0765975 0.0698302 0.0286827 100.008 100.007 99.9605 99.9904 100.07 100.018 99.9003 99.9639 100.126 100.067 99.8564 99.888 100.147 100.17 99.8733 99.7636 100.073 100.297 100.021 99.6681 99.845 100.313 100.312 99.7866 99.5466 100.017 100.521 100.258 99.5555 99.4528 100.177 100.728 100.262 99.3467 99.2595 100.228 101.01 100.486 99.2076 98.8172 99.9693 101.358 101.19 99.4247 98.0575 98.9112 101.362 102.687 100.941 97.4349 95.9917 99.2551 105.282 107.694 99.6888 78.9802 49.9028 21.1676 0.938848 -7.37026 -6.05252 -0.734171 3.30887 3.72682 1.34942 -1.41664 -2.59854 -1.78157 0.0569875 1.52449 1.77801 0.901681 -0.365688 -1.21611 -1.24909 -0.59945 0.260539 0.849418 0.92599 0.552316 -0.00943755 -0.46977 -0.650298 -0.535028 -0.234115 0.0946166 0.322741 0.393261 0.319848 0.165491 -0.00271365 -0.125484 -0.184803 -0.178451 -0.129682 -0.069045 -0.00227487 0.0274088 0.0623341 0.0494078 99.998 100.023 99.9857 99.9504 100.026 100.079 99.9685 99.8892 100.025 100.145 99.9958 99.8215 99.9636 100.203 100.098 99.7914 99.8205 100.181 100.27 99.8942 99.6509 99.9758 100.385 100.202 99.6605 99.6044 100.18 100.542 100.098 99.4452 99.5602 100.356 100.723 100.072 99.2285 99.3807 100.434 101.028 100.285 99.0389 98.8987 100.208 101.464 101.029 99.1807 98.0145 99.1251 101.598 102.682 100.694 97.2055 96.022 99.5197 105.518 107.665 99.4198 78.7232 49.8977 21.4218 1.22792 -7.29811 -6.25964 -1.04886 3.14193 3.83904 1.65241 -1.1521 -2.56505 -1.99897 -0.256172 1.3276 1.82191 1.15072 -0.0710852 -1.05161 -1.30217 -0.82922 -0.0134984 0.674112 0.928455 0.717315 0.229063 -0.268416 -0.566153 -0.588539 -0.38801 -0.0911449 0.174776 0.324538 0.340855 0.251626 0.114227 -0.0167958 -0.111246 -0.144512 -0.144358 -0.0984367 -0.0598958 -0.0123788 0.021157 99.9903 100.018 100.022 99.9565 99.9629 100.066 100.059 99.9166 99.9106 100.091 100.129 99.9157 99.8257 100.056 100.221 99.999 99.7438 99.9157 100.264 100.195 99.7759 99.6861 100.118 100.408 100.06 99.5695 99.7109 100.331 100.508 99.9197 99.3797 99.7092 100.515 100.666 99.8676 99.1529 99.5424 100.627 100.999 100.062 98.9003 99.0223 100.451 101.534 100.837 98.9432 98.0052 99.3619 101.824 102.649 100.431 96.9837 96.0726 99.7974 105.751 107.626 99.1407 78.4612 49.8923 21.6807 1.5274 -7.21299 -6.46049 -1.37295 2.95131 3.92824 1.95225 -0.863055 -2.49198 -2.18833 -0.57522 1.08967 1.81248 1.36743 0.234769 -0.835075 -1.28958 -1.01565 -0.291039 0.448337 0.857216 0.819957 0.444878 -0.0404753 -0.41846 -0.567211 -0.485263 -0.25597 0.00572283 0.205432 0.298461 0.281664 0.198428 0.0806192 -0.0156462 -0.0867517 -0.112307 -0.102085 -0.0883514 -0.0335606 99.9914 99.9973 100.036 99.9993 99.9357 99.9982 100.092 100.013 99.8807 99.9634 100.141 100.075 99.847 99.8726 100.145 100.191 99.8915 99.7433 100.034 100.306 100.082 99.6869 99.7716 100.25 100.376 99.9036 99.5272 99.8562 100.452 100.421 99.7417 99.3675 99.8894 100.641 100.558 99.6639 99.1271 99.7374 100.795 100.92 99.8267 98.7992 99.1858 100.69 101.565 100.616 98.7176 98.0319 99.6192 102.036 102.586 100.152 96.7717 96.1445 100.088 105.982 107.575 98.8512 78.194 49.8866 21.9442 1.83761 -7.11419 -6.65404 -1.70565 2.7366 3.99223 2.24566 -0.551685 -2.37804 -2.34431 -0.893176 0.81478 1.74703 1.54216 0.539657 -0.574256 -1.20895 -1.1456 -0.553484 0.187223 0.71592 0.849087 0.615957 0.189082 -0.224048 -0.474206 -0.511972 -0.375357 -0.156037 0.0596395 0.201655 0.256786 0.228494 0.15318 0.0687758 -0.0161281 -0.0500449 -0.0902678 -0.0661004 99.9996 99.9808 100.02 100.039 99.9643 99.937 100.046 100.091 99.9526 99.876 100.035 100.159 99.9942 99.8096 99.9548 100.209 100.118 99.7984 99.7936 100.153 100.295 99.9484 99.6438 99.8969 100.353 100.29 99.7522 99.5419 100.025 100.529 100.286 99.5813 99.4125 100.087 100.721 100.404 99.4748 99.1554 99.9558 100.927 100.793 99.5894 98.7416 99.3854 100.917 101.553 100.369 98.5098 98.0962 99.8937 102.231 102.494 99.8593 96.5715 96.2385 100.391 106.209 107.512 98.5509 77.9215 49.8805 22.2125 2.15883 -7.00099 -6.83917 -2.046 2.49756 4.02882 2.52909 -0.220743 -2.22256 -2.46176 -1.20242 0.508461 1.62453 1.66602 0.830363 -0.279748 -1.06161 -1.20847 -0.781989 -0.0901652 0.514387 0.800169 0.723395 0.394242 -0.00672994 -0.322387 -0.463939 -0.432672 -0.28045 -0.0885472 0.0764171 0.181355 0.204197 0.186566 0.114685 0.0618533 -0.00257502 -0.0383655 100.007 99.9812 99.9883 100.044 100.02 99.932 99.9658 100.089 100.057 99.8966 99.909 100.107 100.134 99.9067 99.8164 100.055 100.23 100.013 99.7411 99.8881 100.25 100.23 99.8165 99.6569 100.044 100.408 100.159 99.6269 99.6146 100.198 100.55 100.116 99.4556 99.5137 100.284 100.746 100.213 99.3144 99.2389 100.186 101.015 100.621 99.3606 98.7324 99.6157 101.124 101.496 100.103 98.3254 98.199 100.182 102.406 102.37 99.5547 96.3852 96.3555 100.707 106.431 107.436 98.2395 77.6436 49.874 22.4856 2.49132 -6.8727 -7.01472 -2.39292 2.23417 4.03596 2.79883 0.126472 -2.0256 -2.53596 -1.49493 0.177689 1.44592 1.73154 1.09333 0.0351992 -0.852926 -1.19756 -0.958911 -0.362294 0.268754 0.676425 0.754424 0.551357 0.204661 -0.13196 -0.351693 -0.418307 -0.348757 -0.210521 -0.0475553 0.069898 0.148081 0.160844 0.135731 0.104804 0.031535 100.009 99.9965 99.9688 100.013 100.055 99.9815 99.9193 100.016 100.108 99.9979 99.8653 99.9742 100.156 100.07 99.8355 99.8699 100.15 100.2 99.8989 99.7343 100.01 100.306 100.12 99.7099 99.7271 100.192 100.405 100.001 99.5462 99.739 100.354 100.51 99.9261 99.3791 99.6641 100.465 100.711 99.9993 99.1957 99.3749 100.414 101.051 100.412 99.1515 98.7748 99.8698 101.303 101.392 99.8232 98.1701 98.3406 100.48 102.556 102.214 99.2404 96.2153 96.4963 101.033 106.648 107.347 97.9168 77.3602 49.8671 22.7636 2.83538 -6.72862 -7.17954 -2.74525 1.94651 4.01172 3.05109 0.486207 -1.78796 -2.56279 -1.76253 -0.16933 1.21417 1.73309 1.31533 0.35544 -0.592294 -1.11068 -1.06943 -0.607176 0.000316518 0.488134 0.705461 0.64066 0.383471 0.0693763 -0.194547 -0.334736 -0.356425 -0.276828 -0.156332 -0.0376435 0.0642985 0.0961989 0.134624 0.0867576 100.003 100.013 99.9752 99.9748 100.045 100.041 99.9394 99.9367 100.07 100.092 99.9299 99.8725 100.055 100.165 99.9807 99.8015 99.9601 100.215 100.122 99.7998 99.7828 100.137 100.305 99.9834 99.649 99.8456 100.315 100.341 99.8356 99.5236 99.9016 100.473 100.41 99.7374 99.3622 99.8518 100.611 100.617 99.7773 99.1295 99.5571 100.625 101.03 100.174 98.9728 98.8697 100.139 101.446 101.244 99.5356 98.0493 98.5204 100.784 102.677 102.027 98.9186 96.064 96.6617 101.371 106.859 107.243 97.5824 77.0712 49.8598 23.0466 3.19138 -6.56799 -7.3324 -3.10174 1.63482 3.95423 3.28192 0.854249 -1.51115 -2.53875 -1.99701 -0.523258 0.934282 1.66714 1.484 0.66448 -0.293008 -0.95037 -1.1031 -0.80323 -0.266927 0.253456 0.581281 0.649959 0.507733 0.24854 -0.0134818 -0.205411 -0.297685 -0.283735 -0.225804 -0.111422 -0.0409704 0.0445228 0.0712803 99.9956 100.019 99.9999 99.9586 100.001 100.065 100.004 99.9124 99.9827 100.109 100.042 99.8763 99.9207 100.127 100.128 99.8894 99.817 100.066 100.233 100.011 99.7396 99.8797 100.242 100.245 99.8435 99.6472 99.9947 100.393 100.223 99.6879 99.565 100.083 100.54 100.26 99.5703 99.4095 100.06 100.709 100.468 99.5643 99.1232 99.7755 100.807 100.951 99.9173 98.8348 99.0159 100.414 101.547 101.052 99.2479 97.9677 98.7372 101.088 102.767 101.808 98.5921 95.9335 96.8522 101.719 107.062 107.125 97.2357 76.7762 49.8521 23.3348 3.55971 -6.38997 -7.47196 -3.46101 1.29946 3.86173 3.48729 1.22589 -1.19752 -2.46113 -2.19027 -0.873769 0.613482 1.53268 1.58867 0.945028 0.028426 -0.724816 -1.05482 -0.931915 -0.508255 -0.00222779 0.393723 0.58129 0.557514 0.382593 0.158743 -0.0564027 -0.182254 -0.248673 -0.222754 -0.169023 -0.104845 -0.0120328 99.992 100.01 100.022 99.9745 99.9609 100.038 100.06 99.9549 99.9155 100.043 100.113 99.9711 99.8571 99.9983 100.168 100.051 99.8219 99.8817 100.162 100.195 99.8925 99.7342 100.006 100.303 100.136 99.7271 99.7077 100.15 100.41 100.067 99.5803 99.6676 100.259 100.542 100.075 99.4445 99.5191 100.27 100.745 100.274 99.3777 99.1804 100.017 100.946 100.815 99.6551 98.7463 99.2099 100.685 101.598 100.82 98.968 97.9298 98.9887 101.387 102.822 101.558 98.2636 95.8263 97.0685 102.076 107.257 106.991 96.8766 76.4753 49.8438 23.6282 3.94076 -6.19365 -7.59678 -3.8215 0.940994 3.73254 3.66299 1.5959 -0.850303 -2.32807 -2.33457 -1.20967 0.261048 1.33151 1.6209 1.18 0.353105 -0.447816 -0.924775 -0.981123 -0.698117 -0.253251 0.165946 0.443712 0.525059 0.457724 0.28392 0.100399 -0.0563778 -0.16003 -0.174069 -0.192718 -0.103685 99.9945 99.9946 100.027 100.007 99.9524 99.9866 100.067 100.026 99.9153 99.9527 100.096 100.078 99.9022 99.8826 100.083 100.161 99.9544 99.7991 99.9812 100.222 100.109 99.7933 99.7878 100.137 100.303 99.9958 99.6575 99.8223 100.285 100.362 99.8956 99.5307 99.8196 100.407 100.477 99.8745 99.376 99.6822 100.461 100.715 100.051 99.234 99.2998 100.266 101.03 100.627 99.401 98.7143 99.4459 100.94 101.596 100.553 98.704 97.939 99.2718 101.675 102.839 101.278 97.9363 95.7448 97.3109 102.442 107.442 106.84 96.5044 76.168 49.8349 23.9269 4.33488 -5.97814 -7.7053 -4.18143 0.5603 3.56526 3.80476 1.95848 -0.473756 -2.13893 -2.42277 -1.51908 -0.11162 1.06886 1.57492 1.35399 0.659443 -0.13713 -0.721455 -0.943998 -0.815516 -0.473291 -0.0696897 0.249539 0.426864 0.451189 0.355346 0.224956 0.0548437 -0.0284985 -0.130483 -0.123343 100.001 99.9848 100.012 100.032 99.978 99.9494 100.027 100.072 99.9745 99.9039 100.014 100.12 100.012 99.8601 99.9481 100.148 100.106 99.8651 99.8305 100.091 100.228 99.9916 99.7386 99.8911 100.243 100.242 99.8519 99.6502 99.9725 100.376 100.253 99.7352 99.5489 100.001 100.506 100.349 99.683 99.3752 99.8838 100.612 100.618 99.8156 99.147 99.4755 100.506 101.052 100.395 99.1693 98.7435 99.7154 101.167 101.538 100.258 98.4645 97.998 99.5824 101.947 102.814 100.971 97.6137 95.6912 97.5797 102.815 107.616 106.671 96.1189 75.8543 49.8254 24.231 4.74247 -5.74253 -7.79593 -4.53888 0.158509 3.35873 3.90845 2.30742 -0.0731525 -1.89448 -2.4487 -1.79017 -0.491027 0.753008 1.44928 1.4538 0.925904 0.185688 -0.461623 -0.819463 -0.851662 -0.631008 -0.290055 0.0336609 0.276359 0.366195 0.376734 0.270065 0.172551 0.0567409 -0.0422466 100.006 99.9863 99.9904 100.032 100.016 99.9503 99.9725 100.065 100.045 99.9254 99.9295 100.076 100.102 99.9352 99.8618 100.035 100.171 100.017 99.81 99.9102 100.181 100.176 99.8723 99.7435 100.022 100.299 100.128 99.7332 99.7091 100.132 100.403 100.1 99.6121 99.635 100.188 100.539 100.174 99.5241 99.4451 100.104 100.707 100.461 99.5889 99.1266 99.6968 100.718 101.007 100.132 98.974 98.8358 100.008 101.358 101.422 99.9418 98.2579 98.1084 99.9156 102.197 102.747 100.637 97.2994 95.6681 97.8752 103.195 107.778 106.485 95.7195 75.534 49.8151 24.5406 5.16394 -5.48587 -7.86702 -4.89181 -0.263037 3.11211 3.96997 2.6362 0.345234 -1.59678 -2.40755 -2.01127 -0.862338 0.395288 1.24706 1.46876 1.13412 0.493616 -0.163196 -0.62106 -0.799061 -0.708167 -0.470403 -0.162288 0.0790046 0.250683 0.309307 0.275011 0.238827 0.0939172 100.006 99.9968 99.9774 100.011 100.04 99.9841 99.9414 100.015 100.079 99.9942 99.9008 99.9862 100.116 100.046 99.8758 99.9102 100.116 100.142 99.9175 99.8074 100.018 100.226 100.077 99.7808 99.8095 100.152 100.292 99.9846 99.665 99.8254 100.271 100.361 99.9256 99.5475 99.7785 100.353 100.5 99.9721 99.4188 99.5806 100.319 100.732 100.254 99.3916 99.1777 99.9487 100.887 100.895 99.8507 98.828 98.99 100.312 101.5 101.25 99.6145 98.0921 98.2708 100.265 102.418 102.635 100.279 96.9972 95.6776 98.1973 103.58 107.926 106.279 95.3057 75.2068 49.8042 24.856 5.59978 -5.20713 -7.91678 -5.23796 -0.702683 2.8248 3.98534 2.93792 0.774088 -1.24941 -2.2962 -2.17094 -1.21023 0.011407 0.974315 1.39524 1.26547 0.7617 0.148651 -0.371552 -0.654946 -0.709197 -0.566944 -0.334034 -0.10485 0.10749 0.177244 0.266894 0.183511 100.003 100.008 99.9803 99.9852 100.035 100.025 99.9514 99.9608 100.058 100.06 99.939 99.9144 100.054 100.115 99.9684 99.8563 99.9916 100.163 100.067 99.8394 99.8607 100.124 100.211 99.9553 99.7414 99.9228 100.25 100.22 99.8411 99.6631 99.9781 100.363 100.254 99.7601 99.5542 99.9591 100.47 100.391 99.7686 99.3825 99.7684 100.505 100.684 100.017 99.2432 99.2993 100.213 100.997 100.718 99.5691 98.7424 99.2014 100.613 101.585 101.023 99.2862 97.9746 98.4841 100.625 102.604 102.476 99.9007 96.7112 95.7222 98.5461 103.968 108.059 106.053 94.877 74.8724 49.7924 25.1772 6.0505 -4.90516 -7.94328 -5.5749 -1.15848 2.49654 3.95085 3.20529 1.20536 -0.857983 -2.11289 -2.25983 -1.51798 -0.381359 0.642654 1.23541 1.30423 0.972082 0.436301 -0.0842707 -0.450679 -0.62085 -0.578794 -0.458435 -0.225461 -0.0827591 0.0890689 0.148097 99.998 100.013 99.9952 99.9712 100.009 100.045 99.9907 99.9371 100.003 100.081 100.011 99.9039 99.9643 100.105 100.071 99.898 99.8861 100.08 100.159 99.9684 99.8074 99.9563 100.199 100.139 99.8422 99.7661 100.057 100.293 100.098 99.7286 99.7301 100.138 100.389 100.1 99.6323 99.6336 100.15 100.52 100.225 99.5909 99.4224 99.9881 100.64 100.562 99.7722 99.1596 99.4843 100.468 101.037 100.488 99.3046 98.7253 99.4622 100.897 101.607 100.749 98.9681 97.9122 98.7461 100.987 102.75 102.271 99.5055 96.4457 95.8038 98.9211 104.358 108.175 105.805 94.4326 74.5305 49.7796 25.5043 6.51662 -4.57877 -7.94447 -5.89982 -1.62814 2.12757 3.86283 3.43101 1.62966 -0.429578 -1.85819 -2.2702 -1.76818 -0.765402 0.272127 0.990809 1.25041 1.09694 0.678145 0.206735 -0.215318 -0.438641 -0.541787 -0.462647 -0.339616 -0.200335 -0.012881 99.9948 100.01 100.011 99.9762 99.9805 100.036 100.031 99.9542 99.9526 100.05 100.069 99.953 99.9067 100.032 100.119 99.997 99.8615 99.9574 100.144 100.102 99.8769 99.8334 100.067 100.218 100.028 99.7685 99.8505 100.18 100.267 99.9514 99.673 99.8541 100.273 100.341 99.9244 99.5658 99.7747 100.321 100.494 100.024 99.4643 99.5363 100.214 100.706 100.378 99.5431 99.1517 99.7192 100.693 101.002 100.216 99.075 98.7815 99.761 101.149 101.56 100.435 98.6721 97.9102 99.0528 101.344 102.849 102.019 99.0977 96.2051 95.9246 99.3218 104.748 108.273 105.535 93.9721 74.1807 49.7657 25.8376 6.99865 -4.22678 -7.91811 -6.20975 -2.10883 1.71867 3.71814 3.60773 2.03633 0.0274038 -1.53676 -2.19439 -1.94827 -1.11616 -0.119571 0.677703 1.10547 1.11725 0.862764 0.442877 0.0588983 -0.24084 -0.409589 -0.401722 -0.406778 -0.202165 99.995 100.001 100.019 99.9947 99.9666 100.007 100.049 99.9963 99.9357 99.994 100.079 100.024 99.9106 99.949 100.091 100.086 99.9212 99.8744 100.046 100.16 100.011 99.8226 99.9111 100.16 100.176 99.9067 99.7553 99.9743 100.26 100.177 99.8145 99.6881 100.01 100.355 100.228 99.7606 99.5743 99.9556 100.443 100.393 99.8155 99.408 99.7122 100.419 100.693 100.149 99.3544 99.2235 99.9855 100.869 100.889 99.9203 98.8973 98.9116 100.084 101.354 101.443 100.09 98.41 97.9726 99.3989 101.685 102.896 101.721 98.682 95.9941 96.0865 99.7475 105.137 108.35 105.242 93.4947 73.8228 49.7506 26.177 7.49714 -3.84791 -7.86189 -6.50151 -2.59724 1.27089 3.51459 3.72745 2.41538 0.500864 -1.15343 -2.03072 -2.0449 -1.41063 -0.513575 0.326352 0.861307 1.05393 0.938882 0.631849 0.307407 -0.0447006 -0.184978 -0.363818 -0.28963 99.998 99.9926 100.015 100.014 99.9735 99.9772 100.036 100.035 99.9575 99.9479 100.043 100.073 99.9651 99.9047 100.015 100.116 100.019 99.8729 99.9338 100.12 100.123 99.9141 99.8244 100.017 100.206 100.082 99.8107 99.8077 100.106 100.276 100.045 99.719 99.7721 100.165 100.366 100.069 99.6393 99.6585 100.146 100.496 100.23 99.6308 99.4324 99.929 100.577 100.599 99.8986 99.2272 99.3717 100.26 100.977 100.705 99.6209 98.7861 99.1118 100.413 101.5 101.256 99.7282 98.1938 98.1019 99.7772 102.003 102.886 101.379 98.2639 95.8173 96.2912 100.197 105.522 108.406 104.923 92.9997 73.4562 49.7342 26.5228 8.01264 -3.44074 -7.77349 -6.77136 -3.08994 0.786624 3.24982 3.78335 2.755 0.97729 -0.715641 -1.78388 -2.04076 -1.63891 -0.868046 -0.0561578 0.555789 0.896297 0.899701 0.770822 0.442127 0.216923 -0.0479522 -0.187858 100.002 99.9895 100.003 100.023 99.9941 99.9638 100.005 100.05 100 99.9363 99.9879 100.075 100.032 99.9186 99.9402 100.078 100.094 99.9417 99.8721 100.019 100.153 100.042 99.8451 99.883 100.119 100.19 99.9636 99.7674 99.9124 100.21 100.223 99.9009 99.6884 99.9076 100.286 100.302 99.8948 99.5849 99.8049 100.314 100.469 100.029 99.498 99.5367 100.159 100.665 100.432 99.6539 99.1777 99.5849 100.519 101.005 100.459 99.3397 98.7526 99.3735 100.732 101.574 101.004 99.3623 98.0345 98.2982 100.179 102.286 102.817 100.996 97.8494 95.6798 96.5404 100.67 105.901 108.437 104.579 92.4863 73.0806 49.7163 26.8753 8.54593 -3.00385 -7.65013 -7.0156 -3.58281 0.268703 2.92205 3.77022 3.04081 1.44639 -0.241928 -1.45095 -1.93981 -1.77428 -1.16243 -0.442778 0.234148 0.6199 0.821171 0.746305 0.569219 0.380201 0.0702478 100.004 99.9924 99.9912 100.019 100.015 99.9715 99.9758 100.036 100.037 99.9603 99.9465 100.037 100.073 99.974 99.9069 100.003 100.109 100.033 99.8866 99.9205 100.098 100.131 99.9457 99.8281 99.98 100.183 100.116 99.856 99.7902 100.041 100.259 100.113 99.781 99.7312 100.064 100.345 100.174 99.7411 99.6095 99.9879 100.429 100.363 99.8219 99.4389 99.7084 100.371 100.67 100.211 99.4434 99.2144 99.8444 100.735 100.947 100.17 99.0989 98.8033 99.6834 101.02 101.57 100.695 99.0082 97.9419 98.5595 100.595 102.526 102.683 100.576 97.445 95.5862 96.8351 101.164 106.272 108.441 104.206 91.9534 72.6954 49.6966 27.2343 9.09766 -2.53571 -7.48864 -7.23028 -4.07007 -0.280817 2.53299 3.67855 3.26428 1.88771 0.25596 -1.04165 -1.74558 -1.78745 -1.40202 -0.753934 -0.141794 0.334047 0.628846 0.62899 0.662953 0.351368 100.004 99.9988 99.9855 100.005 100.025 99.9928 99.9627 100.005 100.05 100.001 99.9383 99.9854 100.071 100.035 99.9261 99.9371 100.066 100.094 99.9574 99.8762 99.9999 100.14 100.061 99.8689 99.8697 100.083 100.189 100.007 99.7918 99.8731 100.158 100.239 99.974 99.7158 99.838 100.206 100.328 100.01 99.6395 99.7097 100.174 100.468 100.196 99.641 99.4648 99.9243 100.535 100.588 99.9595 99.2931 99.3369 100.125 100.888 100.804 99.8582 98.9191 98.9391 100.024 101.259 101.482 100.34 98.6821 97.9244 98.8816 101.012 102.713 102.485 100.124 97.0578 95.5414 97.1766 101.677 106.63 108.417 103.804 91.4002 72.3002 49.6749 27.6004 9.66816 -2.03437 -7.28692 -7.40979 -4.54748 -0.855377 2.08257 3.50421 3.41465 2.27795 0.769661 -0.592066 -1.43235 -1.71387 -1.51221 -1.01057 -0.493229 0.0691177 0.293149 0.579344 0.469935 100.002 100.005 99.9879 99.9912 100.022 100.015 99.97 99.9765 100.036 100.036 99.9619 99.9481 100.034 100.07 99.9792 99.9117 99.9965 100.101 100.04 99.8996 99.9156 100.079 100.13 99.9692 99.8392 99.9557 100.158 100.134 99.8965 99.7909 99.9922 100.229 100.154 99.8433 99.7224 99.9833 100.299 100.238 99.8439 99.6121 99.867 100.328 100.423 99.9938 99.5176 99.5739 100.153 100.626 100.428 99.7097 99.2231 99.5348 100.4 100.958 100.585 99.5501 98.8177 99.155 100.375 101.431 101.31 99.9548 98.4005 97.9877 99.2572 101.418 102.837 102.22 99.6447 96.6954 95.5503 97.5653 102.208 106.975 108.361 103.37 90.8255 71.8939 49.651 27.9735 10.2589 -1.49818 -7.04103 -7.54956 -5.00983 -1.4483 1.56859 3.25141 3.46877 2.61936 1.2536 -0.0916076 -1.04301 -1.53636 -1.47976 -1.23548 -0.682177 -0.317342 0.109027 0.32403 99.9992 100.008 99.9957 99.9834 100.008 100.026 99.9906 99.9631 100.007 100.048 100 99.9411 99.9861 100.067 100.035 99.9323 99.9388 100.058 100.091 99.9677 99.884 99.9889 100.127 100.07 99.8901 99.8675 100.056 100.178 100.036 99.8202 99.8536 100.112 100.235 100.028 99.7555 99.7997 100.131 100.321 100.094 99.7128 99.6657 100.05 100.418 100.301 99.7927 99.4737 99.7508 100.361 100.629 100.208 99.4933 99.2449 99.7885 100.637 100.935 100.307 99.2722 98.807 99.4392 100.712 101.521 101.059 99.5564 98.1796 98.1351 99.6766 101.8 102.892 101.89 99.147 96.3662 95.6174 98.0013 102.752 107.302 108.271 102.904 90.2283 71.4761 49.6241 28.3533 10.8703 -0.925912 -6.74553 -7.64563 -5.4442 -2.05954 1.00495 2.90263 3.42953 2.87741 1.69059 0.445488 -0.629154 -1.18345 -1.42251 -1.23022 -0.902551 -0.569566 -0.0744485 99.9974 100.007 100.004 99.9845 99.9928 100.024 100.012 99.9688 99.9793 100.036 100.033 99.9625 99.9521 100.033 100.065 99.9809 99.9181 99.9948 100.092 100.04 99.9107 99.9175 100.066 100.123 99.9839 99.8536 99.9432 100.134 100.138 99.9279 99.8028 99.9602 100.196 100.172 99.8961 99.7347 99.9275 100.245 100.266 99.9308 99.6463 99.7897 100.222 100.427 100.124 99.6285 99.5187 99.9684 100.515 100.541 99.9571 99.34 99.3593 100.071 100.81 100.817 99.9934 99.0509 98.8927 99.774 101.011 101.519 100.738 99.1649 98.0341 98.3667 100.128 102.142 102.868 101.498 98.639 96.0787 95.7474 98.4848 103.308 107.606 108.144 102.403 89.607 71.0469 49.5943 28.7414 11.5014 -0.314048 -6.40231 -7.68812 -5.84941 -2.67227 0.395484 2.46171 3.3013 3.00601 2.10445 0.897439 -0.105665 -0.830278 -1.19232 -1.11201 -1.07959 -0.52999 99.9969 100.003 100.01 99.9923 99.9833 100.011 100.025 99.9875 99.9653 100.01 100.045 99.997 99.9448 99.9897 100.062 100.03 99.9371 99.9441 100.053 100.083 99.9727 99.8939 99.9852 100.113 100.07 99.9067 99.8733 100.038 100.163 100.051 99.847 99.8493 100.077 100.219 100.061 99.7967 99.7864 100.072 100.294 100.147 99.7857 99.6601 99.9575 100.347 100.352 99.924 99.5318 99.6464 100.191 100.589 100.373 99.7107 99.2725 99.555 100.349 100.897 100.613 99.6737 98.909 99.0726 100.136 101.249 101.418 100.361 98.8021 97.9763 98.6783 100.596 102.431 102.76 101.047 98.1301 95.8413 95.9442 99.015 103.873 107.886 107.976 101.864 88.9596 70.603 49.5614 29.1369 12.1574 0.339682 -6.00289 -7.67154 -6.22206 -3.27221 -0.276581 1.96473 3.02546 3.07347 2.38575 1.34431 0.416957 -0.479495 -0.750146 -1.13912 -0.824113 99.9979 99.9983 100.01 100.002 99.9825 99.996 100.025 100.008 99.9684 99.9842 100.036 100.027 99.9623 99.9583 100.033 100.058 99.9797 99.9258 99.9972 100.084 100.036 99.9194 99.9243 100.057 100.112 99.9908 99.8687 99.9406 100.115 100.132 99.9491 99.8202 99.9437 100.165 100.174 99.9351 99.758 99.8957 100.194 100.267 99.9942 99.6942 99.7512 100.132 100.397 100.207 99.7404 99.5219 99.8356 100.382 100.57 100.148 99.5043 99.3027 99.8095 100.589 100.884 100.341 99.3795 98.8639 99.3361 100.498 101.403 101.221 99.948 98.4905 98.0159 99.0622 101.062 102.651 102.565 100.544 97.6324 95.6637 96.2109 99.5893 104.44 108.135 107.764 101.287 88.2854 70.1449 49.5222 29.5366 12.8358 1.0326 -5.53415 -7.59637 -6.52154 -3.87485 -0.952214 1.35551 2.64688 3.00204 2.50846 1.80125 0.750634 0.14935 -0.532143 -0.720854 99.9996 99.9954 100.006 100.009 99.989 99.9851 100.015 100.022 99.9839 99.9692 100.014 100.041 99.9922 99.9496 99.9955 100.058 100.023 99.9409 99.9525 100.05 100.074 99.9734 99.9049 99.9872 100.102 100.064 99.9184 99.8843 100.028 100.146 100.055 99.8692 99.8559 100.053 100.198 100.077 99.8325 99.7907 100.031 100.26 100.171 99.8467 99.6786 99.8982 100.274 100.361 100.021 99.6099 99.6017 100.053 100.507 100.458 99.8998 99.3695 99.4295 100.091 100.759 100.769 100.026 99.142 98.9249 99.6648 100.83 101.459 100.932 99.5228 98.2514 98.1583 99.507 101.509 102.788 102.279 99.9983 97.1577 95.5562 96.5528 100.207 105.005 108.348 107.502 100.666 87.5821 69.6758 49.4791 29.9507 13.5305 1.77604 -5.02037 -7.44019 -6.77489 -4.43364 -1.62764 0.666202 2.23797 2.69011 2.66075 1.90515 1.2244 0.482777 -0.209368 100.001 99.9948 100.001 100.011 99.9986 99.982 100 100.025 100.003 99.9691 99.9906 100.036 100.02 99.9622 99.9666 100.035 100.05 99.9765 99.9346 100.003 100.076 100.028 99.9262 99.9348 100.053 100.1 99.9912 99.8831 99.9456 100.1 100.121 99.9606 99.8395 99.9398 100.14 100.165 99.9595 99.785 99.8837 100.153 100.252 100.033 99.7427 99.7424 100.065 100.351 100.248 99.8343 99.5595 99.7565 100.258 100.542 100.271 99.6681 99.3287 99.6372 100.362 100.835 100.562 99.7045 98.989 99.0908 100.032 101.103 101.404 100.569 99.112 98.1035 98.4028 99.9958 101.917 102.832 101.906 99.4197 96.7176 95.5251 96.9702 100.867 105.566 108.522 107.188 99.9956 86.8439 69.1809 49.4319 30.3694 14.2646 2.57293 -4.42638 -7.19476 -6.98315 -4.91989 -2.39823 0.0188245 1.57616 2.43132 2.53631 2.04009 1.65952 0.587712 100.002 99.9963 99.996 100.009 100.007 99.9864 99.9888 100.017 100.017 99.9807 99.975 100.018 100.034 99.9866 99.9557 100.003 100.052 100.014 99.9447 99.9632 100.049 100.062 99.9712 99.9168 99.9935 100.091 100.054 99.926 99.8987 100.026 100.129 100.05 99.8862 99.8695 100.041 100.175 100.079 99.8604 99.8061 100.008 100.225 100.175 99.8912 99.7092 99.8686 100.212 100.344 100.082 99.6871 99.6 99.9563 100.412 100.481 100.039 99.4914 99.391 99.8977 100.585 100.804 100.284 99.4123 98.9417 99.3506 100.403 101.288 101.237 100.153 98.7459 98.0646 98.7444 100.506 102.261 102.769 101.45 98.8256 96.3308 95.5816 97.4621 101.557 106.11 108.651 106.82 99.2869 86.0752 68.6712 49.3677 30.7805 15.0144 3.39651 -3.72392 -6.88761 -6.99817 -5.40409 -3.00741 -0.776145 0.886903 1.97488 2.06032 2.25693 1.3552 100.002 99.9989 99.9937 100.004 100.011 99.9947 99.9836 100.005 100.022 99.9969 99.9716 99.9979 100.034 100.011 99.963 99.9764 100.036 100.039 99.9726 99.9449 100.01 100.067 100.018 99.9321 99.9481 100.051 100.085 99.987 99.8971 99.956 100.09 100.104 99.9644 99.8591 99.9456 100.121 100.148 99.9712 99.8117 99.887 100.123 100.228 100.051 99.7848 99.7539 100.024 100.302 100.256 99.9019 99.6117 99.7231 100.161 100.485 100.332 99.8033 99.3997 99.5486 100.173 100.726 100.666 99.9674 99.1847 99.0101 99.683 100.746 101.364 100.963 99.7095 98.4512 98.1456 99.1745 101.019 102.521 102.591 100.912 98.2263 96.012 95.7397 98.0394 102.282 106.63 108.716 106.377 98.5177 85.2691 68.1598 49.3046 31.2368 15.7665 4.30473 -3.03252 -6.45368 -7.01905 -5.76364 -3.55192 -1.58589 0.455211 1.15732 2.12217 1.66489 100.001 100.001 99.9941 99.9983 100.01 100.003 99.9851 99.994 100.019 100.011 99.9787 99.9824 100.022 100.026 99.9815 99.9636 100.01 100.046 100.004 99.9493 99.9754 100.048 100.049 99.9676 99.9298 100.002 100.081 100.04 99.931 99.9155 100.028 100.112 100.039 99.8988 99.8878 100.037 100.153 100.07 99.8801 99.8278 99.9993 100.194 100.163 99.9187 99.7435 99.8626 100.166 100.312 100.11 99.7511 99.6246 99.9012 100.328 100.462 100.125 99.6061 99.4102 99.7766 100.421 100.762 100.438 99.654 99.0527 99.1896 100.053 101.024 101.32 100.602 99.2742 98.2529 98.3457 99.6697 101.504 102.682 102.303 100.311 97.6394 95.7664 95.9936 98.6915 103.039 107.136 108.734 105.874 97.6757 84.4078 67.577 49.2322 31.6647 16.6134 5.28232 -2.15899 -5.86081 -6.95783 -5.92122 -4.37456 -2.11838 -0.683148 0.76235 1.43736 100 100.003 99.9964 99.9947 100.007 100.009 99.9912 99.9872 100.01 100.018 99.9912 99.9762 100.005 100.03 100.002 99.9657 99.987 100.035 100.027 99.9694 99.9567 100.017 100.057 100.006 99.9385 99.9631 100.051 100.069 99.9803 99.9113 99.97 100.082 100.085 99.963 99.8787 99.958 100.107 100.126 99.9732 99.8367 99.9009 100.105 100.2 100.052 99.8181 99.7778 100.004 100.257 100.242 99.9433 99.6656 99.723 100.095 100.42 100.347 99.8993 99.4853 99.5242 100.039 100.6 100.684 100.148 99.3868 99.0401 99.4671 100.422 101.199 101.147 100.178 98.8873 98.1811 98.667 100.204 101.924 102.715 101.898 99.6685 97.1034 95.6298 96.3585 99.4026 103.792 107.579 108.687 105.304 96.8237 83.5224 67.0107 49.1098 32.0564 17.4069 6.19577 -1.14675 -5.29945 -6.3805 -6.13674 -4.39366 -2.84827 -1.25327 0.180174 99.9995 100.003 99.9992 99.9935 100.002 100.01 99.9987 99.986 99.9998 100.018 100.004 99.9788 99.9908 100.023 100.017 99.978 99.9732 100.017 100.037 99.9944 99.9557 99.9882 100.045 100.034 99.9642 99.9442 100.012 100.07 100.025 99.9353 99.9342 100.033 100.095 100.024 99.9087 99.9093 100.039 100.131 100.054 99.8932 99.8537 100.002 100.168 100.141 99.9316 99.7778 99.8744 100.136 100.274 100.113 99.7978 99.6639 99.882 100.262 100.421 100.163 99.6973 99.4624 99.7212 100.293 100.681 100.501 99.8347 99.1999 99.1502 99.8147 100.754 101.254 100.855 99.7203 98.5748 98.2459 99.1026 100.761 102.262 102.607 101.368 98.9792 96.6183 95.6182 96.8642 100.219 104.566 107.969 108.512 104.601 95.8452 82.5755 66.4613 49.0319 32.6306 18.2119 7.3811 -0.35462 -4.46492 -6.26752 -6.15611 -4.704 -3.64539 -1.0886 99.999 100.002 100.002 99.9947 99.9972 100.008 100.005 99.9893 99.9923 100.012 100.012 99.9872 99.9826 100.011 100.024 99.994 99.9707 99.9973 100.033 100.015 99.9682 99.9695 100.023 100.045 99.9948 99.9463 99.9786 100.05 100.051 99.9732 99.926 99.9853 100.074 100.065 99.9591 99.8982 99.9741 100.097 100.102 99.969 99.8596 99.9212 100.094 100.17 100.041 99.8424 99.8083 100.001 100.221 100.215 99.9617 99.7129 99.7447 100.06 100.36 100.33 99.9543 99.5641 99.542 99.9615 100.488 100.65 100.246 99.552 99.1252 99.3677 100.182 100.999 101.179 100.481 99.2828 98.3726 98.4397 99.607 101.289 102.495 102.378 100.764 98.2896 96.2009 95.6965 97.4556 101.081 105.367 108.355 108.323 103.86 94.7624 81.5284 65.6615 48.8894 32.9327 19.2557 8.52526 1.07957 -3.28819 -5.57867 -5.44755 -5.51232 -3.35896 99.999 100.001 100.003 99.997 99.9949 100.004 100.008 99.9948 99.989 100.005 100.015 99.9971 99.9816 99.9989 100.021 100.008 99.9773 99.9838 100.021 100.026 99.9866 99.9645 100 100.04 100.019 99.9633 99.9599 100.02 100.057 100.009 99.9411 99.954 100.038 100.077 100.008 99.9188 99.9329 100.043 100.109 100.035 99.9037 99.8823 100.012 100.144 100.113 99.9356 99.8118 99.8975 100.118 100.233 100.098 99.8305 99.7104 99.8878 100.214 100.367 100.166 99.7636 99.5292 99.7139 100.203 100.587 100.502 99.9519 99.3453 99.1875 99.6788 100.524 101.115 100.956 100.043 98.915 98.332 98.7874 100.162 101.73 102.551 101.978 100.088 97.6659 95.9515 95.965 98.1681 101.938 106.058 108.551 108.015 103.015 93.8095 80.5145 65.1387 48.6437 33.3065 19.9012 9.3079 2.23928 -2.86611 -4.09524 -5.67923 -3.68808 99.9992 100 100.003 99.9995 99.9945 100 100.008 100 99.9895 99.998 100.013 100.005 99.9857 99.9903 100.014 100.016 99.9881 99.978 100.006 100.028 100.004 99.9699 99.9829 100.027 100.032 99.9853 99.9562 99.9936 100.046 100.033 99.9673 99.9422 100.001 100.066 100.043 99.9546 99.9188 99.9924 100.087 100.075 99.9608 99.8821 99.9468 100.089 100.139 100.022 99.8603 99.8442 100.012 100.191 100.177 99.9605 99.7534 99.7836 100.052 100.309 100.288 99.9713 99.6294 99.5913 99.9379 100.404 100.582 100.269 99.6638 99.2347 99.3664 100.042 100.814 101.104 100.616 99.5741 98.6229 98.4336 99.2649 100.764 102.108 102.46 101.413 99.2985 97.0314 95.8051 96.4276 99.0916 102.984 106.789 108.699 107.412 101.899 92.3984 79.3211 64.4474 48.6008 34.2006 20.9108 11.3143 3.05829 -0.972948 -4.55804 -5.14809 99.9996 99.9991 100.002 100.002 99.9957 99.9974 100.006 100.004 99.9927 99.9934 100.008 100.01 99.9927 99.9866 100.005 100.017 99.9994 99.9798 99.9936 100.021 100.015 99.9823 99.9747 100.009 100.033 100.006 99.9655 99.9751 100.026 100.043 99.9961 99.949 99.9725 100.04 100.058 99.9942 99.9298 99.9554 100.047 100.087 100.015 99.9132 99.9103 100.023 100.123 100.084 99.9348 99.8428 99.9247 100.108 100.195 100.074 99.8507 99.7551 99.9082 100.184 100.315 100.147 99.8027 99.5919 99.7359 100.154 100.507 100.467 100.008 99.4556 99.2548 99.6272 100.372 100.975 100.959 100.228 99.1792 98.4804 98.665 99.7722 101.279 102.337 102.247 100.813 98.5796 96.5074 95.7608 96.8931 99.9881 103.931 107.558 108.887 107.051 100.917 91.0642 77.9888 63.0906 48.1443 33.61 22.0444 11.7385 5.59721 0.596271 -1.75755 100 99.9988 100.001 100.002 99.9976 99.9961 100.003 100.006 99.9967 99.9921 100.003 100.01 99.9991 99.9875 99.9978 100.014 100.007 99.986 99.9871 100.011 100.019 99.9947 99.9757 99.9952 100.025 100.018 99.9801 99.9692 100.006 100.038 100.016 99.9661 99.9607 100.013 100.053 100.022 99.9544 99.9421 100.009 100.073 100.048 99.9552 99.9083 99.9734 100.082 100.104 100 99.8805 99.8851 100.026 100.159 100.132 99.9526 99.7959 99.8338 100.055 100.256 100.23 99.9691 99.692 99.662 99.9454 100.331 100.49 100.245 99.7422 99.3589 99.4281 99.9704 100.646 100.968 100.638 99.7771 98.887 98.5601 99.1137 100.362 101.678 102.296 101.732 100.046 97.9097 96.2798 96.1084 97.739 101.007 104.749 107.876 108.502 106.223 99.5769 90.1227 76.8439 63.2163 47.7798 34.7478 22.0498 12.4665 5.5495 -1.12591 100 99.9988 100 100.003 99.9995 99.9958 100 100.006 100 99.9927 99.9983 100.009 100.004 99.9906 99.9927 100.009 100.011 99.9933 99.9846 100.002 100.019 100.005 99.981 99.9856 100.015 100.024 99.9948 99.9703 99.9897 100.028 100.028 99.9851 99.9587 99.9904 100.041 100.039 99.981 99.9419 99.9783 100.05 100.064 99.9946 99.9219 99.9398 100.038 100.103 100.051 99.9283 99.873 99.9593 100.107 100.156 100.038 99.8577 99.8018 99.9478 100.174 100.261 100.1 99.8117 99.6527 99.7939 100.153 100.441 100.393 99.9931 99.5206 99.3508 99.6717 100.318 100.855 100.866 100.25 99.3212 98.653 98.7306 99.649 100.999 102.074 102.188 101.107 99.1216 97.1066 95.9607 96.5218 98.8024 102.413 106.059 108.508 108.377 104.837 97.82 87.3927 75.0132 61.1707 47.6434 35.3533 23.8892 16.888 7.64815 100 99.9992 99.9994 100.002 100.001 99.9969 99.9983 100.004 100.003 99.9953 99.9957 100.005 100.006 99.9958 99.9913 100.002 100.011 100.001 99.9876 99.9947 100.012 100.011 99.9907 99.9831 100.003 100.021 100.007 99.9803 99.981 100.012 100.029 100.004 99.9698 99.9762 100.019 100.04 100.007 99.9593 99.9618 100.017 100.058 100.027 99.9557 99.9317 99.9917 100.071 100.075 99.987 99.9006 99.9181 100.034 100.13 100.096 99.9489 99.8323 99.8748 100.056 100.213 100.182 99.9653 99.7413 99.7212 99.9575 100.279 100.415 100.216 99.792 99.4538 99.4888 99.9368 100.531 100.855 100.626 99.8987 99.0739 98.6769 99.0474 100.108 101.366 102.137 101.886 100.541 98.5236 96.7386 95.9652 96.9897 99.4871 103.325 106.609 109.071 108.084 104.725 96.6492 86.6499 73.3791 59.4999 46.1573 31.724 23.5307 9.84835 100 99.9995 99.9992 100.001 100.001 99.998 99.9977 100.002 100.003 99.9974 99.9953 100.002 100.006 99.9989 99.9923 99.9991 100.009 100.004 99.9912 99.9924 100.007 100.012 99.9968 99.9852 99.9968 100.015 100.011 99.9884 99.9808 100.002 100.023 100.011 99.9805 99.9745 100.005 100.033 100.017 99.9747 99.9617 99.9998 100.044 100.036 99.979 99.9412 99.9732 100.044 100.071 100.015 99.9316 99.9157 99.9958 100.094 100.103 99.9984 99.8777 99.867 99.9946 100.151 100.183 100.039 99.8296 99.7435 99.8807 100.154 100.344 100.271 99.9507 99.6053 99.5091 99.7829 100.285 100.682 100.668 100.173 99.444 98.9173 98.9718 99.6884 100.775 101.677 101.858 101.065 99.4912 97.7464 96.5915 96.7213 98.32 101.21 104.47 107.192 108.127 106.457 101.997 94.0045 84.7854 71.7507 61.6242 46.1702 39.6762 23.6226 100 99.9999 99.9989 100 100.002 99.9993 99.9971 100.001 100.004 99.9999 99.9951 99.9991 100.006 100.002 99.9938 99.9953 100.006 100.007 99.9958 99.99 100.001 100.012 100.004 99.9881 99.99 100.009 100.016 99.9982 99.9809 99.9914 100.017 100.02 99.9932 99.9729 99.9899 100.024 100.029 99.9929 99.9619 99.9791 100.027 100.046 100.006 99.952 99.951 100.012 100.068 100.049 99.9673 99.9111 99.95 100.053 100.114 100.058 99.9279 99.8526 99.9199 100.083 100.192 100.129 99.9271 99.7556 99.7807 100.014 100.282 100.356 100.139 99.7574 99.4935 99.579 100.014 100.536 100.781 100.517 99.8281 99.089 98.7713 99.1619 100.171 101.343 102.038 101.803 100.498 98.6294 96.8012 96.1069 96.7436 99.3194 102.589 106.472 108.693 109.2 106.342 100.089 91.6713 78.7575 68.4383 51.3113 44.3458 25.5228 100 100 99.9993 99.9998 100.001 100 99.9983 99.9993 100.002 100.001 99.9975 99.9979 100.003 100.003 99.9978 99.9957 100.001 100.005 100 99.9939 99.9971 100.006 100.006 99.9958 99.9914 100.001 100.01 100.005 99.9908 99.9897 100.005 100.015 100.004 99.9858 99.9862 100.007 100.021 100.007 99.9814 99.9778 100.004 100.029 100.019 99.9825 99.9626 99.9873 100.032 100.045 100.005 99.9525 99.9472 100.002 100.065 100.066 99.9942 99.9157 99.9124 100 100.105 100.124 100.025 99.8807 99.8205 99.9147 100.107 100.245 100.2 99.9746 99.7193 99.6331 99.8173 100.186 100.504 100.532 100.188 99.6282 99.1709 99.1346 99.6261 100.489 101.288 101.612 101.113 99.938 98.3657 97.1841 96.8256 97.8346 100.062 102.933 106.093 107.411 108.272 104.112 101.077 89.7321 84.4128 66.9863 62.9354 42.2127 ) ; boundaryField { left { type fixedValue; value uniform 100; } right { type zeroGradient; } up { type zeroGradient; } down { type fixedValue; value uniform 0; } frontAndBack { type empty; } } // ************************************************************************* //
46d80b93632203d9801e85e264caa758798e6730
028a07cc4e8598564c47a82573f31ab36c8ff49c
/PAT_Test_1030/PAT_Test_1030/PAT_1030.cpp
1193d4b151333b56d55c89ca76377b52599bce3d
[]
no_license
yesbutter/HBU-PAT-Work
bf1804ebccd7d37c60925ada38dac9181a8d8692
9a27a5fcc5aaab2f72c8c7d830ed181988ea088b
refs/heads/master
2021-09-23T01:01:10.029605
2018-06-13T05:30:35
2018-06-13T05:30:35
120,148,195
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
558
cpp
PAT_1030.cpp
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<vector> #include<algorithm> using namespace std; vector<long long> v; int main() { long long N, p,cnt=0,min,tmp; cin >> N >> p; for (long long i = 0; i < N; i++) { cin >> tmp; v.push_back(tmp); } sort(v.begin(), v.end()); min = v[0]; for (int j = 0; j < N; j++) { for (int i =j+cnt; i < N; i++)//Õâ¸öÌøcnt·Ç³£ÇÉÃ£¡£¡ { if (v[j]*p < v[i]) { break; } if (i - j + 1>cnt) cnt = i - j + 1; } } cout << cnt; system("pause"); return 0; }
5f588b792bf76df0c9e26e87878a7d6a08b92a57
8a87f5b889a9ce7d81421515f06d9c9cbf6ce64a
/tests/Futures/PromiseTest.cpp
a5fe7938d05f7cdcef13055c51b2c54f83b9d212
[ "Apache-2.0", "BSD-3-Clause", "ICU", "Zlib", "GPL-1.0-or-later", "OpenSSL", "ISC", "LicenseRef-scancode-gutenberg-2020", "MIT", "GPL-2.0-only", "CC0-1.0", "BSL-1.0", "LicenseRef-scancode-autoconf-simple-exception", "LicenseRef-scancode-pcre", "Bison-exception-2.2", "LicenseRef-scancode...
permissive
arangodb/arangodb
0980625e76c56a2449d90dcb8d8f2c485e28a83b
43c40535cee37fc7349a21793dc33b1833735af5
refs/heads/devel
2023-08-31T09:34:47.451950
2023-08-31T07:25:02
2023-08-31T07:25:02
2,649,214
13,385
982
Apache-2.0
2023-09-14T17:02:16
2011-10-26T06:42:00
C++
UTF-8
C++
false
false
8,878
cpp
PromiseTest.cpp
//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2014-2020 ArangoDB GmbH, Cologne, Germany /// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany /// /// 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. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Simon Grätzer //////////////////////////////////////////////////////////////////////////////// #include "Futures/Promise.h" #include "gtest/gtest.h" using namespace arangodb::futures; namespace { auto makeValid() { auto valid = Promise<int>(); EXPECT_TRUE(valid.valid()); return valid; } auto makeInvalid() { auto invalid = Promise<int>::makeEmpty(); EXPECT_FALSE(invalid.valid()); return invalid; } template<typename T> constexpr typename std::decay<T>::type copy(T&& value) noexcept( noexcept(typename std::decay<T>::type(std::forward<T>(value)))) { return std::forward<T>(value); } typedef std::domain_error eggs_t; static eggs_t eggs("eggs"); } // namespace // ----------------------------------------------------------------------------- // --SECTION-- test suite // ----------------------------------------------------------------------------- TEST(PromiseTest, makeEmpty) { auto p = Promise<int>::makeEmpty(); ASSERT_TRUE(p.isFulfilled()); } TEST(PromiseTest, special) { ASSERT_FALSE(std::is_copy_constructible<Promise<int>>::value); ASSERT_FALSE(std::is_copy_assignable<Promise<int>>::value); ASSERT_TRUE(std::is_move_constructible<Promise<int>>::value); ASSERT_TRUE(std::is_move_assignable<Promise<int>>::value); } TEST(PromiseTest, getFuture) { Promise<int> p; Future<int> f = p.getFuture(); ASSERT_FALSE(f.isReady()); } TEST(PromiseTest, setValueUnit) { Promise<Unit> p; p.setValue(); } TEST(PromiseTest, ctorPostconditionValid) { // Ctors/factories that promise valid -- postcondition: valid() #define DOIT(CREATION_EXPR) \ do { \ auto p1 = (CREATION_EXPR); \ ASSERT_TRUE(p1.valid()); \ auto p2 = std::move(p1); \ ASSERT_FALSE(p1.valid()); \ ASSERT_TRUE(p2.valid()); \ } while (false) DOIT(makeValid()); DOIT(Promise<int>()); DOIT(Promise<int>{}); DOIT(Promise<Unit>()); DOIT(Promise<Unit>{}); #undef DOIT } TEST(PromiseTest, ctorPostconditionInvali) { // Ctors/factories that promise invalid -- postcondition: !valid() #define DOIT(CREATION_EXPR) \ do { \ auto p1 = (CREATION_EXPR); \ ASSERT_FALSE(p1.valid()); \ auto p2 = std::move(p1); \ ASSERT_FALSE(p1.valid()); \ ASSERT_FALSE(p2.valid()); \ } while (false) DOIT(makeInvalid()); DOIT(Promise<int>::makeEmpty()); #undef DOIT } TEST(PromiseTest, lacksPreconditionValid) { // Ops that don't throw PromiseInvalid if !valid() -- // without precondition: valid() #define DOIT(STMT) \ do { \ auto p = makeValid(); \ { STMT; } \ copy(std::move(p)); \ STMT; \ } while (false) // misc methods that don't require isValid() DOIT(p.valid()); DOIT(p.isFulfilled()); // move-ctor - move-copy to local, copy(), pass-by-move-value DOIT(auto other = std::move(p)); DOIT(copy(std::move(p))); DOIT(([](auto) {})(std::move(p))); // move-assignment into either {valid | invalid} DOIT({ auto other = makeValid(); other = std::move(p); }); DOIT({ auto other = makeInvalid(); other = std::move(p); }); #undef DOIT } TEST(PromiseTest, hasPreconditionValid) { // Ops that require validity; precondition: valid(); // throw PromiseInvalid if !valid() #define DOIT(STMT) \ do { \ auto p = makeValid(); \ STMT; \ ::copy(std::move(p)); \ EXPECT_ANY_THROW(STMT); \ } while (false) auto const except = std::logic_error("foo"); auto const ewrap = std::make_exception_ptr(except); DOIT(p.getFuture()); DOIT(p.setException(except)); DOIT(p.setException(ewrap)); // DOIT(p.setInterruptHandler([](auto&) {})); DOIT(p.setValue(42)); DOIT(p.setTry(Try<int>(42))); DOIT(p.setTry(Try<int>(ewrap))); DOIT(p.setWith([] { return 42; })); #undef DOIT } TEST(PromiseTest, hasPostconditionValid) { // Ops that preserve validity -- postcondition: valid() #define DOIT(STMT) \ do { \ auto p = makeValid(); \ STMT; \ ASSERT_TRUE(p.valid()); \ } while (false) auto const swallow = [](auto) {}; DOIT(swallow(p.valid())); // p.valid() itself preserves validity DOIT(swallow(p.isFulfilled())); #undef DOIT } TEST(PromiseTest, hasPostconditionInvalid) { // Ops that consume *this -- postcondition: !valid() #define DOIT(CTOR, STMT) \ do { \ auto p = (CTOR); \ STMT; \ ASSERT_FALSE(p.valid()); \ } while (false) // move-ctor of {valid|invalid} DOIT(makeValid(), { auto other{std::move(p)}; }); DOIT(makeInvalid(), { auto other{std::move(p)}; }); // move-assignment of {valid|invalid} into {valid|invalid} DOIT(makeValid(), { auto other = makeValid(); other = std::move(p); }); DOIT(makeValid(), { auto other = makeInvalid(); other = std::move(p); }); DOIT(makeInvalid(), { auto other = makeValid(); other = std::move(p); }); DOIT(makeInvalid(), { auto other = makeInvalid(); other = std::move(p); }); // pass-by-value of {valid|invalid} DOIT(makeValid(), { auto const byval = [](auto) {}; byval(std::move(p)); }); DOIT(makeInvalid(), { auto const byval = [](auto) {}; byval(std::move(p)); }); #undef DOIT } TEST(PromiseTest, setValue) { Promise<int> fund; auto ffund = fund.getFuture(); fund.setValue(42); ASSERT_TRUE(42 == ffund.get()); struct Foo { std::string name; int value; }; Promise<Foo> pod; auto fpod = pod.getFuture(); Foo f = {"the answer", 42}; pod.setValue(f); Foo f2 = fpod.get(); ASSERT_TRUE(f.name == f2.name); ASSERT_TRUE(f.value == f2.value); pod = Promise<Foo>(); fpod = pod.getFuture(); pod.setValue(std::move(f2)); Foo f3 = fpod.get(); ASSERT_TRUE(f.name == f3.name); ASSERT_TRUE(f.value == f3.value); Promise<std::unique_ptr<int>> mov; auto fmov = mov.getFuture(); mov.setValue(std::make_unique<int>(42)); std::unique_ptr<int> ptr = std::move(fmov).get(); ASSERT_TRUE(42 == *ptr); Promise<Unit> v; auto fv = v.getFuture(); v.setValue(); ASSERT_TRUE(fv.isReady()); } TEST(PromiseTest, setException) { { Promise<int> p; auto f = p.getFuture(); p.setException(eggs); EXPECT_THROW(f.get(), eggs_t); } { Promise<int> p; auto f = p.getFuture(); p.setException(std::make_exception_ptr(eggs)); EXPECT_THROW(f.get(), eggs_t); } } TEST(PromiseTest, setWith) { { Promise<int> p; auto f = p.getFuture(); p.setWith([] { return 42; }); ASSERT_TRUE(42 == f.get()); } { Promise<int> p; auto f = p.getFuture(); p.setWith([]() -> int { throw eggs; }); EXPECT_THROW(f.get(), eggs_t); } } TEST(PromiseTest, isFulfilled) { Promise<int> p; ASSERT_FALSE(p.isFulfilled()); p.setValue(42); ASSERT_TRUE(p.isFulfilled()); } TEST(PromiseTest, isFulfilledWithFuture) { Promise<int> p; auto f = p.getFuture(); // so core_ will become null ASSERT_FALSE(p.isFulfilled()); p.setValue(42); // after here ASSERT_TRUE(p.isFulfilled()); } TEST(PromiseTest, brokenOnDelete) { auto p = std::make_unique<Promise<int>>(); auto f = p->getFuture(); ASSERT_FALSE(f.isReady()); p.reset(); ASSERT_TRUE(f.isReady()); auto t = f.getTry(); ASSERT_TRUE(t.hasException()); EXPECT_THROW(t.throwIfFailed(), FutureException); // ASSERT_TRUE(t.hasException<BrokenPromise>()); } /*TEST(PromiseTest, brokenPromiseHasTypeInfo) { auto pInt = std::make_unique<Promise<int>>(); auto fInt = pInt->getFuture(); auto pFloat = std::make_unique<Promise<float>>(); auto fFloat = pFloat->getFuture(); pInt.reset(); pFloat.reset(); try { auto whatInt = fInt.getTry().exception().what(); } catch(e) { } auto whatFloat = fFloat.getTry().exception().what(); ASSERT_TRUE(whatInt != whatFloat); }*/
c90cafef4b30ca7147fcaf5e2a7410dd3d90e909
8b8f2343a288aab7863ac1dc408b60152ed109b0
/libport-core/src/main/native/tests/legacy-tests/test_integration.cc
22c51bc2950c1c479b4429424af062672073fe79
[ "BSD-2-Clause-Views" ]
permissive
jerryz920/libport
afed8bfd699e959faa4f6398d61e42516a459a9f
72c6534e8f064b5507a5c79766a13114478d3ffa
refs/heads/master
2021-01-02T08:52:59.034298
2018-05-05T19:32:12
2018-05-05T19:32:12
99,083,085
0
0
null
null
null
null
UTF-8
C++
false
false
8,482
cc
test_integration.cc
//// Simulate a process call the port library, for some new process and call it in the forked process // This test should be executed on a modified kernel to work out. #include "libport.h" #include <string> #include <stdio.h> #include <thread> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/wait.h> #include <fcntl.h> #include <syslog.h> #include "utils.h" namespace { std::string server_url = "http://10.10.1.1:10011"; uint32_t local_abac_port = 10013; std::string object_to_attest = "integrate_object"; } #define FAIL(msg) fprintf(stderr, "error at line %d: %s\n", __LINE__, (msg)) #define SUSPEND(msg) {fprintf(stderr, "error at line %d: %s\n", __LINE__, (msg)); exit(1);} int wait_principal(pid_t child) { int status; int ret = 0; if (waitpid(child, &status, 0) < 0) { perror("waitpid"); ret = -1; } if (WIFEXITED(status)) { printf("%d exit!\n", child); ret = WEXITSTATUS(status); } else { ret = -2; } fprintf(stderr, "before deleting child\n"); ::delete_principal(child); fprintf(stderr, "after deleting child\n"); return ret; } int create_server_socket(int local_port) { int s = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in addr = { .sin_family = AF_INET, .sin_port = htons(local_port), .sin_addr = {INADDR_ANY}, }; int val = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { perror("setsockopt"); } int flag = fcntl(s, F_GETFL, 0); if (fcntl(s, F_SETFL, flag | O_NONBLOCK) < 0) { perror("fcntl"); } if (bind(s, (struct sockaddr*) (&addr), sizeof(addr)) < 0) { perror("bind"); SUSPEND("fail to allocate socket"); } if (listen(s, 100) < 0) { perror("listen"); SUSPEND("fail to listen on port"); } return s; } bool client_try_access(int local_port, int expected_port_lo = -1, int expected_port_hi = -1) { bool ret = true; int c = socket(AF_INET, SOCK_STREAM, 0); auto myip = latte::utils::get_myip(); struct sockaddr_in addr = { .sin_family = AF_INET, .sin_port = htons(local_port), .sin_addr = {inet_addr(myip.c_str())}, }; struct sockaddr_in my_addr; socklen_t my_addr_len = sizeof(my_addr); if (connect(c, (struct sockaddr*) (&addr), sizeof(addr)) < 0) { /// This way we only quit the client process, server needs // to capture the status perror("connect"); SUSPEND("fail to connect to server "); } getsockname(c, (struct sockaddr*) &my_addr, &my_addr_len); fprintf(stderr, "client socket seen port: %d\n", ntohs(my_addr.sin_port)); if (expected_port_lo != -1) { auto port = ntohs(my_addr.sin_port); ret = port >= expected_port_lo && port < expected_port_hi; } char buf = 0; while (true) { int ret = recv(c, &buf, 1, 0); if (ret == 0 || (ret < 0 && errno == EAGAIN)) { continue; } if (ret == 1) { break; } else { perror("recv"); SUSPEND("error receiving message from server\n"); } } close(c); return buf == 1 && ret; } int accept_child_task() { /// fork twice and do new principal if (client_try_access(local_abac_port)) { return 0; } return 1; } int reject_normal_child_task() { /// connect to local_abac_port if (client_try_access(local_abac_port)) { return 0; } return 1; } int attester_child_task() { /// works as attester, create a new attester with accepted image and try. ::libport_init(server_url.c_str(), "/tmp/libport-integration-child.json", 0); pid_t child; fprintf(stderr, "entering attester\n"); usleep(100000); if ((child = fork()) == 0) { /// child usleep(100000); exit(accept_child_task()); } else { fprintf(stderr, "before create first principal \n"); ::create_principal(child, "image_accept", "config_accept", 10); fprintf(stderr, "this should be allowed, actual value: %d, should also not use child ports\n", client_try_access(local_abac_port)); int ret = wait_principal(child); if (ret != 0) { fprintf(stderr, "ChildAttester: child that should be accepted returns %d\n", ret); FAIL("principal failure\n"); return 1; } } // fork and simulate bad principal if ((child = fork()) == 0) { /// child usleep(100000); exit(reject_normal_child_task()); } else { fprintf(stderr, "before create second principal \n"); ::create_principal(child, "image_reject", "config_reject", 10); int ret = wait_principal(child); if (ret != 1) { fprintf(stderr, "ChildAttester: child that should fail returns %d\n", ret); FAIL("principal failure\n"); return 1; } } return 0; } int main(int argc, char **argv) { if (argc > 1) { server_url = argv[1]; } ::libport_set_log_level(LOG_DEBUG); if (mkdir("/tmp/libport-integration/", 0700) < 0 && errno != EEXIST) { perror("mkdir"); SUSPEND("can not create monitor directory"); } if (::libport_init(server_url.c_str(), "/tmp/libport-integration.json", 1)) { SUSPEND("fail to init the libport"); } bool terminate = false; printf("original terminate %p\n", &terminate); auto listener = std::thread([&terminate]() { int server_s = create_server_socket(local_abac_port); while (!terminate) { struct sockaddr_in client_addr; socklen_t client_addr_len = sizeof(client_addr); int c = accept(server_s, (struct sockaddr*)&client_addr, &client_addr_len); if (c < 0 && errno == EAGAIN) { usleep(100000); continue; } std::thread([c,client_addr]() { char client_ip[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &client_addr.sin_addr, client_ip, INET_ADDRSTRLEN); int client_port = ntohs(client_addr.sin_port); bool allow_access = ::attest_principal_access(client_ip, client_port, object_to_attest.c_str()); char buf = allow_access? 1: 0; while (true) { int ret = send(c, &buf, 1, MSG_NOSIGNAL); if ((ret < 0 && errno == EAGAIN) || ret == 0) { continue; } break; } close(c); }).detach(); } close(server_s); }); /// start a passive port on localhost:local_abac_port // the thread only attests if access to object 'xxx' is permitted // Create new images if (::create_image("image_accept", "git://accept_image", "rev1", "config1")) { SUSPEND("fail to create image_accept"); } if (::create_image("image_reject", "git://accept_reject", "rev2", "config1")) { SUSPEND("fail to create image_accept"); } // Endorse image with new properties if (::endorse_image_new("image_accept", "accept_property", "config1")) { SUSPEND("fail to endorse image property"); } // Create new object acls if (::post_object_acl(object_to_attest.c_str(), "accept_property")) { SUSPEND("fail to endorse object acl"); } // fork and create new principal pid_t child; if ((child = fork()) == 0) { /// child usleep(100000); exit(accept_child_task()); } else { fprintf(stderr, "launched child %d\n", child); ::create_principal(child, "image_accept", "config_accept", 100); int ret = wait_principal(child); if (ret != 0) { fprintf(stderr, "child that should be accepted returns %d\n", ret); FAIL("principal failure\n"); } } fprintf(stderr, "before forking new\n"); // fork and simulate bad principal if ((child = fork()) == 0) { /// child usleep(100000); exit(reject_normal_child_task()); } else { ::create_principal(child, "image_reject", "config_reject", 100); int ret = wait_principal(child); if (ret != 1) { fprintf(stderr, "child that should fail returns %d\n", ret); FAIL("principal failure\n"); } } fprintf(stderr, "------start of attester task -----\n"); // fork and simulate bad principal if ((child = fork()) == 0) { /// child attester_child_task(); exit(0); } else { ::create_principal(child, "image_accept", "config_accept", 100); int ret = wait_principal(child); if (ret != 0) { fprintf(stderr, "MainProcess: attester child returns %d\n", ret); FAIL("main process principal failure\n"); } } // simulate restart, resume from last config check point terminate = true; listener.join(); return 0; }
434abd1183852adabd7309a856a790bf3cae9c1c
09d1138225f295ec2e5f3e700b44acedcf73f383
/Qt/ApplicationComponents/pqEnableWidgetDecorator.h
b930bc2f5743d283d4395b128c0e3a1eabe40134
[ "BSD-3-Clause" ]
permissive
nagyist/ParaView
e86d1ed88a805aecb13f707684103e43d5f6b09f
6810d701c44b2097baace5ad2c05f81c6d0fd310
refs/heads/master
2023-09-04T07:34:57.251637
2023-09-03T00:34:36
2023-09-03T00:34:57
85,244,343
0
0
BSD-3-Clause
2023-09-11T15:57:25
2017-03-16T21:44:59
C++
UTF-8
C++
false
false
934
h
pqEnableWidgetDecorator.h
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation // SPDX-License-Identifier: BSD-3-Clause #ifndef pqEnableWidgetDecorator_h #define pqEnableWidgetDecorator_h #include "pqApplicationComponentsModule.h" #include "pqBoolPropertyWidgetDecorator.h" #include "vtkWeakPointer.h" /** * pqEnableWidgetDecorator can be used to enable/disable a widget based on the * status of another property not directly controlled by the widget. */ class PQAPPLICATIONCOMPONENTS_EXPORT pqEnableWidgetDecorator : public pqBoolPropertyWidgetDecorator { Q_OBJECT typedef pqBoolPropertyWidgetDecorator Superclass; public: pqEnableWidgetDecorator(vtkPVXMLElement* config, pqPropertyWidget* parent); /** * overridden from pqPropertyWidget. */ bool enableWidget() const override { return this->isBoolProperty(); } private: Q_DISABLE_COPY(pqEnableWidgetDecorator) }; #endif
364a6e1533787bdb4dd32b91264e8a0bd0001abd
37513bf262dadb93ab66c4810d8baac4a9107dc1
/lca/main.cpp
f26fb414aa8888438751cd17bb103c0b1d2b16e7
[]
no_license
JeffersonCarvalh0/spoj-problems
9cbd2770af894b6a448a431e955ab830e81351e7
0d1895a0599965a4419fa629b672c5ef2d775c43
refs/heads/master
2020-03-14T17:00:17.692197
2018-09-04T00:54:31
2018-09-04T00:54:31
131,710,096
1
0
null
null
null
null
UTF-8
C++
false
false
2,336
cpp
main.cpp
# include <iostream> # include <vector> # include <list> using namespace std; int logs[2005]; class SparseTable { public: vector<vector<int>> st; vector<int> &a; SparseTable(vector<int> &a): a(a) { int n = a.size(); st = vector<vector<int>>(n, vector<int>(logs[n] + 1)); for (int i = 0; i < n; ++i) st[i][0] = i; for (int j = 1; j <= logs[n]; ++j) { for (int i = 0; i + (1 << j) <= n; ++i) { if (a[st[i][j - 1]] < a[st[i + (1 << (j - 1))][j - 1]]) st[i][j] = st[i][j - 1]; else st[i][j] = st[i + (1 << (j - 1))][j - 1]; } } } int query(int l, int r) { if (r < l) swap(l, r); int span = r - l + 1, j = logs[span]; if (a[st[l][j]] < a[st[l + span - (1 << j)][j]]) return st[l][j]; else return st[l + span - (1 << j)][j]; } }; class LCA { public: vector<int> euler, heights, first; vector<bool> visited; LCA(vector<list<int>> &adj_list) { visited.resize(adj_list.size(), false); first.resize(adj_list.size()); dfs(0, 1, adj_list); } void dfs(int v, int h, vector<list<int>> &adj_list) { visited[v] = true; first[v] = euler.size(); euler.push_back(v); heights.push_back(h); for (auto &adj : adj_list[v]) { if (!visited[adj]) dfs(adj, h + 1, adj_list), euler.push_back(v), heights.push_back(h); } } int query(int v1, int v2, SparseTable &st) { return euler[st.query(first[v1], first[v2])]; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t, n, m, cur, q, v, w; logs[1] = 0; for (int i = 2; i < 2005; ++i) logs[i] = logs[i/2] + 1; cin >> t; for (int c = 1; c <= t; ++c) { cout << "Case " << c << ":\n"; cin >> n; vector<list<int>> adj_list(n); for (int i = 0; i < n; ++i) { cin >> m; while (m--) cin >> cur, adj_list[i].push_back(--cur), adj_list[cur].push_back(i); } LCA lca(adj_list); SparseTable st(lca.heights); cin >> q; while (q--) cin >> v >> w, cout << lca.query(--v, --w, st) + 1 << '\n'; } return 0; }
426b99bd185df9e860ac96e22109cc40ffce5c2d
e5aa3a57f93383020659929c73fa023db18644b7
/cyrinput/keyboard.h
0ba513ed0d2303adc2ba5ca0f45db9b05f4d1199
[]
no_license
pdaxrom/cyrillica
975a4b4231eb4e21360c1715d64a97e023cd1624
bf1491e83ded500df76d2653416cc0ed2d1f0fca
refs/heads/master
2022-12-17T16:27:10.760212
2003-10-09T13:05:31
2003-10-09T13:05:31
297,676,436
0
0
null
null
null
null
UTF-8
C++
false
false
1,210
h
keyboard.h
#include <qframe.h> //#include "../pickboard/pickboardcfg.h" //#include "../pickboard/pickboardpicks.h" class QTimer; class Keyboard : public QFrame { Q_OBJECT public: Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); void resetState(); void mousePressEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); void resizeEvent(QResizeEvent*); void paintEvent(QPaintEvent* e); void timerEvent(QTimerEvent* e); void drawKeyboard( QPainter &p, int key = -1 ); void setMode(int mode) { useOptiKeys = mode; } QSize sizeHint() const; signals: void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); public slots: void message( const QCString& ); private slots: void repeat(); private: int getKey( int &w, int j = -1 ); void clearHighlight(); uint shift:1; uint lock:1; uint ctrl:1; uint alt:1; uint useLargeKeys:1; uint useOptiKeys:1; // uint latcyr:1; int nlayout; int pressedKey; int keyHeight; int defaultKeyWidth; int xoffs; int unicode; int qkeycode; int modifiers; int pressTid; bool pressed; QTimer *repeatTimer; };
ce85f0f8fbe9d58d029e9d4e166709a8ff1d4c86
585205f7e6ae7344dbcaa87518e5782c1f709cdb
/ofApp.cpp
b4ce9592abb68263ffbb4bbcb65e9745f9f4e0d7
[]
no_license
junkiyoshi/Insta20210921
1a1ccd04a227a1be14497b3e12dd04e4e5fa69ce
afcadb908fb4df05c3477ac3d366112e48df0e15
refs/heads/main
2023-08-19T00:51:04.728856
2021-09-21T11:29:27
2021-09-21T11:29:27
408,793,225
0
0
null
null
null
null
UTF-8
C++
false
false
5,870
cpp
ofApp.cpp
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(0); ofEnableBlendMode(ofBlendMode::OF_BLENDMODE_ADD); ofSetCircleResolution(72); this->base_color_list.push_back(glm::vec3(0.4, 0.25, 0.25)); this->base_color_list.push_back(glm::vec3(0.25, 0.4, 0.25)); this->base_color_list.push_back(glm::vec3(0.25, 0.25, 0.4)); this->frame_span = 60; this->size = 15; this->number_of_targets = 120; for (int x = this->size * 6; x <= ofGetWidth() - this->size * 6; x += this->size * 3) { for (int y = this->size * 6; y <= ofGetHeight() - this->size * 6; y += this->size * 3) { this->location_list.push_back(glm::vec2(x, y)); } } for (int i = 0; i < this->number_of_targets; i++) { this->target_list.push_back(glm::vec2()); this->target_color_list.push_back(glm::vec3(1, 1, 1)); this->current_index_list.push_back(0); this->next_index_list.push_back(ofRandom(this->location_list.size())); this->color_list.push_back(this->base_color_list[ofRandom(this->base_color_list.size())]); } this->shader.load("shader/shader.vert", "shader/shader.frag"); } //-------------------------------------------------------------- void ofApp::update() { for (int i = 0; i < this->current_index_list.size(); i++) { if (ofGetFrameNum() % (this->frame_span * 2) == 0) { int next_index = this->next_index_list[i]; int current_index = next_index; vector<int> near_indexes; for (int location_index = 0; location_index < this->location_list.size(); location_index++) { if (current_index == location_index) { continue; } if (glm::distance(this->location_list[current_index], this->location_list[location_index]) < this->size * 5) { near_indexes.push_back(location_index); } } if (near_indexes.size() > 0) { next_index = near_indexes[ofRandom(near_indexes.size())]; } this->current_index_list[i] = current_index; this->next_index_list[i] = next_index; } } for (int i = 0; i < this->number_of_targets; i++) { if (ofGetFrameNum() % (this->frame_span * 2) < this->frame_span) { this->target_list[i] = this->location_list[this->current_index_list[i]]; this->target_color_list[i] = this->color_list[i]; } else { this->target_list[i] = this->location_list[this->next_index_list[i]]; this->target_color_list[i] = this->color_list[i]; } } } //-------------------------------------------------------------- void ofApp::draw() { int frame_param = ofGetFrameNum() % this->frame_span; ofSetLineWidth(5); for (int i = 0; i < this->next_index_list.size(); i++) { ofSetColor(ofMap(this->target_color_list[i].x, 0.25, 0.4, 0, 255), ofMap(this->target_color_list[i].y, 0.25, 0.4, 0, 255), ofMap(this->target_color_list[i].z, 0.25, 0.4, 0, 255)); int current_index = this->current_index_list[i]; int next_index = this->next_index_list[i]; auto angle_current = std::atan2(this->location_list[next_index].y - this->location_list[current_index].y, this->location_list[next_index].x - this->location_list[current_index].x); auto satellite_point_current = this->location_list[current_index] + glm::vec2(this->size * cos(angle_current), this->size * sin(angle_current)); auto angle_next = std::atan2(this->location_list[current_index].y - this->location_list[next_index].y, this->location_list[current_index].x - this->location_list[next_index].x); auto satellite_point_next = this->location_list[next_index] + glm::vec2(this->size * cos(angle_next), this->size * sin(angle_next)); if (ofGetFrameNum() % (this->frame_span * 2) < this->frame_span) { auto distance = glm::distance(satellite_point_next, satellite_point_current); distance = ofMap(frame_param, 0, this->frame_span, 0, distance); auto direction = satellite_point_next - satellite_point_current; ofDrawLine(satellite_point_current, satellite_point_current + glm::normalize(direction) * distance); } else { auto distance = glm::distance(satellite_point_next, satellite_point_current); distance = ofMap(frame_param, 0, this->frame_span, distance, 0); auto direction = satellite_point_next - satellite_point_current; ofDrawLine(satellite_point_next, satellite_point_next - glm::normalize(direction) * distance); } } ofSetLineWidth(0.1); ofSetColor(255); ofNoFill(); for (int location_index = 0; location_index < this->location_list.size(); location_index++) { ofDrawCircle(this->location_list[location_index], this->size); } for (int i = 0; i < this->target_color_list.size(); i++) { if (ofGetFrameNum() % (this->frame_span * 2) < this->frame_span) { float p = ofGetFrameNum() % this->frame_span < this->frame_span * 0.5 ? 1 : ofMap(ofGetFrameNum() % this->frame_span, this->frame_span * 0.5, this->frame_span, 1, 0); this->target_color_list[i] = this->target_color_list[i] * p; } else { this->target_color_list[i] = this->target_color_list[i] * ofMap(ofGetFrameNum() % this->frame_span, 0, this->frame_span, 0, 1); } } ofFill(); this->shader.begin(); this->shader.setUniform1f("time", ofGetElapsedTimef()); this->shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight()); this->shader.setUniform2fv("targets", &this->target_list[0].x, this->number_of_targets); this->shader.setUniform3fv("colors", &this->target_color_list[0].x, this->number_of_targets); ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight()); this->shader.end(); } //-------------------------------------------------------------- int main() { ofGLWindowSettings settings; settings.setGLVersion(3, 2); settings.setSize(720, 720); ofCreateWindow(settings); ofRunApp(new ofApp()); }
42a6c011907e62ead13d51aba9ecdfeae2d3502c
f77af4f304918271e2864547841fc30c100fb471
/macros/halflifefit.cpp
7ca00ea682ad9203cfdc482ea042f3bd3f73e140
[]
no_license
jianghongping/EURICA12
ec6038415c928e5fee07dcc2bd6180e28ed68ae0
cfc9d311a063123c21e2c2a77c9b28864b11eb4b
refs/heads/master
2021-02-28T23:48:32.258360
2018-07-19T12:45:08
2018-07-19T12:45:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
134,433
cpp
halflifefit.cpp
/****************************************************************/ /* This is a ROOT macro for fitting half-life curves. The */ /* input file is a .top file, which can be up to 10000 lines */ /* long. Longer, and hacking the code would be required. The */ /* program has a GUI interface, and should warn you about */ /* most common errors. There are a number of fitting options, */ /* which require various degrees of input. */ /* Last edited: H.Crawford 05/30/2008 */ /****************************************************************/ #include <iostream> #include <iomanip> #include <fstream> #include <string> #include <cstring> #include <TH1D.h> #include <TMath.h> #include <TGClient.h> #include <TGCanvas.h> #include <TF1.h> #include <TRandom.h> #include <TGButton.h> #include <TGComboBox.h> #include <TGFrame.h> #include <TRootEmbeddedCanvas.h> #include <RQ_OBJECT.h> #include <TGNumberEntry.h> // Define global fitting and control variables double GRANDDAUGHTER = 0; double DAUGHTER_ONENEUTRON = 0; double DAUGHTER_TWONEUTRON = 0; double ONE_NEUTRON = 0; double TWO_NEUTRON = 0; double NO_NEUTRON = 1; double LIFE_LOW_LIMIT = 0.001; double LIFE_HIGH_LIMIT = 10.0; double LIFE_GUESS = 5; double DAUGHTER_LOW_LIMIT = 0; double DAUGHTER_HIGH_LIMIT = 50000; double DAUGHTER_GUESS = 0; double BACKLIN_LOW_LIMIT = 0; double BACKLIN_HIGH_LIMIT = 50000; double BACKLIN_GUESS = 100; double EXPINIT_GUESS = 0; double EXPINIT_LOW_LIMIT = 0; double EXPINIT_HIGH_LIMIT = 50000; double EXPDECAY_GUESS = 0; double EXPDECAY_LOW_LIMIT = 0; double EXPDECAY_HIGH_LIMIT = 50000; double INITIAL_LOW_LIMIT = 1; double INITIAL_HIGH_LIMIT = 50000; double INITIAL_GUESS = 100; double COMPONENT2_GUESS = 1.0; double COMPONENT2_LOW_LIMIT = 0.001; double COMPONENT2_HIGH_LIMIT = 2.0; double COMPONENT2_FRACTION = 0.5; double COMPONENT2_FRACTION_LOW_LIMIT = 0; double COMPONENT2_FRACTION_HIGH_LIMIT = 1; bool DAUGHTER_FREE = 0; bool EXPDECAY_FREE = 0; bool FRACTION_FREE = 0; bool TWOCOMP = 0; bool COMPONE_FREE = 0; bool COMPTWO_FREE = 0; bool LINEAR = 0; bool EXP = 0; char* FILENAME = 0; double BIN[100000] = {0}; int DATA[100000] = {0}; int COUNT = 0; int DRAW_CONTROL = 0; /****************************************************************/ /* These are the Bateman equations that are used to fit the */ /* half-life curves. */ /****************************************************************/ Double_t background_linear (Double_t *x, Double_t *par) { return par[3]; } Double_t background_exp (Double_t *x, Double_t *par) { return par[4]*(TMath::Exp(-par[5]*x[0])); } Double_t parent (Double_t *x, Double_t *par) { if (par[1] != 0) { return par[0]*(TMath::Exp(-((0.69314718)/par[1])*x[0])); } else { return 0; } } Double_t two_component (Double_t *x, Double_t *par) { if (par[1] != 0 && par[12] != 0) { return par[0]*(par[11]*(TMath::Exp(-((0.69314718)/par[12])*x[0])) + (1-par[11])*(TMath::Exp(-((0.69314718)/par[1])*x[0]))); } else if (par[1] != 0 && par[12] == 0) { return par[0]*(1-par[11])*(TMath::Exp(-((0.69314718)/par[1])*x[0])); } else if (par[12] != 0 && par[1] == 0) { return par[0]*(par[11]*(TMath::Exp(-((0.69314718)/par[12]*x[0])))); } else { return 0; } } Double_t twocomponentfit (Double_t *x, Double_t *par) { return two_component(x, par); } Double_t component1 (Double_t *x, Double_t *par) { if (par[0] != 0) { return par[0]*(1-par[11])*(TMath::Exp(-((0.69314718)/par[1])*x[0])); } else { return 0; } } Double_t component2 (Double_t *x, Double_t *par) { if (par[12] != 0) { return par[0]*par[11]*(TMath::Exp(-((0.69314718)/par[12])*x[0])); } else { return 0; } } Double_t daughter_only (Double_t *x, Double_t *par) { if (((0.69314718)/par[1]) != ((0.69314718)/par[2])) { return par[0]*(NO_NEUTRON)*(((0.69314718)/par[2])/(((0.69314718)/par[2]) - ((0.69314718)/par[1])))* ((TMath::Exp(-((0.69314718)/par[1])*x[0])) - (TMath::Exp(-((0.69314718)/par[2])*x[0]))); } else if (((0.69314718)/par[1]) == ((0.69314718)/par[2])) { return par[0]*(NO_NEUTRON)*(((0.69314718)/par[2])/(0.0000001))* ((TMath::Exp(-((0.69314718)/par[1])*x[0])) - (TMath::Exp(-((0.69314718)/par[2])*x[0]))); } } Double_t component_1_daughter_only (Double_t *x, Double_t *par) { if (((0.69314718)/par[1]) != ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(NO_NEUTRON)*(((0.69314718)/par[2])/(((0.69314718)/par[2]) - ((0.69314718)/par[1])))* ((TMath::Exp(-((0.69314718)/par[1])*x[0])) - (TMath::Exp(-((0.69314718)/par[2])*x[0]))); } else if (((0.69314718)/par[1]) == ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(NO_NEUTRON)*(((0.69314718)/par[2])/(0.0000001))* ((TMath::Exp(-((0.69314718)/par[1])*x[0])) - (TMath::Exp(-((0.69314718)/par[2])*x[0]))); } } Double_t component_2_daughter_only (Double_t *x, Double_t *par) { if (((0.69314718)/par[12]) != ((0.69314718)/par[2])) { return par[11]*par[0]*(NO_NEUTRON)*(((0.69314718)/par[2])/(((0.69314718)/par[2]) - ((0.69314718)/par[12])))* ((TMath::Exp(-((0.69314718)/par[12])*x[0])) - (TMath::Exp(-((0.69314718)/par[2])*x[0]))); } else if (((0.69314718)/par[12]) == ((0.69314718)/par[2])) { return par[11]*par[0]*(NO_NEUTRON)*(((0.69314718)/par[2])/(0.0000001))* ((TMath::Exp(-((0.69314718)/par[12])*x[0])) - (TMath::Exp(-((0.69314718)/par[2])*x[0]))); } } Double_t daughter_two_component (Double_t *x, Double_t *par) { return component_1_daughter_only(x, par) + component_2_daughter_only(x, par); } Double_t granddaughter (Double_t *x, Double_t *par) { if (((0.69314718)/par[1]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[1]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[6]))*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[2]))*(((0.69314718)/par[6]) - ((0.69314718)/par[2])))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[1]))* (((0.69314718)/par[6]) - ((0.69314718)/par[1]))))); } else if (((0.69314718)/par[1]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) == ((0.69314718)/par[1]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((0.0000001)*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[2]))*(((0.69314718)/par[6]) - ((0.69314718)/par[2])))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[1]))* (0.0000001)))); } else if (((0.69314718)/par[1]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[1]) && ((0.69314718)/par[6]) == ((0.69314718)/par[2])) { return par[0]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[6]))*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[2]))*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[1]))* (((0.69314718)/par[6]) - ((0.69314718)/par[2]))))); } else if (((0.69314718)/par[1]) == ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[1]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[6]))*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((0.0000001)*(((0.69314718)/par[6]) - ((0.69314718)/par[1])))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((0.0000001)* (((0.69314718)/par[6]) - ((0.69314718)/par[1]))))); } else if (((0.69314718)/par[1]) == ((0.69314718)/par[2]) && ((0.69314718)/par[6]) == ((0.69314718)/par[1]) && ((0.69314718)/par[6]) == ((0.69314718)/par[2])) { return par[0]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((0.0000001)*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((0.0000001)*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((0.0000001)* (0.0000001)))); } } Double_t component1_granddaughter (Double_t *x, Double_t *par) { if (((0.69314718)/par[1]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[1]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[6]))*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[2]))*(((0.69314718)/par[6]) - ((0.69314718)/par[2])))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[1]))* (((0.69314718)/par[6]) - ((0.69314718)/par[1]))))); } else if (((0.69314718)/par[1]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) == ((0.69314718)/par[1]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((0.0000001)*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[2]))*(((0.69314718)/par[6]) - ((0.69314718)/par[2])))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[1]))* (0.0000001)))); } else if (((0.69314718)/par[1]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[1]) && ((0.69314718)/par[6]) == ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[6]))*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[2]))*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[1]))* (((0.69314718)/par[6]) - ((0.69314718)/par[2]))))); } else if (((0.69314718)/par[1]) == ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[1]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[1]) - ((0.69314718)/par[6]))*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((0.0000001)*(((0.69314718)/par[6]) - ((0.69314718)/par[1])))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((0.0000001)* (((0.69314718)/par[6]) - ((0.69314718)/par[1]))))); } else if (((0.69314718)/par[1]) == ((0.69314718)/par[2]) && ((0.69314718)/par[6]) == ((0.69314718)/par[1]) && ((0.69314718)/par[6]) == ((0.69314718)/par[2])) { return par[0]*(1-par[11])*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((0.0000001)*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((0.0000001)*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[1])*x[0]))/((0.0000001)* (0.0000001)))); } } Double_t component2_granddaughter (Double_t *x, Double_t *par) { if (((0.69314718)/par[12]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[12]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*par[11]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[12]) - ((0.69314718)/par[6]))*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[12]) - ((0.69314718)/par[2]))*(((0.69314718)/par[6]) - ((0.69314718)/par[2])))) + ((TMath::Exp(-((0.69314718)/par[12])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[12]))* (((0.69314718)/par[6]) - ((0.69314718)/par[12]))))); } else if (((0.69314718)/par[12]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) == ((0.69314718)/par[12]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*par[11]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((0.0000001)*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[12]) - ((0.69314718)/par[2]))*(((0.69314718)/par[6]) - ((0.69314718)/par[2])))) + ((TMath::Exp(-((0.69314718)/par[12])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[12]))* (0.0000001)))); } else if (((0.69314718)/par[12]) != ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[12]) && ((0.69314718)/par[6]) == ((0.69314718)/par[2])) { return par[0]*par[11]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[12]) - ((0.69314718)/par[6]))*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((((0.69314718)/par[12]) - ((0.69314718)/par[2]))*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[12])*x[0]))/((((0.69314718)/par[2]) - ((0.69314718)/par[12]))* (((0.69314718)/par[6]) - ((0.69314718)/par[2]))))); } else if (((0.69314718)/par[12]) == ((0.69314718)/par[2]) && ((0.69314718)/par[6]) != ((0.69314718)/par[12]) && ((0.69314718)/par[6]) != ((0.69314718)/par[2])) { return par[0]*par[11]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((((0.69314718)/par[12]) - ((0.69314718)/par[6]))*(((0.69314718)/par[2]) - ((0.69314718)/par[6])))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((0.0000001)*(((0.69314718)/par[6]) - ((0.69314718)/par[12])))) + ((TMath::Exp(-((0.69314718)/par[12])*x[0]))/((0.0000001)* (((0.69314718)/par[6]) - ((0.69314718)/par[12]))))); } else if (((0.69314718)/par[12]) == ((0.69314718)/par[2]) && ((0.69314718)/par[6]) == ((0.69314718)/par[12]) && ((0.69314718)/par[6]) == ((0.69314718)/par[2])) { return par[0]*par[11]*(((0.69314718)/par[2]))*(((0.69314718)/par[6]))* (((TMath::Exp(-((0.69314718)/par[6])*x[0]))/ ((0.0000001)*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[2])*x[0]))/ ((0.0000001)*(0.0000001))) + ((TMath::Exp(-((0.69314718)/par[12])*x[0]))/((0.0000001)* (0.0000001)))); } } Double_t granddaughter_two_component (Double_t *x, Double_t *par) { return component1_granddaughter(x, par) + component2_granddaughter(x, par); } Double_t oneneutron_daughter (Double_t *x, Double_t *par) { if (par[7] != 0) { return par[0]*par[9]*(((0.69314718)/par[7])/ (((0.69314718)/par[7]) - ((0.69314718)/par[1])))* ((TMath::Exp(-((0.69314718)/par[1])*x[0])) - (TMath::Exp(-((0.69314718)/par[7])*x[0]))); } else { return 0; } } Double_t twoneutron_daughter (Double_t *x, Double_t *par) { if (par[8] != 0) { return par[0]*par[10]*(((0.69314718)/par[8])/ (((0.69314718)/par[8]) - ((0.69314718)/par[1])))* ((TMath::Exp(-((0.69314718)/par[1])*x[0])) - (TMath::Exp(-((0.69314718)/par[8])*x[0]))); } else { return 0; } } Double_t parent_lin (Double_t *x, Double_t *par) { return parent(x, par) + background_linear(x, par); } Double_t parent_exp (Double_t *x, Double_t *par) { return parent(x, par) + background_exp(x, par); } Double_t parent_both (Double_t *x, Double_t *par) { return parent(x, par) + background_linear(x, par) + background_exp(x, par); } Double_t two_component_lin (Double_t *x, Double_t *par) { return two_component(x, par) + background_linear(x, par); } Double_t two_component_exp (Double_t *x, Double_t *par) { return two_component(x, par) + background_exp(x, par); } Double_t two_component_both (Double_t *x, Double_t *par) { return two_component(x, par) + background_linear(x, par) + background_exp(x, par); } Double_t two_component_daughter (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par); } Double_t two_component_daughter_lin (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + background_linear(x, par); } Double_t two_component_daughter_exp (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + background_exp(x, par); } Double_t two_component_daughter_both (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + background_linear(x, par) + background_exp(x, par); } Double_t two_component_granddaughter (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + granddaughter_two_component(x, par); } Double_t two_component_granddaughter_lin (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + granddaughter_two_component(x, par) + background_linear(x, par); } Double_t two_component_granddaughter_exp (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + granddaughter_two_component(x, par) + background_exp(x, par); } Double_t two_component_granddaughter_both (Double_t *x, Double_t *par) { return two_component(x, par) + daughter_two_component(x, par) + granddaughter_two_component(x, par) + background_linear(x, par) + background_exp(x, par); } Double_t parent_daughter (Double_t *x, Double_t *par) { return parent(x, par) + daughter_only(x, par); } Double_t parent_daughter_lin (Double_t *x, Double_t *par) { return parent_daughter(x, par) + background_linear(x, par); } Double_t parent_daughter_exp (Double_t *x, Double_t *par) { return parent_daughter(x, par) + background_exp(x, par); } Double_t parent_daughter_both (Double_t *x, Double_t *par) { return parent_daughter(x, par) + background_linear(x, par) + background_exp(x, par); } Double_t parent_granddaughter (Double_t *x, Double_t *par) { return parent_daughter(x, par) + granddaughter(x, par); } Double_t parent_granddaughter_lin (Double_t *x, Double_t *par) { return parent_daughter(x, par) + granddaughter(x, par) + background_linear(x, par); } Double_t parent_granddaughter_exp (Double_t *x, Double_t *par) { return parent_daughter(x, par) + granddaughter(x, par) + background_exp(x, par); } Double_t parent_granddaughter_both (Double_t *x, Double_t *par) { return parent_daughter(x, par) + granddaughter(x, par) + background_linear (x, par) + background_exp(x, par); } Double_t parent_neutronbranch (Double_t *x, Double_t *par) { return parent(x, par) + daughter_only(x, par) + oneneutron_daughter(x, par) + twoneutron_daughter(x, par); } Double_t parent_neutronbranch_lin (Double_t *x, Double_t *par) { return parent_neutronbranch(x, par) + background_linear(x, par); } Double_t parent_neutronbranch_exp (Double_t *x, Double_t *par) { return parent_neutronbranch(x, par) + background_exp(x, par); } Double_t parent_neutronbranch_both (Double_t *x, Double_t *par) { return parent_neutronbranch(x, par) + background_linear(x, par) + background_exp(x, par); } /****************************************/ /* Parameter # Key */ /****************************************/ /* ### Meaning */ /* 0 Initial activity */ /* 1 Parent halflife */ /* 2 Daughter halflife */ /* 3 Linear bckgrnd */ /* 4 Exp. bckgrnd initial value */ /* 5 Exp. bckgrnd decay constant */ /* 6 Granddaughter halflife */ /* 7 Beta-1n daughter halflife */ /* 8 Beta-2n daughter halflife */ /* 9 Beta-1n branching ratio */ /* 10 Beta-2n branching ratio */ /* 11 2nd component fraction */ /* 12 2nd component halflife */ /****************************************/ /****************************************************************/ /* This is the definitionsr all of the GUI classes, */ /* including the main window, and all of the pop-up data entry */ /* windows. */ /****************************************************************/ // This is the main class, where the plots are drawn, and all the really // cool stuff happens. class Fitter { RQ_OBJECT("Fitter") private: TGMainFrame *fMain; TRootEmbeddedCanvas *fFitCanvas; TGVerticalFrame *left, *right; TGHorizontalFrame *hframe, *guesslimitFrame, *lowlimitFrame, *highlimitFrame, *hframe2, *hframe3, *hframe4, *hframe5, *hframe6, *hframe7, *hframe8, *timeframe, *lowrangeFrame, *yminFrame; TGGroupFrame *group, *group2, *group3, *group4, *group5; TGTextButton *draw, *close, *save, *setparameters; TGCheckButton *back_lin, *back_exp, *daugh, *daugh_free, *grand, *neutron, *limits, *log, *print,*two_component, *logmethod, *integrate, *covarmatrix, *setymin; TGNumberEntry *highlimit, *lowlimit, *guesslimit, *bins, *width, *channel, *lowrange, *ymin; TGLabel *highlimit_label, *lowlimit_label, *guesslimit_label, *file_label, *bin_label, *title_label, *widthlabel, *lowrange_label, *channel_label, *save_label, *time_label, *ymin_label; TGTextEntry *file_name, *title, *saved; TGTextBuffer *filename, *titlevalue, *savevalue; TGComboBox *timechoice, *filechoice; TH1D *histo; ifstream input; public: Fitter(const TGWindow *p, UInt_t w, UInt_t h); virtual ~Fitter(); // Slots, or functions for this window void OpenExp(); void OpenComponents(); void OpenDaughter(); void OpenGrand(); void OpenNeutron(); void OpenParameters(); void CloseWindow(); void Update(); void Draw(); void Save(); }; // This is an input window for entering daughter half-life values. class InputExponential { RQ_OBJECT("InputExponential") private: TGTransientFrame *fMain; TGHorizontalFrame *expFrame, *expFrame2, *buttonFrame; TGCheckButton *exp_free; TGNumberEntry *exp_decay; TGLabel *exp_label; TGTextButton *okay, *cancel; TGGroupFrame *group; public: InputExponential(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame); virtual ~InputExponential(); // Slots, or functions for this window void CloseWindow(); void DoOK(); void DoCancel(); }; class InputComponents { RQ_OBJECT("InputComponents") private: TGTransientFrame *fMain; TGHorizontalFrame *buttonFrame, *comp1Frame, *comp2Frame, *frac2Frame, *frac2Frame2, *comp1Frame2, *comp2Frame2; TGCheckButton *freefraction, *freecomp1, *freecomp2; TGNumberEntry *comp1, *comp2, *frac2; TGLabel *comp1Label, *comp2Label, *frac2Label; TGTextButton *okay, *cancel; TGGroupFrame *group; public: InputComponents(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame); virtual ~InputComponents(); // Slots, or functions for this window void CloseWindow(); void DoOK(); void DoCancel(); }; class InputDaughter { RQ_OBJECT("InputDaughter") private: TGTransientFrame *fMain; TGHorizontalFrame *daughFrame, *daughFrame2, *buttonFrame; TGCheckButton *daugh_free; TGNumberEntry *daugh_life; TGLabel *daugh_label; TGTextButton *okay, *cancel; TGGroupFrame *group; public: InputDaughter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame); virtual ~InputDaughter(); // Slots, or functions for this window void CloseWindow(); void DoOK(); void DoCancel(); }; // This is an input window for entering grand-daughter half-life values. class InputGrand { RQ_OBJECT("InputGrand") private: TGTransientFrame *fMain; TGHorizontalFrame *grandFrame, *buttonFrame; TGNumberEntry *grand_life; TGLabel *grand_label; TGTextButton *okay, *cancel; TGGroupFrame *group; public: InputGrand(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame); virtual ~InputGrand(); // Slots, or functions for this window void CloseWindow(); void DoOK(); void DoCancel(); }; // This is an input window for entering initial values for parameters in the // fits. class InputParameters { RQ_OBJECT("InputParameters") private: TGTransientFrame *fMain; TGHorizontalFrame *lifeGuessFrame, *lifeLowFrame, *lifeHighFrame, *daughterGuessFrame, *daughterLowFrame, *daughterHighFrame, *backLinGuessFrame, *backLinLowFrame, *backLinHighFrame, *initialGuessFrame, *initialLowFrame, *initialHighFrame, *buttonFrame, *expDecayGuessFrame, *expDecayLowFrame, *expDecayHighFrame, *expInitGuessFrame, *expInitLowFrame, *expInitHighFrame, *fracGuessFrame, *fracLowFrame, *fracHighFrame, *component2GuessFrame, *component2LowFrame, *component2HighFrame; TGNumberEntry *lifeGuessNum, *lifeLowNum, *lifeHighNum, *daughterGuessNum, *daughterLowNum, *daughterHighNum, *backLinGuessNum, *backLinLowNum, *backLinHighNum,*initialGuessNum, *initialLowNum, *initialHighNum, *expDecayGuessNum, *expDecayLowNum, *expDecayHighNum, *expInitGuessNum, *expInitLowNum, *expInitHighNum, *fracGuessNum, *fracLowNum, *fracHighNum, *component2GuessNum, *component2LowNum, *component2HighNum; TGLabel *lifeGuessLabel, *lifeLowLabel, *lifeHighLabel, *daughterGuessLabel, *daughterLowLabel, *daughterHighLabel, *backLinGuessLabel, *backLinLowLabel, *backLinHighLabel, *initialGuessLabel, *initialLowLabel, *initialHighLabel, *expDecayGuessLabel, *expDecayLowLabel, *expDecayHighLabel, *expInitGuessLabel, *expInitLowLabel, *expInitHighLabel, *fracGuessLabel, *fracLowLabel, *fracHighLabel, *component2GuessLabel *component2LowLabel, *component2HighLabel; TGTextButton *okay, *cancel; TGGroupFrame *group1, *group2, *group3, *group4, *group5; public: InputParameters(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame); virtual ~InputParameters(); //Slots, or functions for this window void CloseWindow(); void DoOK(); void DoCancel(); }; // This is an input window for neutron branching information. class InputNeutron { RQ_OBJECT("InputNeutron") private: TGTransientFrame *fMain; TGHorizontalFrame *oneBranchFrame, *oneLifeFrame, *twoBranchFrame, *twoLifeFrame, *buttonFrame; TGNumberEntry *oneBranch, *oneLife, *twoBranch, *twoLife; TGLabel *oneBranchLabel, *oneLifeLabel, *twoBranchLabel, *twoLifeLabel; TGTextButton *okay, *cancel; TGGroupFrame *group; public: InputNeutron(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame); virtual ~InputNeutron(); // Slots, or functions for this window void CloseWindow(); void DoOK(); void DoCancel(); }; /****************************************************************/ /* These are now the functions of the macro itself, including */ /* constructors for all of the GUI windows, etc. */ /****************************************************************/ // This is the function that is called when the macro is run. // It simply opens an instance of the main GUI. void halflifefit() { // Popup the GUI new Fitter(gClient->GetRoot(), 800, 300); } // The constructor for the main GUI window. Fitter::Fitter(const TGWindow *p, UInt_t w, UInt_t h) { gStyle->SetFillColor(10); // Create a main frame fMain = new TGMainFrame(p, w, h); fMain->Connect ("CloseWindow()", "Fitter", this, "CloseWindow()"); // Create sub-frames to allow correct arrangement of widgets hframe = new TGHorizontalFrame(fMain, 900, 400); left = new TGVerticalFrame(hframe, 100, 400); right = new TGVerticalFrame(hframe, 100, 400); // Create the histogram canvas on the RHS of the GUI fFitCanvas = new TRootEmbeddedCanvas("FitCanvas", right, 600, 400); right->AddFrame(fFitCanvas, new TGLayoutHints(kLHintsExpandY|kLHintsCenterX| kLHintsExpandX, 10, 10, 10, 10)); // Create the fit options subframe on the LHS of the GUI group5 = new TGGroupFrame(left, "Fit Method Options", kVerticalFrame); left->AddFrame(group5, new TGLayoutHints(kLHintsTop|kLHintsCenterX| kLHintsExpandX, 2,2,2,2)); group = new TGGroupFrame(left, "Fit Options", kVerticalFrame); left->AddFrame(group, new TGLayoutHints(kLHintsTop|kLHintsCenterX| kLHintsExpandX, 2,2,2,2)); logmethod = new TGCheckButton(group5, "Use Log Likelihood method?"); group5->AddFrame(logmethod, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); integrate = new TGCheckButton(group5, "Fit to integral over time bins?"); group5->AddFrame(integrate, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); covarmatrix = new TGCheckButton(group5, "Print out covariance matrix?"); group5->AddFrame(covarmatrix, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); back_lin = new TGCheckButton(group, "Linear background?"); group->AddFrame(back_lin, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); back_exp = new TGCheckButton(group, "Exponential background?"); group->AddFrame(back_exp, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); two_component = new TGCheckButton(group, "Two-component fit?"); group->AddFrame(two_component, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); daugh = new TGCheckButton(group, "Include daughter activity?"); group->AddFrame(daugh, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); grand = new TGCheckButton(group, "Include grand-daughter activity?"); group->AddFrame(grand, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); neutron = new TGCheckButton(group, "Include parent neutron branching?"); group->AddFrame(neutron, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2,2,2,2)); setparameters = new TGTextButton(group, "&Set Parameter Values..."); setparameters->Connect("Clicked()", "Fitter", this, "OpenParameters()"); group->AddFrame(setparameters, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); // Connect the check boxes to data entry pop-up windows, where all needed // information will be entered. back_lin->Connect("Clicked()", "Fitter", this, "Update()"); back_exp->Connect("Clicked()", "Fitter", this, "OpenExp()"); two_component->Connect("Clicked()", "Fitter", this, "OpenComponents()"); daugh->Connect("Clicked()", "Fitter", this, "OpenDaughter()"); grand->Connect("Clicked()", "Fitter", this, "OpenGrand()"); neutron->Connect("Clicked()", "Fitter", this, "OpenNeutron()"); // Create the data file info sub-frame on the LHS of GUI group4 = new TGGroupFrame(left, "File Info", kVerticalFrame); left->AddFrame(group4, new TGLayoutHints(kLHintsTop|kLHintsCenterX| kLHintsExpandX, 2,2,2,2)); hframe3 = new TGHorizontalFrame(group4, 100, 30); group4->AddFrame(hframe3, new TGLayoutHints(kLHintsCenterX|kLHintsTop, 2,2,2,2)); // File name information... file_label = new TGLabel(hframe3, new TGString("File: ")); file_name = new TGTextEntry(hframe3, filename = new TGTextBuffer(300)); filename->AddText(0, "decay_db/"); file_name->Resize(300, 25); hframe3->AddFrame(file_label, new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 2,2,2,2)); hframe3->AddFrame(file_name, new TGLayoutHints(kLHintsCenterY|kLHintsRight, 2,2,2,2)); // Data format -- how many ms/channel in data hframe7 = new TGHorizontalFrame(group4, 100, 30); group4->AddFrame(hframe7, new TGLayoutHints(kLHintsCenterX|kLHintsTop, 2,2,2,2)); channel_label = new TGLabel(hframe7, new TGString("time units/channel in file: ")); channel = new TGNumberEntry(hframe7, 1, 12); hframe7->AddFrame(channel_label, new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 2,2,2,2)); hframe7->AddFrame(channel, new TGLayoutHints(kLHintsCenterY|kLHintsRight, 2,2,2,2)); // Create thlotting options sub-frame on LHS of GUI group3 = new TGGroupFrame(left, "Plot Options", kVerticalFrame); left->AddFrame(group3, new TGLayoutHints(kLHintsTop|kLHintsCenterX| kLHintsExpandX, 2,2,2,2)); // Histogram title entry hframe4 = new TGHorizontalFrame(group3, 100, 30); group3->AddFrame(hframe4, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); title_label = new TGLabel(hframe4, new TGString(" Plot Name: ")); hframe4->AddFrame(title_label, new TGLayoutHints(kLHintsCenterY| kLHintsCenterX, 2,2,2,2)); title = new TGTextEntry(hframe4, titlevalue = new TGTextBuffer(100)); hframe4->AddFrame(title, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); titlevalue->AddText(0, "^{}"); title->Resize(200, 25); // Histogram bin width options hframe5 = new TGHorizontalFrame(group3, 100, 20); group3->AddFrame(hframe5, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); bin_label = new TGLabel(hframe5, new TGString("# of time units per bin: ")); hframe5->AddFrame(bin_label, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); bins = new TGNumberEntry(hframe5, 1, 12); hframe5->AddFrame(bins, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); // Range option hframe6 = new TGHorizontalFrame(group3, 100, 30); group3->AddFrame(hframe6, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); widthlabel = new TGLabel(hframe6, new TGString("Range to plot (in time units): ")); hframe6->AddFrame(widthlabel, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); width = new TGNumberEntry(hframe6, 1000, 12); hframe6->AddFrame(width, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); lowrangeFrame = new TGHorizontalFrame(group3, 100, 30); group3->AddFrame(lowrangeFrame, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); lowrange_label = new TGLabel(lowrangeFrame, new TGString("Minimum to plot (in time units): ")); lowrangeFrame->AddFrame(lowrange_label, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); lowrange = new TGNumberEntry(lowrangeFrame, 0, 12); lowrangeFrame->AddFrame(lowrange, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); // Plot appearance options, like the time scale to be used, log settings // for the y-axis, etc. timeFrame = new TGHorizontalFrame(group3, 100, 30); group3->AddFrame(timeFrame, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); time_label = new TGLabel(timeFrame, new TGString("Time unit for plot:")); timeFrame->AddFrame(time_label, new TGLayoutHints(kLHintsCenterY| kLHintsCenterX, 2,2,2,2)); timechoice = new TGComboBox(timeFrame); timeFrame->AddFrame(timechoice, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); timechoice->AddEntry("ms", 1); timechoice->AddEntry("s", 2); timechoice->AddEntry("us", 3); timechoice->AddEntry("ns", 4); timechoice->AddEntry("min", 5); timechoice->AddEntry("days", 6); timechoice->Select(1); timechoice->Resize(50, 20); log = new TGCheckButton(group3, "Log scale for y-axis?"); group3->AddFrame(log, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); setymin = new TGCheckButton(group3, "Fix minimum on y-axis?"); group3->AddFrame(setymin, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); setymin->Connect("Clicked()", "Fitter", this, "Update()"); yminFrame = new TGHorizontalFrame(group3, 100, 30); group3->AddFrame(yminFrame, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); ymin_label = new TGLabel(yminFrame, new TGString("Minimum on y-axis: ")); yminFrame->AddFrame(ymin_label, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); ymin = new TGNumberEntry(yminFrame, 1, 12); yminFrame->AddFrame(ymin, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); print = new TGCheckButton(group3, "Print-out fit results on plot?"); group3->AddFrame(print, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); hframe2 = new TGHorizontalFrame(left, 100, 50); left->AddFrame(hframe2, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX| kLHintsBottom, 2,2,2,2)); // Saved file file name entry hframe8 = new TGHorizontalFrame(group3, 100, 30); group3->AddFrame(hframe8, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); save_label = new TGLabel(hframe8, new TGString("Save plot as: ")); hframe8->AddFrame(save_label, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); saved = new TGTextEntry(hframe8, savevalue = new TGTextBuffer(100)); hframe8->AddFrame(saved, new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2)); savevalue->AddText(0, "Enter file name (with '.eps')..."); saved->Resize(200, 25); filechoice = new TGComboBox(hframe8); hframe8->AddFrame(filechoice, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); filechoice->AddEntry(".eps", 1); filechoice->AddEntry(".ps", 2); filechoice->AddEntry(".pdf", 3); filechoice->AddEntry(".gif", 4); filechoice->AddEntry(".jpg", 5); filechoice->AddEntry(".png", 6); filechoice->Select(6); filechoice->Resize(50, 25); // Draw and Exit buttons for the GUI draw = new TGTextButton(hframe2, "&Draw"); draw->Connect("Clicked()", "Fitter", this, "Draw()"); hframe2->AddFrame(draw, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); save = new TGTextButton(hframe2, "&Save"); save->Connect("Clicked()", "Fitter", this, "Save()"); hframe2->AddFrame(save, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); close = new TGTextButton(hframe2, "&Exit"); close->Connect("Clicked()", "Fitter", this, "CloseWindow()"); hframe2->AddFrame(close, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); // Arrange all of the window properly and we're finished building the GUI hframe->AddFrame(left, new TGLayoutHints(kLHintsLeft|kLHintsTop, 2,2,2,2)); hframe->AddFrame(right, new TGLayoutHints(kLHintsRight|kLHintsTop| kLHintsExpandX|kLHintsExpandY, 2,2,2,2)); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 2,2,2,2)); fMain->SetWindowName("Half-Life Fitter"); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); fMain->MapWindow(); ymin->SetState(0); } // GUI destructor Fitter::~Fitter() { // Delete all created widgets delete saved, save_label, savevalue; delete title, title_label, titlevalue; delete time_label, ymin_label; delete bins, bin_label, widthlabel, width; delete lowrange_label, lowrange, lowrangeFrame, yminFrame; delete setymin, filechoice; delete hframe4, hframe5, group3, hframe6, hframe7, hframe8; delete hframe2, timeFrame, *ymin; delete close, draw; delete filename, file_label, file_name, channel_label, channel; delete hframe3; delete neutron, daugh, back_lin, grand, limits, print, back_exp, two_component, logmethod, integrate, covarmatrix; delete timechoice; delete group, group5, group4; delete left; delete fFitCanvas; delete right; delete hframe; delete fMain; } void Fitter::OpenExp() { bool exponential = (back_exp->GetState() == kButtonDown); EXP = exponential; if (exponential) { new InputExponential(gClient->GetRoot(), fMain, 400, 200); }; } void Fitter::OpenComponents() { bool twocomp = (two_component->GetState() == kButtonDown); TWOCOMP = twocomp; if (twocomp) { new InputComponents(gClient->GetRoot(), fMain, 400, 200); }; } void Fitter::OpenDaughter() { bool daughter = (daugh->GetState() == kButtonDown); if (daughter) { new InputDaughter(gClient->GetRoot(), fMain, 400, 200); }; } void Fitter::OpenGrand() { bool granddaughter = (grand->GetState() == kButtonDown); if (granddaughter) { new InputGrand(gClient->GetRoot(), fMain, 400, 200); }; } void Fitter::OpenParameters() { new InputParameters(gClient->GetRoot(), fMain, 400, 200); } void Fitter::OpenNeutron() { bool neutronbranch = (neutron->GetState() == kButtonDown); if (neutron) { new InputNeutron(gClient->GetRoot(), fMain, 400, 200); }; } // GUI Exit funtion (terminates ROOT too) void Fitter::CloseWindow() { // When called, closes the whole thing, and exit ROOT. gApplication->Terminate(0); } // The Update() function to respond to check boxes by enabling other data // entry fields void Fitter::Update() { // Check which check-buttons are selected bool linear = (back_lin->GetState() == kButtonDown); LINEAR = linear; bool daughter = (daugh->GetState() == kButtonDown); bool neutronbranch = (neutron->GetState() == kButtonDown); bool granddaugh = (grand->GetState() == kButtonDown); bool setyminimum = (setymin->GetState() == kButtonDown); if (setyminimum) { ymin->SetState(1); } else { ymin->SetState(0); } } // The main function, which actually fits the histograms. void Fitter::Draw() { if (DRAW_CONTROL == 1) { delete histo; } // Get the information regarding the number of ms/channel in the data and // the desired range of the histogram double range = width->GetNumber(); double per_channel = channel->GetNumber(); double lowrangelimit = lowrange->GetNumber(); double minimumy = ymin->GetNumber(); int i = 1; // This is just here to avoid a weird error message...I'll take it out when // I figure out the problem. int data[100000] = {0}; if (((int)range/per_channel) > 100000) { cout<<"careful man!!"<<endl; // cout << "Sorry, the range you have chosen is too long." << endl; //goto end; } gStyle->SetFillColor(10); // Only read in from the data file the first time, or if the data file // changes, otherwise just use the original data stored in the arrays. if (FILENAME != filename->GetString()) { FILENAME = filename->GetString(); cout << "Reading in file: " << FILENAME << endl; input.open(FILENAME); if (input.fail()) { cerr << "Couldn't open " << FILENAME << ". Sorry." << endl; goto end; } // Read in data from .top file format while (!input.eof()) { input >> BIN[COUNT]; input >> DATA[COUNT]; COUNT ++; } input.close(); } // Find out what check boxes are selected int timescale = timechoice->GetSelected(); bool linear = (back_lin->GetState() == kButtonDown); bool exp = (back_exp->GetState() == kButtonDown); bool twocomponent = (two_component->GetState() == kButtonDown); bool daughter = (daugh->GetState() == kButtonDown); bool neutronbranch = (neutron->GetState() == kButtonDown); bool granddaugh = (grand->GetState() == kButtonDown); bool logony = (log->GetState() == kButtonDown); bool printout = (print->GetState() == kButtonDown); bool uselogmethod = (logmethod->GetState() == kButtonDown); bool useintegrate = (integrate->GetState() == kButtonDown); bool printoutmatrix = (covarmatrix->GetState() == kButtonDown); bool setyminimum = (setymin->GetState() == kButtonDown); // Some error messages to avoid unpleasant ROOT errors. int FLAG = 0; int retval; if (daughter) { if (!DAUGHTER_FREE) { if (DAUGHTER_GUESS <= 0) { FLAG = 1; new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "You need to enter a valid beta daughter half-life. \nOr just don't include the daughter in the fit!", kMBIconStop, kMBDismiss, &retval); } } } if (neutronbranch) { if ((ONE_NEUTRON + TWO_NEUTRON) < 1) { if (DAUGHTER_GUESS <= 0) { FLAG = 1; new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "You need to enter a valid beta daughter half-life. \n With the neutron branches as they are now, the beta daughter will be included in the fit.", kMBIconStop, kMBDismiss, &retval); } } } if (granddaugh) { if (GRANDDAUGHTER <= 0) { FLAG = 1; new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "You need to enter a valid grand-daughter half-life. \nOr just don't include the grand-daughter in the fit.", kMBIconStop, kMBDismiss, &retval); } else if (!daughter) { FLAG = 1; new TGMsgBox(gClient->GetRoot(), fMain,"Something is weird...", "Sorry, right now to include a grand-daughter in the fit \nyou also need to include the daughter with a set half-life. \nPlease do this.", kMBIconStop, kMBDismiss, &retval); } } if (FLAG == 1) { goto end; } // Get info on desired bin width for histogram if (bins->GetNumber() != 0) { double number_time = bins->GetNumber(); } else { cout << "Bin width value is invalid." << endl; goto end; } // Create the correct y-axis label based on bin width char ytitle[40]; // Build the histogram int nbins = (int)range/number_time; // Fill the histogram char timeunit[5]; char xtitle[40]; histo = new TH1D("", titlevalue->GetString(), nbins, lowrangelimit, range+lowrangelimit); for (int j=0; j<=COUNT; j++) { histo->Fill((per_channel*BIN[j]+(0.5*per_channel)), DATA[j]); } if (timescale == 2) { sprintf(timeunit, " s"); sprintf(xtitle, "Time (s)"); sprintf(ytitle, "Counts / %g s", number_time); DRAW_CONTROL = 1; } else if (timescale == 1) { sprintf(timeunit, " ms"); sprintf(xtitle, "Time (ms)"); sprintf(ytitle, "Counts / %g ms", number_time); DRAW_CONTROL = 1; } else if (timescale == 4) { sprintf(timeunit, " ns"); sprintf(xtitle, "Time (ns)"); sprintf(ytitle, "Counts / %g ns", number_time); DRAW_CONTROL = 1; } else if (timescale == 3) { sprintf(timeunit, " us"); sprintf(xtitle, "Time (us)"); sprintf(ytitle, "Counts / %g us", number_time); DRAW_CONTROL = 1; } else if (timescale == 5) { sprintf(timeunit, " min"); sprintf(xtitle, "Time (min)"); sprintf(ytitle, "Counts / %g min", number_time); DRAW_CONTROL = 1; } else if (timescale == 6) { sprintf(timeunit, " days"); sprintf(xtitle, "Time (days)"); sprintf(ytitle, "Counts / %g days", number_time); DRAW_CONTROL = 1; } // Get the canvas for the histogram to be plotted TCanvas *fCanvas = fFitCanvas->GetCanvas(); fCanvas->cd(); fCanvas->Update(); fCanvas->SetBorderMode(0); fCanvas->SetFillColor(0); // Set the log y scale if desired if (logony) { fCanvas->SetLogy(1); } else { fCanvas->SetLogy(0); } // fCanvas->SetLogy(1); gStyle->SetTitleFillColor(0); gStyle->SetTitleBorderSize(0); gStyle->SetCanvasBorderMode(0); gStyle->SetCanvasColor(2); gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(2); histo->GetXaxis()->CenterTitle(); histo->GetYaxis()->CenterTitle(); histo->GetYaxis()->SetTitleSize(0.02); histo->GetYaxis()->SetLabelSize(0.02); histo->GetXaxis()->SetTitleSize(0.02); histo->GetXaxis()->SetLabelSize(0.02); /* if(noxerror) { gStyle->SetErrorX(0); histo->SetMarkerStyle(20); histo->SetMarkerSize(1); } */ int freeparameters = 0; // We need to count the free parameters, for a reduced chi-square // Perform fit based on selected check-boxes if (!linear && !exp && !daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent, lowrangelimit, range+lowrangelimit, 13); freeparameters = 2; } else if (linear && !exp && !daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 3; } else if (!linear && exp && !daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 4; } else if (linear && exp && !daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 5; } else if (!linear && !exp && daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_daughter, lowrangelimit, range+lowrangelimit, 13); freeparameters = 3; } else if (linear && !exp && daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_daughter_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 4; } else if (!linear && exp && daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_daughter_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 5; } else if (linear && exp && daughter && !neutronbranch && !granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_daughter_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 6; } else if (!linear && !exp && daughter && neutronbranch && !granddaugh && !twocomponent) { NO_NEUTRON = 1 - ONE_NEUTRON - TWO_NEUTRON; TF1 *fitFcn = new TF1("fitFcn", parent_neutronbranch, lowrangelimit, range+lowrangelimit, 13); freeparameters = 7; } else if (linear && !exp && daughter && neutronbranch && !granddaugh && !twocomponent) { NO_NEUTRON = 1 - ONE_NEUTRON - TWO_NEUTRON; TF1 *fitFcn = new TF1("fitFcn", parent_neutronbranch_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 8; } else if (!linear && exp && daughter && neutronbranch && !granddaugh && !twocomponent) { NO_NEUTRON = 1 - ONE_NEUTRON - TWO_NEUTRON; TF1 *fitFcn = new TF1("fitFcn", parent_neutronbranch_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 9; } else if (linear && exp && daughter && neutronbranch && !granddaugh && !twocomponent) { NO_NEUTRON = 1 - ONE_NEUTRON - TWO_NEUTRON; TF1 *fitFcn = new TF1("fitFcn", parent_neutronbranch_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 10; } else if (!linear && !exp && daughter && !neutronbranch && granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_granddaughter, lowrangelimit, range+lowrangelimit, 13); freeparameters = 4; } else if (linear && !exp && daughter && !neutronbranch && granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_granddaughter_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 5; } else if (!linear && exp && daughter && !neutronbranch && granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_granddaughter_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 6; } else if (linear && exp && daughter && !neutronbranch && granddaugh && !twocomponent) { TF1 *fitFcn = new TF1("fitFcn", parent_granddaughter_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 7; } else if (!linear && !exp && !daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", twocomponentfit, lowrangelimit, range+lowrangelimit, 13); freeparameters = 4; } else if (linear && !exp && !daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 5; } else if (!linear && exp && !daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 6; } else if (linear && exp && !daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 7; } else if (!linear && !exp && daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_daughter, lowrangelimit, range+lowrangelimit, 13); freeparameters = 5; } else if (linear && !exp && daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_daughter_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 6; } else if (!linear && exp && daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_daughter_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 7; } else if (linear && exp && daughter && !neutronbranch && !granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_daughter_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 8; } else if (!linear && !exp && daughter && !neutronbranch && granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_granddaughter, lowrangelimit, range+lowrangelimit, 13); freeparameters = 6; } else if (linear && !exp && daughter && !neutronbranch && granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_granddaughter_lin, lowrangelimit, range+lowrangelimit, 13); freeparameters = 7; } else if (!linear && exp && daughter && !neutronbranch && granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_granddaughter_exp, lowrangelimit, range+lowrangelimit, 13); freeparameters = 8; } else if (linear && exp && daughter && !neutronbranch && granddaugh && twocomponent) { TF1 *fitFcn = new TF1("fitFcn", two_component_granddaughter_both, lowrangelimit, range+lowrangelimit, 13); freeparameters = 9; } else if (!daughter && granddaugh) { FLAG = 1; new TGMsgBox(gClient->GetRoot(), fMain, "To include a granddaughter, you must also include the daughter.", kMBIconStop, kMBDismiss, &retval); } else if (granddaugh && neutronbranch) { FLAG = 1; new TGMsgBox(gClient->GetRoot(), fMain, "At this time, you cannot include both a granddaughter and neutron branching.\n I'm sorry.", kMBIconStop, KMBDismiss, &retval); } // Set the initial values of all the parameters for the fit. fitFcn->SetParameter(0, INITIAL_GUESS); fitFcn->SetParLimits(0, INITIAL_LOW_LIMIT, INITIAL_HIGH_LIMIT); if (!twocomponent) { fitFcn->SetParameter(1, LIFE_GUESS); fitFcn->SetParLimits(1, LIFE_LOW_LIMIT, LIFE_HIGH_LIMIT); } if (daughter) { if (DAUGHTER_FREE) { fitFcn->SetParameter(2, DAUGHTER_GUESS); fitFcn->SetParLimits(2, DAUGHTER_LOW_LIMIT, DAUGHTER_HIGH_LIMIT); } else if (!DAUGHTER_FREE) { fitFcn->FixParameter(2, DAUGHTER_GUESS); freeparameters = freeparameters - 1; } } else if (!daughter) { fitFcn->FixParameter(2, 0); } if (linear) { fitFcn->SetParameter(3, BACKLIN_GUESS); fitFcn->SetParLimits(3, BACKLIN_LOW_LIMIT, BACKLIN_HIGH_LIMIT); } else if (!linear) { fitFcn->FixParameter(3, 0); } if (exp) { fitFcn->SetParameter(4, EXPINIT_GUESS); fitFcn->SetParLimits(4, EXPINIT_LOW_LIMIT, EXPINIT_HIGH_LIMIT); if (EXPDECAY_FREE) { fitFcn->SetParameter(5, EXPDECAY_GUESS); fitFcn->SetParLimits(5, EXPDECAY_LOW_LIMIT, EXPDECAY_HIGH_LIMIT); } else if (!EXPDECAY_FREE) { fitFcn->FixParameter(5, EXPDECAY_GUESS); freeparameters = freeparameters - 1; } } else if (!exp) { fitFcn->FixParameter(4, 0); fitFcn->FixParameter(5, 0); } if (granddaugh) { fitFcn->FixParameter(6, GRANDDAUGHTER); freeparameters = freeparameters - 1; } else if (!granddaugh) { fitFcn->FixParameter(6, 0); } if (neutronbranch) { fitFcn->FixParameter(7, DAUGHTER_ONENEUTRON); fitFcn->FixParameter(8, DAUGHTER_TWONEUTRON); fitFcn->FixParameter(9, ONE_NEUTRON); fitFcn->FixParameter(10, TWO_NEUTRON); freeparameters = freeparameters - 4; } else if (!neutronbranch) { fitFcn->FixParameter(7, 0); fitFcn->FixParameter(8, 0); fitFcn->FixParameter(9, 0); fitFcn->FixParameter(10, 0); } if (twocomponent) { if (!FRACTION_FREE) { fitFcn->FixParameter(11, COMPONENT2_FRACTION); freeparameters = freeparameters - 1; } else if (FRACTION_FREE) { fitFcn->SetParameter(11, COMPONENT2_FRACTION); fitFcn->SetParLimits(11, COMPONENT2_FRACTION_LOW_LIMIT, COMPONENT2_FRACTION_HIGH_LIMIT); } if (!COMPONE_FREE) { fitFcn->FixParameter(1, LIFE_GUESS); freeparameters = freeparameters - 1; } else if (COMPONE_FREE) { fitFcn->SetParameter(1, LIFE_GUESS); fitFcn->SetParLimits(1, LIFE_LOW_LIMIT, LIFE_HIGH_LIMIT); } if (!COMPTWO_FREE) { fitFcn->FixParameter(12, COMPONENT2_GUESS); freeparameters = freeparameters - 1; } else { fitFcn->SetParameter(12, COMPONENT2_GUESS); fitFcn->SetParLimits(12, COMPONENT2_LOW_LIMIT, COMPONENT2_HIGH_LIMIT); } } else if (!twocomponent) { fitFcn->FixParameter(11, 0); fitFcn->FixParameter(12, 0); } cout << "The number of free parameters in the fit is " << freeparameters << endl; cout << " " << endl; // Actually fit the histogram, and set the appearance (i.e. titles, etc.) if (uselogmethod && !useintegrate) { histo->Fit("fitFcn", "LQMR"); } else if (uselogmethod && useintegrate) { histo->Fit("fitFcn", "ILQMR"); } else if (!uselogmethod && useintegrate) { histo->Fit("fitFcn", "IQMR"); } else if (!uselogmethod && !useintegrate) { histo->Fit("fitFcn", "QMR"); } histo->GetXaxis()->SetTitle(xtitle); histo->GetYaxis()->SetTitle(ytitle); histo->GetYaxis()->SetTitleOffset(1.3); if (setyminimum) { histo->SetMinimum(minimumy); } gStyle->SetOptStat(0); if (printoutmatrix) { TVirtualFitter *actualfitter = TVirtualFitter::GetFitter(); TMatrixD errormatrix(13,13, actualfitter->GetCovarianceMatrix()); // Print out the covariance matrix for (int i=0; i<=12; i++) { for (int j=0; j<=12; j++) { if (errormatrix(i,j) < 1e-15) { errormatrix(i,j) = 0; } } cout << setprecision(5) << setw(12) << errormatrix(i,0) << setprecision(5) << setw(12) << errormatrix(i,1) << setprecision(5) << setw(12) << errormatrix(i,2) << setprecision(5) << setw(12) << errormatrix(i,3) << setprecision(5) << setw(8) << errormatrix(i,4) << setprecision(5) << setw(8) << errormatrix(i,5) << setprecision(5) << setw(12) << errormatrix(i,6) << setprecision(5) << setw(8) << errormatrix(i,7) << setprecision(5) << setw(8) << errormatrix(i,8) << setprecision(5) << setw(8) << errormatrix(i,9) << setprecision(5) << setw(8) << errormatrix(i,10) << setprecision(5) << setw(8) << errormatrix(i,11) << setprecision(5) << setw(8) << errormatrix(i,12) << endl; } } // Define the constituent functions of the fit. if (!twocomponent) { TF1 *parentFcn = new TF1 ("parentFcn", parent, lowrangelimit, range+lowrangelimit, 13); parentFcn->SetLineColor(3); if (granddaugh) { TF1 *grandFcn = new TF1("grandFcn", granddaughter, lowrangelimit, range+lowrangelimit, 13); grandFcn->SetLineColor(7); } if (daughter) { TF1 *daughterFcn = new TF1("daughterFcn", daughter_only, lowrangelimit, range+lowrangelimit, 13); daughterFcn->SetLineColor(4); } } if (linear) { TF1 *backFcn = new TF1("backFcn", background_linear, lowrangelimit, range+lowrangelimit, 13); backFcn->SetLineColor(2); } if (exp) { TF1 *backFcn = new TF1("backFcn", background_exp, lowrangelimit, range+lowrangelimit, 13); backFcn->SetLineColor(2); } if (neutronbranch) { TF1 *ndaughFcn = new TF1("ndaughFcn", oneneutron_daughter, lowrangelimit, range+lowrangelimit, 13); ndaughFcn->SetLineColor(5); TF1 *n2daughFcn = new TF1("n2daughFcn", twoneutron_daughter, lowrangelimit, range+lowrangelimit, 13); n2daughFcn->SetLineColor(6); } if (twocomponent) { TF1 *comp1Fcn = new TF1("comp1Fcn", component1, lowrangelimit, range+lowrangelimit, 13); comp1Fcn->SetLineColor(8); TF1 *comp2Fcn = new TF1("comp2Fcn", component2, lowrangelimit, range+lowrangelimit, 13); comp2Fcn->SetLineColor(9); if (granddaugh) { TF1 *grandFcn = new TF1("grandFcn", granddaughter_two_component, lowrangelimit, range+lowrangelimit, 13); grandFcn->SetLineColor(7); } if (daughter) { TF1 *daughterFcn = new TF1("daughterFcn", daughter_two_component, lowrangelimit, range+lowrangelimit, 13); daughterFcn->SetLineColor(4); } } Double_t par[13]; fitFcn->GetParameters(par); double chisquare = fitFcn->GetChisquare(); Double_t chimean[100000] = {0}; Double_t function_value = 0; Double_t logfunction = 0; Double_t bincenter = 0; Double_t bincontents = 0; Double_t chi[100000] = {0}; for (int i=0; i <= (nbins-1); i++) { bincenter = histo->GetXaxis()->GetBinCenter(i+1); bincontents = histo->GetBinContent(i+1); function_value = fitFcn->Eval(bincenter, 0, 0); chi[i] = function_value - bincontents*TMath::Log(function_value) + TMath::LnGamma(bincontents+1); logfunction = TMath::Log(function_value); chimean[i] = 1.009303*logfunction + 2.766579; function_value = 0; logfunction = 0; bincenter = 0; bincontents = 0; } Double_t degreesoffreedom = 0; Double_t chisquared_loglike = 0; for (int i = 0; i <= (nbins-1); i++) { degreesoffreedom = degreesoffreedom + chimean[i]; chisquared_loglike = chisquared_loglike + chi[i]; } degreesoffreedom = degreesoffreedom - freeparameters; chisquared_loglike = chisquared_loglike*2; // Extract all of the results of the fit. double initial_activity = par[0]; double initial_activity_error = fitFcn->GetParError(0); if (!twocomponent) { double halflife = par[1]; double halflife_error = fitFcn->GetParError(1); } if (daughter) { double daughter_halflife = par[2]; double daughter_halflife_error = fitFcn->GetParError(2); } if (linear) { double background_linear = par[3]; double background_linear_error = fitFcn->GetParError(3); } if (exp) { double background_exp_initial = par[4]; double background_exp_initial_error = fitFcn->GetParError(4); if (EXPDECAY_FREE) { double background_exp_decay = par[5]; double background_exp_decay_error = fitFcn->GetParError(5); } else { double background_exp_decay = par[5]; } } double granddaughter = GRANDDAUGHTER; double one_neutron_halflife = DAUGHTER_ONENEUTRON; double two_neutron_halflife = DAUGHTER_TWONEUTRON; if (twocomponent) { double halflife = par[1]; double component2_halflife = par[12]; double component2_fraction = par[11]; if (FRACTION_FREE) { double component2_fraction_error = fitFcn->GetParError(11); } if (COMPONE_FREE) { double halflife_error = fitFcn->GetParError(1); } if (COMPTWO_FREE) { double component2_halflife_error = fitFcn->GetParError(12); } } // Print out the results of the fit to the screen. cout << titlevalue->GetString() << endl; if (twocomponent) { if (COMPONE_FREE) { cout << "Component 1 half-life = " << halflife << timeunit << " +/- " << halflife_error << endl; } else if (!COMPONE_FREE) { cout << "Component 1 half-life = " << halflife << timeunit << " (fixed)" << endl; } if (COMPTWO_FREE) { cout << "Component 2 half-life = " << component2_halflife << timeunit << " +/- " << component2_halflife_error << endl; } else if (!COMPTWO_FREE) { cout << "Component 2 half-life = " << component2_halflife << timeunit << " (fixed)" << endl; } if (FRACTION_FREE) { cout << "Fraction of component 2 = " << component2_fraction << " +/- " << component2_fraction_error << endl; } else if (!FRACTION_FREE) { cout << "Fraction of component 2 = " << component2_fraction << " (fixed)" << endl; } } else if (!twocomponent) { cout << "Half-life = " << halflife << " +/- " << halflife_error << timeunit << endl; } cout << "Initial activity = " << initial_activity << " +/- " << initial_activity_error << " counts/" << number_time << timeunit << endl; if (linear) { cout << "Background (constant) = " << background_linear << " +/- " << background_linear_error << " counts/" << number_time << timeunit << endl; } if (exp) { cout << "Background (exponential) intial value = " << background_exp_initial << " +/- " << background_exp_initial_error << " counts/" << number_time << timeunit << endl; if (EXPDECAY_FREE) { cout << "Background (exponential) decay constant = " << background_exp_decay << " +/- " << background_exp_decay_error << timeunit << "-1" << endl; } else { cout << "Background (exponential) decay constant = " << background_exp_decay << timeunit << "-1 (fixed)" << endl; } } if (daughter) { if (DAUGHTER_FREE) { cout << "Daughter half-life = " << daughter_halflife << " +/- " << daughter_halflife_error << timeunit << endl; } else if (!DAUGHTER_FREE) { cout << "Daughter half-life = " << daughter_halflife << timeunit << " (fixed)" << endl; } } if (granddaugh) { cout << "Granddaughter half-life = " << granddaughter << timeunit << " (fixed)" << endl; } if (neutronbranch) { cout << "One-neutron daughter branching ratio = " << ONE_NEUTRON << " (fixed)" << endl; cout << "One-neutron daughter half-life = " << one_neutron_halflife << timeunit << " (fixed)" << endl; cout << "Two-neutron daughter branching ratio = " << TWO_NEUTRON << " (fixed)" << endl; cout << "Two-neutron daughter half-life = " << two_neutron_halflife << timeunit << " (fixed)" << endl; } if (uselogmethod) { cout << "Chi-square (ROOT) = " << chisquare << endl; cout << "Reduced chi-square (ROOT) = " << chisquare/degreesoffreedom << endl; if (chisquared_loglike >= 0 && degreesoffreedom > 0) { cout << "Chi-square (calculated) = " << chisquared_loglike << endl; cout << "Reduced chi-square (calculated) = " << chisquared_loglike/degreesoffreedom << endl; } else { cout << "Error calculating the chi-squared directly. Sorry." << endl; } } else if (!uselogmethod) { cout << "Chi-square = " << chisquare << endl; cout << "Reduced chi-square = " << chisquare/(nbins - freeparameters) << endl; } cout << "" << endl; // Draw the histogram, with the options for displaying fit results on the plot. histo->Draw("E1P"); // histo->Draw("histo"); fCanvas->Update(); if (twocomponent) { comp1Fcn->SetParameters(par); comp1Fcn->Draw("same"); comp2Fcn->SetParameters(par); comp2Fcn->Draw("same"); fitFcn->Draw("same"); } else if (!twocomponent) { parentFcn->SetParameters(par); parentFcn->Draw("same"); fitFcn->Draw("same"); } if (linear || exp) { backFcn->SetParameters(par); backFcn->Draw("same"); } if (daughter) { daughterFcn->SetParameters(par); daughterFcn->Draw("same"); } if (neutronbranch) { ndaughFcn->SetParameters(par); ndaughFcn->Draw("same"); n2daughFcn->SetParameters(par); n2daughFcn->Draw("same"); } if (granddaugh) { grandFcn->SetParameters(par); grandFcn->Draw("same"); } fCanvas->Update(); TLatex la; // la.SetTextAlign(15); la.SetTextSize(0.1); la.SetTextAngle(0); // la.SetTextFont(11); // la.DrawLatex(2.015,47.2,""); // la.DrawLatex(25,40,"790 keV"); // la.DrawLatex(25,20,"12^{+}#rightarrow10^{+}"); if (printout) { TPaveText *text = new TPaveText(0.45, 0.65, 0.65, 0.88,"NDC"); text->ConvertNDCtoPad(); text->SetTextSize(0.025); text->SetBorderSize(0); text->SetFillStyle(0); if (!twocomponent) { char str1[80]; sprintf (str1, "Half-life: %.3f +/- %.3f%s", halflife, halflife_error, timeunit); text->AddText(str1); } else if (twocomponent) { char str1[80]; if (COMPONE_FREE) { sprintf(str1, "Component 1 Half-life: %.3f +/- %.3f%s", halflife, halflife_error, timeunit); } else if (!COMPONE_FREE) { sprintf(str1, "Component 1 Half-life: %.3f%s (fixed)", halflife, timeunit); } char str11[80]; if (COMPTWO_FREE) { sprintf(str11, "Component 2 Half-life: %.3f +/- %.3f%s", component2_halflife, component2_halflife_error, timeunit); } else if (!COMPTWO_FREE) { sprintf(str11, "Component 2 Half-life: %.3f%s (fixed)", component2_halflife, timeunit); } if (FRACTION_FREE) { char str12[80]; sprintf(str12, "Component 2 Fraction: %.3f +/- %.3f", component2_fraction, component2_fraction_error); } else if (!FRACTION_FREE) { char str12[80]; sprintf(str12, "Component 2 Fraction: %.3f (fixed)", component2_fraction); } text->AddText(str1); text->AddText(str11); text->AddText(str12); } char str2[80]; sprintf (str2, "Initial Activity: %.3f +/- %.3f counts/%g%s", initial_activity, initial_activity_error, number_time, timeunit); text->AddText(str2); if (linear) { char str3[80]; sprintf (str3, "Background (constant): %.3f +/- %.3f counts/%g%s", background_linear, background_linear_error, number_time, timeunit); text->AddText(str3); } if (exp) { char str3[80]; sprintf(str3, "Background (exponential) initial value: %.3f +/- %.3f counts/%g%s", background_exp_initial, background_exp_initial_error, number_time, timeunit); if (EXPDECAY_FREE) { char str4[80]; sprintf(str4, "Background (exponential) decay constant: %.5f +/- %.5f%s-1", background_exp_decay, background_exp_decay_error, timeunit); } else if (!EXPDECAY_FREE) { char str4[80]; sprintf(str4, "Background (exponential) decay constant: %.5f%s-1 (fixed)", background_exp_decay, timeunit); } text->AddText(str3); text->AddText(str4); } if (daughter) { if (DAUGHTER_FREE) { char str5[80]; sprintf(str5, "Daughter half-life: %.3f +/- %.3f%s", daughter_halflife, daughter_halflife_error, timeunit); } else if (!DAUGHTER_FREE) { char str5[80]; sprintf(str5, "Daughter half-life: %.3f%s (fixed)", daughter_halflife, timeunit); } text->AddText(str5); } if (granddaugh) { char str6[80]; sprintf(str6, "Grand-daughter halflife: %.3f%s (fixed)", granddaughter, timeunit); text->AddText(str6); } if (neutronbranch) { char str7[80]; sprintf (str7, "One-neutron branching ratio: %.3f (fixed)", ONE_NEUTRON); char str8[80]; sprintf (str8, "One-neutron daughter half-life: %.3f%s (fixed)", one_neutron_halflife, timeunit); if (TWO_NEUTRON != 0) { char str9[80]; sprintf(str9, "Two-neutron branching ratio: %.3f (fixed)", TWO_NEUTRON); char str10[80]; sprintf(str10, "Two-neutron daughter half-life: %.3f%s (fixed)", two_neutron_halflife, timeunit); } text->AddText(str7); text->AddText(str8); if (TWO_NEUTRON != 0) { text->AddText(str9); text->AddText(str10); } } text->Draw(""); } fCanvas->Update(); end: } void Fitter::Save() { int filetype = filechoice->GetSelected(); TCanvas *fCanvas = fFitCanvas->GetCanvas(); if (filetype == 1) { fCanvas->Print(savevalue->GetString(), "eps"); } else if (filetype == 2) { fCanvas->Print(savevalue->GetString(), "ps"); } else if (filetype == 3) { fCanvas->Print(savevalue->GetString(), "pdf"); } else if (filetype == 4) { fCanvas->Print(savevalue->GetString(), "gif"); } else if (filetype == 5) { fCanvas->Print(savevalue->GetString(), "jpg"); } else if (filetype == 6) { fCanvas->Print(savevalue->GetString(), "png"); } } InputExponential::InputExponential(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { // Create message box test dialog. Use this dialog to select the different // message dialog box styles and show the message dialog by clicking the // "Test" button. fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "InputExponential", this, "CloseWindow()"); group = new TGGroupFrame(fMain, "Exponential Background Options", kVerticalFrame); fMain->AddFrame(group, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); expFrame = new TGHorizontalFrame(group, 0, 0, 0); expFrame2 = new TGHorizontalFrame(group, 0, 0, 0); buttonFrame = new TGHorizontalFrame(fMain, 0, 0, 0); exp_decay = new TGNumberEntry(expFrame, EXPDECAY_GUESS, 12); expFrame->AddFrame(exp_decay, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); exp_label = new TGLabel(expFrame, "Background Decay Constant (1/(time unit))"); expFrame->AddFrame(exp_label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(expFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); exp_free = new TGCheckButton(expFrame2, "Keep background decay constant as free parameter?"); expFrame2->AddFrame(exp_free, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); group->AddFrame(expFrame2, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); if (EXPDECAY_FREE) { exp_free->SetState(1); } okay = new TGTextButton(buttonFrame, "&OK"); okay->Connect("Clicked()", "InputExponential", this, "DoOK()"); buttonFrame->AddFrame(okay, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); cancel = new TGTextButton(buttonFrame, "&Cancel"); cancel->Connect("Clicked()", "InputExponential", this, "DoCancel()"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); fMain->AddFrame(buttonFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("Exponential Background Entry"); fMain->MapWindow(); gClient->WaitFor(fMain); } // Order is important when deleting frames. Delete children first, // parents last. InputExponential::~InputExponential() { // Delete widgets created by dialog. delete okay; delete cancel; delete exp_free; delete exp_decay; delete exp_label; delete buttonFrame; delete expFrame2; delete expFrame; delete group; delete fMain; } void InputExponential::CloseWindow() { // Close dialog in response to window manager close. delete this; } void InputExponential::DoCancel() { // Handle Close button. fMain->SendCloseMessage(); } void InputExponential::DoOK() { EXPDECAY_GUESS = (exp_decay->GetNumber()); EXPDECAY_FREE = (exp_free->GetState() == kButtonDown); if (EXPDECAY_FREE) { cout << "Exponential background decay constant is a free parameter." << endl; } else { cout << "Exponential background decay constant is set to " << EXPDECAY_GUESS << " 1/time units." << endl; } cout << "" << endl; fMain->SendCloseMessage(); } InputComponents::InputComponents(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "InputComponents", this, "CloseWindow()"); group = new TGGroupFrame(fMain, "Two-Component Fit Options", kVerticalFrame); fMain->AddFrame(group, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); comp1Frame = new TGHorizontalFrame(group, 0, 0, 0); comp1Frame2 = new TGHorizontalFrame(group, 0, 0, 0); comp2Frame = new TGHorizontalFrame(group, 0, 0, 0); comp2Frame2 = new TGHorizontalFrame(group, 0, 0, 0); frac2Frame = new TGHorizontalFrame(group, 0, 0, 0); frac2Frame2 = new TGHorizontalFrame(group, 0, 0, 0); buttonFrame = new TGHorizontalFrame(fMain, 0, 0, 0); comp1 = new TGNumberEntry(comp1Frame, LIFE_GUESS, 12); comp1Frame->AddFrame(comp1, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); comp1Label = new TGLabel(comp1Frame, "Component 1 (i.e. ground state) Half-Life"); comp1Frame->AddFrame(comp1Label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(comp1Frame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); freecomp1 = new TGCheckButton(comp1Frame2, "Keep component 1 half-life as free parameter?"); comp1Frame2->AddFrame(freecomp1, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); group->AddFrame(comp1Frame2, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); comp2 = new TGNumberEntry(comp2Frame, COMPONENT2_GUESS, 12); comp2Frame->AddFrame(comp2, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); comp2Label = new TGLabel(comp2Frame, "Component 2 (i.e. excited state) Half-Life"); comp2Frame->AddFrame(comp2Label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(comp2Frame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); freecomp2 = new TGCheckButton(comp2Frame2, "Keep component 2 half-life as free parameter?"); comp2Frame2->AddFrame(freecomp2, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); group->AddFrame(comp2Frame2, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); frac2 = new TGNumberEntry(frac2Frame, COMPONENT2_FRACTION, 12); frac2Frame->AddFrame(frac2, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); frac2Label = new TGLabel(frac2Frame, "Fraction in State 2?"); frac2Frame->AddFrame(frac2Label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(frac2Frame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); freefraction = new TGCheckButton(frac2Frame2, "Keep component 2 fraction as free parameter?"); frac2Frame2->AddFrame(freefraction, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); group->AddFrame(frac2Frame2, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); if (FRACTION_FREE) { freefraction->SetState(1); } if (COMPONE_FREE) { freecomp1->SetState(1); } if (COMPTWO_FREE) { freecomp2->SetState(1); } okay = new TGTextButton(buttonFrame, "&OK"); okay->Connect("Clicked()", "InputComponents", this, "DoOK()"); buttonFrame->AddFrame(okay, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); cancel = new TGTextButton(buttonFrame, "&Cancel"); cancel->Connect("Clicked()", "InputComponents", this, "DoCancel()"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); fMain->AddFrame(buttonFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("Two Component Information Entry"); fMain->MapWindow(); gClient->WaitFor(fMain); } // Order is important when deleting frames. Delete children first, // parents last. InputComponents::~InputComponents() { // Delete widgets created by dialog. delete okay; delete cancel; delete comp1; delete comp2; delete frac2; delete freefraction; delete freecomp1; delete freecomp2; delete comp1Label; delete comp2Label; delete frac2Label; delete buttonFrame; delete comp1Frame; delete comp2Frame; delete frac2Frame; delete frac2Frame2; delete comp2Frame2; delete comp1Frame2; delete group; delete fMain; } void InputComponents::CloseWindow() { // Close dialog in response to window manager close. delete this; } void InputComponents::DoCancel() { // Handle Close button. fMain->SendCloseMessage(); } void InputComponents::DoOK() { FRACTION_FREE = (freefraction->GetState() == kButtonDown); COMPONE_FREE = (freecomp1->GetState() == kButtonDown); COMPTWO_FREE = (freecomp2->GetState() == kButtonDown); LIFE_GUESS = comp1->GetNumber(); COMPONENT2_GUESS = comp2->GetNumber(); COMPONENT2_FRACTION = (frac2->GetNumber()); if (COMPONE_FREE) { cout << "Component 1 half-life is a free parameter." << endl; } else { cout << "Component 1 Half-life is " << comp1->GetNumber() << " time units." << endl; } if (COMPTWO_FREE) { cout << "Component 2 half-life is a free parameter." << endl; } else { cout << "Component 2 Half-life is " << comp2->GetNumber() << " time units." << endl; } if (FRACTION_FREE) { cout << "Fraction of component 2 is a free parameter." << endl; } else { cout << "Fraction of component 2 is " << frac2->GetNumber() << " time units." << endl; } cout << "" << endl; fMain->SendCloseMessage(); } InputDaughter::InputDaughter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { // Create message box test dialog. Use this dialog to select the different // message dialog box styles and show the message dialog by clicking the // "Test" button. fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "InputDaughter", this, "CloseWindow()"); group = new TGGroupFrame(fMain, "Half-life Options", kVerticalFrame); fMain->AddFrame(group, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); daughFrame = new TGHorizontalFrame(group, 0, 0, 0); daughFrame2 = new TGHorizontalFrame(group, 0, 0, 0); buttonFrame = new TGHorizontalFrame(fMain, 0, 0, 0); daugh_life = new TGNumberEntry(daughFrame, DAUGHTER_GUESS, 12); daughFrame->AddFrame(daugh_life, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); daugh_label = new TGLabel(daughFrame, "Beta Daughter Half-life"); daughFrame->AddFrame(daugh_label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(daughFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); daugh_free = new TGCheckButton(daughFrame2, "Keep daughter half-life as free parameter?"); daughFrame2->AddFrame(daugh_free, new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,2,2)); group->AddFrame(daughFrame2, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); if (DAUGHTER_FREE) { daugh_free->SetState(1); } okay = new TGTextButton(buttonFrame, "&OK"); okay->Connect("Clicked()", "InputDaughter", this, "DoOK()"); buttonFrame->AddFrame(okay, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); cancel = new TGTextButton(buttonFrame, "&Cancel"); cancel->Connect("Clicked()", "InputDaughter", this, "DoCancel()"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); fMain->AddFrame(buttonFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("Daughter Half-life Entry"); fMain->MapWindow(); gClient->WaitFor(fMain); } // Order is important when deleting frames. Delete children first, // parents last. InputDaughter::~InputDaughter() { // Delete widgets created by dialog. delete okay; delete cancel; delete daugh_free; delete daugh_life; delete daugh_label; delete buttonFrame; delete daughFrame2; delete daughFrame; delete group; delete fMain; } void InputDaughter::CloseWindow() { // Close dialog in response to window manager close. delete this; } void InputDaughter::DoCancel() { // Handle Close button. fMain->SendCloseMessage(); } void InputDaughter::DoOK() { DAUGHTER_GUESS = daugh_life->GetNumber(); DAUGHTER_FREE = (daugh_free->GetState() == kButtonDown); if (DAUGHTER_FREE) { cout << "Beta-daughter half-life is a free parameter." << endl; } else if (DAUGHTER_GUESS!=0) { cout << "Beta-daughter half-life set to " << DAUGHTER_GUESS << " time units." << endl; } else { cout << "Beta-daughter half-life is set to 0 time units." << endl; } cout << "" << endl; fMain->SendCloseMessage(); } InputGrand::InputGrand(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { // Create message box test dialog. Use this dialog to select the different // message dialog box styles and show the message dialog by clicking the // "Test" button. fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "InputGrand", this, "CloseWindow()"); group = new TGGroupFrame(fMain, "Half-life Options", kVerticalFrame); fMain->AddFrame(group, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); grandFrame = new TGHorizontalFrame(group, 0, 0, 0); buttonFrame = new TGHorizontalFrame(fMain, 0, 0, 0); grand_life = new TGNumberEntry(grandFrame, GRANDDAUGHTER, 12); grandFrame->AddFrame(grand_life, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); grand_label = new TGLabel(grandFrame, "Beta Grand-Daughter Half-life"); grandFrame->AddFrame(grand_label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(grandFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); okay = new TGTextButton(buttonFrame, "&OK"); okay->Connect("Clicked()", "InputGrand", this, "DoOK()"); buttonFrame->AddFrame(okay, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); cancel = new TGTextButton(buttonFrame, "&Cancel"); cancel->Connect("Clicked()", "InputGrand", this, "DoCancel()"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); fMain->AddFrame(buttonFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("Grand-Daughter Half-life Entry"); fMain->MapWindow(); gClient->WaitFor(fMain); } // Order is important when deleting frames. Delete children first, // parents last. InputGrand::~InputGrand() { // Delete widgets created by dialog. delete okay; delete cancel; delete grand_life; delete grand_label; delete buttonFrame; delete grandFrame; delete group; delete fMain; } void InputGrand::CloseWindow() { // Close dialog in response to window manager close. delete this; } void InputGrand::DoCancel() { // Handle Close button. fMain->SendCloseMessage(); } void InputGrand::DoOK() { GRANDDAUGHTER = (grand_life->GetNumber()); if (GRANDDAUGHTER != 0) { cout << "Beta grand-daughter half-life set to " << GRANDDAUGHTER << " time units." << endl; } else { cout << "Beta grand-daughter half-life is set to 0 time units." << endl; } cout << "" << endl; fMain->SendCloseMessage(); } InputNeutron::InputNeutron(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { // Create message box test dialog. Use this dialog to select the different // message dialog box styles and show the message dialog by clicking the // "Test" button. fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "InputNeutron", this, "CloseWindow()"); group = new TGGroupFrame(fMain, "Neutron Branching Options", kVerticalFrame); fMain->AddFrame(group, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); oneBranchFrame = new TGHorizontalFrame(group, 0, 0, 0); oneLifeFrame = new TGHorizontalFrame(group, 0, 0, 0); twoBranchFrame = new TGHorizontalFrame(group, 0, 0, 0); twoLifeFrame = new TGHorizontalFrame(group, 0, 0, 0); buttonFrame = new TGHorizontalFrame(fMain, 0, 0, 0); oneBranch = new TGNumberEntry(oneBranchFrame, ONE_NEUTRON, 12); oneBranchFrame->AddFrame(oneBranch, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); oneBranchLabel = new TGLabel(oneBranchFrame, "Parent Beta-1n Branching Ratio"); oneBranchFrame->AddFrame(oneBranchLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(oneBranchFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); oneLife = new TGNumberEntry(oneLifeFrame, DAUGHTER_ONENEUTRON, 12); oneLifeFrame->AddFrame(oneLife, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); oneLifeLabel = new TGLabel(oneLifeFrame, "Beta-1n Daughter Half-life"); oneLifeFrame->AddFrame(oneLifeLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(oneLifeFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); twoBranch = new TGNumberEntry(twoBranchFrame, TWO_NEUTRON, 12); twoBranchFrame->AddFrame(twoBranch, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); twoBranchLabel = new TGLabel(twoBranchFrame, "Parent Beta-2n Branching Ratio"); twoBranchFrame->AddFrame(twoBranchLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(twoBranchFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); twoLife = new TGNumberEntry(twoLifeFrame, DAUGHTER_TWONEUTRON, 12); twoLifeFrame->AddFrame(twoLife, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); twoLifeLabel = new TGLabel(twoLifeFrame, "Beta-2n Daughter Half-life"); twoLifeFrame->AddFrame(twoLifeLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group->AddFrame(twoLifeFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); okay = new TGTextButton(buttonFrame, "&OK"); okay->Connect("Clicked()", "InputNeutron", this, "DoOK()"); buttonFrame->AddFrame(okay, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); cancel = new TGTextButton(buttonFrame, "&Cancel"); cancel->Connect("Clicked()", "InputNeutron", this, "DoCancel()"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); fMain->AddFrame(buttonFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("Neutron Branching Entry"); fMain->MapWindow(); gClient->WaitFor(fMain); } // Order is important when deleting frames. Delete children first, // parents last. InputNeutron::~InputNeutron() { // Delete widgets created by dialog. delete okay; delete cancel; delete oneBranch; delete twoBranch; delete oneLife; delete twoLife; delete oneBranchLabel; delete twoBranchLabel; delete oneLifeLabel; delete twoLifeLabel; delete buttonFrame; delete oneBranchFrame; delete twoBranchFrame; delete oneLifeFrame; delete twoLifeFrame; delete group; delete fMain; } void InputNeutron::CloseWindow() { // Close dialog in response to window manager close. delete this; } void InputNeutron::DoCancel() { // Handle Close button. fMain->SendCloseMessage(); } void InputNeutron::DoOK() { if (oneBranch->GetNumber() != 0) { ONE_NEUTRON = oneBranch->GetNumber(); } else { ONE_NEUTRON = 0; } if (twoBranch->GetNumber() != 0) { TWO_NEUTRON = twoBranch->GetNumber(); } else { TWO_NEUTRON = 0; } if (oneLife->GetNumber() != 0) { DAUGHTER_ONENEUTRON = oneLife->GetNumber(); } else { DAUGHTER_ONENEUTRON = 0; } if (twoLife->GetNumber() != 0) { DAUGHTER_TWONEUTRON = twoLife->GetNumber(); } else { DAUGHTER_TWONEUTRON = 0; } int retval; if (ONE_NEUTRON + TWO_NEUTRON > 1) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "The branching ratios you have entered sum to more than 1.\n This is non-physical.\n Please enter new values.", kMBIconStop, kMBDismiss, &retval); } else { cout << "Beta-1n branching ratio is " << ONE_NEUTRON << endl; if (DAUGHTER_ONENEUTRON != 0) { cout << "Beta-1n daughter half-life is " << DAUGHTER_ONENEUTRON << " time units." << endl; } else { cout << "Beta-1n daughter half-life is 0 time units." << endl; } cout << "Beta-2n branching ratio is " << TWO_NEUTRON << endl; if (DAUGHTER_TWONEUTRON != 0) { cout << "Beta-2n daughter half-life is " << DAUGHTER_TWONEUTRON << " time units." << endl; } else { cout << "Beta-2n daughter half-life is 0 time units." << endl; } cout << "" << endl; fMain->SendCloseMessage(); } } InputParameters::InputParameters(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) { // Create message box test dialog. Use this dialog to select the different // message dialog box styles and show the message dialog by clicking the // "Test" button. fMain = new TGTransientFrame(p, main, w, h, options); fMain->Connect("CloseWindow()", "InputParameters", this, "CloseWindow()"); if (!TWOCOMP) { group1 = new TGGroupFrame(fMain, "Parent Half-life Parameter Control", kVerticalFrame); fMain->AddFrame(group1, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); } if (DAUGHTER_FREE) { group2 = new TGGroupFrame(fMain, "Daughter Half-life Parameter Control", kVerticalFrame); fMain->AddFrame(group2, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); } if (LINEAR || EXP) { group3 = new TGGroupFrame(fMain, "Background Parameter Control", kVerticalFrame); fMain->AddFrame(group3, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); } group4 = new TGGroupFrame(fMain, "Initial Activity Parameter Control", kVerticalFrame); fMain->AddFrame(group4, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); if (TWOCOMP) { if (FRACTION_FREE || COMPONE_FREE || COMPTWO_FREE) { group5 = new TGGroupFrame(fMain, "Two-Component Fit Parameter Control", kVerticalFrame); fMain->AddFrame(group5, new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); } } if (!TWOCOMP) { lifeGuessFrame = new TGHorizontalFrame(group1, 0, 0, 0); lifeLowFrame = new TGHorizontalFrame(group1, 0, 0, 0); lifeHighFrame = new TGHorizontalFrame(group1, 0, 0, 0); } if (DAUGHTER_FREE) { daughterGuessFrame = new TGHorizontalFrame(group2, 0, 0, 0); daughterLowFrame = new TGHorizontalFrame(group2, 0, 0, 0); daughterHighFrame = new TGHorizontalFrame(group2, 0, 0, 0); } if (LINEAR) { backLinGuessFrame = new TGHorizontalFrame(group3, 0, 0, 0); backLinLowFrame = new TGHorizontalFrame(group3, 0, 0, 0); backLinHighFrame = new TGHorizontalFrame(group3, 0, 0, 0); } if (EXP) { if (EXPDECAY_FREE) { expDecayGuessFrame = new TGHorizontalFrame(group3, 0, 0, 0); expDecayLowFrame = new TGHorizontalFrame(group3, 0, 0, 0); expDecayHighFrame = new TGHorizontalFrame(group3, 0, 0, 0); } expInitGuessFrame = new TGHorizontalFrame(group3, 0, 0, 0); expInitLowFrame = new TGHorizontalFrame(group3, 0, 0, 0); expInitHighFrame = new TGHorizontalFrame(group3, 0, 0, 0); } if (TWOCOMP) { if (FRACTION_FREE) { fracGuessFrame = new TGHorizontalFrame(group5, 0, 0, 0); fracLowFrame = new TGHorizontalFrame(group5, 0, 0, 0); fracHighFrame = new TGHorizontalFrame(group5, 0, 0, 0); } if (COMPONE_FREE) { lifeGuessFrame = new TGHorizontalFrame(group5, 0, 0, 0); lifeLowFrame = new TGHorizontalFrame(group5, 0, 0, 0); lifeHighFrame = new TGHorizontalFrame(group5, 0, 0, 0); } if (COMPTWO_FREE) { component2GuessFrame = new TGHorizontalFrame(group5, 0, 0, 0); component2LowFrame = new TGHorizontalFrame(group5, 0, 0, 0); component2HighFrame = new TGHorizontalFrame(group5, 0, 0, 0); } } initialGuessFrame = new TGHorizontalFrame(group4, 0, 0, 0); initialLowFrame = new TGHorizontalFrame(group4, 0, 0, 0); initialHighFrame = new TGHorizontalFrame(group4, 0, 0, 0); buttonFrame = new TGHorizontalFrame(fMain, 0, 0, 0); if (!TWOCOMP){ if (LIFE_GUESS != 0) { lifeGuessNum = new TGNumberEntry(lifeGuessFrame, LIFE_GUESS, 12); } else { lifeGuessNum = new TGNumberEntry(lifeGuessFrame, 0, 12); } lifeGuessFrame->AddFrame(lifeGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); lifeGuessLabel = new TGLabel(lifeGuessFrame, "Guess for Half-life?"); lifeGuessFrame->AddFrame(lifeGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group1->AddFrame(lifeGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); lifeLowNum = new TGNumberEntry(lifeLowFrame, LIFE_LOW_LIMIT, 12); lifeLowFrame->AddFrame(lifeLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); lifeLowLabel = new TGLabel(lifeLowFrame, "Lower Bound for Half-life?"); lifeLowFrame->AddFrame(lifeLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group1->AddFrame(lifeLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); lifeHighNum = new TGNumberEntry(lifeHighFrame, LIFE_HIGH_LIMIT, 12); lifeHighFrame->AddFrame(lifeHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); lifeHighLabel = new TGLabel(lifeHighFrame, "Upper Bound for Half-life?"); lifeHighFrame->AddFrame(lifeHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group1->AddFrame(lifeHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } if (DAUGHTER_FREE) { daughterGuessNum = new TGNumberEntry(daughterGuessFrame, DAUGHTER_GUESS, 12); daughterGuessFrame->AddFrame(daughterGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); daughterGuessLabel = new TGLabel(daughterGuessFrame, "Guess for Daughter Half-life?"); daughterGuessFrame->AddFrame(daughterGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group2->AddFrame(daughterGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); daughterLowNum = new TGNumberEntry(daughterLowFrame, DAUGHTER_LOW_LIMIT, 12); daughterLowFrame->AddFrame(daughterLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); daughterLowLabel = new TGLabel(daughterLowFrame, "Lower Bound for Daughter Half-life?"); daughterLowFrame->AddFrame(daughterLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group2->AddFrame(daughterLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); daughterHighNum = new TGNumberEntry(daughterHighFrame, DAUGHTER_HIGH_LIMIT, 12); daughterHighFrame->AddFrame(daughterHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); daughterHighLabel = new TGLabel(daughterHighFrame, "Upper Bound for Daughter Half-life?"); daughterHighFrame->AddFrame(daughterHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group2->AddFrame(daughterHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } if (LINEAR) { backLinGuessNum = new TGNumberEntry(backLinGuessFrame, BACKLIN_GUESS, 12); backLinGuessFrame->AddFrame(backLinGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); backLinGuessLabel = new TGLabel(backLinGuessFrame, "Guess for Background (linear)?"); backLinGuessFrame->AddFrame(backLinGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(backLinGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); backLinLowNum = new TGNumberEntry(backLinLowFrame, BACKLIN_LOW_LIMIT, 12); backLinLowFrame->AddFrame(backLinLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); backLinLowLabel = new TGLabel(backLinLowFrame, "Lower Bound for Background (linear)?"); backLinLowFrame->AddFrame(backLinLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(backLinLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); backLinHighNum = new TGNumberEntry(backLinHighFrame, BACKLIN_HIGH_LIMIT, 12); backLinHighFrame->AddFrame(backLinHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); backLinHighLabel = new TGLabel(backLinHighFrame, "Upper Bound for Background (linear)?"); backLinHighFrame->AddFrame(backLinHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(backLinHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } if (EXP) { if (EXPDECAY_FREE) { expDecayGuessNum = new TGNumberEntry(expDecayGuessFrame, EXPDECAY_GUESS, 12); expDecayGuessFrame->AddFrame(expDecayGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); expDecayGuessLabel = new TGLabel(expDecayGuessFrame, "Guess for Background Decay Constant (exp)?"); expDecayGuessFrame->AddFrame(expDecayGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(expDecayGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); expDecayLowNum = new TGNumberEntry(expDecayLowFrame, EXPDECAY_LOW_LIMIT, 12); expDecayLowFrame->AddFrame(expDecayLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); expDecayLowLabel = new TGLabel(expDecayLowFrame, "Lower Bound for Background Decay Constant (exp)?"); expDecayLowFrame->AddFrame(expDecayLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(expDecayLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); expDecayHighNum = new TGNumberEntry(expDecayHighFrame, EXPDECAY_HIGH_LIMIT, 12); expDecayHighFrame->AddFrame(expDecayHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); expDecayHighLabel = new TGLabel(expDecayHighFrame, "Upper Bound for Background Decay Constant (exp)?"); expDecayHighFrame->AddFrame(expDecayHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(expDecayHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } expInitGuessNum = new TGNumberEntry(expInitGuessFrame, EXPINIT_GUESS, 12); expInitGuessFrame->AddFrame(expInitGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); expInitGuessLabel = new TGLabel(expInitGuessFrame, "Guess for Background Initial Value (exp)?"); expInitGuessFrame->AddFrame(expInitGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(expInitGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); expInitLowNum = new TGNumberEntry(expInitLowFrame, EXPINIT_LOW_LIMIT, 12); expInitLowFrame->AddFrame(expInitLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); expInitLowLabel = new TGLabel(expInitLowFrame, "Lower Bound for Background Initial Value (exp)?"); expInitLowFrame->AddFrame(expInitLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(expInitLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); expInitHighNum = new TGNumberEntry(expInitHighFrame, EXPINIT_HIGH_LIMIT, 12); expInitHighFrame->AddFrame(expInitHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); expInitHighLabel = new TGLabel(expInitHighFrame, "Upper Bound for Background Initial Value (exp)?"); expInitHighFrame->AddFrame(expInitHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group3->AddFrame(expInitHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } if (TWOCOMP && FRACTION_FREE) { if (FRACTION_FREE){ fracGuessNum = new TGNumberEntry(fracGuessFrame, COMPONENT2_FRACTION, 12); fracGuessFrame->AddFrame(fracGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); fracGuessLabel = new TGLabel(fracGuessFrame, "Guess for Fraction of Component 2?"); fracGuessFrame->AddFrame(fracGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(fracGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fracLowNum = new TGNumberEntry(fracLowFrame, COMPONENT2_FRACTION_LOW_LIMIT, 12); fracLowFrame->AddFrame(fracLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); fracLowLabel = new TGLabel(fracLowFrame, "Lower Bound for Fraction of Component 2?"); fracLowFrame->AddFrame(fracLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(fracLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fracHighNum = new TGNumberEntry(fracHighFrame, COMPONENT2_FRACTION_HIGH_LIMIT, 12); fracHighFrame->AddFrame(fracHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); fracHighLabel = new TGLabel(fracHighFrame, "Upper Bound for Fraction of Component 2?"); fracHighFrame->AddFrame(fracHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(fracHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } if (COMPONE_FREE) { if (LIFE_GUESS != 0) { lifeGuessNum = new TGNumberEntry(lifeGuessFrame, LIFE_GUESS, 12); } else { lifeGuessNum = new TGNumberEntry(lifeGuessFrame, 0, 12); } lifeGuessFrame->AddFrame(lifeGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); lifeGuessLabel = new TGLabel(lifeGuessFrame, "Guess for component 1 Half-life?"); lifeGuessFrame->AddFrame(lifeGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(lifeGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); lifeLowNum = new TGNumberEntry(lifeLowFrame, LIFE_LOW_LIMIT, 12); lifeLowFrame->AddFrame(lifeLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); lifeLowLabel = new TGLabel(lifeLowFrame, "Lower Bound for component 1 half-life?"); lifeLowFrame->AddFrame(lifeLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(lifeLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); lifeHighNum = new TGNumberEntry(lifeHighFrame, LIFE_HIGH_LIMIT, 12); lifeHighFrame->AddFrame(lifeHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); lifeHighLabel = new TGLabel(lifeHighFrame, "Upper Bound for component 1 half-life?"); lifeHighFrame->AddFrame(lifeHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(lifeHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } if (COMPTWO_FREE) { if (COMPONENT2_GUESS != 0) { component2GuessNum = new TGNumberEntry(component2GuessFrame, COMPONENT2_GUESS, 12); } else { component2GuessNum = new TGNumberEntry(component2GuessFrame, 0, 12); } component2GuessFrame->AddFrame(component2GuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); component2GuessLabel = new TGLabel(component2GuessFrame, "Guess for component 2 half-life?"); component2GuessFrame->AddFrame(component2GuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(component2GuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); component2LowNum = new TGNumberEntry(component2LowFrame, LIFE_LOW_LIMIT, 12); component2LowFrame->AddFrame(component2LowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); component2LowLabel = new TGLabel(component2LowFrame, "Lower Bound for component 2 half-life?"); component2LowFrame->AddFrame(component2LowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(component2LowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); component2HighNum = new TGNumberEntry(component2HighFrame, LIFE_HIGH_LIMIT, 12); component2HighFrame->AddFrame(component2HighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); component2HighLabel = new TGLabel(component2HighFrame, "Upper Bound for component 2 half-life?"); component2HighFrame->AddFrame(component2HighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group5->AddFrame(component2HighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); } } initialGuessNum = new TGNumberEntry(initialGuessFrame, INITIAL_GUESS, 12); initialGuessFrame->AddFrame(initialGuessNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); initialGuessLabel = new TGLabel(initialGuessFrame, "Guess for Initial Activity?"); initialGuessFrame->AddFrame(initialGuessLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group4->AddFrame(initialGuessFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); initialLowNum = new TGNumberEntry(initialLowFrame, INITIAL_LOW_LIMIT, 12); initialLowFrame->AddFrame(initialLowNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); initialLowLabel = new TGLabel(initialLowFrame, "Lower Bound for Initial Activity?"); initialLowFrame->AddFrame(initialLowLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group4->AddFrame(initialLowFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); initialHighNum = new TGNumberEntry(initialHighFrame, INITIAL_HIGH_LIMIT, 12); initialHighFrame->AddFrame(initialHighNum, new TGLayoutHints(kLHintsRight|kLHintsCenterY, 2,2,2,2)); initialHighLabel = new TGLabel(initialHighFrame, "Upper Bound for Initial Activity?"); initialHighFrame->AddFrame(initialHighLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2)); group4->AddFrame(initialHighFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); okay = new TGTextButton(buttonFrame, "&OK"); okay->Connect("Clicked()", "InputParameters", this, "DoOK()"); buttonFrame->AddFrame(okay, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); cancel = new TGTextButton(buttonFrame, "&Cancel"); cancel->Connect("Clicked()", "InputParameters", this, "DoCancel()"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsCenterX|kLHintsExpandX, 2,2,2,2)); fMain->AddFrame(buttonFrame, new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2,2,2,2)); fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); // position relative to the parent's window Window_t wdum; int ax, ay; gVirtualX->TranslateCoordinates(main->GetId(), fMain->GetParent()->GetId(), (Int_t)(((TGFrame *) main)->GetWidth() - fMain->GetWidth()) >> 1, (Int_t)(((TGFrame *) main)->GetHeight() - fMain->GetHeight()) >> 1, ax, ay, wdum); fMain->Move(ax, ay); fMain->SetWindowName("Parameter Entry"); fMain->MapWindow(); gClient->WaitFor(fMain); } // Order is important when deleting frames. Delete children first, // parents last. InputParameters::~InputParameters() { // Delete widgets created by dialog. delete okay; delete cancel; if (!TWOCOMP) { delete lifeGuessNum; delete lifeLowNum; delete lifeHighNum; delete lifeGuessLabel; delete lifeLowLabel; delete lifeHighLabel; delete lifeGuessFrame; delete lifeLowFrame; delete lifeHighFrame; } delete initialGuessNum; delete initialLowNum; delete initialHighNum; delete initialGuessLabel; delete initialLowLabel; delete initialHighLabel; delete initialGuessFrame; delete initialLowFrame; delete initialHighFrame; if (DAUGHTER_FREE) { delete daughterGuessNum; delete daughterLowNum; delete daughterHighNum; delete daughterGuessLabel; delete daughterLowLabel; delete daughterHighLabel; delete daughterGuessFrame; delete daughterLowFrame; delete daughterHighFrame; } if (LINEAR) { delete backLinGuessNum; delete backLinLowNum; delete backLinHighNum; delete backLinGuessLabel; delete backLinLowLabel; delete backLinHighLabel; delete backLinGuessFrame; delete backLinLowFrame; delete backLinHighFrame; } if (TWOCOMP && FRACTION_FREE) { delete fracGuessNum; delete fracLowNum; delete fracHighNum; delete fracGuessLabel; delete fracLowLabel; delete fracHighLabel; delete fracGuessFrame; delete fracLowFrame; delete fracHighFrame; } if (TWOCOMP && COMPONE_FREE) { delete lifeGuessNum; delete lifeLowNum; delete lifeHighNum; delete lifeGuessLabel; delete lifeLowLabel; delete lifeHighLabel; delete lifeGuessFrame; delete lifeLowFrame; delete lifeHighFrame; } if (TWOCOMP && COMPTWO_FREE) { delete component2GuessNum; delete component2LowNum; delete component2HighNum; // delete component2GuessLabel; // delete component2LowLabel; delete component2HighLabel; delete component2GuessFrame; delete component2LowFrame; delete component2HighFrame; } if (EXP) { if (EXPDECAY_FREE) { delete expDecayGuessNum; delete expDecayLowNum; delete expDecayHighNum; delete expDecayGuessLabel; delete expDecayLowLabel; delete expDecayHighLabel; delete expDecayGuessFrame; delete expDecayLowFrame; delete expDecayHighFrame; } delete expInitGuessNum; delete expInitLowNum; delete expInitHighNum; delete expInitGuessLabel; delete expInitLowLabel; delete expInitHighLabel; delete expInitGuessFrame; delete expInitLowFrame; delete expInitHighFrame; } delete buttonFrame; if (!TWOCOMP) { delete group1; } if (DAUGHTER_FREE) { delete group2; } if (LINEAR || EXP) { delete group3; } delete group4; if (TWOCOMP && (FRACTION_FREE || COMPONE_FREE || COMPTWO_FREE)) { delete group5; } delete fMain; } void InputParameters::CloseWindow() { // Close dialog in response to window manager close. delete this; } void InputParameters::DoCancel() { // Handle Close button. fMain->SendCloseMessage(); } void InputParameters::DoOK() { if (!TWOCOMP) { if (lifeGuessNum->GetNumber() != 0) { LIFE_GUESS = lifeGuessNum->GetNumber(); cout << "Guess for half-life is set to " << LIFE_GUESS << "." << endl; } else { LIFE_GUESS = 0; cout << "Guess for half-life is set to 0." << endl; } if (lifeLowNum->GetNumber() != 0) { LIFE_LOW_LIMIT = lifeLowNum->GetNumber(); cout << "The half-life lower bound is " << LIFE_LOW_LIMIT << "." << endl; } else { LIFE_LOW_LIMIT = 0; cout << "The half-life lower bound is 0." << endl; } if (lifeHighNum->GetNumber() != 0) { LIFE_HIGH_LIMIT = (lifeHighNum->GetNumber()); cout << "The half-life upper bound is " << LIFE_HIGH_LIMIT << "." << endl; } else { LIFE_HIGH_LIMIT = 0; cout << "The half-life upper bound is 0." << endl; } int retval; if (lifeLowNum->GetNumber() >= lifeHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper half-life bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((lifeGuessNum->GetNumber() < lifeLowNum->GetNumber()) || (lifeGuessNum->GetNumber() > lifeHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your half-life guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } } if (DAUGHTER_FREE){ if (daughterGuessNum->GetNumber() != 0) { DAUGHTER_GUESS = (daughterGuessNum->GetNumber()); cout << "Guess for daughter half-life is set to " << DAUGHTER_GUESS << "." << endl; } else { DAUGHTER_GUESS = 0; cout << "Guess for daughter half-life is set to 0." << endl; } if (daughterLowNum->GetNumber() != 0) { DAUGHTER_LOW_LIMIT = (daughterLowNum->GetNumber()); cout << "The daughter half-life lower bound is " << DAUGHTER_LOW_LIMIT << "." << endl; } else { DAUGHTER_LOW_LIMIT = 0; cout << "The daughter half-life lower bound is 0." << endl; } if (daughterHighNum->GetNumber() != 0) { DAUGHTER_HIGH_LIMIT = (daughterHighNum->GetNumber()); cout << "The daughter half-life upper bound is " << DAUGHTER_HIGH_LIMIT << "." << endl; } else { DAUGHTER_HIGH_LIMIT = 0; cout << "The daughter half-life upper bound is 0." << endl; } if (daughterLowNum->GetNumber() >= daughterHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper daughter half-life bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((daughterGuessNum->GetNumber() < daughterLowNum->GetNumber()) || (daughterGuessNum->GetNumber() > daughterHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your daughter half-life guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } } INITIAL_GUESS = initialGuessNum->GetNumber(); cout << "Guess for initial activity is set to " << INITIAL_GUESS << "." << endl; INITIAL_LOW_LIMIT = initialLowNum->GetNumber(); cout << "The initial activity lower bound is " << INITIAL_LOW_LIMIT << "." << endl; INITIAL_HIGH_LIMIT = initialHighNum->GetNumber(); cout << "The initial activity upper bound is " << INITIAL_HIGH_LIMIT << "." << endl; if (initialLowNum->GetNumber() >= initialHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper initial activity bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((initialGuessNum->GetNumber() < initialLowNum->GetNumber()) || (initialGuessNum->GetNumber() > initialHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your initial activity guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } if (LINEAR) { BACKLIN_GUESS = backLinGuessNum->GetNumber(); cout << "Guess for linear background is set to " << BACKLIN_GUESS << "." << endl; BACKLIN_LOW_LIMIT = backLinLowNum->GetNumber(); cout << "The linear background lower bound is " << BACKLIN_LOW_LIMIT << "." << endl; BACKLIN_HIGH_LIMIT = backLinHighNum->GetNumber(); cout << "The linear background upper bound is " << BACKLIN_HIGH_LIMIT << "." << endl; if (backLinLowNum->GetNumber() >= backLinHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper background (linear) bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((backLinGuessNum->GetNumber() < backLinLowNum->GetNumber()) || (backLinGuessNum->GetNumber() > backLinHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your background (linear) guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } cout << "" << endl; } if (TWOCOMP) { if (FRACTION_FREE) { COMPONENT2_FRACTION = fracGuessNum->GetNumber(); cout << "Guess for fraction of component 2 is set to " << COMPONENT2_FRACTION << "." << endl; COMPONENT2_FRACTION_LOW_LIMIT = fracLowNum->GetNumber(); cout << "The fraction of component 2 lower bound is " << COMPONENT2_FRACTION_LOW_LIMIT << "." << endl; COMPONENT2_FRACTION_HIGH_LIMIT = fracHighNum->GetNumber(); cout << "The fraction of component 2 upper bound is " << COMPONENT2_FRACTION_HIGH_LIMIT << "." << endl; if (fracLowNum->GetNumber() >= fracHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper fraction of component 2 bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((fracGuessNum->GetNumber() < fracLowNum->GetNumber()) || (fracGuessNum->GetNumber() > fracHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your fraction of component 2 guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if (fracHighNum->GetNumber() > 1) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "The upper limit on the fraction of component 2 cannot be higher than one. \n Please lower it.", kMBIconStop, kMBDismiss, &retval); goto end; } cout << "" << endl; } if (COMPONE_FREE) { if (lifeGuessNum->GetNumber() != 0) { LIFE_GUESS = lifeGuessNum->GetNumber(); cout << "Guess for component 1 half-life is set to " << LIFE_GUESS << "." << endl; } else { LIFE_GUESS = 0; cout << "Guess for component 1 half-life is set to 0." << endl; } if (lifeLowNum->GetNumber() != 0) { LIFE_LOW_LIMIT = lifeLowNum->GetNumber(); cout << "The component 1 half-life lower bound is " << LIFE_LOW_LIMIT << "." << endl; } else { LIFE_LOW_LIMIT = 0; cout << "The component 1 half-life lower bound is 0." << endl; } if (lifeHighNum->GetNumber() != 0) { LIFE_HIGH_LIMIT = (lifeHighNum->GetNumber()); cout << "The component 1 half-life upper bound is " << LIFE_HIGH_LIMIT << "." << endl; } else { LIFE_HIGH_LIMIT = 0; cout << "The component 1 half-life upper bound is 0." << endl; } int retval; if (lifeLowNum->GetNumber() >= lifeHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your component 1 upper half-life bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((lifeGuessNum->GetNumber() < lifeLowNum->GetNumber()) || (lifeGuessNum->GetNumber() > lifeHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your component 1 half-life guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } } if (COMPTWO_FREE) { if (component2GuessNum->GetNumber() != 0) { COMPONENT2_GUESS = component2GuessNum->GetNumber(); cout << "Guess for component 2 half-life is set to " << COMPONENT2_GUESS << "." << endl; } else { COMPONENT2_GUESS = 0; cout << "Guess for component 2 half-life is set to 0." << endl; } if (component2LowNum->GetNumber() != 0) { COMPONENT2_LOW_LIMIT = component2LowNum->GetNumber(); cout << "The component 2 half-life lower bound is " << COMPONENT2_LOW_LIMIT << "." << endl; } else { COMPONENT2_LOW_LIMIT = 0; cout << "The component 2 half-life lower bound is 0." << endl; } if (component2HighNum->GetNumber() != 0) { COMPONENT2_HIGH_LIMIT = (component2HighNum->GetNumber()); cout << "The component 2 half-life upper bound is " << COMPONENT2_HIGH_LIMIT << "." << endl; } else { COMPONENT2_HIGH_LIMIT = 0; cout << "The component 2 half-life upper bound is 0." << endl; } int retval; if (component2LowNum->GetNumber() >= component2HighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your component 2 upper half-life bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((component2GuessNum->GetNumber() < component2LowNum->GetNumber()) || (component2GuessNum->GetNumber() > component2HighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your component 2 half-life guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } } } if (EXP) { if (EXPDECAY_FREE) { EXPDECAY_GUESS = expDecayGuessNum->GetNumber(); cout << "Guess for exponential background decay constant is set to " << EXPDECAY_GUESS << "." << endl; EXPDECAY_LOW_LIMIT = expDecayLowNum->GetNumber(); cout << "The exponential background decay constant lower bound is " << EXPDECAY_LOW_LIMIT << "." << endl; EXPDECAY_HIGH_LIMIT = expDecayHighNum->GetNumber(); cout << "The exponential background decay constant upper bound is " << EXPDECAY_HIGH_LIMIT << "." << endl; if (expDecayLowNum->GetNumber() >= expDecayHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper background decay constant (exp) bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((expDecayGuessNum->GetNumber() < expDecayLowNum->GetNumber()) || (expDecayGuessNum->GetNumber() > expDecayHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your background decay constant (exp) guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } cout << "" << endl; } EXPINIT_GUESS = expInitGuessNum->GetNumber(); cout << "Guess for exponential background initial value is set to " << EXPINIT_GUESS << "." << endl; EXPINIT_LOW_LIMIT = expInitLowNum->GetNumber(); cout << "Guess for exponential background initial value lower bound is " << EXPINIT_LOW_LIMIT << "." << endl; EXPINIT_HIGH_LIMIT = expInitHighNum->GetNumber(); cout << "Guess for exponential background initial value upper bound is " << EXPINIT_HIGH_LIMIT << "." << endl; if (expInitLowNum->GetNumber() >= expInitHighNum->GetNumber()) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your upper background (exp) initial value bound is below your lower bound.\n This doesn't make any sense.\n Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } else if ((expInitGuessNum->GetNumber() < expInitLowNum->GetNumber()) || (expInitGuessNum->GetNumber() > expInitHighNum->GetNumber())) { new TGMsgBox(gClient->GetRoot(), fMain, "Something is weird...", "Your background (exp) initial value guess is out of the limits you set.\n That's silly. Please fix this.", kMBIconStop, kMBDismiss, &retval); goto end; } cout << "" << endl; } fMain->SendCloseMessage(); end: }
6e2987f223c2edf95aa714a49fd4cd035fcf8e4b
441bcc13269b28abf5f6b6f3b917eac4ed70b39d
/src/ui/private/windows/ButtonPrivate.h
6e2c7a07177ad089ef88b3cc37528426410e7418
[]
no_license
raynardbrown/ui
ce3254206ebc4ceaddfc2683e490f8c1447581eb
0217df1a0947d922661e13f56c1da3f0763dc160
refs/heads/master
2020-09-21T22:59:52.826466
2020-06-16T04:50:30
2020-06-16T04:50:30
224,963,943
0
0
null
null
null
null
UTF-8
C++
false
false
731
h
ButtonPrivate.h
//////////////////////////////////////////////////////////////////////////////// // // File: ButtonPrivate.h // // Author: Raynard Brown // // Copyright (c) 2019 Raynard Brown // // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// #ifndef UI_PRIVATE_WINDOWS_BUTTONPRIVATE_H_ #define UI_PRIVATE_WINDOWS_BUTTONPRIVATE_H_ #include <windows.h> #include <string> #include "ui/private/UiComponentPrivate.h" class ButtonPrivate : public UiComponentPrivate { public: ButtonPrivate(const std::string& text); virtual ~ButtonPrivate(); std::string buttonText; DWORD style; }; #endif /* UI_PRIVATE_WINDOWS_BUTTONPRIVATE_H_ */
e31f5088208965914c8a8f7114aa43138ea105e6
39100b66c5359c5fa7ce2dc3e0bba754f70d73f7
/Hugo/Ex ListasInventario/FilaPessoas.h
fa6c20d1b587e745bbceacc9e64385d61cc61435
[]
no_license
raphaellc/AlgEDCPP
74db9cf0b2a27239c7b44b585e436637aa522151
f37fca39d16aa8b11572603ba173e7bc2e0e870a
refs/heads/master
2020-03-25T21:11:30.969638
2018-11-29T14:24:06
2018-11-29T14:24:06
144,163,894
0
0
null
2018-12-11T22:08:25
2018-08-09T14:28:14
C++
UTF-8
C++
false
false
275
h
FilaPessoas.h
#pragma once #include "Lista.h" #include <iostream> using namespace std; class FilaPessoas : public Lista<Pessoa> { public: FilaPessoas(); ~FilaPessoas(); void enfileirar(Pessoa * p); void desenfileirar(); void percorrerFila(No<Pessoa> * lista); };
78400e3067b4907146ffa77eeb1b2072da2f9497
156884c5005fc0be626159030f41319ee801bc8b
/Source/Renderer/Passes/PostProcess/Bloom/BloomPass.cpp
e8c0f0f278df30aeac670f7dd0f998bc7a8375c8
[ "MIT" ]
permissive
aaronmjacobs/Forge
1ddd0c9f088b728dea3316d5c64b2c0184d3d438
d9c4b0282926b77edb0633489b9b12a10351c1a1
refs/heads/master
2023-08-03T12:33:32.246365
2023-07-21T01:06:54
2023-07-21T01:06:54
236,388,385
1
0
null
null
null
null
UTF-8
C++
false
false
16,654
cpp
BloomPass.cpp
#include "Renderer/Passes/PostProcess/Bloom/BloomPass.h" #include "Core/Assert.h" #include "Core/Enum.h" #include "Graphics/DebugUtils.h" #include "Graphics/Pipeline.h" #include "Graphics/Swapchain.h" #include "Graphics/Texture.h" #include "Renderer/Passes/PostProcess/Bloom/BloomDownsampleShader.h" #include "Renderer/Passes/PostProcess/Bloom/BloomUpsampleShader.h" #include <string> #include <utility> namespace { std::unique_ptr<Texture> createBloomTexture(const GraphicsContext& context, vk::Format format, vk::SampleCountFlagBits sampleCount, uint32_t downscalingFactor) { ASSERT(downscalingFactor > 0); const Swapchain& swapchain = context.getSwapchain(); ImageProperties imageProperties; imageProperties.format = format; imageProperties.width = swapchain.getExtent().width / downscalingFactor; imageProperties.height = swapchain.getExtent().height / downscalingFactor; TextureProperties textureProperties; textureProperties.sampleCount = sampleCount; textureProperties.usage = vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eSampled; textureProperties.aspects = vk::ImageAspectFlagBits::eColor; TextureInitialLayout initialLayout; initialLayout.layout = vk::ImageLayout::eColorAttachmentOptimal; initialLayout.memoryBarrierFlags = TextureMemoryBarrierFlags(vk::AccessFlagBits::eColorAttachmentWrite, vk::PipelineStageFlagBits::eColorAttachmentOutput); return std::make_unique<Texture>(context, imageProperties, textureProperties, initialLayout); } RenderQuality getDownsampleStepQuality(RenderQuality overallQuality, uint32_t step) { switch (overallQuality) { case RenderQuality::Disabled: return RenderQuality::Disabled; case RenderQuality::Low: // Low quality for the higher resolutions, medium quality for the lower resolutions return step <= BloomPass::kNumSteps / 2 ? RenderQuality::Low : RenderQuality::Medium; case RenderQuality::Medium: // Low quality for the highest resolution, medium quality for the rest return step == 0 ? RenderQuality::Low : RenderQuality::Medium; case RenderQuality::High: // Medium quality for the highest resolution, high quality for the rest return step == 0 ? RenderQuality::Medium : RenderQuality::High; default: ASSERT(false); return RenderQuality::Disabled; } } RenderQuality getUpsampleStepQuality(RenderQuality overallQuality, uint32_t step) { switch (overallQuality) { case RenderQuality::Disabled: return RenderQuality::Disabled; case RenderQuality::Low: // Low quality for the higher resolutions, medium quality for the lower resolutions return step <= BloomPass::kNumSteps / 2 ? RenderQuality::Low : RenderQuality::Medium; case RenderQuality::Medium: // Medium quality for the higher resolutions, high quality for the lower resolutions return step <= BloomPass::kNumSteps / 2 ? RenderQuality::Medium : RenderQuality::High; case RenderQuality::High: // Always high quality return RenderQuality::High; default: ASSERT(false); return RenderQuality::Disabled; } } #if FORGE_WITH_DEBUG_UTILS std::string getTextureResolutionString(const Texture& texture) { const ImageProperties& imageProperties = texture.getImageProperties(); return DebugUtils::toString(imageProperties.width) + "x" + DebugUtils::toString(imageProperties.height); } const char* getBloomPassTypeString(BloomPassType type) { switch (type) { case BloomPassType::Downsample: return "Downsample"; case BloomPassType::HorizontalUpsample: return "Horizontal Upsample"; case BloomPassType::VerticalUpsample: return "Vertical Upsample"; default: ASSERT(false); return nullptr; } } #endif // FORGE_WITH_DEBUG_UTILS } BloomPass::BloomPass(const GraphicsContext& graphicsContext, DynamicDescriptorPool& dynamicDescriptorPool, ResourceManager& resourceManager) : SceneRenderPass(graphicsContext) , downsampleShader(std::make_unique<BloomDownsampleShader>(context, resourceManager)) , upsampleShader(std::make_unique<BloomUpsampleShader>(context, resourceManager)) { downsampleDescriptorSets.reserve(kNumSteps); horizontalUpsampleDescriptorSets.reserve(kNumSteps); verticalUpsampleDescriptorSets.reserve(kNumSteps); upsampleUniformBuffers.reserve(kNumSteps); for (uint32_t i = 0; i < kNumSteps; ++i) { downsampleDescriptorSets.emplace_back(context, dynamicDescriptorPool, BloomDownsampleShader::getLayoutCreateInfo()); horizontalUpsampleDescriptorSets.emplace_back(context, dynamicDescriptorPool, BloomUpsampleShader::getLayoutCreateInfo()); verticalUpsampleDescriptorSets.emplace_back(context, dynamicDescriptorPool, BloomUpsampleShader::getLayoutCreateInfo()); upsampleUniformBuffers.emplace_back(context); NAME_CHILD(downsampleDescriptorSets.back(), "Downsample Step " + DebugUtils::toString(i)); NAME_CHILD(horizontalUpsampleDescriptorSets.back(), "Horizontal Upsample Step " + DebugUtils::toString(i)); NAME_CHILD(verticalUpsampleDescriptorSets.back(), "Vertical Upsample Step " + DebugUtils::toString(i)); NAME_CHILD(upsampleUniformBuffers.back(), "Step " + DebugUtils::toString(i)); for (uint32_t frameIndex = 0; frameIndex < GraphicsContext::kMaxFramesInFlight; ++frameIndex) { vk::DescriptorBufferInfo bufferInfo = upsampleUniformBuffers[i].getDescriptorBufferInfo(frameIndex); vk::WriteDescriptorSet horizontalBufferDescriptorWrite = vk::WriteDescriptorSet() .setDstSet(horizontalUpsampleDescriptorSets[i].getSet(frameIndex)) .setDstBinding(2) .setDstArrayElement(0) .setDescriptorType(vk::DescriptorType::eUniformBuffer) .setDescriptorCount(1) .setPBufferInfo(&bufferInfo); vk::WriteDescriptorSet verticalBufferDescriptorWrite = vk::WriteDescriptorSet() .setDstSet(verticalUpsampleDescriptorSets[i].getSet(frameIndex)) .setDstBinding(2) .setDstArrayElement(0) .setDescriptorType(vk::DescriptorType::eUniformBuffer) .setDescriptorCount(1) .setPBufferInfo(&bufferInfo); device.updateDescriptorSets({ horizontalBufferDescriptorWrite, verticalBufferDescriptorWrite }, {}); } } std::vector<vk::DescriptorSetLayout> downsampleDescriptorSetLayouts = downsampleShader->getSetLayouts(); vk::PipelineLayoutCreateInfo downsamplePipelineLayoutCreateInfo = vk::PipelineLayoutCreateInfo() .setSetLayouts(downsampleDescriptorSetLayouts); downsamplePipelineLayout = device.createPipelineLayout(downsamplePipelineLayoutCreateInfo); NAME_CHILD(downsamplePipelineLayout, "Downsample Pipeline Layout"); std::vector<vk::DescriptorSetLayout> upsampleDescriptorSetLayouts = upsampleShader->getSetLayouts(); vk::PipelineLayoutCreateInfo upsamplePipelineLayoutCreateInfo = vk::PipelineLayoutCreateInfo() .setSetLayouts(upsampleDescriptorSetLayouts); upsamplePipelineLayout = device.createPipelineLayout(upsamplePipelineLayoutCreateInfo); NAME_CHILD(upsamplePipelineLayout, "Upsample Pipeline Layout"); vk::SamplerCreateInfo samplerCreateInfo = vk::SamplerCreateInfo() .setMagFilter(vk::Filter::eLinear) .setMinFilter(vk::Filter::eLinear) .setAddressModeU(vk::SamplerAddressMode::eClampToEdge) .setAddressModeV(vk::SamplerAddressMode::eClampToEdge) .setAddressModeW(vk::SamplerAddressMode::eClampToEdge) .setBorderColor(vk::BorderColor::eIntOpaqueBlack) .setAnisotropyEnable(false) .setMaxAnisotropy(1.0f) .setUnnormalizedCoordinates(false) .setCompareEnable(false) .setCompareOp(vk::CompareOp::eAlways) .setMipmapMode(vk::SamplerMipmapMode::eNearest) .setMipLodBias(0.0f) .setMinLod(0.0f) .setMaxLod(16.0f); sampler = context.getDevice().createSampler(samplerCreateInfo); NAME_CHILD(sampler, "Sampler"); } BloomPass::~BloomPass() { destroyTextures(); context.delayedDestroy(std::move(sampler)); context.delayedDestroy(std::move(downsamplePipelineLayout)); context.delayedDestroy(std::move(upsamplePipelineLayout)); downsampleShader.reset(); upsampleShader.reset(); } void BloomPass::render(vk::CommandBuffer commandBuffer, Texture& hdrColorTexture, Texture& defaultBlackTexture, RenderQuality quality) { ASSERT(hdrColorTexture.getExtent() == context.getSwapchain().getExtent()); SCOPED_LABEL(getName()); { SCOPED_LABEL("Downsample"); for (uint32_t step = 0; step < kNumSteps; ++step) { renderDownsample(commandBuffer, step, hdrColorTexture, quality); } } { SCOPED_LABEL("Upsample"); for (uint32_t step = kNumSteps; step > 0; --step) { renderUpsample(commandBuffer, step - 1, defaultBlackTexture, quality, true); renderUpsample(commandBuffer, step - 1, defaultBlackTexture, quality, false); } } } void BloomPass::recreateTextures(vk::Format format, vk::SampleCountFlagBits sampleCount) { destroyTextures(); createTextures(format, sampleCount); } Pipeline BloomPass::createPipeline(const PipelineDescription<BloomPass>& description, const AttachmentFormats& attachmentFormats) { vk::PipelineColorBlendAttachmentState attachmentState = vk::PipelineColorBlendAttachmentState() .setColorWriteMask(vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA) .setBlendEnable(false); PipelineInfo pipelineInfo; pipelineInfo.passType = PipelinePassType::Screen; PipelineData pipelineData(attachmentFormats); pipelineData.layout = description.type == BloomPassType::Downsample ? downsamplePipelineLayout : upsamplePipelineLayout; pipelineData.shaderStages = description.type == BloomPassType::Downsample ? downsampleShader->getStages(description.quality) : upsampleShader->getStages(description.quality, description.type == BloomPassType::HorizontalUpsample); pipelineData.colorBlendStates = { attachmentState }; Pipeline pipeline(context, pipelineInfo, pipelineData); NAME_CHILD(pipeline, getBloomPassTypeString(description.type)); return pipeline; } void BloomPass::renderDownsample(vk::CommandBuffer commandBuffer, uint32_t step, Texture& hdrColorTexture, RenderQuality quality) { ASSERT(step < kNumSteps); Texture& inputTexture = step == 0 ? hdrColorTexture : *textures[step - 1]; Texture& outputTexture = *textures[step]; const DescriptorSet& descriptorSet = downsampleDescriptorSets[step]; RenderQuality stepQuality = getDownsampleStepQuality(quality, step); SCOPED_LABEL(getTextureResolutionString(inputTexture) + " --> " + getTextureResolutionString(outputTexture) + " (" + RenderSettings::getQualityString(stepQuality) + ")"); inputTexture.transitionLayout(commandBuffer, TextureLayoutType::ShaderRead); outputTexture.transitionLayout(commandBuffer, TextureLayoutType::AttachmentWrite); AttachmentInfo colorAttachmentInfo = AttachmentInfo(outputTexture) .setLoadOp(vk::AttachmentLoadOp::eDontCare); executePass(commandBuffer, &colorAttachmentInfo, nullptr, [this, &inputTexture, &descriptorSet, stepQuality](vk::CommandBuffer commandBuffer) { vk::DescriptorImageInfo imageInfo = vk::DescriptorImageInfo() .setImageLayout(inputTexture.getLayout()) .setImageView(inputTexture.getDefaultView()) .setSampler(sampler); vk::WriteDescriptorSet descriptorWrite = vk::WriteDescriptorSet() .setDstSet(descriptorSet.getCurrentSet()) .setDstBinding(0) .setDstArrayElement(0) .setDescriptorType(vk::DescriptorType::eCombinedImageSampler) .setDescriptorCount(1) .setPImageInfo(&imageInfo); device.updateDescriptorSets(descriptorWrite, {}); PipelineDescription<BloomPass> pipelineDescription; pipelineDescription.type = BloomPassType::Downsample; pipelineDescription.quality = stepQuality; downsampleShader->bindDescriptorSets(commandBuffer, downsamplePipelineLayout, descriptorSet); renderScreenMesh(commandBuffer, getPipeline(pipelineDescription)); }); } void BloomPass::renderUpsample(vk::CommandBuffer commandBuffer, uint32_t step, Texture& defaultBlackTexture, RenderQuality quality, bool horizontal) { ASSERT(step < kNumSteps); Texture& inputTexture = horizontal ? *textures[step] : *horizontalBlurTextures[step]; Texture& blendTexture = step == kNumSteps - 1 ? defaultBlackTexture : *textures[step + 1]; Texture& outputTexture = horizontal ? *horizontalBlurTextures[step] : *textures[step]; const DescriptorSet& descriptorSet = horizontal ? horizontalUpsampleDescriptorSets[step] : verticalUpsampleDescriptorSets[step]; UniformBuffer<BloomUpsampleUniformData>& uniformBuffer = upsampleUniformBuffers[step]; RenderQuality stepQuality = getUpsampleStepQuality(quality, step); SCOPED_LABEL(getTextureResolutionString(outputTexture) + (horizontal ? " Horizontal" : " Vertical") + (horizontal || step == kNumSteps - 1 ? "" : " + " + getTextureResolutionString(blendTexture)) + " (" + RenderSettings::getQualityString(stepQuality) + ")"); BloomUpsampleUniformData uniformData; uniformData.filterRadius = 1.0f + step * 0.35f; uniformData.colorMix = step == kNumSteps - 1 ? 0.0f : 0.5f; uniformBuffer.update(uniformData); inputTexture.transitionLayout(commandBuffer, TextureLayoutType::ShaderRead); blendTexture.transitionLayout(commandBuffer, TextureLayoutType::ShaderRead); outputTexture.transitionLayout(commandBuffer, TextureLayoutType::AttachmentWrite); AttachmentInfo colorAttachmentInfo = AttachmentInfo(outputTexture) .setLoadOp(vk::AttachmentLoadOp::eDontCare); executePass(commandBuffer, &colorAttachmentInfo, nullptr, [this, horizontal, &inputTexture, &blendTexture, &descriptorSet, stepQuality](vk::CommandBuffer commandBuffer) { vk::DescriptorImageInfo inputImageInfo = vk::DescriptorImageInfo() .setImageLayout(inputTexture.getLayout()) .setImageView(inputTexture.getDefaultView()) .setSampler(sampler); vk::DescriptorImageInfo blendImageInfo = vk::DescriptorImageInfo() .setImageLayout(blendTexture.getLayout()) .setImageView(blendTexture.getDefaultView()) .setSampler(sampler); vk::WriteDescriptorSet inputDescriptorWrite = vk::WriteDescriptorSet() .setDstSet(descriptorSet.getCurrentSet()) .setDstBinding(0) .setDstArrayElement(0) .setDescriptorType(vk::DescriptorType::eCombinedImageSampler) .setDescriptorCount(1) .setPImageInfo(&inputImageInfo); vk::WriteDescriptorSet blendDescriptorWrite = vk::WriteDescriptorSet() .setDstSet(descriptorSet.getCurrentSet()) .setDstBinding(1) .setDstArrayElement(0) .setDescriptorType(vk::DescriptorType::eCombinedImageSampler) .setDescriptorCount(1) .setPImageInfo(&blendImageInfo); device.updateDescriptorSets({ inputDescriptorWrite, blendDescriptorWrite }, {}); PipelineDescription<BloomPass> pipelineDescription; pipelineDescription.type = horizontal ? BloomPassType::HorizontalUpsample : BloomPassType::VerticalUpsample; pipelineDescription.quality = stepQuality; upsampleShader->bindDescriptorSets(commandBuffer, upsamplePipelineLayout, descriptorSet); renderScreenMesh(commandBuffer, getPipeline(pipelineDescription)); }); } void BloomPass::createTextures(vk::Format format, vk::SampleCountFlagBits sampleCount) { for (uint32_t i = 0; i < kNumSteps; ++i) { ASSERT(!textures[i]); ASSERT(!horizontalBlurTextures[i]); textures[i] = createBloomTexture(context, format, sampleCount, 1 << (i + 1)); horizontalBlurTextures[i] = createBloomTexture(context, format, sampleCount, 1 << (i + 1)); NAME_CHILD_POINTER(textures[i], "Texture " + DebugUtils::toString(i)); NAME_CHILD_POINTER(horizontalBlurTextures[i], "Horizontal Blur Texture " + DebugUtils::toString(i)); } } void BloomPass::destroyTextures() { for (std::unique_ptr<Texture>& texture : textures) { texture.reset(); } for (std::unique_ptr<Texture>& horizontalBlurTexture : horizontalBlurTextures) { horizontalBlurTexture.reset(); } }
b51e1e4e41b756fbaf7e2a107d364a7f24377b28
1c390cd4fd3605046914767485b49a929198b470
/luogu/P1892.cpp
63747d9de7e9437e5eee7869d35ee03dd9977ef7
[]
no_license
wwwwodddd/Zukunft
f87fe736b53506f69ab18db674311dd60de04a43
03ffffee9a76e99f6e00bba6dbae91abc6994a34
refs/heads/master
2023-01-24T06:14:35.691292
2023-01-21T15:42:32
2023-01-21T15:42:32
163,685,977
7
8
null
null
null
null
UTF-8
C++
false
false
581
cpp
P1892.cpp
#include <bits/stdc++.h> using namespace std; int f[1020]; int e[1020]; int n, m, x, y, z; char o; int F(int x) { return f[x] != x ? f[x] = F(f[x]) : x; } void U(int x, int y) { x = F(x); y = F(y); if (x != y) { z--; f[x] = y; } } int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { f[i] = i; } z = n; for (int i = 0; i < m; i++) { cin >> o >> x >> y; if (o == 'F') { U(x, y); } else { if (e[x]) { U(e[x], y); } else { e[x] = y; } if (e[y]) { U(e[y], x); } else { e[y] = x; } } } printf("%d\n", z); return 0; }
2595aa17673a0fc6002fba0191a9faca69394b68
fd3f9ef20ad11c4fff7061988c6093ae5c11f820
/GUI/gui.cpp
c80f364c8b365427126aa0a30d7f46ccd48525ba
[]
no_license
maielln/CS-370-Spring2018
547e4ef41e6fb7f5199899a18e5c135ff2e376d3
3caeda2386a5b46df572ccd3ad282eeff6966835
refs/heads/master
2021-09-27T13:06:58.918881
2018-11-08T18:05:36
2018-11-08T18:05:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,949
cpp
gui.cpp
#include <SDL.h> #include <SDL_image.h> #include <stdio.h> #include <string> #include <iostream> #include <SDL_mixer.h> #include "helloworld.cpp" #include "fOpen.cpp" #include "fOpen.h" #include <SDL_ttf.h> #include <vector> #include <windows.h> #include <sstream> #include <ctime> /* Written by Eric McLean and Tyler Corey Written in C++ (GNU GCC) Last updated 3/18/2018 Desc: This program initializes SDL libraries, snipes sprites to create buttons, then formats the images to the gui onscreen. The gui then produces another window upon clicking a button, and plays a sound effect. 4/15/2018 -- fix that goddamn while loop 4/17/2018 */ using namespace std; //sets screen dimensions const int SCREEN_WIDTH = 800; const int SCREEN_HEIGHT = 600; //set button dimensions and number of buttons const int BUTTON_WIDTH = 200; const int BUTTON_HEIGHT = 100; const int TOTAL_BUTTONS = 2; //basic functions that start, load, and run SDL bool init(); bool loadMedia(); void closeAll(); void launch(); void closeMenu(); string disect(string); void createRenderer(); void selectScreen(); void displayText(int); //the name of the window we create SDL_Window* gWindow = NULL; SDL_Window* nWindow = NULL; // the selector window SDL_Window* aWindow = NULL; // arena window //the "screen" created by the window SDL_Surface* gWindowSurface = NULL; SDL_Surface* nWindowSurface = NULL; SDL_Surface* aWindowSurface = NULL; //arena surface //our images SDL_Surface* titleScreen = NULL; SDL_Surface* playButton = NULL; SDL_Surface* exitButton = NULL; SDL_Surface* playButtonClick = NULL; SDL_Surface* exitButtonClick = NULL; //on click default = 0, click = 1 //button arrays SDL_Rect buttonParams [TOTAL_BUTTONS]; SDL_Rect buttonPos [TOTAL_BUTTONS]; // 0: play // 1: exit //mouse handler SDL_Point MPos[TOTAL_BUTTONS]; // 0: play // 1: exit //sound effect Mix_Chunk *onClick = NULL; //text SDL_Color textColor = {255, 255, 255, 255}; SDL_Surface *message = NULL; SDL_Renderer *renderer; SDL_Texture *SurfaceToTexture( SDL_Surface* surf ); SDL_Texture *messageTexture = NULL; SDL_Rect textRect; TTF_Font* font = TTF_OpenFont("arial.ttf", 25); //selector SDL stuff const int TOTAL_R_BUTTONS = 6; SDL_Surface* selectRButton [TOTAL_R_BUTTONS]; SDL_Surface* selectRButtonClick [TOTAL_R_BUTTONS]; SDL_Surface* selectBG = NULL; SDL_Rect rButtonParam[TOTAL_R_BUTTONS]; SDL_Rect rCButtonParam[TOTAL_R_BUTTONS]; SDL_Rect rButtonPos[TOTAL_R_BUTTONS]; SDL_Event* S[TOTAL_R_BUTTONS]; //mouse handler for the select screen SDL_Point SPos[TOTAL_R_BUTTONS]; //arena stuff const int MAX_ROBOTS = 2; SDL_Rect robPos [2]; SDL_Rect arenaPos; const int rob1 = 0; //becky const int rob2 = 1; //steve SDL_Surface* arena = NULL; SDL_Surface* robot1 = NULL; SDL_Surface* robot2 = NULL; void closeSelect(); void loadArena(); bool init() { /* Desc: This fucntion initializes the SDL Libraries used in this program, as well as creating the window and surface we will use. Our audio is also initalized. */ bool success = true; //initalize audio and vid if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) { printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); success = false; } else { //Create window gWindow = SDL_CreateWindow( "ATRobots: Revised", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); if( gWindow == NULL ) { printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() ); success = false; } else { //Get window surface gWindowSurface = SDL_GetWindowSurface( gWindow ); } } //freq, format, channels, sample size if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 ) { printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() ); success = false; } //turn on text if (TTF_Init() == -1) { cout << "ttf init error: " << TTF_GetError(); } return success; } bool loadMedia() { /* Desc: This fucntion loads in the files needed to format the screen and sound effects. The buttons are clipped from a sprite sheet. The audio is loaded. */ int xMax, yMax, xMin, yMin, xRange, yRange; bool success = true; //title image loaded titleScreen = SDL_LoadBMP("mainmenu.bmp"); if (titleScreen == NULL) { printf("Title Image could not be loaded"); success = false; } //set buttons playButton = SDL_LoadBMP("play.bmp"); if (playButton == NULL) { printf("Play image could not be loaded"); success = false; } playButtonClick = SDL_LoadBMP("playClick.bmp"); if (playButtonClick == NULL) { printf("play click could not be loaded"); success = false; } exitButton = SDL_LoadBMP("exit.bmp"); if (exitButton == NULL) { printf("exit image could not be loaded"); success = false; } exitButtonClick = SDL_LoadBMP("exitClick.bmp"); if (exitButtonClick == NULL) { printf("exit image click could not be loaded"); success = false; } //set param and pos for each button //0: play //1: exit //2: play click //3: exit click for (int cnt = 0; cnt < TOTAL_BUTTONS; cnt++) { buttonParams[cnt].w = BUTTON_WIDTH; buttonParams[cnt].h = BUTTON_HEIGHT; buttonPos[cnt].x = 300; buttonPos[cnt].y = 300; if (cnt > 0) { buttonPos[cnt].y = buttonPos[cnt-1].y + 100; } } //load images for the select screen selectRButton[0] = SDL_LoadBMP("r0.bmp"); if (exitButtonClick == NULL) { printf("r 0 could not be loaded "); success = false; } selectRButton[1] = SDL_LoadBMP("r1.bmp"); if (exitButtonClick == NULL) { printf("r 1 could not be loaded "); success = false; } for (int cnt = 0; cnt < TOTAL_R_BUTTONS; cnt++) { rButtonParam[cnt].w = 75; rButtonParam[cnt].h = 75; rButtonPos[cnt].x = 100; rButtonPos[cnt].y = 100; if (cnt > 0) { if (cnt > 0) { rButtonPos[cnt].y = rButtonPos[cnt-1].y + 100; if (cnt > 4) { rButtonPos[cnt].x = rButtonPos[cnt-1].x + 200; } } } } selectRButtonClick[0] = SDL_LoadBMP("r0click.bmp"); if (exitButtonClick == NULL) { printf("r 0 click could not be loaded "); success = false; } selectRButtonClick[1] = SDL_LoadBMP("r1click.bmp"); if (exitButtonClick == NULL) { printf("r 1 click could not be loaded "); success = false; } for (int cnt = 0; cnt < TOTAL_R_BUTTONS; cnt++) { rCButtonParam[cnt].w = 75; rCButtonParam[cnt].h = 75; rButtonPos[cnt].x = 100; rButtonPos[cnt].y = 100; if (cnt > 0) { rButtonPos[cnt].y = rButtonPos[cnt-1].y + 100; if (cnt > 4) { rButtonPos[cnt].x = rButtonPos[cnt-1].x + 200; } } } //load select screen background selectBG = SDL_LoadBMP("selectBG.bmp"); if (selectBG == NULL) { printf("Select bg not loaded"); success = false; } arena = SDL_LoadBMP("arena.bmp"); if (arena == NULL) { printf("arena Image could not be loaded"); success = false; } //set buttons robot1 = SDL_LoadBMP("becky.bmp"); if (robot1 == NULL) { printf("Play image could not be loaded"); success = false; } robot2 = SDL_LoadBMP("steve.bmp"); if (robot2 == NULL) { printf("play click could not be loaded"); success = false; } arenaPos.x = 50; arenaPos.y = 50; xMin = 50; yMin = 50; xMax = 600; yMax = 550; xRange = xMax - xMin; yRange = yMax - yMin; //RNG for robots //position has to be within arena //pos cannot be == int pos = 5; srand (time(NULL)); for (int cnt = 0; cnt < 2; cnt++) { pos = xMin + (int)(xRange * rand()) / ((RAND_MAX + 1.0)); cout << pos << endl; robPos[cnt].x = pos; pos = yMin + (int)(yRange * rand()) / ((RAND_MAX + 1.0)); cout << pos << endl;; robPos[cnt].y = pos; } //load audio onClick = Mix_LoadWAV("ring.wav"); if (onClick == NULL) { printf( "Failed to load scratch sound effect! SDL_mixer Error: %s\n", Mix_GetError() ); success = false; } return success; } void closeAll(){ /* Desc: This fucntion frees all the resources brought in by the GUI. This also closes the window currently in use. */ //Deallocate surface SDL_FreeSurface(titleScreen); SDL_FreeSurface(playButton); SDL_FreeSurface(exitButton); SDL_FreeSurface(playButtonClick); SDL_FreeSurface(exitButtonClick); titleScreen = NULL; playButton = NULL; exitButton = NULL; playButtonClick = NULL; exitButtonClick = NULL; //free music Mix_FreeChunk (onClick); onClick = NULL; //Destroy window SDL_DestroyWindow( gWindow ); gWindow = NULL; SDL_DestroyWindow( nWindow ); nWindow = NULL; //Quit SDL subsystems Mix_Quit(); SDL_Quit(); } bool mouseHandle (SDL_Event* M) { /* Desc: this fucntion handles the position and actions of the mouse. The mouse is located, and on click a new button is shown to create a "flash" effect. A sound effect is also played. */ bool quitter = false; MPos[0].x = buttonPos[0].x; MPos[0].y = buttonPos[0].y; MPos[1].x = buttonPos[1].x; MPos[1].y = buttonPos[1].y; //play button if( M->type == SDL_MOUSEMOTION || M->type == SDL_MOUSEBUTTONDOWN || M->type == SDL_MOUSEBUTTONUP ) { //Get mouse position int x, y; SDL_GetMouseState( &x, &y ); bool inside = true; //left if (x < MPos[0].x) { inside = false; //printf("left"); } if (x > MPos[0].x + BUTTON_WIDTH) { inside = false; //printf("right"); } if (y < MPos[0].y) { inside = false; //printf("above"); } if (y > MPos[0].y + BUTTON_HEIGHT) { inside = false; //printf("below"); } if (inside) { switch (M->type) { case SDL_MOUSEBUTTONDOWN: Mix_PlayChannel(-1, onClick, 0); SDL_BlitSurface(playButtonClick, &buttonParams[0], gWindowSurface, &buttonPos[0]); launch(); break; case SDL_MOUSEBUTTONUP: SDL_BlitSurface(playButton, &buttonParams[0], gWindowSurface, &buttonPos[0]); break; } } } //exit button if( M->type == SDL_MOUSEMOTION || M->type == SDL_MOUSEBUTTONDOWN || M->type == SDL_MOUSEBUTTONUP ) { //Get mouse position int x, y; SDL_GetMouseState( &x, &y ); bool inside = true; //left if (x < MPos[1].x) { inside = false; } if (x > MPos[1].x + BUTTON_WIDTH) { inside = false; } if (y < MPos[1].y) { inside = false; } if (y > MPos[1].y + BUTTON_HEIGHT) { inside = false; } if (inside) { switch (M->type) { case SDL_MOUSEBUTTONDOWN: SDL_BlitSurface(exitButtonClick, &buttonParams[1], gWindowSurface, &buttonPos[1]); Mix_PlayChannel(-1, onClick, 0); break; case SDL_MOUSEBUTTONUP: SDL_BlitSurface(exitButton, &buttonParams[1], gWindowSurface, &buttonPos[1]); quitter = true; break; } } } return quitter; } bool mouseHandleS(SDL_Event* S) { /* Desc: this fucntion handles the position and actions of the mouse. The mouse is located, and on click a new button is shown to create a "flash" effect. A sound effect is also played. */ bool quitter = false; //don't really know why i had to do this, but it's leftover from the gui for (int cnt = 0; cnt < TOTAL_R_BUTTONS; cnt++) { SPos[cnt].x = rButtonPos[cnt].x; SPos[cnt].y = rButtonPos[cnt].y; } //r1 button if( S->type == SDL_MOUSEMOTION || S->type == SDL_MOUSEBUTTONDOWN || S->type == SDL_MOUSEBUTTONUP ) { //Get mouse position int x, y; SDL_GetMouseState( &x, &y ); bool inside = true; //left if (x < SPos[0].x) { inside = false; //printf("left"); } if (x > SPos[0].x + BUTTON_WIDTH) { inside = false; //printf("right"); } if (y < SPos[0].y) { inside = false; //printf("above"); } if (y > SPos[0].y + BUTTON_HEIGHT) { inside = false; //printf("below"); } if (inside) { switch (S->type) { case SDL_MOUSEBUTTONDOWN: SDL_BlitSurface(selectRButton[0], &rButtonParam[0], nWindowSurface, &rButtonPos[0]); displayText(0); quitter = true; break; case SDL_MOUSEBUTTONUP: break; } } } //r2 if( S->type == SDL_MOUSEMOTION || S->type == SDL_MOUSEBUTTONDOWN || S->type == SDL_MOUSEBUTTONUP ) { //Get mouse position int x, y; SDL_GetMouseState( &x, &y ); bool inside = true; //left if (x < SPos[1].x) { inside = false; } if (x > SPos[1].x + BUTTON_WIDTH) { inside = false; } if (y < SPos[1].y) { inside = false; } if (y > SPos[1].y + BUTTON_HEIGHT) { inside = false; } if (inside) { switch (S->type) { case SDL_MOUSEBUTTONDOWN: SDL_BlitSurface(selectRButtonClick[1], &rCButtonParam[1], nWindowSurface, &rButtonPos[1]); displayText(1); break; case SDL_MOUSEBUTTONUP: SDL_BlitSurface(selectRButton[1], &rButtonParam[1], nWindowSurface, &rButtonPos[1]); break; } } } return quitter; } int main( int argc, char* args[] ) { int cnt = 0; bool quit = false; SDL_Event M; //boot SDL and load menu init(); loadMedia(); //load title screen SDL_BlitSurface(titleScreen, NULL, gWindowSurface, NULL); //display buttons SDL_BlitSurface(playButton, &buttonParams[cnt], gWindowSurface, &buttonPos[cnt]); cnt++; SDL_BlitSurface(exitButton, &buttonParams[cnt], gWindowSurface, &buttonPos[cnt]); while (!quit) { while(SDL_PollEvent( &M ) != 0 ) { quit = mouseHandle(&M); if( M.type == SDL_QUIT ) { quit = true; } } //Update the screen SDL_UpdateWindowSurface( gWindow ); } closeAll(); return 0; } void launch() { SDL_Event S; bool quit = false; string fileName; TTF_Font* font = TTF_OpenFont("arial.ttf", 25); if (!font) { TTF_GetError(); } closeMenu(); selectScreen(); while (!quit) { while(SDL_PollEvent( &S ) != 0 ) { quit = mouseHandleS(&S); if (quit == true) { break; } } //Update the screen SDL_UpdateWindowSurface( nWindow ); } //createRenderer closeSelect(); loadArena(); } void closeMenu() { //closes the main menu SDL_FreeSurface(titleScreen); SDL_FreeSurface(playButton); SDL_FreeSurface(exitButton); SDL_FreeSurface(playButtonClick); SDL_FreeSurface(exitButtonClick); titleScreen = NULL; playButton = NULL; exitButton = NULL; playButtonClick = NULL; exitButtonClick = NULL; //free music Mix_FreeChunk (onClick); onClick = NULL; SDL_DestroyWindow( gWindow ); gWindow = NULL; } void closeSelect() { SDL_FreeSurface(nWindowSurface); for (int cnt = 0; cnt > TOTAL_R_BUTTONS; cnt++) { SDL_FreeSurface(selectRButton[cnt]); SDL_FreeSurface(selectRButtonClick[cnt]); SDL_FreeSurface(selectBG); } SDL_DestroyWindow( nWindow ); nWindow = NULL; } string disect(string path) { string fileName = ""; int length = path.length(); int lastBack = 0; int dotCnt; for (int cnt = 3; cnt < length; cnt++) { if (path[cnt] == '.') { dotCnt = cnt; } if (path[cnt] == '\\') { lastBack = cnt; } } for (int cnt = lastBack + 1; cnt < dotCnt; cnt++) { if (path[cnt] == '.') { break; } fileName += path[cnt]; } return fileName; } void selectScreen() { nWindow = SDL_CreateWindow("Select Your RBT CHUNGUS", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); nWindowSurface = SDL_GetWindowSurface(nWindow); SDL_BlitSurface(selectBG, NULL, nWindowSurface, NULL); for (int cnt = 0; cnt < 2; cnt++) { SDL_BlitSurface(selectRButton[cnt], &rButtonParam[cnt], nWindowSurface, &rButtonPos[cnt]); } SDL_UpdateWindowSurface( nWindow ); } void displayText (int buttonNum) { string fileName; TTF_Font* font = TTF_OpenFont("arial.ttf", 25); if (!font) { cout << "no font " << SDL_GetError(); exit(1); } if (!TTF_WasInit() && TTF_Init() == -1) { cout << "ya done fucked up " << TTF_GetError(); exit(1); } fOpen f; fileName = disect(f.getInPath()); const char *c = fileName.c_str(); message = TTF_RenderText_Solid(font, c, textColor); int x = 180; int y = 120; SDL_Rect textLocation = { x, y, 0, 0 }; if (buttonNum > 0) { textLocation.y = textLocation.y + (100 * buttonNum); } SDL_BlitSurface(message, NULL, nWindowSurface, &textLocation); SDL_UpdateWindowSurface(nWindow); TTF_CloseFont( font ); if (!font) { cout << "null is working" << endl; } font = NULL; } void loadArena () { aWindow = SDL_CreateWindow("FIGHT!!!!!!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); aWindowSurface = SDL_GetWindowSurface(aWindow); SDL_BlitSurface(arena, NULL, aWindowSurface, &arenaPos); SDL_BlitSurface(robot1, NULL, aWindowSurface, &robPos[0]); SDL_BlitSurface(robot2, NULL, aWindowSurface, &robPos[1]); SDL_UpdateWindowSurface(aWindow); int cnt = 0; int cnta = 0; robPos[1].x = 500; while (cnta < 10) { while (cnt < 200) { robPos[1].x++; if (robPos[1].x >= 589) { cout << "break" << endl; cout << robPos[1].x << endl; break; } SDL_BlitSurface(robot2, NULL, aWindowSurface, &robPos[1]); SDL_UpdateWindowSurface(aWindow); cnt++; } while (cnt > -500) { robPos[1].x--; if (robPos[1].x <= 51) { cout << "break" << endl; cout << robPos[1].x << endl; break; } SDL_BlitSurface(robot2, NULL, aWindowSurface, &robPos[1]); SDL_UpdateWindowSurface(aWindow); cnt--; } cnta++; } //reset cnt = 0; cnta = 0; cout << "y pos is " << robPos[1].y << endl; while (cnta < 5) { while (cnt > -200) { robPos[1].y--; //cout << robPos[1].x << endl; if (robPos[1].y <= 51) { cout << "break" << endl; cout << robPos[1].y << endl; break; } SDL_BlitSurface(robot2, NULL, aWindowSurface, &robPos[1]); SDL_UpdateWindowSurface(aWindow); cnt--; } while (cnt < 1000) { robPos[1].y++; //cout << robPos[1].x << endl; if (robPos[1].y >= 539) { cout << "break" << endl; cout << robPos[1].y << endl; break; } SDL_BlitSurface(robot2, NULL, aWindowSurface, &robPos[1]); SDL_UpdateWindowSurface(aWindow); cnt++; } cnta++; } SDL_Delay( 6000 ); exit(0); }
92f7470b4f341c4980e72e8becd1906b66ea8934
ca9587f39ebcfd4c95be6a5d71582a562ada8375
/Assignment 2/ass2/ass2/dijkstra.cpp
f4a66414158e65f5e6ada45f3bf8e089d6f03200
[]
no_license
eek9/CSS-343
8681e30cc38f487d6ef2991c1a4075ec8c0e7ee2
8cee7c70ae6278f8cb15eb8d5fc0cef5044708dd
refs/heads/main
2023-02-23T06:01:24.969573
2021-01-20T00:59:32
2021-01-20T00:59:32
331,147,358
0
0
null
null
null
null
UTF-8
C++
false
false
5,751
cpp
dijkstra.cpp
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <map> #include <queue> #include <algorithm> #include "dijkstra.h" using namespace std; //constructor that takes in an int value and initializes the amount of vertices //and pairs dijkstra::dijkstra(int v) : V{v}, adj{new list<p>[v]}{} //this function will take in int values of the points and the distance between void dijkstra::addEdge(int v1, int v2, int dist) { //this will direct the two points to be adjacent to one another //and push back the pairs of making the distances between them adj[v1].push_back(make_pair(v2, dist)); adj[v2].push_back(make_pair(v1, dist)); } //this function will calculate and print the shortest distance between the //departing airport and the destination airport void dijkstra::shortestPath(int depart, int dest) { //a priority queue to keep track of the vertices priority_queue< p, vector <p>, greater<p> > q; //a vector for distances and initializing all unvisited distances to INF vector<int> dis(V, INF); //pushing the departing airport into the priority queue and initilizing //the distance to itself as 0 q.push(make_pair(0, depart)); dis[depart] = 0; //while the priority queue is not empty, or until it becomes empty while (!q.empty()) { //the priority queue will be popped after labeling vertex into //an int second pair int u = q.top().second; q.pop(); //using an iterator to find the adjacent vertices list< pair<int, int> >::iterator i; //for loop to go through the adjacent points for (i = adj[u].begin(); i != adj[u].end(); ++i) { //storing the label of the vertex and weight of the //current adjacent of u int v = (*i).first; int weight = (*i).second; //if a shorter path from v to u is found if (dis[v] > dis[u] + weight) { //will update the distance of v dis[v] = dis[u] + weight; //pushing the new shorter length into the priority queue q.push(make_pair(dis[v], v)); } } } //an array to keep track of the airports available in the file const char* airports[26] = { "OLM", "BOI", "HLN", "EKO", "SAF", "LAS", "SLC", "BIS", "DEN", "FOE", "LIT", "BTR", "AUS", "TLH", "CVG", "RDU", "LCK", "PIT", "LAN", "STL", "DSM", "OKC", "XMD", "LNK", "AUM", "PIR" }; //printing the shortest distance between the two airports that were requested //from the parameter inputs printf("shortest distance between the two airports:\n"); printf("%d\n", dis[dest]); } int main() { //int value of how many vertices are available int V = 26; //initializing the amount of vertices into the constructor dijkstra g(V); //array that keeps track of airports const string airports[26] = { "OLM", "BOI", "HLN", "EKO", "SAF", "LAS", "SLC", "BIS", "DEN", "FOE", "LIT", "BTR", "AUS", "TLH", "CVG", "RDU", "LCK", "PIT", "LAN", "STL", "DSM", "OKC", "XMD", "LNK", "AUM", "PIR" }; //opening the file ifstream file("AirportDistances.csv"); //if the file is found if (file.is_open()) { string line; //while getting the next line while (getline(file, line)) { stringstream ss(line); string d; string a; string dis; //identify and direct the departing, arriving, and distance values from the file //into the variables getline(ss, d, ','); getline(ss, a, ','); getline(ss, dis, ','); //convert the string of distance into an int int distance = stoi(dis); int dd = 0; int aa = 0; //finding the index of where the string comes from in the array //to label as an int(making it able to be used as an input to a function) for (int i = 0; i < 27; i++) { if (airports[i] == d) { dd = i; } } for (int i = 0; i < 27; i++) { if (airports[i] == a) { aa = i; } } //adding an edge by inputing the designated array numbers based on the matching //airport code, and the distance between the two g.addEdge(dd, aa, distance); } } else { cout << "file not found" << endl; } string d; string de; //asking the user which airport to depart from cout << "where would you like to depart from?" << endl; cin >> d; //asking the user which airport to arrive at cout << "where is your destination?" << endl; cin >> de; int departure = 0; int destination = 0; //finding the array index based on the input given from user for (int i = 0; i < 27; i++) { if (airports[i] == d) { departure = i; } } for (int i = 0; i < 27; i++) { if (airports[i] == de) { destination = i; } } //calculate the shortest path that was requested g.shortestPath(departure, destination); return 0; }
06ac415f99149c613b5f9213d3cf3c424af4bd5a
d36d7b33e1f1b2ff439ea6aa62d14ec60c19faa1
/08.binary-tree-with-pre-inorder.cpp
103d922e6be4816409621de81c90fa80fb3b635c
[]
no_license
kameshkotwani/june2021-leetcode
142f9c51306cfc76e2d7bbb52040dd6310adc622
944230f3d5045fbbc880da4d6e4bdad7b134cb61
refs/heads/main
2023-06-04T10:01:55.454856
2021-06-29T14:43:51
2021-06-29T14:43:51
372,685,737
0
0
null
null
null
null
UTF-8
C++
false
false
1,550
cpp
08.binary-tree-with-pre-inorder.cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ class Solution { public: TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) { set<TreeNode*> s; stack<TreeNode*> st; int n=preorder.size(); TreeNode* root = NULL; for(int pre=0,in=0;pre<n;){ TreeNode* node=NULL; do{ node = new TreeNode(preorder[pre]); if(root ==NULL){ root=node; } if(st.size()>0){ if(s.find(st.top())!=s.end()){ s.erase(st.top()); st.top()->right=node; st.pop(); } else{ st.top()->left=node; } } st.push(node); }while(preorder[pre++]!=inorder[in] && pre<n); node=NULL; while(st.size()>0 && in<n && st.top()->val==inorder[in]){ node=st.top(); st.pop(); in++; } if(node!=NULL){ s.insert(node); st.push(node); } } return root; } };
1c06df0fc148c4ffc48385bed403a12cd24b2106
f0c26d14f817c2572786354d09b4c814575437f3
/TokenAnalizer/main.cpp
f61833d34b28568538dff5e37694ebfc593b5881
[]
no_license
alexis-matuk/ReconocimientoTokens
49d7e3bea4fb7c43c9bfff229bc414762eecce38
9a94eff8aca2b825fd08cf2d755f57323ce9a9e0
refs/heads/master
2021-01-10T14:22:16.551763
2016-01-31T16:50:02
2016-01-31T16:50:02
50,733,853
0
0
null
null
null
null
UTF-8
C++
false
false
6,580
cpp
main.cpp
/****************************************************************** Name: Alexis Matuk Date: 30 de enero de 2016 Description: Analizador de tokens aritméticos basados en un DFA ***********************************************************/ #include <iostream> #include <vector> #include <fstream> /****************************************************************** Función que sirve para mapear un caracter a la posición correspondiente en la tabla de transición ***********************************************************/ int getInputFromChar(char c) { int result = 0; if(c == '+') result = 0; if(c == '-') result = 1; if(c == '*') result = 2; if(c == '/') result = 3; if(c == '^') result = 4; if(c == '=') result = 5; if(c == '(') result = 6; if(c == ')') result = 7; if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) result = 8; if(c >= '0' && c <= '9') result = 9; if(c == '.') result = 10; if(c == ' ') result = 11; return result; } /****************************************************************** Función para determinar si un estado es final o no ***********************************************************/ bool isFinalState(int state) { if(state == 0 || state == 14) return false; return true; } /****************************************************************** Función para obtener el nombre del estado a partir de la posición en la tabla de transición ***********************************************************/ std::string getNameFromState(int state) { if(state == 0) return "Inicio"; if(state == 1) return "Variable"; if(state == 2) return "Entero"; if(state == 3) return "Real"; if(state == 4) return "Comentario"; if(state == 5) return "Paréntesis abre"; if(state == 6) return "Paréntesis cierra"; if(state == 7) return "Suma"; if(state == 8) return "Resta"; if(state == 9) return "Multiplicación"; if(state == 10) return "División"; if(state == 11) return "Potencia"; if(state == 12) return "Asignación"; if(state == 13) return "Error"; if(state == 14) return "Punto Flotante"; return ""; } /****************************************************************** Función para abrir un archivo .txt ***********************************************************/ void openFile(std::ifstream & _file, std::string route) { try { if (std::ifstream(route)) { std::cout << "File found... opening " << std::endl; _file.open(route); if(_file.fail()) { std::cout << "Error reading file... aborting" << std::endl; throw 2; } } else { std::cout << "File not found... Aborting" << std::endl; throw 1; } } catch (int e) { std::cerr << "Error reading data... Exception " << e << " caught" << std::endl; } } /****************************************************************** Función principal que evalúa un string e introduce los caracteres en el autómata para determinar cuál es el token y de qué tipo es ***********************************************************/ void evaluateString(std::string entrada, int automata [15][12]) { int currentState = 0; int lastState = 0; std::string result = ""; for(int i = 0; i < entrada.size(); i++) { lastState = currentState; currentState = automata[currentState][getInputFromChar(entrada[i])];//realizar transición if(currentState == 0 && i != 0) { if(entrada[i-1] != ' ')//Ignorar espacios { if(isFinalState(lastState)) std::cout << result << " --> " << getNameFromState(lastState) << std::endl; else std::cout << result << " --> " << "Error" << std::endl; } result = ""; if(entrada[i] != ' ')//Ignorar espacios i--;//Simular transición nula } else { result += entrada[i]; } } if(!result.empty())//Último token leído { if(isFinalState(currentState)) std::cout << result << " --> " << getNameFromState(currentState) << std::endl; else std::cout << result << " --> " << "Error" << std::endl; } } int main(int argc, const char * argv[]) { //Tabla de transición del autómata int automata[15][12] = {{7, 8, 9, 10, 11, 12, 5, 6, 1, 2, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 14, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 13, 0}, {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0}, {13, 13, 13, 13, 13, 13, 13, 13, 13, 3, 13, 13}, }; /****************************************************************** Lectura del archivo y evaluación línea por línea en el autómata ***********************************************************/ std::ifstream file; std::string route; std::cout << "Ruta del archivo a analizar: "; std::getline(std::cin, route); openFile(file, route); if(file.is_open()) { std::string line; while(!file.eof()) { std::string line(""); if(getline(file,line)) { evaluateString(line, automata); } } } else { std::cout << "File is not open" << std::endl; } file.close(); }
00bff2520fdbf1b5b4493a1b4598d91d7fbbd0f5
b8c883017e1d4dc48deef0394b96c164f8bc7686
/Code/Studio/Source/ComponentEditors/ModelRendererComponentEditor.hpp
3e20896768980ef5dd4a1bcf72ad2c8da83091f9
[ "MIT" ]
permissive
JX-Master/Luna-Engine-0.6
78a814b609d19c24ba15b4a066269d3e2a590494
fd30086840efcf191c4b52a317a17f1ada64f0a5
refs/heads/master
2023-04-21T14:18:58.390778
2023-04-14T01:52:04
2023-04-14T01:52:04
270,267,431
201
27
null
null
null
null
UTF-8
C++
false
false
1,368
hpp
ModelRendererComponentEditor.hpp
// Copyright 2018-2020 JXMaster. All rights reserved. /* * @file ModelRendererComponentEditor.hpp * @author JXMaster * @date 2020/5/28 */ #pragma once #include "../IComponentEditorType.hpp" namespace Luna { namespace editor { class ModelRendererComponentEditor : public IComponentEditor { public: lucid("{991679a8-1354-415c-b0d6-74d25fc7476c}"); luiimpl(ModelRendererComponentEditor, IComponentEditor, IObject); Name m_type_name; WP<E3D::IModelRenderer> m_component; String m_model_name; bool m_editing = false; ModelRendererComponentEditor() : m_model_name(String()) {} virtual Name type_name() override { return m_type_name; } virtual void on_render(ImGui::IContext* ctx) override; }; class ModelRendererComponentEditorType : public IComponentEditorType { public: lucid("{df3ec6fd-36c4-4f27-8f72-47e318362b1b}"); luiimpl(ModelRendererComponentEditorType, IComponentEditorType, IObject); Name m_type_name; ModelRendererComponentEditorType() : m_type_name(Name("Model Renderer")) {} virtual Name type() override { return m_type_name; } virtual P<IComponentEditor> new_editor(Scene::IComponent* component) override { auto r = newobj<ModelRendererComponentEditor>(); r->m_component = component; r->m_type_name = m_type_name; return r; } }; } }
ed6d431009e17884b6be735c18d4f5c5683dccf5
23c84c283f0dd2ffe6811e85d5924102a05d7ed1
/UVa/V113/11367 - Full Tank.cpp
11c401880be97b4c32e68580771ef7840b31fa8a
[]
no_license
HJackH/OnlineJudges
efaaaf35fabeb5393a3fefac9a19e3c89a535b3b
1e5bfc7ad13cc171e16d562a4cac0bcdc92bbce2
refs/heads/master
2022-07-08T21:31:37.960165
2022-06-22T07:01:57
2022-06-22T07:01:57
245,434,136
4
1
null
null
null
null
UTF-8
C++
false
false
2,052
cpp
11367 - Full Tank.cpp
#include <bits/stdc++.h> using namespace std; using LL = long long; #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #define pb push_back const int INF = 1e9; const int MAXN = 1000 + 5; struct Edge { int v; int w; }; struct Car { int v; int rem; int cost; bool operator < (const Car &other) const { return cost > other.cost; } }; int n, m; int price[MAXN], dp[MAXN][100 + 5]; vector<Edge> G[MAXN]; int dijk(int st, int ed, int c) { for (int i = 0; i < n; i++) { for (int j = 0; j <= c; j++) { dp[i][j] = INF; } } priority_queue<Car> pq; pq.push({st, 0, 0}); dp[st][0] = 0; while (!pq.empty()) { auto now = pq.top(); pq.pop(); if (now.v == ed && now.rem == 0) { return now.cost; } if (dp[now.v][now.rem] < now.cost) { continue; } for (auto &e : G[now.v]) { if (e.w > now.rem) { continue; } if (dp[e.v][now.rem - e.w] > now.cost) { dp[e.v][now.rem - e.w] = now.cost; pq.push({e.v, now.rem - e.w, dp[e.v][now.rem - e.w]}); } } if (now.rem + 1 <= c && dp[now.v][now.rem + 1] > now.cost + price[now.v]) { dp[now.v][now.rem + 1] = now.cost + price[now.v]; pq.push({now.v, now.rem + 1, dp[now.v][now.rem + 1]}); } } return INF; } int main() { IOS while (cin >> n >> m) { for (int i = 0; i < n; i++) { cin >> price[i]; G[i].clear(); } for (int i = 0, u, v, w; i < m; i++) { cin >> u >> v >> w; G[u].pb({v, w}); G[v].pb({u, w}); } int q, c, st, ed; cin >> q; while (q--) { cin >> c >> st >> ed; int ans = dijk(st, ed, c); if (ans == INF) { cout << "impossible\n"; } else { cout << ans << "\n"; } } } }
bdf481bf6c3f0531a26eaa5fe9e9eed45bbce982
3fd87fa4b5c921d71b9f4b3c20c2ec710a285d54
/src/constraint_point_2D.h
1772c01fdce2ec163c8c2ea14f41f815b381cb37
[]
no_license
mshicom/wolf
8358bf5f84376a9f80b25c5cff8cf8a82f5d1d91
1d21ba4a2c72dcdc4347d91071f570beaadd3a29
refs/heads/master
2020-12-24T06:06:53.465173
2016-09-19T07:26:02
2016-09-19T07:26:02
73,229,005
0
0
null
2016-11-08T21:34:42
2016-11-08T21:34:41
null
UTF-8
C++
false
false
5,663
h
constraint_point_2D.h
#ifndef CONSTRAINT_POINT_2D_THETA_H_ #define CONSTRAINT_POINT_2D_THETA_H_ //Wolf includes #include "constraint_sparse.h" #include "feature_polyline_2D.h" #include "landmark_polyline_2D.h" namespace wolf { class ConstraintPoint2D: public ConstraintSparse<2,2,1,2,1,2> { protected: unsigned int feature_point_id_; int landmark_point_id_; StateBlock* point_state_ptr_; Eigen::VectorXs measurement_; ///< the measurement vector Eigen::MatrixXs measurement_covariance_; ///< the measurement covariance matrix Eigen::MatrixXs measurement_sqrt_information_; ///< the squared root information matrix public: static const unsigned int N_BLOCKS = 5; ConstraintPoint2D(FeaturePolyline2D* _ftr_ptr, LandmarkPolyline2D* _lmk_ptr, unsigned int _ftr_point_id, int _lmk_point_id, bool _apply_loss_function = false, ConstraintStatus _status = CTR_ACTIVE) : ConstraintSparse<2,2,1,2,1,2>(CTR_POINT_2D, _lmk_ptr, _apply_loss_function, _status, _ftr_ptr->getFramePtr()->getPPtr(), _ftr_ptr->getFramePtr()->getOPtr(), _lmk_ptr->getPPtr(), _lmk_ptr->getOPtr(), _lmk_ptr->getPointStateBlockPtr(_lmk_point_id)), feature_point_id_(_ftr_point_id), landmark_point_id_(_lmk_point_id), point_state_ptr_(_lmk_ptr->getPointStateBlockPtr(_lmk_point_id)), measurement_(_ftr_ptr->getPoints().col(_ftr_point_id)), measurement_covariance_(_ftr_ptr->getPointsCov().middleCols(_ftr_point_id*2,2)) { //std::cout << "Constriant point: feature " << _ftr_ptr->id() << " landmark " << _lmk_ptr->id() << "(point " << _lmk_point_id << ")" << std::endl; //std::cout << "landmark state block " << _lmk_ptr->getPointStateBlockPtr(_lmk_point_id)->getVector().transpose() << std::endl; setType("POINT TO POINT 2D"); Eigen::LLT<Eigen::MatrixXs> lltOfA(measurement_covariance_); // compute the Cholesky decomposition of A Eigen::MatrixXs measurement_sqrt_covariance = lltOfA.matrixU(); measurement_sqrt_information_ = measurement_sqrt_covariance.inverse().transpose(); // retrieve factor U in the decomposition } /** \brief Default destructor (not recommended) * * Default destructor (please use destruct() instead of delete for guaranteeing the wolf tree integrity) * **/ virtual ~ConstraintPoint2D() { //std::cout << "deleting ConstraintPoint2D " << nodeId() << std::endl; } LandmarkPolyline2D* getLandmarkPtr() { return (LandmarkPolyline2D*) landmark_ptr_; } int getLandmarkPointId() { return landmark_point_id_; } unsigned int getFeaturePointId() { return feature_point_id_; } StateBlock* getLandmarkPointPtr() { return point_state_ptr_; } template <typename T> bool operator ()(const T* const _robotP, const T* const _robotO, const T* const _landmarkOriginP, const T* const _landmarkOriginO, const T* const _landmarkPoint, T* _residuals) const; /** \brief Returns the jacobians computation method * * Returns the jacobians computation method * **/ virtual JacobianMethod getJacobianMethod() const { return JAC_AUTO; } /** \brief Returns a reference to the feature measurement **/ virtual const Eigen::VectorXs& getMeasurement() const { return measurement_; } /** \brief Returns a reference to the feature measurement covariance **/ virtual const Eigen::MatrixXs& getMeasurementCovariance() const { return measurement_covariance_; } /** \brief Returns a reference to the feature measurement square root information **/ virtual const Eigen::MatrixXs& getMeasurementSquareRootInformation() const { return measurement_sqrt_information_; } }; template<typename T> inline bool ConstraintPoint2D::operator ()(const T* const _robotP, const T* const _robotO, const T* const _landmarkOriginP, const T* const _landmarkOriginO, const T* const _landmarkPoint, T* _residuals) const { //std::cout << "ConstraintPointToLine2D::operator" << std::endl; // Mapping Eigen::Map<const Eigen::Matrix<T,2,1>> landmark_origin_position_map(_landmarkOriginP); Eigen::Map<const Eigen::Matrix<T,2,1>> landmark_position_map(_landmarkPoint); Eigen::Map<const Eigen::Matrix<T,2,1>> robot_position_map(_robotP); Eigen::Map<Eigen::Matrix<T,2,1>> residuals_map(_residuals); // Landmark point global position Eigen::Matrix<T,2,1> landmark_point = landmark_origin_position_map + Eigen::Rotation2D<T>(*_landmarkOriginO) * landmark_position_map; // sensor transformation Eigen::Matrix<T,2,1> sensor_position = getCapturePtr()->getSensorPtr()->getPPtr()->getVector().head(2).cast<T>(); Eigen::Matrix<T,2,2> inverse_R_sensor = Eigen::Rotation2D<T>(T(-getCapturePtr()->getSensorOPtr()->getVector()(0))).matrix(); // robot transformation Eigen::Matrix<T,2,2> inverse_R_robot = Eigen::Rotation2D<T>(-_robotO[0]).matrix(); // Expected measurement Eigen::Matrix<T,2,1> expected_measurement_position = inverse_R_sensor * (inverse_R_robot * (landmark_point - robot_position_map) - sensor_position); // Residuals residuals_map = getMeasurementSquareRootInformation().cast<T>() * (expected_measurement_position - getMeasurement().head<2>().cast<T>()); //std::cout << "residuals_map" << residuals_map[0] << std::endl; return true; } } // namespace wolf #endif
81a390c97a49553e8428425ce7fa93bbbcd9ba45
3f4e19c120c2d2c5c0b4ec766e41f2b41b8bdc13
/csf_workspace/csf/src/modules/connect/csf_ip_connect/url/csf_ipv4_url.cpp
95d59895b325540cc96268fe18dcbe055255f76b
[ "BSD-2-Clause" ]
permissive
Kitty-Kitty/csf_library
7618a84d0479028c3c7f491073742a8f4719070a
011e56fb8b687818d20b9998a0cdb72332375534
refs/heads/master
2021-06-04T08:47:21.104992
2020-08-28T01:52:41
2020-08-28T01:52:41
143,405,037
2
0
null
null
null
null
UTF-8
C++
false
false
1,920
cpp
csf_ipv4_url.cpp
/******************************************************************************* * *Copyright: fangzhenmu * *Author: fangzhenmu * *File name: csf_ipv4_url.hpp * *Version: 1.0 * *Date: 13-3月-2019 17:52:23 * *Description: Class(csf_ipv4_url) * *Others: * *History: * *******************************************************************************/ #include <regex> #include "csf_ipv4_url.hpp" using csf::modules::connect::csf_ipv4_url; csf_ipv4_url::csf_ipv4_url() :csf_ip_url(csf::modules::connect::csf_ip_url::csf_ip_type_v4) { } csf_ipv4_url::~csf_ipv4_url() { } /** * 功能: * 表示解析地址函数。地址格式为:1、[ip]:port;2、ip:port两种;例如:[192.168.1.10]:80和192.168.1.10: * 80。推荐使用1格式,可以兼容ipv6格式的ip地址,更适合未来的url描述需求。 * * 返回: * 0 :表示成功 * 非0:表示错误 * * @param url 表示url字符串数据,地址格式为:1. [ip]:port; 2.ip:port两种;例如:[192.168.1.10]: * 80和192.168.1.10:80 */ csf_int32 csf_ipv4_url::parse(const csf_string& url) { return 0; } /** * 功能: * 对ip地址的格式合法性校验。地址格式为:1、[ip]:port;2、ip:port两种;例如:[192.168.1.10]:80和192.168.1. * 10。推荐使用1格式,可以兼容ipv6格式的ip地址,更适合未来的url描述需求。 * * 返回: * true表示成功; * false表示失败; * * @param ip 表示网络地址格式,地址格式为:1. [ip]:port; 2.ip:port两种;例如:[192.168.1.10]:80和192. * 168.1.10:80 */ csf_bool csf_ipv4_url::check_ip(const csf_string& ip) { std::regex tmp_pattern("((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"); if (ip.empty()) { return csf_false; } if (!std::regex_match(ip, tmp_pattern)) { return csf_false; } return csf_true; }
efdc58f1197cff4a95e2abed9b4d9a71b996f645
4b07b7f430a754d2e4d093b4db6a23b5f99d92f0
/src/InputSystem.h
0b2a9e24823b01669884ae725ee14c145d8588d7
[]
no_license
Enyss/The-Dreamers-Realm
8c573e24dad140ae24ea22c66771bb1a7623cb74
4a821e0123ca34229b587891e74122b5c6544d8e
refs/heads/master
2016-08-12T23:50:44.890840
2015-12-23T15:47:02
2015-12-23T15:47:02
48,454,031
0
0
null
null
null
null
UTF-8
C++
false
false
249
h
InputSystem.h
#pragma once class Engine; #include <SDL.h> #include "Hash.h" #include "System.h" #include "Engine.h" class InputSystem : public System { public: InputSystem(Engine * engine); void update(float dt); void init(); private: Engine * engine; };
5ba2cbfefb02aa78271cb70a1cab4851bd1b705b
e13f46124430941c71b3461668c8fbc65e5aac6a
/Assets/shaders.inc
b601bcb3d4b8a1ddc443cda2b59fa9aa7151aca2
[]
no_license
nonathaj/EAE_Engineering_2
263f4e4a3a5fdee9a4cc1e4f078eb664c96bc109
da0093ae45f4cc3f354a39a0ca5ac3d067b701e5
refs/heads/master
2021-01-10T05:41:32.175232
2016-02-26T00:06:52
2016-02-26T00:06:52
45,748,596
0
0
null
null
null
null
UTF-8
C++
false
false
1,854
inc
shaders.inc
/* This file should be #included in every shader to set up platform-specific preprocessor directives so that the shader itself can be mostly platform-independent */ //////////////////////////////////////////////////////////////////////////////////////// #if defined( EAE6320_PLATFORM_D3D ) //////////////////////////////////////////////////////////////////////////////////////// #define Transform(i_vector, i_matrix) mul(i_vector, i_matrix) #define SampleFromTexture(i_texture, i_texture_coordinates) tex2D(i_texture, i_texture_coordinates) //////////////////////////////////////////////////////////////////////////////////////// #elif defined( EAE6320_PLATFORM_GL ) //////////////////////////////////////////////////////////////////////////////////////// // The version of GLSL to use must come first #version 330 // This extension is required in order to specify explicit locations for shader inputs and outputs #extension GL_ARB_separate_shader_objects : require // Translate GLSL variable types to HLSL #define float2 vec2 #define float3 vec3 #define float4 vec4 #define float2x2 mat2 #define float3x3 mat3 #define float4x4 mat4 #define Transform(i_vector, i_matrix) i_vector * i_matrix #define SampleFromTexture(i_texture, i_texture_coordinates) texture2D(i_texture, i_texture_coordinates) //////////////////////////////////////////////////////////////////////////////////////// #else //////////////////////////////////////////////////////////////////////////////////////// #error No platform defined for shader file #error Missing define for Transform(i_vector, i_matrix) #error Missing define for SampleFromTexture(i_texture, i_texture_coordinates) //////////////////////////////////////////////////////////////////////////////////////// #endif ////////////////////////////////////////////////////////////////////////////////////////
e40a8cbb9dada683aa0af4a5e781521393a4b95f
34fc36da5d684f908bb988cc76bf542fabca88db
/ABC/ABC193/b193c.cpp
f45fd5ba893a9a738b4b9c2cdc09841bda6da066
[]
no_license
take1010/MyAtCoder
6f2dc830d75ae4c99edfb3638734854e905bc557
d85aecee85f7ebf5232fd82599b21ff5658c4e1c
refs/heads/main
2023-05-31T12:44:32.336673
2021-06-19T14:01:24
2021-06-19T14:01:24
308,521,140
0
0
null
null
null
null
UTF-8
C++
false
false
597
cpp
b193c.cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define MOD 1000000007 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } int main(){ ll n; cin >> n; set<ll> s; for(ll i=2; i*i<=n; i++){ ll tmp; tmp=i; while(1){ tmp *= i; if(tmp<=n) s.insert(tmp); else break; } } cout << n-s.size() << endl; return 0; }
07158e535cffddfa4a9870487eb7058005245c26
0c5fd443401312fafae18ea6a9d17bac9ee61474
/code/tools/Composer/Main.cpp
b2f232346b291063a3647cad340b3e31028aa9db
[]
no_license
nurF/Brute-Force-Game-Engine
fcfebc997d6ab487508a5706b849e9d7bc66792d
b930472429ec6d6f691230e36076cd2c868d853d
refs/heads/master
2021-01-18T09:29:44.038036
2011-12-02T17:31:59
2011-12-02T17:31:59
2,877,061
1
0
null
null
null
null
UTF-8
C++
false
false
79,085
cpp
Main.cpp
/* ___ _________ ____ __ / _ )/ __/ ___/____/ __/___ ___ _/_/___ ___ / _ / _// (_ //___/ _/ / _ | _ `/ // _ | -_) /____/_/ \___/ /___//_//_|_, /_//_//_|__/ /___/ This file is part of the Brute-Force Game Engine, BFG-Engine For the latest info, see http://www.brute-force-games.com Copyright (c) 2011 Brute-Force Games GbR The BFG-Engine is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The BFG-Engine 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 the BFG-Engine. If not, see <http://www.gnu.org/licenses/>. */ #include <OgreException.h> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/units/quantity.hpp> #include <boost/units/systems/si/time.hpp> #include <limits> #include <OgreBlendMode.h> #include <OgreEntity.h> #include <OgreMaterialManager.h> #include <OgreMeshManager.h> #include <OgreParticleSystem.h> #include <OgreRoot.h> #include <OgreSceneManager.h> #include <OgreSceneNode.h> #include <OgreSubEntity.h> #include <MyGUI.h> #include <tinyxml.h> #include <Base/CEntryPoint.h> #include <Base/CLogger.h> #include <Base/Cpp.h> #include <Base/Pause.h> #include <Controller/Action.h> #include <Controller/ControllerEvents.h> #include <Controller/ControllerInterface.h> #include <EventSystem/Core/EventLoop.h> #include <EventSystem/Emitter.h> #include <EventSystem/EventFactory.h> #include <Core/ClockUtils.h> #include <Core/Location.h> #include <Core/Math.h> #include <Core/Mesh.h> #include <Core/Path.h> #include <Core/ShowException.h> #include <Core/Types.h> #include <Core/Utils.h> #include <Model/Environment.h> #include <Model/GameObject.h> #include <Model/Property/SpacePlugin.h> #include <View/Camera.h> #include <View/CameraCreation.h> #include <View/ControllerMyGuiAdapter.h> #include <View/Convert.h> #include <View/Event.h> #include <View/Explosion.h> #include <View/Interface.h> #include <View/Light.h> #include <View/LoadMesh.h> #include <View/Main.h> #include <View/Owner.h> #include <View/RenderObject.h> #include <View/SkyCreation.h> #include <View/Skybox.h> #include <View/State.h> #include <OpenSaveDialog.h> using namespace BFG; using namespace boost::units; const s32 A_QUIT = 10000; const s32 A_LOADING_MESH = 10001; const s32 A_LOADING_MATERIAL = 10002; const s32 A_CAMERA_AXIS_X = 10003; const s32 A_CAMERA_AXIS_Y = 10004; const s32 A_CAMERA_AXIS_Z = 10005; const s32 A_CAMERA_MOVE = 10006; const s32 A_CAMERA_RESET = 10007; const s32 A_CAMERA_ORBIT = 10008; const s32 A_SCREENSHOT = 10009; const s32 A_LOADING_SKY = 10010; const s32 A_CREATE_LIGHT = 10011; const s32 A_DESTROY_LIGHT = 10012; const s32 A_PREV_LIGHT = 10013; const s32 A_NEXT_LIGHT = 10014; const s32 A_FIRST_LIGHT = 10015; const s32 A_LAST_LIGHT = 10016; const s32 A_INFO_WINDOW = 10017; const s32 A_CAMERA_MOUSE_X = 10018; const s32 A_CAMERA_MOUSE_Y = 10019; const s32 A_CAMERA_MOUSE_Z = 10020; const s32 A_CAMERA_MOUSE_MOVE = 10021; const s32 A_SUB_MESH = 10022; const s32 A_TEX_UNIT = 10023; const s32 A_ANIMATION = 10024; const s32 A_ADAPTER = 10025; const s32 A_MOUSE_MIDDLE_PRESSED = 10026; const f32 DEFAULT_CAM_DISTANCE = 10.0f; const f32 DEFAULT_CAM_VELOCITY = 2.0f; // m/s const std::string DEFAULT_TEXTURE_MAP = "white.png"; const std::string DEFAULT_NORMAL_MAP = "flat_n.png"; const std::string DEFAULT_ILLUMINATION_MAP = "black.png"; struct TextureUnitChange { std::string mMaterial; std::string mAlias; std::string mTexture; bool mEnabled; }; struct Settings { std::string mMesh; std::string mMaterial; std::string mSkybox; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & mMesh; ar & mMaterial; ar & mSkybox; } }; struct ConnectionData { u32 mAdapterID; u32 mParentAdapterID; }; struct ComposerState : Emitter { ComposerState(GameHandle handle, EventLoop* loop) : Emitter(loop), mClock(new Clock::StopWatch(Clock::milliSecond)), mExitNextTick(false) { mClock->start(); } void ControllerEventHandler(Controller_::VipEvent* iCE) { switch(iCE->getId()) { case A_QUIT: { mExitNextTick = true; emit<BFG::View::Event>(BFG::ID::VE_SHUTDOWN, 0); break; } case A_SCREENSHOT: { emit<BFG::View::Event>(BFG::ID::VE_SCREENSHOT, 0); break; } } } void LoopEventHandler(LoopEvent* iLE) { if (mExitNextTick) { // Error happened, while doing stuff iLE->getData().getLoop()->setExitFlag(); } long timeSinceLastFrame = mClock->stop(); if (timeSinceLastFrame) mClock->start(); f32 timeInSeconds = static_cast<f32>(timeSinceLastFrame) / Clock::milliSecond; tick(timeInSeconds); } void tick(const f32 timeSinceLastFrame) { if (timeSinceLastFrame < EPSILON_F) return; quantity<si::time, f32> TSLF = timeSinceLastFrame * si::seconds; } boost::scoped_ptr<Clock::StopWatch> mClock; bool mExitNextTick; }; void allFilesOfDirectory(std::vector<std::string>& result, const std::string& location) { boost::filesystem::directory_iterator it(location), end; for (; it != end; ++it) { if (boost::filesystem::is_directory(*it)) continue; const std::string directoryName = it->path().filename().string(); result.push_back(it->path().filename().string()); } } void loadLayout(const std::string& fileName, MyGUI::VectorWidgetPtr& container) { BFG::Path path; std::string layout = path.Expand(fileName); container = MyGUI::LayoutManager::getInstance().load(layout); } struct ViewComposerState : public View::State { public: typedef std::map<std::string, std::vector<BFG::Adapter> > AdapterMapT; ViewComposerState(GameHandle handle, EventLoop* loop) : State(handle, loop), mLoop(loop), mMainObject(NULL), mObject(generateHandle()), mCamHandle(generateHandle()), mControllerAdapter(handle, loop), mCameraPosition(NULL), mCameraRotation(NULL), mCameraDistance(NULL), mSelectedSubEntity(NULL), mDeltaRot(v3::ZERO), mDeltaDis(0.0f), mCamDistance(DEFAULT_CAM_DISTANCE), mCamOrbit(false), mInfoChanged(false), mMouseCamPitchYaw(false), mMouseCamRoll(false), mIsZooming(false), mShowingMeshLoadingMenu(false), mShowingMaterialLoadingMenu(false), mShowingSkyLoadingMenu(false), mShowingLightCreatingMenu(false), mShowingInfoWindow(false), mShowingSubMeshMenu(false), mShowingTextureUnitMenu(false), mShowingAnimationMenu(false), mShowingAdapterMenu(false), mShowingPreviewMenu(false), mShowingLoadPreviewMeshMenu(false), mShowingLoadPreviewAdapterMenu(false), mGui(MyGUI::Gui::getInstance()), mAnimationLoop(false), mAnimationState(NULL), mPositionAdapter(false), mAdapterSelected(0), mMenuFocus(false) { mEnvironment.reset(new Environment); registerEventHandler(); createDefaultCamera(); createGui(); // create picking values Ogre::SceneManager* sceneMan = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); Ogre::SceneNode* rootSceneNode = sceneMan->getRootSceneNode(); mPickingNode = rootSceneNode->createChildSceneNode("PickingNode"); Ogre::Entity* ent = sceneMan->createEntity("Sphere", "Marker.mesh"); mPickingNode->attachObject(ent); mPickingNode->setDirection(Ogre::Vector3::UNIT_Y); mPickingNode->setVisible(false); } ~ViewComposerState() { unregisterEventHandler(); BOOST_FOREACH(TextureUnitChange* tex, mTextureChanges) { delete tex; } mTextureChanges.clear(); } void createDefaultCamera() { Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); mCameraPosition = sceneMgr->getRootSceneNode()->createChildSceneNode(); mCameraPosition->setPosition(0, 0, 0); mCameraRotation = mCameraPosition->createChildSceneNode(); mCameraDistance = mCameraRotation->createChildSceneNode(stringify(mCamHandle)); View::CameraCreation cc ( mCamHandle, mCamHandle, true, 0, 0 ); createCamera(cc); Ogre::Vector3 pos(0.0f, 0.0f, -mCamDistance); mCameraDistance->setPosition(pos); } void lostFocus(MyGUI::Widget*, MyGUI::Widget*) { mMenuFocus = false; } void gotFocus(MyGUI::Widget*, MyGUI::Widget*) { mMenuFocus = true; } void createGui() { loadLayout("Composer.layout", mGuiButtons); MyGUI::Widget* button = mGui.findWidgetT("Mesh"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("Material"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("Skybox"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("Light"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("SubEntity"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("TexUnits"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("Animation"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("Adapter"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); button = mGui.findWidget<MyGUI::Button>("Preview"); button->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::pressEvent); button->eventMouseLostFocus = MyGUI::newDelegate(this, &ViewComposerState::lostFocus); button->eventMouseSetFocus = MyGUI::newDelegate(this, &ViewComposerState::gotFocus); } void pressEvent(MyGUI::Widget* w) { std::string name = w->getName(); if (name == "Mesh") { showLoadingMesh(!mShowingMeshLoadingMenu); } else if (name == "Material") { showLoadingMaterial(!mShowingMaterialLoadingMenu); } else if (name == "Skybox") { showLoadingSky(!mShowingSkyLoadingMenu); } else if (name == "Light") { showCreatingLight(!mShowingLightCreatingMenu); } else if (name == "SubEntity") { showSubMesh(!mShowingSubMeshMenu); } else if (name == "TexUnits") { showTextureUnits(!mShowingTextureUnitMenu); } else if (name == "Animation") { showAnimation(!mShowingAnimationMenu); } else if (name == "Adapter") { showAdapter(!mShowingAdapterMenu); } else if (name == "Preview") { showPreview(!mShowingPreviewMenu); } } bool isMenuShowing() { return !mLoadedMenu.empty(); } void controllerEventHandler(Controller_::VipEvent* ve) { switch(ve->getId()) { case A_LOADING_MESH: { showLoadingMesh(!mShowingMeshLoadingMenu); break; } case A_LOADING_MATERIAL: { showLoadingMaterial(!mShowingMaterialLoadingMenu); break; } case A_INFO_WINDOW: { showInfoWindow(!mShowingInfoWindow); break; } case A_CAMERA_AXIS_X: { onCamX(boost::get<f32>(ve->getData())); break; } case A_CAMERA_MOUSE_X: { if (mMouseCamPitchYaw) { onCamX(boost::get<f32>(ve->getData())); } break; } case A_CAMERA_AXIS_Y: { onCamY(boost::get<f32>(ve->getData())); break; } case A_CAMERA_MOUSE_Y: { if (mMouseCamPitchYaw) { onCamY(boost::get<f32>(ve->getData())); } break; } case A_CAMERA_AXIS_Z: { onCamZ(boost::get<f32>(ve->getData())); break; } case A_CAMERA_MOUSE_Z: { if (mMouseCamRoll) { onCamZ(boost::get<f32>(ve->getData())); } break; } case A_CAMERA_MOVE: { f32 value = boost::get<f32>(ve->getData()); if (value > EPSILON_F || value < -EPSILON_F) { mIsZooming = true; mDeltaDis += value; } else { mIsZooming = false; mDeltaDis = 0.0f; } break; } case A_CAMERA_MOUSE_MOVE: { if (isMenuShowing()) break; mIsZooming = false; mDeltaDis = boost::get<f32>(ve->getData()); break; } case A_CAMERA_RESET: { onReset(); break; } case A_CAMERA_ORBIT: { mCamOrbit = boost::get<bool>(ve->getData()); dbglog << "OrbitCamera: " << mCamOrbit; break; } case A_LOADING_SKY: { showLoadingSky(!mShowingSkyLoadingMenu); break; } case A_CREATE_LIGHT: { showCreatingLight(!mShowingLightCreatingMenu); break; } case A_DESTROY_LIGHT: { std::vector<boost::shared_ptr<View::Light> >::iterator it = std::find(mLights.begin(), mLights.end(), mActiveLight); if (it != mLights.end()) { mLights.erase(it); } mActiveLight.reset(); break; } case A_PREV_LIGHT: { std::vector<boost::shared_ptr<View::Light> >::iterator it = std::find(mLights.begin(), mLights.end(), mActiveLight); if (it != mLights.end()) { if (it != mLights.begin()) { --it; mActiveLight = (*it); } } break; } case A_NEXT_LIGHT: { std::vector<boost::shared_ptr<View::Light> >::iterator it = std::find(mLights.begin(), mLights.end(), mActiveLight); if (it != mLights.end()) { ++it; if (it != mLights.end()) { mActiveLight = (*it); } } break; } case A_FIRST_LIGHT: { if (!mLights.empty()) { mActiveLight = (*mLights.begin()); } break; } case A_LAST_LIGHT: { if (!mLights.empty()) { mActiveLight = (*mLights.rbegin()); } break; } case A_MOUSE_MIDDLE_PRESSED: { if (isMenuShowing()) { mMouseCamPitchYaw = false; break; } if ( boost::get<bool>(ve->getData()) ) mMouseCamPitchYaw = true; else mMouseCamPitchYaw = false; break; } case BFG::ID::A_MOUSE_LEFT_PRESSED: { bool pressed = boost::get<bool>(ve->getData()); if (!pressed) break; if (mMeshName == "") break; if (!mPositionAdapter) break; if (mMenuFocus) break; pickPosition(); break; } case BFG::ID::A_MOUSE_RIGHT_PRESSED: { if (isMenuShowing()) { mMouseCamRoll = false; break; } if ( boost::get<bool>(ve->getData()) ) mMouseCamRoll = true; else mMouseCamRoll = false; break; } case A_SUB_MESH: { showSubMesh(!mShowingSubMeshMenu); break; } case A_TEX_UNIT: { showTextureUnits(!mShowingTextureUnitMenu); break; } case A_ANIMATION: { showAnimation(!mShowingAnimationMenu); break; } case A_ADAPTER: { showAdapter(!mShowingAdapterMenu); break; } default: throw std::logic_error("ViewComposerState::controllerEventHandler: Unknown event received"); } } void onCamX(f32 x) { mDeltaRot.x = M_PI * x; } void onCamY(f32 y) { mDeltaRot.y = M_PI * y; } void onCamZ(f32 z) { mDeltaRot.z = M_PI * z; } // universal stuff void unloadLoadingMenu() { if (!mLoadedMenu.empty()) { MyGUI::LayoutManager::getInstance().unloadLayout(mLoadedMenu); mLoadedMenu.clear(); mShowingMeshLoadingMenu = false; mShowingMaterialLoadingMenu = false; mShowingSkyLoadingMenu = false; mShowingLightCreatingMenu = false; mShowingSubMeshMenu = false; mShowingTextureUnitMenu = false; mShowingAnimationMenu = false; mShowingAdapterMenu = false; mShowingPreviewMenu = false; mShowingLoadPreviewMeshMenu = false; mShowingLoadPreviewAdapterMenu = false; if (mAnimationState) { mAnimationState->setEnabled(false); mAnimationState = NULL; } } } void onCancelPressed(MyGUI::Widget* _widget) { unloadLoadingMenu(); } void fullsizePanel(const std::string& panelName) { MyGUI::WidgetPtr backgroundPanel = mGui.findWidgetT(panelName); MyGUI::IntSize size = mGui.getViewSize(); backgroundPanel->setSize(size); } // Mesh stuff void showLoadingMesh(bool show) { unloadLoadingMenu(); if (show) { showPredefinedFiles ( mLoadedMenu, ID::P_GRAPHICS_MESHES, MyGUI::newDelegate(this, &ViewComposerState::onMeshOk), MyGUI::newDelegate(this, &ViewComposerState::onMeshSelected) ); mShowingMeshLoadingMenu = true; } } void showPredefinedFiles(MyGUI::VectorWidgetPtr& container, ID::PathType id, MyGUI::delegates::IDelegate1<MyGUI::Widget*>* okHandler, MyGUI::delegates::IDelegate2<MyGUI::List*, size_t>* listSelected) { loadLayout("ChooseListItem.layout", container); fullsizePanel("MainMenuPanel"); MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); if (list) { list->eventListSelectAccept = listSelected; BFG::Path path; mFiles.clear(); allFilesOfDirectory(mFiles, path.Get(id)); list->removeAllItems(); for (size_t l = 0; l < mFiles.size(); ++l) { list->addItem(mFiles[l]); } } MyGUI::WidgetPtr buttonOk = mGui.findWidgetT("ListOk"); buttonOk->eventMouseButtonClick = okHandler; MyGUI::WidgetPtr buttonCancel = mGui.findWidgetT("ListCancel"); buttonCancel->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onCancelPressed); } void onMeshOk(MyGUI::Widget* w) { MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); size_t index = list->getIndexSelected(); if (index != MyGUI::ITEM_NONE) { onMeshSelected(list, index); } } void onMeshSelected(MyGUI::List* list, size_t index) { useMesh(mFiles[index]); showLoadingMesh(false); } void useMesh(const std::string& meshName) { mRenderObject.reset(); mRenderObject.reset(new View::RenderObject ( NULL_HANDLE, mObject, meshName, v3::ZERO, qv4::IDENTITY )); mCurrentSettings.mMesh = meshName; mMeshName = meshName; Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); Ogre::Entity* ent = sceneMgr->getEntity(stringify(mObject)); onReset(); mCamDistance = ent->getBoundingRadius() * 1.5f; mSelectedSubEntity = ent->getSubEntity(0); mMaterialName = mSelectedSubEntity->getMaterialName(); updateAllInfo(); clearAdapters(); } // Material stuff void showLoadingMaterial(bool show) { unloadLoadingMenu(); if (show) { loadMaterial(); mShowingMaterialLoadingMenu = true; } } void loadMaterial() { loadLayout("ChooseListItem.layout", mLoadedMenu); fullsizePanel("MainMenuPanel"); MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); if (list) { list->eventListSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onMatSelected); Ogre::MaterialManager* matMan = Ogre::MaterialManager::getSingletonPtr(); Ogre::MaterialManager::ResourceMapIterator resIt = matMan->getResourceIterator(); mFiles.clear(); list->removeAllItems(); while(resIt.hasMoreElements()) { Ogre::MaterialPtr mat = matMan->getByHandle(resIt.peekNextKey()); list->addItem(mat->getName()); mFiles.push_back(mat->getName()); resIt.getNext(); } } MyGUI::WidgetPtr buttonOk = mGui.findWidgetT("ListOk"); buttonOk->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onMatOk); MyGUI::WidgetPtr buttonCancel = mGui.findWidgetT("ListCancel"); buttonCancel->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onCancelPressed); } void onMatOk(MyGUI::Widget* w) { MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); size_t index = list->getIndexSelected(); if (index != MyGUI::ITEM_NONE) { onMatSelected(list, index); } } void onMatSelected(MyGUI::List* list, size_t index) { const std::string& matName = list->getItemNameAt(index); useMaterial(matName); unloadLoadingMenu(); } void useMaterial(const std::string& matName) { Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); if (mSelectedSubEntity) { mSelectedSubEntity->setMaterialName(matName); } else if (sceneMgr->hasEntity(stringify(mObject))) { Ogre::Entity* ent = sceneMgr->getEntity(stringify(mObject)); ent->setMaterialName(matName); } mMaterialName = matName; updateAllInfo(); mCurrentSettings.mMaterial = matName; } // Skybox stuff void showLoadingSky(bool show) { unloadLoadingMenu(); if (show) { loadSky(); mShowingSkyLoadingMenu = true; } } void loadSky() { loadLayout("ChooseListItem.layout", mLoadedMenu); fullsizePanel("MainMenuPanel"); MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); if (list) { list->eventListSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onSkySelected); Ogre::MaterialManager* matMan = Ogre::MaterialManager::getSingletonPtr(); Ogre::MaterialManager::ResourceMapIterator resIt = matMan->getResourceIterator(); mFiles.clear(); list->removeAllItems(); std::string matName; while(resIt.hasMoreElements()) { matName = ""; Ogre::MaterialPtr mat = matMan->getByHandle(resIt.peekNextKey()); for (size_t index = 0; index < mat->getNumTechniques(); ++index) { Ogre::Technique* tech = mat->getTechnique(index); for (size_t passIndex = 0; passIndex < tech->getNumPasses(); ++passIndex) { Ogre::Pass* pass = tech->getPass(passIndex); for (size_t texIndex = 0; texIndex < pass->getNumTextureUnitStates(); ++texIndex) { Ogre::TextureUnitState* tex = pass->getTextureUnitState(texIndex); if(tex->isCubic()) matName = mat->getName(); } } } if ( (matName != "") && (matName.substr(0, 16) != BFG_SCENEMANAGER) ) { list->addItem(mat->getName()); mFiles.push_back(mat->getName()); } resIt.getNext(); } } MyGUI::WidgetPtr buttonOk = mGui.findWidgetT("ListOk"); buttonOk->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onSkyOk); MyGUI::WidgetPtr buttonCancel = mGui.findWidgetT("ListCancel"); buttonCancel->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onCancelPressed); } void onSkyOk(MyGUI::Widget* w) { MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); size_t index = list->getIndexSelected(); if (index != MyGUI::ITEM_NONE) { onSkySelected(list, index); } } void onSkySelected(MyGUI::List* list, size_t index) { mSkyName = mFiles[index]; updateAllInfo(); useSky(mSkyName); unloadLoadingMenu(); } void useSky(const std::string& skyName) { View::SkyCreation sc(skyName); setSky(sc); mCurrentSettings.mSkybox = skyName; Ogre::TextureUnitState* skyTexUnit = findAliasInMaterial("sky", skyName); if (!skyTexUnit) return; std::vector<Ogre::TextureUnitState*> texVec = findTextureAlias("Environment"); std::vector<Ogre::TextureUnitState*>::iterator it = texVec.begin(); for (; it != texVec.end(); ++it) { Ogre::TextureUnitState* tex = *it; std::string texName = skyTexUnit->getTextureName(); std::string extension = texName.substr(texName.find_last_of(".")); std::string name = texName.substr(0, texName.find("_fr")); tex->setCubicTextureName(name + extension, true); tex->setColourOperationEx(Ogre::LBX_ADD, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT); tex->setColourOpMultipassFallback(Ogre::SBF_ONE, Ogre::SBF_ONE); tex->setEnvironmentMap(true, Ogre::TextureUnitState::ENV_REFLECTION); } } std::vector<Ogre::TextureUnitState*> findTextureAlias(const std::string alias) { Ogre::MaterialManager* matMan = Ogre::MaterialManager::getSingletonPtr(); Ogre::MaterialManager::ResourceMapIterator::iterator resIt = matMan->getResourceIterator().begin(); std::vector<Ogre::TextureUnitState*> result; for (; resIt != matMan->getResourceIterator().end(); ++resIt) { Ogre::MaterialPtr mat = resIt->second; Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); while(techIt.hasMoreElements()) { Ogre::Technique* tech = techIt.getNext(); Ogre::Technique::PassIterator passIt = tech->getPassIterator(); while(passIt.hasMoreElements()) { Ogre::Pass* pass = passIt.getNext(); Ogre::Pass::TextureUnitStateIterator texIt = pass->getTextureUnitStateIterator(); while (texIt.hasMoreElements()) { Ogre::TextureUnitState* tex = texIt.getNext(); if (tex->getTextureNameAlias() == alias) { result.push_back(tex); } } } } } return result; } Ogre::TextureUnitState* findAliasInMaterial(const std::string alias, const std::string matName) { Ogre::MaterialManager* matMan = Ogre::MaterialManager::getSingletonPtr(); Ogre::MaterialPtr mat = matMan->getByName(matName); Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); while(techIt.hasMoreElements()) { Ogre::Technique* tech = techIt.getNext(); Ogre::Technique::PassIterator passIt = tech->getPassIterator(); while(passIt.hasMoreElements()) { Ogre::Pass* pass = passIt.getNext(); Ogre::Pass::TextureUnitStateIterator texIt = pass->getTextureUnitStateIterator(); while (texIt.hasMoreElements()) { Ogre::TextureUnitState* tex = texIt.getNext(); if (tex->getTextureNameAlias() == alias) { return tex; } } } } return NULL; } // Light stuff void showCreatingLight(bool show) { unloadLoadingMenu(); if (show) { loadLight("Light.layout"); mShowingLightCreatingMenu = true; } } void loadLight(const std::string& fileName) { loadLayout(fileName, mLoadedMenu); fullsizePanel("MainMenuPanel"); MyGUI::WidgetPtr dCreate = mGui.findWidgetT("dCreate"); dCreate->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::createDLight); MyGUI::WidgetPtr pCreate = mGui.findWidgetT("pCreate"); pCreate->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::createPLight); MyGUI::WidgetPtr sCreate = mGui.findWidgetT("sCreate"); sCreate->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::createSLight); // Ambient Ogre::SceneManager* sceneMgr = Ogre::Root::getSingletonPtr()->getSceneManager(BFG_SCENEMANAGER); MyGUI::WidgetPtr aSet = mGui.findWidgetT("aSet"); aSet->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::setAmbientLight); cv4 ambient = sceneMgr->getAmbientLight(); cv4ToGui("aDiff", ambient); } v3 guiEditToV3(const std::string& x, const std::string& y, const std::string& z) { MyGUI::Edit* wX = mGui.findWidget<MyGUI::Edit>(x); MyGUI::Edit* wY = mGui.findWidget<MyGUI::Edit>(y); MyGUI::Edit* wZ = mGui.findWidget<MyGUI::Edit>(z); v3 ret ( MyGUI::utility::parseValue<f32>(wX->getCaption()), MyGUI::utility::parseValue<f32>(wY->getCaption()), MyGUI::utility::parseValue<f32>(wZ->getCaption()) ); return ret; } cv4 guiToCv4(const std::string& r, const std::string& g, const std::string& b) { v3 rgb = guiEditToV3(r, g, b); return cv4(rgb.x, rgb.y, rgb.z, 1.0f); } void qv4ToGui(const std::string widgetPrefix, const qv4& ori) { const std::string wX = widgetPrefix + "X"; const std::string wY = widgetPrefix + "Y"; const std::string wZ = widgetPrefix + "Z"; const std::string wW = widgetPrefix + "W"; f32ToGuiEdit(wX, ori.x); f32ToGuiEdit(wY, ori.y); f32ToGuiEdit(wZ, ori.z); f32ToGuiEdit(wW, ori.w); } void cv4ToGui(const std::string widgetPrefix, const cv4& color) { const std::string wR = widgetPrefix + "R"; const std::string wG = widgetPrefix + "G"; const std::string wB = widgetPrefix + "B"; f32ToGuiEdit(wR, color.r); f32ToGuiEdit(wG, color.g); f32ToGuiEdit(wB, color.b); } f32 guiEditToF32(const std::string& name) { MyGUI::Edit* w = mGui.findWidget<MyGUI::Edit>(name); return MyGUI::utility::parseValue<f32>(w->getCaption()); } void f32ToGuiEdit(const std::string& name, f32 value) { MyGUI::Edit* w = mGui.findWidget<MyGUI::Edit>(name); w->setCaption(MyGUI::utility::toString(value)); } void createDLight(MyGUI::Widget* w) { View::DirectionalLightCreation dlc ( generateHandle(), guiEditToV3("dDirX", "dDirY", "dDirZ"), guiToCv4("dDiffR", "dDiffG", "dDiffB"), guiToCv4("dSpecR", "dSpecG", "dSpecB"), guiEditToF32("dPower") ); mActiveLight.reset(new View::Light(dlc)); mLights.push_back(mActiveLight); unloadLoadingMenu(); } void createPLight(MyGUI::Widget* w) { View::PointLightCreation plc ( generateHandle(), guiEditToV3("pPosX", "pPosY", "pPosZ"), guiEditToF32("pRange"), guiEditToF32("pConst"), guiEditToF32("pLinear"), guiEditToF32("pQuad"), guiToCv4("pDiffR", "pDiffG", "pDiffB"), guiToCv4("pSpecR", "pSpecG", "pSpecB"), guiEditToF32("pPower") ); mActiveLight.reset(new View::Light(plc)); mLights.push_back(mActiveLight); unloadLoadingMenu(); } void createSLight(MyGUI::Widget* w) { View::SpotLightCreation slc ( generateHandle(), guiEditToV3("sPosX", "sPosY", "sPosZ"), guiEditToV3("sDirX", "sDirY", "sDirZ"), guiEditToF32("sRange"), guiEditToF32("sConst"), guiEditToF32("sLinear"), guiEditToF32("sQuad"), guiEditToF32("sFalloff"), guiEditToF32("sInner"), guiEditToF32("sOuter"), guiToCv4("sDiffR", "sDiffG", "sDiffB"), guiToCv4("sSpecR", "sSpecG", "sSpecB"), guiEditToF32("sPower") ); mActiveLight.reset(new View::Light(slc)); mLights.push_back(mActiveLight); unloadLoadingMenu(); } void setAmbientLight(MyGUI::Widget* w) { Ogre::SceneManager* sceneMgr = Ogre::Root::getSingletonPtr()->getSceneManager(BFG_SCENEMANAGER); sceneMgr->setAmbientLight(guiToCv4("aDiffR", "aDiffG", "aDiffB")); } // Info stuff void showInfoWindow(bool show) { if (show) { loadInfo(); } else { MyGUI::LayoutManager::getInstance().unloadLayout(mInfoWindow); mInfoWindow.clear(); } mShowingInfoWindow = show; } void loadInfo() { loadLayout("infoPanel.layout", mInfoWindow); fullsizePanel("MainInfoPanel"); updateAllInfo(); } void updateAllInfo() { if (mInfoWindow.empty()) return; MyGUI::StaticText* wSky = mGui.findWidget<MyGUI::StaticText>("infoSky"); wSky->setCaption(mSkyName); MyGUI::StaticText* wLight = mGui.findWidget<MyGUI::StaticText>("infoLight"); wLight->setCaption(mLightName); MyGUI::StaticText* wMesh = mGui.findWidget<MyGUI::StaticText>("infoMesh"); wMesh->setCaption(mMeshName); MyGUI::StaticText* wSubEntity = mGui.findWidget<MyGUI::StaticText>("infoSubEntity"); wSubEntity->setCaption(mSubEntityName); MyGUI::StaticText* wMat = mGui.findWidget<MyGUI::StaticText>("infoMat"); wMat->setCaption(mMaterialName); } // submesh stuff void showSubMesh(bool show) { unloadLoadingMenu(); if (show) { loadSubMesh(); mShowingSubMeshMenu = true; } } void loadSubMesh() { loadLayout("subMesh.layout", mLoadedMenu); Ogre::SceneManager* sceneMgr = Ogre::Root::getSingletonPtr()->getSceneManager(BFG_SCENEMANAGER); if (sceneMgr->hasEntity(stringify(mObject))) { MyGUI::Window* window = mGui.findWidget<MyGUI::Window>("subMeshWindow"); MyGUI::List* list = mGui.findWidget<MyGUI::List>("subMeshList"); Ogre::Entity* ent = sceneMgr->getEntity(stringify(mObject)); Ogre::MeshPtr mesh = ent->getMesh(); std::string captionText = "SubMeshes of " + mesh->getName(); window->setCaption(captionText); const Ogre::Mesh::SubMeshNameMap subMap = mesh->getSubMeshNameMap(); Ogre::Mesh::SubMeshNameMap::const_iterator subIt = subMap.begin(); for (; subIt != subMap.end(); ++subIt) { list->addItem(subIt->first); } list->eventListSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onSubMeshSelected); } } void onSubMeshSelected(MyGUI::List* list, size_t index) { std::string subName = list->getItemNameAt(index); Ogre::SceneManager* sceneMgr = Ogre::Root::getSingletonPtr()->getSceneManager(BFG_SCENEMANAGER); if (sceneMgr->hasEntity(stringify(mObject))) { Ogre::Entity* ent = sceneMgr->getEntity(stringify(mObject)); mSelectedSubEntity = ent->getSubEntity(subName); mSubEntityName = subName; mMaterialName = mSelectedSubEntity->getMaterialName(); updateAllInfo(); } unloadLoadingMenu(); } void showTextureUnits(bool show) { unloadLoadingMenu(); if (show) { loadTextureUnitMenu(); mShowingTextureUnitMenu = true; } } void loadTextureUnitMenu() { loadLayout("texUnit.layout", mLoadedMenu); MyGUI::ItemBox* box = mGui.findWidget<MyGUI::ItemBox>("itemBox"); if (mObject == NULL_HANDLE) return; if (mMaterialName == "") return; Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(mMaterialName); Ogre::Technique* tech = mat->getSupportedTechnique(0); unsigned int height = 0; Ogre::Technique::PassIterator passIt = tech->getPassIterator(); while (passIt.hasMoreElements()) { Ogre::Pass* pass = passIt.getNext(); std::stringstream passName; passName << "Pass: " << pass->getName() << " (" << pass->getIndex() << ")"; MyGUI::StaticText* staticText = box->createWidget<MyGUI::StaticText>("StaticText", 2, height, 374, 16, MyGUI::Align::Default); staticText->setCaption(passName.str()); staticText->setTextColour(MyGUI::Colour::White); height += 16; Ogre::Pass::TextureUnitStateIterator texIt = pass->getTextureUnitStateIterator(); while (texIt.hasMoreElements()) { Ogre::TextureUnitState* tex = texIt.getNext(); std::string texName = tex->getTextureName(); f32 texBias = tex->getTextureMipmapBias(); TextureUnitChange* tuc = findChanges(mMaterialName, tex->getTextureNameAlias()); MyGUI::Widget* panel = box->createWidgetT("Widget", "Transparent", 0, height, 504, 70, MyGUI::Align::Default); MyGUI::StaticText* staticText = panel->createWidget<MyGUI::StaticText>("StaticText", 2, 4, 374, 16, MyGUI::Align::Default); MyGUI::Button* checkButton = panel->createWidget<MyGUI::Button>("CheckBox", 2, 22, 64, 22, MyGUI::Align::Default, "unitEnabled"); MyGUI::Edit* edit = panel->createWidget<MyGUI::Edit>("Edit", 68, 22, 310, 22, MyGUI::Align::Default, "texUnitName"); MyGUI::StaticText* staticTextBias = panel->createWidget<MyGUI::StaticText>("StaticText", 2, 46, 64, 22, MyGUI::Align::Default); MyGUI::Edit* editBias = panel->createWidget<MyGUI::Edit>("Edit", 68, 46, 64, 22, MyGUI::Align::Default, "texUnitBias"); checkButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onMapEnabled); edit->eventEditSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onMaterialChanged); editBias->eventEditSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onBiasChanged); checkButton->setEnabled(true); checkButton->setCaption("on"); staticTextBias->setCaption("Bias"); staticTextBias->setTextColour(MyGUI::Colour::White); staticText->setCaption(tex->getTextureNameAlias()); staticText->setTextColour(MyGUI::Colour::White); editBias->setUserString("Material", mMaterialName); editBias->setUserString("Alias", tex->getTextureNameAlias()); editBias->setCaption(MyGUI::utility::toString(texBias)); edit->setUserString("Material", mMaterialName); edit->setUserString("Alias", tex->getTextureNameAlias()); edit->setCaption(texName); if (tuc) { checkButton->setStateCheck(tuc->mEnabled); edit->setUserString("SelectedMat", tuc->mTexture); edit->setEnabled(tuc->mEnabled); } else { checkButton->setStateCheck(true); edit->setUserString("SelectedMat", texName); } if (tex->getTextureNameAlias() == "TextureMap" || tex->getTextureNameAlias() == "aoMap" || tex->getTextureNameAlias() == "SpecularMap") { edit->setUserString("DefaultMat", "white.png"); } else if (tex->getTextureNameAlias() == "NormalMap") { edit->setUserString("DefaultMat", "flat_n.png"); } else if (tex->getTextureNameAlias() == "IlluminationMap") { edit->setUserString("DefaultMat", "black.png"); } height += 70; } } } void onBiasChanged(MyGUI::Edit* sender) { if (mMaterialName.empty()) return; Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(mMaterialName); Ogre::Technique* tech = mat->getSupportedTechnique(0); Ogre::Technique::PassIterator passIt = tech->getPassIterator(); while (passIt.hasMoreElements()) { Ogre::Pass* pass = passIt.getNext(); Ogre::TextureUnitState* tex = pass->getTextureUnitState(sender->getUserString("Alias")); if (tex) tex->setTextureMipmapBias(MyGUI::utility::parseValue<f32>(sender->getCaption())); } } void onMaterialChanged(MyGUI::Edit* sender) { if (mMaterialName.empty()) return; Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(mMaterialName); Ogre::Technique* tech = mat->getSupportedTechnique(0); Ogre::Technique::PassIterator passIt = tech->getPassIterator(); while (passIt.hasMoreElements()) { Ogre::Pass* pass = passIt.getNext(); Ogre::TextureUnitState* tex = pass->getTextureUnitState(sender->getUserString("Alias")); if (tex) tex->setTextureName(sender->getCaption()); } } void onMapEnabled(MyGUI::Widget* sender) { MyGUI::Button* button = sender->castType<MyGUI::Button>(); MyGUI::Widget* parent = button->getParent(); MyGUI::Edit* edit = parent->findWidget("texUnitName")->castType<MyGUI::Edit>(); if(button->getStateCheck()) { TextureUnitChange* tuc = findChanges(edit->getUserString("Material"), edit->getUserString("Alias")); if (!tuc) { tuc = new TextureUnitChange; tuc->mMaterial = edit->getUserString("Material"); tuc->mAlias = edit->getUserString("Alias"); mTextureChanges.push_back(tuc); } tuc->mTexture = edit->getCaption(); tuc->mEnabled = false; button->setStateCheck(false); edit->setUserString("SelectedMat", edit->getCaption()); edit->setCaption(edit->getUserString("DefaultMat")); edit->setEnabled(false); } else { TextureUnitChange* tuc = findChanges(edit->getUserString("Material"), edit->getUserString("Alias")); if (tuc) { edit->setCaption(tuc->mTexture); tuc->mEnabled = true; } else { edit->setCaption(edit->getUserString("SelectedMat")); } button->setStateCheck(true); edit->setEnabled(true); } onMaterialChanged(edit); } TextureUnitChange* findChanges(const std::string& material, const std::string& alias) { std::vector<TextureUnitChange*>::iterator tucIt = mTextureChanges.begin(); for (; tucIt != mTextureChanges.end(); ++tucIt) { TextureUnitChange* tuc = *(tucIt); if (tuc->mMaterial == material && tuc->mAlias == alias ) { return tuc; } } return NULL; } // animation stuff void showAnimation(bool show) { unloadLoadingMenu(); if (show) { loadAnimationWindow(); } } void loadAnimationWindow() { if (!mRenderObject) return; Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); if (sceneMgr == NULL) return; Ogre::Entity* ent = sceneMgr->getEntity(stringify(mObject)); if (ent == NULL) return; Ogre::AnimationStateSet* animStateSet = ent->getAllAnimationStates(); if (!animStateSet) { errlog << "No animation found in mesh " << mMeshName; return; } loadLayout("Animation.layout", mLoadedMenu); MyGUI::ComboBox* statesBox = mGui.findWidget<MyGUI::ComboBox>("animStates"); Ogre::AnimationStateIterator animStateIt = animStateSet->getAnimationStateIterator(); while(animStateIt.hasMoreElements()) { Ogre::AnimationState* state = animStateIt.getNext(); statesBox->addItem(state->getAnimationName()); } statesBox->eventComboChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onAnimationSelected); MyGUI::HScroll* slider = mGui.findWidget<MyGUI::HScroll>("animSlider"); slider->eventScrollChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onChangeSliderPosition); MyGUI::Button* playButton = mGui.findWidget<MyGUI::Button>("bPlay"); playButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onPlayPressed); MyGUI::Button* pauseButton = mGui.findWidget<MyGUI::Button>("bPause"); pauseButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onPausePressed); MyGUI::Button* stopButton = mGui.findWidget<MyGUI::Button>("bStop"); stopButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onStopPressed); mShowingAnimationMenu = true; } void onAnimationSelected(MyGUI::ComboBox* sender, size_t index) { if (mAnimationState) { mAnimationState->setEnabled(false); mAnimationState->setTimePosition(0.0f); } std::string stateName = sender->getItemNameAt(index); if (stateName.empty()) return; Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); Ogre::Entity* ent = sceneMgr->getEntity(stringify(mObject)); mAnimationState = ent->getAnimationState(stateName); mAnimationState->setEnabled(true); } void onChangeSliderPosition(MyGUI::VScroll* sender, size_t newPos) { if (mAnimationState) { f32 length = mAnimationState->getLength(); size_t sliderLength = sender->getScrollRange() - 1; f32 timePos = length * ((f32)newPos / (f32)sliderLength); mAnimationState->setTimePosition(timePos); } } void onPlayPressed(MyGUI::Widget* sender) { if (mAnimationState) { mAnimationLoop = true; } } void onPausePressed(MyGUI::Widget* sender) { if (mAnimationState) { mAnimationLoop = false; } } void onStopPressed(MyGUI::Widget* sender) { if (mAnimationState) { mAnimationLoop = false; mAnimationState->setTimePosition(0.0f); MyGUI::HScroll* slider = mGui.findWidget<MyGUI::HScroll>("animSlider"); slider->setScrollPosition(0); } } void pickPosition() { MyGUI::InputManager* inputMan = MyGUI::InputManager::getInstancePtr(); Ogre::SceneManager* sceneMan = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); // Get mouse position const MyGUI::IntPoint& mousePos = inputMan->getMousePosition(); MyGUI::IntSize size = mGui.getViewSize(); f32 x = (f32)mousePos.left / (f32)size.width; f32 y = (f32)mousePos.top / (f32)size.height; // Get ray from camera Ogre::Camera* cam = sceneMan->getCamera(stringify(mCamHandle)); Ogre::Ray mouseRay = cam->getCameraToViewportRay(x, y); BFG::Mesh* mesh = new BFG::Mesh(BFG::View::loadMesh(mMeshName)); // Test if ray intersects with polygons f32 distance = std::numeric_limits<float>::max(); Ogre::Vector3 normal; u32 lastIndex = mesh->mIndexCount - 2; for (u32 i = 0; i < lastIndex; ++i) { u32 index1 = mesh->mIndices[i]; u32 index2 = mesh->mIndices[i+1]; u32 index3 = mesh->mIndices[i+2]; std::pair<bool, Ogre::Real> result = Ogre::Math::intersects ( mouseRay, BFG::View::toOgre(mesh->mVertices[index1]), BFG::View::toOgre(mesh->mVertices[index2]), BFG::View::toOgre(mesh->mVertices[index3]), true, false ); if (result.first) { if (result.second < distance) { distance = result.second; Ogre::Plane p ( BFG::View::toOgre(mesh->mVertices[index1]), BFG::View::toOgre(mesh->mVertices[index2]), BFG::View::toOgre(mesh->mVertices[index3]) ); normal = p.normal; } } } // only select polygons in front of the camera (no hits = max float value) if (distance > EPSILON_F && distance < std::numeric_limits<float>::max()) { Ogre::Vector3 pos(mouseRay.getPoint(distance)); Ogre::Quaternion rot1 = Ogre::Vector3::UNIT_Y.getRotationTo(Ogre::Vector3(normal.x, normal.y, 0.0f), Ogre::Vector3::UNIT_Z); Ogre::Quaternion rot2 = rot1.yAxis().getRotationTo(normal, rot1.xAxis()); Ogre::Quaternion rot = rot2 * rot1; showMarker(true, pos, rot); } else { showMarker(false); } } void showMarker(bool show, const Ogre::Vector3& position = Ogre::Vector3::ZERO, const Ogre::Quaternion& orientation = Ogre::Quaternion::IDENTITY) { mPickingNode->setVisible(show); mPickingNode->setPosition(position); mPickingNode->setOrientation(orientation); } void showAdapter(bool show) { unloadLoadingMenu(); if (show) { loadAdapterWindow(); } } void loadAdapterWindow() { if (!mRenderObject) return; Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); if (sceneMgr == NULL) return; loadLayout("Adapter.layout", mLoadedMenu); MyGUI::ComboBox* nameBox = mGui.findWidget<MyGUI::ComboBox>("name"); nameBox->eventComboChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onAdapterNameChanged); AdapterMapT::iterator mapIt = mAdapters.begin(); for(; mapIt != mAdapters.end(); ++mapIt) { nameBox->addItem(mapIt->first); } nameBox->setIndexSelected(nameBox->findItemIndexWith(mSelectedAdapterGroup)); nameBox->beginToItemSelected(); MyGUI::Button* newGroupButton = mGui.findWidget<MyGUI::Button>("newGroup"); newGroupButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onNewGroupClicked); // new button MyGUI::Button* newButton = mGui.findWidget<MyGUI::Button>("newAdapter"); newButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onNewAdapter); // Adapter selection comboBox MyGUI::ComboBox* adapterBox = mGui.findWidget<MyGUI::ComboBox>("adapterSelect"); std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; for (size_t i = 0; i < adapterVec.size(); ++i) { adapterBox->addItem(MyGUI::utility::toString(i + 1)); } adapterBox->eventComboChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onAdapterSelected); // Adapter Position MyGUI::Edit* positionEdit = mGui.findWidget<MyGUI::Edit>("position"); positionEdit->eventEditSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onPositionChanged); // Select adapter position via mouse click MyGUI::Button* mousePos = mGui.findWidget<MyGUI::Button>("mousePos"); mousePos->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onMousePos); MyGUI::Edit* pitchEdit = mGui.findWidget<MyGUI::Edit>("pitch"); pitchEdit->eventEditSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onPitchChange); MyGUI::Edit* yawEdit = mGui.findWidget<MyGUI::Edit>("yaw"); yawEdit->eventEditSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onYawChange); MyGUI::Edit* rollEdit = mGui.findWidget<MyGUI::Edit>("roll"); rollEdit->eventEditSelectAccept = MyGUI::newDelegate(this, &ViewComposerState::onRollChange); MyGUI::Button* saveAsButton = mGui.findWidget<MyGUI::Button>("saveAs"); saveAsButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onSaveAsClicked); MyGUI::Button* loadButton = mGui.findWidget<MyGUI::Button>("load"); loadButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onLoadClicked); MyGUI::Button* appendButton = mGui.findWidget<MyGUI::Button>("append"); appendButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onAppendClicked); MyGUI::Button* clearButton = mGui.findWidget<MyGUI::Button>("clear"); clearButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onClearClicked); mShowingAdapterMenu = true; if (mSelectedAdapterGroup == "") { enableFields(false); } if (mPositionAdapter) { size_t itemIndex = nameBox->findItemIndexWith(mSelectedAdapterGroup); if (itemIndex == MyGUI::ITEM_NONE) { mSelectedAdapterGroup = ""; itemIndex = 0; } nameBox->setIndexSelected(itemIndex); nameBox->beginToItemSelected(); std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; BFG::Adapter& adapter = adapterVec.at(mAdapterSelected - 1); adapter.mParentPosition = BFG::View::toBFG(mPickingNode->getPosition()); adapter.mParentOrientation = BFG::View::toBFG(mPickingNode->getOrientation()); adapterBox->setIndexSelected(mAdapterSelected - 1); onAdapterSelected(adapterBox, mAdapterSelected - 1); mPositionAdapter = false; } } void enableFields(bool enable) { std::vector<std::string> fieldNames; fieldNames.push_back("newAdapter"); fieldNames.push_back("adapterSelect"); fieldNames.push_back("position"); fieldNames.push_back("qX"); fieldNames.push_back("qY"); fieldNames.push_back("qZ"); fieldNames.push_back("qW"); fieldNames.push_back("mousePos"); fieldNames.push_back("pitch"); fieldNames.push_back("yaw"); fieldNames.push_back("roll"); std::vector<std::string>::iterator it = fieldNames.begin(); for (; it != fieldNames.end(); ++it) { MyGUI::Widget* w = mGui.findWidgetT(*it); w->setEnabled(enable); } } void onNewGroupClicked(MyGUI::Widget* sender) { MyGUI::Edit* newGroupEdit = mGui.findWidget<MyGUI::Edit>("newGroupEdit"); std::string name = newGroupEdit->getCaption(); if (name == "") return; MyGUI::ComboBox* groupCombo = mGui.findWidget<MyGUI::ComboBox>("name"); size_t index = groupCombo->findItemIndexWith(name); if (index == MyGUI::ITEM_NONE) { groupCombo->addItem(name); index = groupCombo->findItemIndexWith(name); mAdapters[name] = std::vector<BFG::Adapter>(); mSelectedAdapterGroup = name; } onAdapterNameChanged(groupCombo, index); } void onPitchChange(MyGUI::Edit* sender) { f32 pitchVal = MyGUI::utility::parseFloat(sender->getCaption()); mPickingNode->pitch(Ogre::Degree(pitchVal)); updateGuiOri(); } void onYawChange(MyGUI::Edit* sender) { f32 yawVal = MyGUI::utility::parseFloat(sender->getCaption()); mPickingNode->yaw(Ogre::Degree(yawVal)); updateGuiOri(); } void onRollChange(MyGUI::Edit* sender) { f32 rollVal = MyGUI::utility::parseFloat(sender->getCaption()); mPickingNode->roll(Ogre::Degree(rollVal)); updateGuiOri(); } void updateGuiOri() { std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; BFG::Adapter& adapter = adapterVec.at(mAdapterSelected - 1); adapter.mParentOrientation = BFG::View::toBFG(mPickingNode->getOrientation()); qv4ToGui("q", adapter.mParentOrientation); } void onSaveAsClicked(MyGUI::Widget* sender) { fileDialog.setDialogInfo("Save Adapter", "Save", MyGUI::newDelegate(this, &ViewComposerState::saveAdapter)); fileDialog.setVisible(true); } void onLoadClicked(MyGUI::Widget* sender) { fileDialog.setDialogInfo("Load Adapter", "Load", MyGUI::newDelegate(this, &ViewComposerState::loadAdapterClicked)); fileDialog.setVisible(true); } void onAppendClicked(MyGUI::Widget* sender) { fileDialog.setDialogInfo("Append Adapter to", "Append", MyGUI::newDelegate(this, &ViewComposerState::appendAdapter)); fileDialog.setVisible(true); } // Adapter stuff void saveAdapter(MyGUI::Widget* sender) { TiXmlDocument document; TiXmlDeclaration* declaration = new TiXmlDeclaration("1.0", "utf-8", "" ); document.LinkEndChild(declaration); TiXmlElement* adapterConfigs = new TiXmlElement("AdapterConfigs"); document.LinkEndChild(adapterConfigs); AdapterMapT::iterator mapIt = mAdapters.begin(); for (; mapIt != mAdapters.end(); ++mapIt) { TiXmlElement* adapters = new TiXmlElement("AdapterConfig"); adapters->SetAttribute("name", mapIt->first); adapterConfigs->LinkEndChild(adapters); std::vector<BFG::Adapter>& adapterVec = mapIt->second; std::vector<BFG::Adapter>::iterator it = adapterVec.begin(); for (; it != adapterVec.end(); ++it) { v3 pos = (*it).mParentPosition; TiXmlElement* adapter = new TiXmlElement("Adapter"); adapter->SetAttribute ( "id", (*it).mIdentifier ); adapter->SetAttribute ( "position", MyGUI::utility::toString ( pos.x, ", ", pos.y, ", ", pos.z ) ); qv4 ori = (*it).mParentOrientation; adapter->SetAttribute ( "orientation", MyGUI::utility::toString ( ori.w, ", ", ori.x, ", ", ori.y, ", ", ori.z ) ); adapters->LinkEndChild(adapter); } } document.SaveFile(fileDialog.getFileName()); fileDialog.setVisible(false); } void loadAdapterClicked(MyGUI::Widget* sender) { std::string filename = fileDialog.getFileName(); mAdapters.clear(); mAdapterSelected = 0; loadAdapter(filename, mAdapters); fileDialog.setVisible(false); showAdapter(false); showAdapter(true); } void loadAdapter(const std::string& filename, AdapterMapT& adapterMap) { TiXmlDocument doc(filename); if (!doc.LoadFile()) { throw std::runtime_error("Could not load " + filename); } TiXmlElement* adapterConfigs = doc.FirstChildElement("AdapterConfigs"); TiXmlElement* adapterConfig = adapterConfigs->FirstChildElement("AdapterConfig"); for (; adapterConfig != NULL; adapterConfig = adapterConfig->NextSiblingElement("AdapterConfig")) { std::string name(adapterConfig->Attribute("name")); std::vector<BFG::Adapter> adapterVector; TiXmlElement* adapter = adapterConfig->FirstChildElement("Adapter"); for (; adapter != NULL; adapter = adapter->NextSiblingElement("Adapter")) { BFG::Adapter a; a.mIdentifier = MyGUI::utility::parseUInt(adapter->Attribute("id")); BFG::stringToVector3(adapter->Attribute("position"), a.mParentPosition); BFG::stringToQuaternion4(adapter->Attribute("orientation"), a.mParentOrientation); adapterVector.push_back(a); } adapterMap[name] = adapterVector; } } void appendAdapter(MyGUI::Widget* sender) { std::string filename = fileDialog.getFileName(); TiXmlDocument doc(filename); if (!doc.LoadFile()) { throw std::runtime_error("Could not open " + filename); } TiXmlElement* adapterConfigs = doc.FirstChildElement("AdapterConfigs"); if (!adapterConfigs) { throw std::runtime_error("This is not an adapter file!"); } AdapterMapT::iterator mapIt = mAdapters.begin(); for (; mapIt != mAdapters.end(); ++mapIt) { bool nameFound = false; int lastId = 0; TiXmlElement* adapterConfig = adapterConfigs->FirstChildElement("AdapterConfig"); for (; adapterConfig != NULL; adapterConfig = adapterConfig->NextSiblingElement("AdapterConfig")) { std::string name(adapterConfig->Attribute("name")); if (name == mapIt->first) { nameFound = true; TiXmlElement* adapter = adapterConfig->FirstChildElement("Adapter"); do { adapter->Attribute("id", &lastId); adapter = adapter->NextSiblingElement("Adapter"); } while (adapter); break; } } if (!nameFound) { adapterConfig = new TiXmlElement("AdapterConfig"); adapterConfig->SetAttribute("name", mapIt->first); adapterConfigs->LinkEndChild(adapterConfig); } std::vector<BFG::Adapter>& adapterVec = mapIt->second; std::vector<BFG::Adapter>::iterator it = adapterVec.begin(); for (; it != adapterVec.end(); ++it) { v3 pos = (*it).mParentPosition; TiXmlElement* adapter = new TiXmlElement("Adapter"); adapter->SetAttribute ( "id", (*it).mIdentifier + lastId ); adapter->SetAttribute ( "position", MyGUI::utility::toString ( pos.x, ", ", pos.y, ", ", pos.z ) ); qv4 ori = (*it).mParentOrientation; adapter->SetAttribute ( "orientation", MyGUI::utility::toString ( ori.w, ", ", ori.x, ", ", ori.y, ", ", ori.z ) ); adapterConfig->LinkEndChild(adapter); } } doc.SaveFile(filename); fileDialog.setVisible(false); } void onClearClicked(MyGUI::Widget* sender) { mAdapters.clear(); mAdapterSelected = 0; mSelectedAdapterGroup = ""; showAdapter(false); showAdapter(true); } void onAdapterNameChanged(MyGUI::ComboBox* list, size_t index) { if (index == MyGUI::ITEM_NONE) { enableFields(false); return; } mSelectedAdapterGroup = list->getItemNameAt(index); list->setIndexSelected(index); list->beginToItemSelected(); enableFields(true); refreshAdapter(); } void onNewAdapter(MyGUI::Widget* sender) { std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; size_t index = adapterVec.size(); BFG::Adapter adapter; adapter.mIdentifier = index + 1; adapterVec.push_back(adapter); refreshAdapter(); MyGUI::ComboBox* adapterBox = mGui.findWidget<MyGUI::ComboBox>("adapterSelect"); adapterBox->setIndexSelected(index); onAdapterSelected(adapterBox, index); } void refreshAdapter() { std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; MyGUI::ComboBox* adapterBox = mGui.findWidget<MyGUI::ComboBox>("adapterSelect"); adapterBox->removeAllItems(); adapterBox->setCaption(""); std::vector<BFG::Adapter>::iterator it = adapterVec.begin(); for (; it != adapterVec.end(); ++it) { Adapter& adapter = *it; adapterBox->addItem(MyGUI::utility::toString(adapter.mIdentifier)); } refreshAdapterFields(); } void onAdapterSelected(MyGUI::ComboBox* sender, size_t index) { std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; BFG::Adapter& adapter = adapterVec.at(index); MyGUI::Edit* positionEdit = mGui.findWidget<MyGUI::Edit>("position"); positionEdit->setCaption(MyGUI::utility::toString(adapter.mParentPosition.x, " ", adapter.mParentPosition.y, " ", adapter.mParentPosition.z)); qv4ToGui("q", adapter.mParentOrientation); mAdapterSelected = index + 1; showMarker(true, BFG::View::toOgre(adapter.mParentPosition), BFG::View::toOgre(adapter.mParentOrientation)); } void refreshAdapterFields() { clearEdit("position"); clearEdit("qX"); clearEdit("qY"); clearEdit("qZ"); clearEdit("qW"); } void clearEdit(const std::string name) { MyGUI::Edit* w = mGui.findWidget<MyGUI::Edit>(name); w->setCaption(""); } void onPositionChanged(MyGUI::Edit* sender) { if (!mAdapterSelected) return; std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; BFG::Adapter& adapter = adapterVec.at(mAdapterSelected-1); adapter.mParentPosition = MyGUI::utility::parseValueEx3<v3, f32>(sender->getCaption()); showMarker(true, BFG::View::toOgre(adapter.mParentPosition), BFG::View::toOgre(adapter.mParentOrientation)); } void onMousePos(MyGUI::Widget* sender) { if (!mAdapterSelected) return; mPositionAdapter = true; unloadLoadingMenu(); } void clearAdapters() { showMarker(false); mAdapters.clear(); mAdapterSelected = 0; mPositionAdapter = false; } void showPreview(bool show) { unloadLoadingMenu(); if (show) { loadPreviewMenu(); mShowingPreviewMenu = true; } } void loadPreviewMenu() { Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER); if (sceneMgr == NULL) return; loadLayout("Preview.layout", mLoadedMenu); MyGUI::Button* loadMeshButton = mGui.findWidget<MyGUI::Button>("loadMesh"); loadMeshButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onLoadPreviewMesh); MyGUI::Button* loadAdapterButton = mGui.findWidget<MyGUI::Button>("loadAdapter"); loadAdapterButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onLoadPreviewAdapter); mGroupName = mGui.findWidget<MyGUI::ComboBox>("groupName"); mGroupName->eventComboChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onGroupNameSelected); mParentAdapter = mGui.findWidget<MyGUI::ComboBox>("parent"); mParentAdapter->eventComboChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onParentSelected); std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; std::vector<BFG::Adapter>::iterator it = adapterVec.begin(); for (; it != adapterVec.end(); ++it) { BFG::Adapter& adapter = *it; mParentAdapter->addItem(MyGUI::utility::toString(adapter.mIdentifier)); } mChildAdapter = mGui.findWidget<MyGUI::ComboBox>("child"); mChildAdapter->eventComboChangePosition = MyGUI::newDelegate(this, &ViewComposerState::onChildSelected); MyGUI::Button* setPreviewButton = mGui.findWidget<MyGUI::Button>("setPreview"); setPreviewButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ViewComposerState::onSetPreview); mShowingPreviewMenu = true; } void onLoadPreviewMesh(MyGUI::Widget* sender) { showPredefinedFiles ( mPreviewMeshMenu, ID::P_GRAPHICS_MESHES, MyGUI::newDelegate(this, &ViewComposerState::onLoadPreviewMeshOk), MyGUI::newDelegate(this, &ViewComposerState::onLoadPreviewMeshSelected) ); } void onLoadPreviewMeshOk(MyGUI::Widget* sender) { MyGUI::List* list = mGui.findWidget<MyGUI::List>("ItemList"); size_t index = list->getIndexSelected(); if (index != MyGUI::ITEM_NONE) { onLoadPreviewMeshSelected(list, index); } } void onLoadPreviewMeshSelected(MyGUI::List* list, size_t index) { mPreviewMeshName = list->getItemNameAt(index); if (!mPreviewMeshMenu.empty()) { MyGUI::LayoutManager::getInstance().unloadLayout(mPreviewMeshMenu); mPreviewMeshMenu.clear(); } } void onLoadPreviewAdapter(MyGUI::Widget* sender) { fileDialog.setDialogInfo ( "Load Preview Adapter", "Load", MyGUI::newDelegate(this, &ViewComposerState::onLoadPreviewAdapterSelected) ); fileDialog.setVisible(true); } void onLoadPreviewAdapterSelected(MyGUI::Widget* sender) { std::string fileName = fileDialog.getFileName(); mPreviewAdapter.clear(); loadAdapter(fileName, mPreviewAdapter); mGroupName->removeAllItems(); AdapterMapT::iterator groupIt = mPreviewAdapter.begin(); for (; groupIt != mPreviewAdapter.end(); ++groupIt) { mGroupName->addItem(groupIt->first); } fileDialog.setVisible(false); } void onSetPreview(MyGUI::Widget* sender) { destroyGameObject(); createGameObject(); mPreviewRenderObject.reset(); mPreviewRenderObject.reset(new View::RenderObject ( mObject, mPreviewObject, mPreviewMeshName, v3::ZERO, qv4::IDENTITY )); boost::shared_ptr<BFG::Module> module; module.reset(new BFG::Module(mPreviewObject)); std::vector<BFG::Adapter>& adapterVec = mPreviewAdapter[mSelectedPreviewAdapterGroup]; mMainObject->attachModule(module, adapterVec, mSelectedPreviewAdapter, mObject, mAdapterSelected); } void onGroupNameSelected(MyGUI::ComboBox* sender, size_t index) { mSelectedPreviewAdapterGroup = sender->getItemNameAt(index); std::vector<BFG::Adapter>& adapterVec = mPreviewAdapter[mSelectedPreviewAdapterGroup]; MyGUI::ComboBox* childAdapter = mGui.findWidget<MyGUI::ComboBox>("child"); std::vector<BFG::Adapter>::iterator it = adapterVec.begin(); for (; it != adapterVec.end(); ++it) { BFG::Adapter& adapter = *it; childAdapter->addItem(MyGUI::utility::toString(adapter.mIdentifier)); } } void onParentSelected(MyGUI::ComboBox* sender, size_t index) { } void onChildSelected(MyGUI::ComboBox* sender, size_t index) { mSelectedPreviewAdapter = MyGUI::utility::parseUInt(sender->getItemNameAt(index)); } void createGameObject() { // Create Property Plugin (Space) BFG::PluginId spId = BFG::ValueId::ENGINE_PLUGIN_ID; boost::shared_ptr<BFG::SpacePlugin> sp(new BFG::SpacePlugin(spId)); BFG::Property::PluginMapT plugMap; plugMap.insert(sp); mMainObject = new BFG::GameObject(mLoop, mObject, "Test", plugMap, mEnvironment); boost::shared_ptr<BFG::Module> module; module.reset(new BFG::Module(mObject)); std::vector<BFG::Adapter>& adapterVec = mAdapters[mSelectedAdapterGroup]; mMainObject->attachModule(module, adapterVec, 0, NULL_HANDLE, 0); } void destroyGameObject() { if (mMainObject) delete mMainObject; } void addPreviewModule(const GameHandle moduleHandle, const std::vector<BFG::Adapter>& adapterList, const u32 childAdapterID, const u32 parentAdapterID) { boost::shared_ptr<BFG::Module> module; module.reset(new BFG::Module(moduleHandle)); mMainObject->attachModule(module, adapterList, childAdapterID, mObject, parentAdapterID); saveConnection(moduleHandle, childAdapterID, parentAdapterID); } void saveConnection(const GameHandle moduleHandle, const u32 adapterID, const u32 parentAdapterID) { std::map<GameHandle, ConnectionData*>::iterator conIt = mPreviewConnections.find(moduleHandle); if (conIt != mPreviewConnections.end()) { ConnectionData* connection = conIt->second; connection->mAdapterID = adapterID; connection->mParentAdapterID = parentAdapterID; } } void removePreviewModule(const GameHandle moduleHandle) { mMainObject->detachModule(moduleHandle); } void updatePreview() { //std::vector<GameHandle>::iterator previewIt = mPreviewObjects.begin(); //for(; previewIt != mPreviewObjects.end(); ++previewIt) //{ // removePreviewModule(*previewIt); // // todo attachModule(parameter...) //} } void onReset() { mCameraRotation->setOrientation(Ogre::Quaternion::IDENTITY); } void viewEventHandler(View::Event* VE) { dbglog << VE->getId(); } bool frameStarted(const Ogre::FrameEvent& evt) { return true; } bool frameRenderingQueued(const Ogre::FrameEvent& evt) { if (mCamOrbit) { mCameraRotation->rotate ( Ogre::Vector3::UNIT_Y, Ogre::Radian(mDeltaRot.y) * evt.timeSinceLastFrame, Ogre::Node::TS_WORLD ); mCameraRotation->rotate ( Ogre::Vector3::UNIT_X, Ogre::Radian(mDeltaRot.x) * evt.timeSinceLastFrame, Ogre::Node::TS_WORLD ); } else { mCameraRotation->yaw(Ogre::Radian(mDeltaRot.y) * evt.timeSinceLastFrame); mCameraRotation->pitch(Ogre::Radian(mDeltaRot.x) * evt.timeSinceLastFrame); mCameraRotation->roll(Ogre::Radian(mDeltaRot.z) * evt.timeSinceLastFrame); } mCamDistance += mDeltaDis * evt.timeSinceLastFrame; if (mCamDistance <= 1.0f) mCamDistance = 1.0f; mCameraDistance->setPosition(0.0f, 0.0f, -mCamDistance); mDeltaRot = v3::ZERO; if (!mIsZooming) { mDeltaDis = 0.0f; } // animation if (mAnimationState) { if (mAnimationLoop) { MyGUI::HScroll* animSlider = mGui.findWidget<MyGUI::HScroll>("animSlider"); mAnimationState->addTime(evt.timeSinceLastEvent); f32 pos = mAnimationState->getTimePosition(); f32 length = mAnimationState->getLength(); size_t sliderLength = animSlider->getScrollRange(); size_t sliderPos = (sliderLength - 1) * (pos / length); animSlider->setScrollPosition(sliderPos); } } return true; } bool frameEnded(const Ogre::FrameEvent& evt) { return true; } private: void registerEventHandler() { } void unregisterEventHandler() { } virtual void pause(){ registerEventHandler(); } virtual void resume(){ unregisterEventHandler(); } BFG::GameObject* mMainObject; MyGUI::Gui& mGui; MyGUI::VectorWidgetPtr mLoadedMenu; MyGUI::VectorWidgetPtr mInfoWindow; MyGUI::VectorWidgetPtr mGuiButtons; std::vector<std::string> mFiles; GameHandle mObject; GameHandle mCamHandle; boost::shared_ptr<View::RenderObject> mRenderObject; BFG::View::ControllerMyGuiAdapter mControllerAdapter; std::vector<boost::shared_ptr<View::Light> > mLights; boost::shared_ptr<View::Light> mActiveLight; Ogre::SceneNode* mCameraPosition; Ogre::SceneNode* mCameraRotation; Ogre::SceneNode* mCameraDistance; Ogre::SceneNode* mPickingNode; Ogre::SubEntity* mSelectedSubEntity; v3 mDeltaRot; f32 mDeltaDis; f32 mCamDistance; bool mCamOrbit; bool mInfoChanged; bool mMouseCamPitchYaw; bool mMouseCamRoll; bool mIsZooming; bool mShowingMeshLoadingMenu; bool mShowingMaterialLoadingMenu; bool mShowingSkyLoadingMenu; bool mShowingLightCreatingMenu; bool mShowingInfoWindow; bool mShowingSubMeshMenu; bool mShowingTextureUnitMenu; bool mShowingAnimationMenu; bool mShowingAdapterMenu; bool mShowingPreviewMenu; bool mShowingLoadPreviewMeshMenu; bool mShowingLoadPreviewAdapterMenu; std::string mSkyName; std::string mLightName; std::string mMeshName; std::string mSubEntityName; std::string mMaterialName; std::string mAdapterGroupName; Settings mCurrentSettings; std::vector<TextureUnitChange*> mTextureChanges; bool mAnimationLoop; Ogre::AnimationState* mAnimationState; bool mPositionAdapter; AdapterMapT mAdapters; size_t mAdapterSelected; std::string mSelectedAdapterGroup; bool mMenuFocus; OpenSaveDialog fileDialog; // Preview boost::shared_ptr<BFG::Environment> mEnvironment; EventLoop* mLoop; std::map<GameHandle, ConnectionData*> mPreviewConnections; std::map<GameHandle, boost::shared_ptr<BFG::View::RenderObject> > mRenderObjects; MyGUI::ComboBox* mGroupName; MyGUI::ComboBox* mParentAdapter; MyGUI::ComboBox* mChildAdapter; MyGUI::VectorWidgetPtr mPreviewMeshMenu; std::string mPreviewMeshName; AdapterMapT mPreviewAdapter; size_t mSelectedPreviewAdapter; std::string mSelectedPreviewAdapterGroup; GameHandle mPreviewObject; boost::shared_ptr<View::RenderObject> mPreviewRenderObject; }; // This is the Ex-'GameStateManager::SingleThreadEntryPoint(void*)' function void* SingleThreadEntryPoint(void *iPointer) { EventLoop* loop = static_cast<EventLoop*>(iPointer); GameHandle siHandle = BFG::generateHandle(); // Hack: Using leaking pointers, because vars would go out of scope ComposerState* ps = new ComposerState(siHandle, loop); ViewComposerState* vps = new ViewComposerState(siHandle, loop); // Init Controller GameHandle handle = generateHandle(); { BFG::Controller_::ActionMapT actions; actions[A_QUIT] = "A_QUIT"; actions[A_LOADING_MESH] = "A_LOADING_MESH"; actions[A_LOADING_MATERIAL] = "A_LOADING_MATERIAL"; actions[A_CAMERA_AXIS_X] = "A_CAMERA_AXIS_X"; actions[A_CAMERA_AXIS_Y] = "A_CAMERA_AXIS_Y"; actions[A_CAMERA_AXIS_Z] = "A_CAMERA_AXIS_Z"; actions[A_CAMERA_MOVE] = "A_CAMERA_MOVE"; actions[A_CAMERA_RESET] = "A_CAMERA_RESET"; actions[A_CAMERA_ORBIT] = "A_CAMERA_ORBIT"; actions[A_SCREENSHOT] = "A_SCREENSHOT"; actions[A_LOADING_SKY] = "A_LOADING_SKY"; actions[A_CREATE_LIGHT] = "A_CREATE_LIGHT"; actions[A_DESTROY_LIGHT] = "A_DESTROY_LIGHT"; actions[A_PREV_LIGHT] = "A_PREV_LIGHT"; actions[A_NEXT_LIGHT] = "A_NEXT_LIGHT"; actions[A_FIRST_LIGHT] = "A_FIRST_LIGHT"; actions[A_LAST_LIGHT] = "A_LAST_LIGHT"; actions[A_INFO_WINDOW] = "A_INFO_WINDOW"; actions[A_CAMERA_MOUSE_X] = "A_CAMERA_MOUSE_X"; actions[A_CAMERA_MOUSE_Y] = "A_CAMERA_MOUSE_Y"; actions[A_CAMERA_MOUSE_Z] = "A_CAMERA_MOUSE_Z"; actions[A_CAMERA_MOUSE_MOVE] = "A_CAMERA_MOUSE_MOVE"; actions[A_SUB_MESH] = "A_SUB_MESH"; actions[A_TEX_UNIT] = "A_TEX_UNIT"; actions[A_ANIMATION] = "A_ANIMATION"; actions[A_ADAPTER] = "A_ADAPTER"; actions[A_MOUSE_MIDDLE_PRESSED] = "A_MOUSE_MIDDLE_PRESSED"; BFG::Controller_::fillWithDefaultActions(actions); BFG::Controller_::sendActionsToController(loop, actions); Path path; const std::string config_path = path.Expand("Composer.xml"); const std::string state_name = "Composer"; Controller_::StateInsertion si(config_path, state_name, handle, true); EventFactory::Create<Controller_::ControlEvent> ( loop, ID::CE_LOAD_STATE, si ); loop->connect(A_QUIT, ps, &ComposerState::ControllerEventHandler); loop->connect(A_SCREENSHOT, ps, &ComposerState::ControllerEventHandler); loop->connect(A_LOADING_MESH, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_LOADING_MATERIAL, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_AXIS_X, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_AXIS_Y, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_AXIS_Z, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_MOVE, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_RESET, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_ORBIT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_LOADING_SKY, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CREATE_LIGHT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_DESTROY_LIGHT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_PREV_LIGHT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_NEXT_LIGHT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_FIRST_LIGHT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_LAST_LIGHT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_INFO_WINDOW, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_SUB_MESH, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_TEX_UNIT, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_ANIMATION, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_ADAPTER, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_MOUSE_X, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_MOUSE_Y, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_MOUSE_Z, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_CAMERA_MOUSE_MOVE, vps, &ViewComposerState::controllerEventHandler); loop->connect(A_MOUSE_MIDDLE_PRESSED, vps, &ViewComposerState::controllerEventHandler); loop->connect(BFG::ID::A_MOUSE_LEFT_PRESSED, vps, &ViewComposerState::controllerEventHandler); loop->connect(BFG::ID::A_MOUSE_RIGHT_PRESSED, vps, &ViewComposerState::controllerEventHandler); } assert(loop); loop->registerLoopEventListener(ps, &ComposerState::LoopEventHandler); return 0; } int main( int argc, const char* argv[] ) try { Base::Logger::Init(Base::Logger::SL_DEBUG, "Logs/Composer.log"); EventLoop iLoop(true); size_t controllerFrequency = 1000; const std::string caption = "Composer: He composes everything!"; boost::scoped_ptr<Base::IEntryPoint> epView(View::Interface::getEntryPoint(caption)); iLoop.addEntryPoint(epView.get()); iLoop.addEntryPoint(ControllerInterface::getEntryPoint(controllerFrequency)); iLoop.addEntryPoint(new Base::CEntryPoint(SingleThreadEntryPoint)); iLoop.run(); } catch (Ogre::Exception& e) { showException(e.getFullDescription().c_str()); } catch (std::exception& ex) { showException(ex.what()); } catch (...) { showException("Unknown exception"); }
ff3208c64015eb031fb86f760977a35299e4c7d2
b0d639cf93f9e2fb988654e9b35112a97ad8885b
/src/mgr/MgrPyModule.h
b466d1ac20f4824da4357d59949df2fe8ef94c28
[]
no_license
eunjicious/buddystore_src
53849ffb424fbba96e5dabea8ef383e60dfd59ab
ed6dd5c3a5813edef638b6fabc7956aecead5968
refs/heads/master
2021-07-11T14:54:27.054164
2017-10-14T20:48:32
2017-10-14T20:48:32
106,961,323
1
0
null
null
null
null
UTF-8
C++
false
false
1,625
h
MgrPyModule.h
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab /* * Ceph - scalable distributed file system * * Copyright (C) 2016 John Spray <john.spray@redhat.com> * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software * Foundation. See file COPYING. */ #ifndef MGR_PY_MODULE_H_ #define MGR_PY_MODULE_H_ // Python.h comes first because otherwise it clobbers ceph's assert #include "Python.h" #include "common/cmdparse.h" #include "common/LogEntry.h" #include <vector> #include <string> class MgrPyModule; /** * A Ceph CLI command description provided from a Python module */ class ModuleCommand { public: std::string cmdstring; std::string helpstring; std::string perm; MgrPyModule *handler; }; class MgrPyModule { private: const std::string module_name; PyObject *pModule; PyObject *pClass; PyObject *pClassInstance; std::vector<ModuleCommand> commands; int load_commands(); public: MgrPyModule(const std::string &module_name); ~MgrPyModule(); int load(); int serve(); void shutdown(); void notify(const std::string &notify_type, const std::string &notify_id); void notify_clog(const LogEntry &le); const std::vector<ModuleCommand> &get_commands() const { return commands; } const std::string &get_name() const { return module_name; } int handle_command( const cmdmap_t &cmdmap, std::stringstream *ds, std::stringstream *ss); }; std::string handle_pyerror(); #endif
39f740af2710bbae45bd4f71f1863ff6b5bc02e8
59e51f6466c7232f9d235e32b15a421b37bfb772
/Graph store/GraphStore/GraphStore.h
87aa4fbb78b31f8ebb5f56edf3174df045e8ea1b
[]
no_license
IDragnev/Graph-store
125fe050d5081b4a85430cad88f1b79ce419a6f3
e435064a63e84c12b16d37b66a13b7799644f5ba
refs/heads/master
2021-03-27T20:41:13.824270
2019-07-28T16:22:07
2019-07-28T16:22:07
122,102,047
0
0
null
null
null
null
UTF-8
C++
false
false
1,917
h
GraphStore.h
#ifndef __GRAPH_STORE_H_INCLUDED__ #define __GRAPH_STORE_H_INCLUDED__ #include "Containers\Dynamic Array\DArray.h" namespace IDragnev { class String; namespace Containers { template <typename Iterator, typename Extractor> class ProjectionIterator; } } namespace IDragnev::GraphStore { class Graph; class GraphStore { private: using GraphPtr = std::unique_ptr<Graph>; using GraphCollection = Containers::DArray<GraphPtr>; class Extractor { public: const Graph& operator()(GraphCollection::const_iterator it) const; Graph& operator()(GraphCollection::iterator it) const; private: template <typename Iterator> static decltype(auto) extractGraph(Iterator it) { return *(it->get()); } }; public: using iterator = Containers::ProjectionIterator<GraphCollection::iterator, Extractor>; using const_iterator = Containers::ProjectionIterator<GraphCollection::const_iterator, Extractor>; GraphStore() = default; GraphStore(const GraphStore&) = delete; GraphStore(GraphStore&& source) = default; ~GraphStore() = default; GraphStore& operator=(const GraphStore&) = delete; GraphStore& operator=(GraphStore&& rhs) = default; iterator begin() noexcept; iterator end() noexcept; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; Graph& operator[](const String& ID); const Graph& operator[](const String& ID) const; void insert(GraphPtr graph); void remove(const String& ID); bool isEmpty() const noexcept; void clear() noexcept; private: bool hasGraphWithID(const String& ID) const; const_iterator searchGraph(const String& ID) const; GraphPtr& getGraphPtr(const String& ID); GraphCollection::iterator searchGraphPtr(const String& ID); private: GraphCollection graphs; }; } #endif //__GRAPH_STORE_H_INCLUDED__
32985bddd8d207993bb842418b89384afcc75d8e
48d408c0e9c313000a29edbb9a16490dd47bb34a
/source/ResourceManager.h
c5f16073b794ac07ec3d7a52063beb50a07e5da3
[]
no_license
tshea149/Tim-s-2D-Engine
8a63ba5c51cf47f7c1b431ed499712e0f1bb0b22
a3a9c8016c030ad7ea7aeda7bacc47f682c2be23
refs/heads/master
2020-05-30T12:52:33.842442
2020-01-17T05:11:06
2020-01-17T05:11:06
189,745,979
0
0
null
null
null
null
UTF-8
C++
false
false
718
h
ResourceManager.h
/* Author: Tim */ #ifndef RESOURCEMANAGER_H #define RESOURCEMANAGER_H #include "EngineSettings.h" // for USE_RESOURCE_FILE #include <string> #include <memory> #include <stdint.h> #include <unordered_map> #include <vector> #if _DEBUG static_assert(sizeof(char) == 1, "char data type larger than 1 byte."); #endif // This module loads files into a buffer from the resource file (if USE_RESOURCE_FILE) or loose files if not using the resource file class ResourceManager { private: // only the AssetManager can create a ResourceManager friend class AssetManager; ResourceManager(); public: std::unique_ptr<std::vector<char>> loadFile(std::string filepath); }; #endif // !FILEMANAGER_H
148b75d59370e67d4f3e7bb0d9255ef5a0b472d0
b8d438bea9a3dd601ca0fd4b3e3d893f8926201d
/C_C++/Algorithm/priority_queueNTU.cpp
a1261d27ebd4148aca2c1451464e83518cdf19c7
[]
no_license
lng8212/DSA
dfa43e6ab3cd4f4b81f16dd52820dcaaa3ce410c
affd23596e19cc1595b3a8f339163621e9ceb3b1
refs/heads/main
2023-06-16T09:52:35.363218
2021-07-17T08:44:26
2021-07-17T08:44:26
386,876,462
1
0
null
null
null
null
UTF-8
C++
false
false
947
cpp
priority_queueNTU.cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); priority_queue<int> ans; char c; while (cin >> c) { if (c == '+') { int n; cin >> n; if (ans.size() < 15000) ans.push(n); } else { if (ans.size()) { int tmp = ans.top(); while (ans.size() && ans.top() == tmp) { ans.pop(); } } } } vector<int> an; if (ans.size()) { an.push_back(ans.top()); ans.pop(); } while (ans.size()) { if (ans.top() != an[an.size() - 1]) an.push_back(ans.top()); ans.pop(); } cout << an.size() << endl; for (int i = 0; i < an.size(); i++) { cout << an[i] << ' '; } return 0; }
45c2696f7252e7a3d6a465ef6cb3cd3786acdd98
acc4c74c930d90583e35d7e8a698e880d02bf45e
/Rational Number/Rational Number With Classes/main.cpp
24291ce13ba9482576d346271e3b0b6271ef4d23
[]
no_license
zornitsa25/oop-samples
de394542dc5036f11c542d65e38568867bff65d6
806bede217cb000a558cad2fb4553a938b11f8e6
refs/heads/master
2020-12-25T08:42:24.007094
2015-03-23T07:55:02
2015-03-23T07:55:02
32,747,258
0
1
null
null
null
null
UTF-8
C++
false
false
5,409
cpp
main.cpp
#include <iostream> /// /// Намира най-големия общ делител на две цели числа /// int gcd(int a, int b) { int temp; while (b != 0) { temp = a % b; a = b; b = temp; } return a; } /// /// Представя рационално число /// class Rational { public: /// Числителят на рационалното число int Numerator; /// Знаменателят на рационалното число int Denominator; /// Указва дали рационалното число трябва /// автоматично да се нормализира след всяка операция bool AutoNormalize; Rational(); Rational(int, int, bool); Rational(bool); ~Rational(); bool IsValid() const; void Add(Rational &); void Print() const; void Input(); void Normalize(); private: inline void PerformAutoNormalize(); }; /// /// Конструктор по подразбиране /// Rational::Rational() { std::cout << " -> Entering Rational(), object at " << this << std::endl; this->Numerator = 0; this->Denominator = 0; this->AutoNormalize = true; PerformAutoNormalize(); } /// /// Създава ново рационално число с числител Numerator и знаменател Denominator /// Rational::Rational(int Numerator, int Denominator, bool AutoNormalize=true) { std::cout << " -> Entering Rational(" << Numerator << ", " << Denominator << "), object at " << this << std::endl; this->Numerator = Numerator; this->Denominator = Denominator; this->AutoNormalize = AutoNormalize; PerformAutoNormalize(); } /// /// Създава празно рационално число, указвайки дали то да се нормализира автоматично /// Rational::Rational(bool AutoNormalize) { std::cout << " -> Entering Rational(" << (AutoNormalize ? "true" : "false") << "), object at " << this << std::endl; this->Numerator = 0; this->Denominator = 0; this->AutoNormalize = AutoNormalize; } /// /// Деструктор /// Rational::~Rational() { std::cout << " -> Entering ~Rational(), object at " << this << std::endl; } /// /// Връща true, ако данните в обекта са коректни. /// /// Данните се считат за коректни, ако знаменателят е различен от нула. /// bool Rational::IsValid() const { return Denominator != 0; } /// /// Добавя стойността на рационалното число other към текущия обект. /// void Rational::Add(Rational& other) { Numerator = Numerator*other.Denominator + other.Numerator*Denominator; Denominator = Denominator * other.Denominator; PerformAutoNormalize(); } /// /// Извежда рационалното число на екрана. /// void Rational::Print() const { std::cout << Numerator << "/" << Denominator; } /// /// Въвежда данните за рационалното число от STDIN. /// void Rational::Input() { std::cout << "Enter Numerator: "; std::cin >> Numerator; std::cout << "Enter Denominator: "; std::cin >> Denominator; PerformAutoNormalize(); } /// /// Нормализира рационалното число /// /// Нормализацията прави две неща: /// /// 1. Коригира знаците на числителя и знаменателя: /// 1.1 Ако числото е отрицателно, знакът минус се изнася в числителя /// 1.2 Ако и числителят и знаменателят са отрицателни, те стават положителни /// /// 2. Съкращава числителя и знаменателя на най-големия им общ делител /// void Rational::Normalize() { if( ! IsValid() ) return; // Коригираме знаците if(Denominator < 0) { Numerator = -Numerator; Denominator = -Denominator; } // Съкращаваме числителя и знаменателя на най-големия им общ делител // Взимаме НОД по модул, за да не обърка знаците при делението int g = abs(gcd(Denominator, Numerator)); Numerator /= g; Denominator /= g; } /// /// Нормализира числото, но само ако флагът AutoNormalize е вдигнат /// inline void Rational::PerformAutoNormalize() { if(AutoNormalize) Normalize(); } int main() { std::cout << "Entering main()\n"; std::cout << "Constructing r1\n"; Rational r1; std::cout << "Constructing a dynamic object\n"; Rational *pSingle = new Rational(); std::cout << "Constructing a dynamic array of five objects\n"; Rational *pArray = new Rational[5]; std::cout << "Destroy the dynamic object\n"; delete pSingle; std::cout << "Destroy the dynamic array\n"; delete [] pArray; std::cout << "Create and sum two rational numbers\n"; Rational a(1,2); Rational b(2,4); std::cout << " -> "; a.Print(); std::cout << " + "; b.Print(); std::cout << " = "; a.Add(b); a.Print(); std::cout << "\n"; std::cout << "Input a rational number from STDIN\n"; Rational temp; temp.Input(); std::cout << "You entered "; temp.Print(); std::cout << std::endl; std::cout << "Leaving main()\n"; return 0; }
3d768f973d11980a72f6cd3a6dff52f52ca46194
f7436f805535f4870c5ad70a947e86fce90bc296
/pair_sum_in_array.cpp
b9a7f16f772db3488d71e728946c9ee4639f8436
[]
no_license
ksatyam59/Array_Problems
29e185863fd8262cd9f551de9af2fcc077967abc
8413c09723dc9a321cc00fadab0977363e409a6d
refs/heads/master
2020-07-25T08:19:09.299692
2019-10-13T09:15:32
2019-10-13T09:15:32
208,228,159
0
0
null
null
null
null
UTF-8
C++
false
false
394
cpp
pair_sum_in_array.cpp
#include<iostream> using namespace std; int main() { int arr[]={2,7,3,9,4,6,1}; int n=sizeof(arr)/sizeof(arr[0]); for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(arr[i]+arr[j]==5) { cout<<"("<<arr[i]<<","<<arr[j]<<")"; } } } return 0; }
0f8f73b4aae0f329a50cb60420c24eb520299a34
14582f8c74c28d346399f877b9957d0332ba1c3c
/branches/pstade_1_03_5_head/pstade_subversive/pstade/junk/auto_fun.hpp
829af01327402b772c016f4b1641024580b63ddd
[]
no_license
svn2github/p-stade
c7b421be9eeb8327ddd04d3cb36822ba1331a43e
909b46567aa203d960fe76055adafc3fdc48e8a5
refs/heads/master
2016-09-05T22:14:09.460711
2014-08-22T08:16:11
2014-08-22T08:16:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
715
hpp
auto_fun.hpp
#ifndef PSTADE_AUTO_FUN_HPP #define PSTADE_AUTO_FUN_HPP // PStade.Wine // // Copyright Shunsuke Sogame 2005-2007. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <boost/typeof/typeof.hpp> #if !defined(BOOST_TYPEOF_NATIVE) #include <boost/function.hpp> #define PSTADE_AUTO_FUN(Sig, Var, Fun) boost::function<Sig> Var = Fun #define PSTADE_AUTO_FUN_TPL(Sig, Var, Fun) boost::function<Sig> Var = Fun #else #define PSTADE_AUTO_FUN(Sig, Var, Fun) BOOST_AUTO(Var, Fun) #define PSTADE_AUTO_FUN_TPL(Sig, Var, Fun) BOOST_AUTO_TPL(Var, Fun) #endif #endif
b0f5769f427241c5a9430fd46a31afa0a96163a5
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir521/dir3871/dir4221/dir4598/file4659.cpp
9f7b477831a3f857c70f5dcdd773e507d539a01c
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
111
cpp
file4659.cpp
#ifndef file4659 #error "macro file4659 must be defined" #endif static const char* file4659String = "file4659";