問題は、2 番目のファイルをロードするボタンが押されたときに、クラス インスタンス LowE が MedE で上書きされることです。
プロジェクトコード全体を投稿せずにこの質問をしようとしましたが、成功しませんでした。
ファイル runData.h
#pragma once
#define MAXPOINTS 1536
#define LDBL_MAX 1.7976931348623158e+308
#define MAXORDER 10
#define MAXVOLUME 100.0
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Diagnostics;
namespace EDCCalApp02 {
public ref class runData //: public System::ComponentModel::Component
{
public:
static array<double^> ^WPcoefs = gcnew array<double^>(MAXORDER+1);
(MAXPOINTS,7); 静的配列 ^fData1 = gcnew 配列 (MAXPOINTS,7);
static array<int^,2> ^iData1 = gcnew array<int^,2>(MAXPOINTS,7);
static array<int^,2> ^DataSize = gcnew array<int^,2>(3,3);
int numLines;
int numCols;
int indx;
int drops;
runData(void)
{
for (int n = 0; n<1536; n++) {
fData1[n,0] = 0.0;
fData1[n,1] = 0.0;
fData1[n,2] = 0.0;
fData1[n,3] = 0.0;
fData1[n,4] = 0.0;
fData1[n,5] = 0.0;
fData1[n,6] = 0.0;
iData1[n,0] = 0;
iData1[n,1] = 0;
iData1[n,2] = 0;
iData1[n,3] = 0;
iData1[n,4] = 0;
iData1[n,5] = 0;
iData1[n,6] = 0;
}
//InitializeComponent();
//
//TODO: Add the constructor code here
//
}
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
components = gcnew System::ComponentModel::Container();
}
#pragma endregion
};
}
ファイル Form1.h
#pragma once
#define MAXPOINTS 1536
#define LDBL_MAX 1.7976931348623158e+308
#define MAXORDER 10
#define MAXVOLUME 100.0
#include "runData.h"
#include "Graph1.h"
#include "Global1.h"
namespace EDCCalApp02 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
array<double^> ^polyfit(array<double^,2> ^, int, int);
array<double^,2> ^datasort(array<double^,2> ^, int);
double ldpow( double , unsigned );
float poly_correlcoef( array<double^,2> ^ ,int, array<double^> ^, int );
array<double^> ^get_xy_max_min( array<double^,2> ^ ,int );
array<double^,2> ^fillData(int, array<double^> ^, runData ^ );
array<double^,2> ^makeCurve(array<double^,2> ^, array<double^,2> ^, array<double^,2> ^, double);
array<double^,2> ^makeCoefs(array<double^,2> ^, array<double^> ^);
runData ^LoadData(array<String^> ^);
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
int numLines = 0, numCols=0;
try{
System::IO::StreamReader ^ sr = gcnew
System::IO::StreamReader("WellPlate Volume Definitions.txt");
array<String^> ^lines= System::IO::File::ReadAllLines("WellPlate Volume Definitions.txt");
numLines = lines->Length;
array<String^> ^Header=lines[0]->Split(',');
numCols = Header->Length;
staVolFile = gcnew array<String^,2>(numLines,numCols);
for(int i=1;i<numLines;i++) {
array<String^> ^lineSplit=lines[i]->Split(',');
for(int j=0;j<numCols;j++){
staVolFile[i-1,j] = lineSplit[j];
}
cbx_WellPlateList->Items->Add(staVolFile[i-1,0]);
}
sr->Close();
}
catch(IOException ^) {
MessageBox::Show(L"WellPlate Volume Definitions.txt\n\n"
L"Was Not Read\n\n"
L"Please Check the File\n"
L"and Try Again");
}
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ tbx_File1;
protected:
protected:
private: System::Windows::Forms::Label^ lbl_File1;
private: System::Windows::Forms::ComboBox^ cbx_WellPlateList;
private: System::Windows::Forms::TextBox^ tbx_File2;
private: System::Windows::Forms::TextBox^ tbx_File3;
private: System::Windows::Forms::Label^ lbl_Volume;
private: System::Windows::Forms::Button^ btn_Exit;
private:
public:
array<String^,2> ^staVolFile;
static array<bool^> ^loaded = gcnew array<bool^>(4) {false,false,false,false};
static runData ^LowE = ( gcnew runData);
static runData ^MedE = ( gcnew runData);
static runData ^HighE = (gcnew runData);
private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;
private: System::Windows::Forms::SaveFileDialog^ saveFileDialog1;
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->tbx_File1 = (gcnew System::Windows::Forms::TextBox());
this->lbl_File1 = (gcnew System::Windows::Forms::Label());
this->cbx_WellPlateList = (gcnew System::Windows::Forms::ComboBox());
this->btn_Exit = (gcnew System::Windows::Forms::Button());
this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
this->SuspendLayout();
//
// tbx_File1
//
this->tbx_File1->Location = System::Drawing::Point(40, 100);
this->tbx_File1->Name = L"tbx_File1";
this->tbx_File1->Size = System::Drawing::Size(267, 20);
this->tbx_File1->TabIndex = 0;
this->tbx_File1->Text = L"Enter .csv File 1";
// cbx_WellPlateList
//
this->cbx_WellPlateList->FormattingEnabled = true;
this->cbx_WellPlateList->Location = System::Drawing::Point(40, 40);
this->cbx_WellPlateList->Name = L"cbx_WellPlateList";
this->cbx_WellPlateList->Size = System::Drawing::Size(221, 21);
this->cbx_WellPlateList->TabIndex = 2;
this->cbx_WellPlateList->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::cbx_WellPlateList_SelectedIndexChanged);
this->btnFile1->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
this->btnFile1->Location = System::Drawing::Point(306, 98);
this->btnFile1->Name = L"btnFile1";
this->btnFile1->Size = System::Drawing::Size(25, 24);
this->btnFile1->TabIndex = 7;
this->btnFile1->UseVisualStyleBackColor = true;
this->btnFile1->Click += gcnew System::EventHandler(this, &Form1::btnFile1_Click);
// lbl_WellplateList
//
this->lbl_WellplateList->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->lbl_WellplateList->AutoSize = true;
this->lbl_WellplateList->Location = System::Drawing::Point(45, 25);
this->lbl_WellplateList->Name = L"lbl_WellplateList";
this->lbl_WellplateList->Size = System::Drawing::Size(98, 13);
this->lbl_WellplateList->TabIndex = 28;
this->lbl_WellplateList->Text = L"Wellplate Selection";
//
// btn_Graph1
//
this->btn_Graph1->BackColor = System::Drawing::Color::White;
this->btn_Graph1->Location = System::Drawing::Point(348, 99);
this->btn_Graph1->Name = L"btn_Graph1";
this->btn_Graph1->Size = System::Drawing::Size(38, 23);
this->btn_Graph1->TabIndex = 29;
this->btn_Graph1->Text = L"G1";
this->btn_Graph1->UseVisualStyleBackColor = true;
this->btn_Graph1->Click += gcnew System::EventHandler(this, &Form1::btn_Graph1_Click);
//
// btn_Create
//
this->btn_Create->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
this->btn_Create->Location = System::Drawing::Point(40, 292);
this->btn_Create->Name = L"btn_Create";
this->btn_Create->Size = System::Drawing::Size(75, 23);
this->btn_Create->TabIndex = 33;
this->btn_Create->Text = L"Create Cal";
this->btn_Create->UseVisualStyleBackColor = true;
this->btn_Create->Click += gcnew System::EventHandler(this, &Form1::btn_Create_Click);
this->btn_Exit->Anchor = System::Windows::Forms::AnchorStyles::Bottom;
this->btn_Exit->Location = System::Drawing::Point(657, 304);
this->btn_Exit->Name = L"btn_Exit";
this->btn_Exit->Size = System::Drawing::Size(75, 23);
this->btn_Exit->TabIndex = 36;
this->btn_Exit->Text = L"Exit";
this->btn_Exit->UseVisualStyleBackColor = true;
this->btn_Exit->Click += gcnew System::EventHandler(this, &Form1::btn_Exit_Click);
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::White;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(830, 348);
this->Controls->Add(this->btn_Exit);
this->Controls->Add(this->btn_Graph1);
this->Controls->Add(this->lbl_WellplateList);
this->Controls->Add(this->lbl_Order1);
this->Controls->Add(this->lbl_Max1);
this->Controls->Add(this->lbl_Min1);
this->Controls->Add(this->tbx_Order1);
this->Controls->Add(this->cbx_WellPlateList);
this->Controls->Add(this->lbl_File1);
this->Controls->Add(this->tbx_File1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"Form1";
this->Text = L"EDC Calibration App";
this->ResumeLayout(false);
this->PerformLayout();
}
pragma endregion
プライベート: System::Void cbx_WellPlateList_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
double WPcoefs[MAXORDER+1];// = gcnew array<double^>(MAXORDER+1);
int selectedIndex = cbx_WellPlateList->SelectedIndex;
for(int i=0; i <= MAXORDER; i++) WPcoefs[i]=0.0;
for(int i=3;i<8;i++){
WPcoefs[i-3] = double::Parse(staVolFile[selectedIndex,i]);
}
for(int i=0;i<MAXORDER+1;i++){
LowE->WPcoefs[i] = WPcoefs[i];
MedE->WPcoefs[i] = WPcoefs[i];
HighE->WPcoefs[i] = WPcoefs[i];
}
loaded[0] = true;
}
private: System::Void btnFile1_Click(System::Object^ sender, System::EventArgs^ e) {
if(!*loaded[0]) {
MessageBox::Show("Please select a plate and try again.");
return;
}
try {
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
System::IO::StreamReader ^ sr = gcnew
System::IO::StreamReader(openFileDialog1->FileName);
if (!sr) { tbx_File1->Text = "ファイルを開けませんでした。";
}
String^ FilePath = openFileDialog1->FileName;
array<String^> ^File = FilePath->Split('\\');
int num = File->Length;
tbx_File1->Text = File[num-1];
array<String^> ^rawData1= System::IO::File::ReadAllLines(openFileDialog1->FileName);
LowE = LoadData(rawData1);
loaded[1] = true;
sr->Close();
}
}
catch(IOException ^)
{
MessageBox::Show("File Not Read\n Please Check the File\n and Try Again");
return;
}
}
private: System::Void btnFile2_Click(System::Object^ sender, System::EventArgs^ e) {
if(!*loaded[0]) {
MessageBox::Show("Please select a plate and try again.");
return;
}
try {
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
System::IO::StreamReader ^ sr = gcnew
System::IO::StreamReader(openFileDialog1->FileName);
if (!sr) { tbx_File2->Text = "ファイルを開けませんでした。";
}
String^ FilePath = openFileDialog1->FileName;
array<String^> ^File = FilePath->Split('\\');
int num = File->Length;
tbx_File2->Text = File[num-1];
array<String^> ^rawData2= System::IO::File::ReadAllLines(openFileDialog1->FileName);
MedE = LoadData(rawData2);
loaded[2] = true;
sr->Close();
}
}
catch(IOException ^)
{
MessageBox::Show("File Not Read\n Please Check the File\n and Try Again");
return;
}
}
private: System::Void btnFile3_Click(System::Object^ sender, System::EventArgs^ e) {
if(!*loaded[0]) {
MessageBox::Show("Please select a plate and try again.");
return;
}
try {
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
System::IO::StreamReader ^ sr = gcnew
System::IO::StreamReader(openFileDialog1->FileName);
if (!sr) { tbx_File3->Text = "ファイルを開けませんでした。";
}
String^ FilePath = openFileDialog1->FileName;
array<String^> ^File = FilePath->Split('\\');
int num = File->Length;
tbx_File3->Text = File[num-1];
array<String^> ^rawData3= System::IO::File::ReadAllLines(openFileDialog1->FileName);
HighE = LoadData(rawData3);
loaded[3] = true;
sr->Close();
}
}
catch(IOException ^)
{
MessageBox::Show("File Not Read\n Please Check the File\n and Try Again");
return;
}
}
private: System::Void btn_Exit_Click(System::Object^ sender, System::EventArgs^ e) {
this->Close();
}
private: System::Void btn_Graph1_Click(System::Object^ sender, System::EventArgs^ e) {
int Size = LowE->indx;
if(Size > 3){
array<double^,2> ^plotData = gcnew array<double^,2>(Size,4);
array<double^,2> ^fitData = gcnew array<double^,2>(Size,2);
double Min = Convert::ToDouble(tbx_Min1->Text);
double Max = Convert::ToDouble(tbx_Max1->Text);
int Ord = Convert::ToInt32(tbx_Order1->Text);
double Vol;
int count = 0;
int iData;
for(int i=1; i < Size-1 ; i++){
if((*LowE->fData1[i,0] <= Max) && (*LowE->fData1[i,0] >= Min )){
Vol = ((*LowE->fData1[i,6] / *LowE->iData1[i,4]));
if(Vol > -1.0*MAXVOLUME && Vol < MAXVOLUME){
plotData[count,0] = *LowE->fData1[i,0];
fitData[count,0] = *plotData[count,0];
iData = (int) (100.0 * *plotData[count,0]);
plotData[count,0] = iData / 100.0;
plotData[count,1] = Vol;
fitData[count,1] = Vol;
count++;
}
}
}
array<double^> ^plotCoefs = gcnew array<double^>(MAXORDER +1);
plotCoefs = polyfit(fitData,count-1,Ord);
double Delta = (Max + 0.2)/count;
plotData[0,2] = 0.0;
for(int i=0; i < count; i++) {
double LLOrd = 1.0;
plotData[i,3] = 0.0;
if(i>0) plotData[i,2] = *plotData[i-1,2] + Delta;
for(int k=0; k <= Ord; k++) {
plotData[i,3] = *plotData[i,3] +*plotCoefs[k] * LLOrd;
LLOrd = LLOrd * *plotData[i,2];
}
}
if(count > 2){
Graph1^ plot1 = gcnew Graph1(count-1,plotData);
plot1->ShowDialog();
} else{
MessageBox::Show(" Not Enough Valid Data\n Please Check the File\n and Try Again");
}
} else{
MessageBox::Show(" File Does Not Contain Enough Data\n Please Check the File\n and Try Again");
}
}
private: System::Void btn_Graph2_Click(System::Object^ sender, System::EventArgs^ e) {
int Size = MedE->indx;
if(Size > 3){
array<double^,2> ^plotData = gcnew array<double^,2>(Size,4);
array<double^,2> ^fitData = gcnew array<double^,2>(Size,2);
double Min = Convert::ToDouble(tbx_Min2->Text);
double Max = Convert::ToDouble(tbx_Max2->Text);
int Ord = Convert::ToInt32(tbx_Order2->Text);
double Vol;
int count = 0;
int iData;
for(int i=1; i < Size-1 ; i++){
if((*MedE->fData1[i,0] <= Max) && (*MedE->fData1[i,0] >= Min )){
Vol = ((*MedE->fData1[i,6] / *MedE->iData1[i,4]));
if(Vol > -1.0*MAXVOLUME && Vol < MAXVOLUME){
plotData[count,0] = *MedE->fData1[i,0];
fitData[count,0] = *plotData[count,0];
iData = (int) (100.0 * *plotData[count,0]);
plotData[count,0] = iData / 100.0;
plotData[count,1] = Vol;
fitData[count,1] = Vol;
count++;
}
}
}
array<double^> ^plotCoefs = gcnew array<double^>(MAXORDER +1);
plotCoefs = polyfit(fitData,count-1,Ord);
double Delta = (Max + 0.2)/count;
plotData[0,2] = 0.0;
for(int i=0; i < count; i++) {
double LLOrd = 1.0;
plotData[i,3] = 0.0;
if(i>0) plotData[i,2] = *plotData[i-1,2] + Delta;
for(int k=0; k <= Ord; k++) {
plotData[i,3] = *plotData[i,3] +*plotCoefs[k] * LLOrd;
LLOrd = LLOrd * *plotData[i,2];
}
}
if(count > 2){
Graph1^ plot1 = gcnew Graph1(count-1,plotData);
plot1->ShowDialog();
} else{
MessageBox::Show(" Not Enough Valid Data\n Please Check the File\n and Try Again");
}
} else{
MessageBox::Show(" File Does Not Contain Enough Data\n Please Check the File\n and Try Again");
}
}
private: System::Void btn_Graph3_Click(System::Object^ sender, System::EventArgs^ e) {
int Size = HighE->indx;
if(Size > 3){
array<double^,2> ^plotData = gcnew array<double^,2>(Size,4);
array<double^,2> ^fitData = gcnew array<double^,2>(Size,2);
double Min = Convert::ToDouble(tbx_Min3->Text);
double Max = Convert::ToDouble(tbx_Max3->Text);
int Ord = Convert::ToInt32(tbx_Order3->Text);
double Vol;
int count = 0;
int iData;
for(int i=1; i < Size-1 ; i++){
if((*HighE->fData1[i,0] <= Max) && (*HighE->fData1[i,0] >= Min )){
Vol = ((*HighE->fData1[i,6] / *HighE->iData1[i,4]));
if(Vol > -1.0*MAXVOLUME && Vol < MAXVOLUME){
plotData[count,0] = *HighE->fData1[i,0];
fitData[count,0] = *plotData[count,0];
iData = (int) (100.0 * *plotData[count,0]);
plotData[count,0] = iData / 100.0;
plotData[count,1] = Vol;
fitData[count,1] = Vol;
count++;
}
}
}
array<double^> ^plotCoefs = gcnew array<double^>(MAXORDER +1);
plotCoefs = polyfit(fitData,count-1,Ord);
double Delta = (Max + 0.2)/count;
plotData[0,2] = 0.0;
for(int i=0; i < count; i++) {
double LLOrd = 1.0;
plotData[i,3] = 0.0;
if(i>0) plotData[i,2] = *plotData[i-1,2] + Delta;
for(int k=0; k <= Ord; k++) {
plotData[i,3] = *plotData[i,3] +*plotCoefs[k] * LLOrd;
LLOrd = LLOrd * *plotData[i,2];
}
}
if(count > 2){
Graph1^ plot1 = gcnew Graph1(count-1,plotData);
plot1->ShowDialog();
} else{
MessageBox::Show(" Not Enough Valid Data\n Please Check the File\n and Try Again");
}
} else{
MessageBox::Show(" File Does Not Contain Enough Data\n Please Check the File\n and Try Again");
}
}
private: System::Void btn_Create_Click(System::Object^ sender, System::EventArgs^ e) {
int i=0;
array<double^> ^Args1 = gcnew array<double^>(6) {0.0,0.0,2.0,5.0,3.0,3.0};
array<double^> ^Args2 = gcnew array<double^>(6) {0.0,0.0,2.0,5.0,3.0,3.0};
array<double^> ^Args3 = gcnew array<double^>(6) {0.0,0.0,2.0,5.0,3.0,3.0};
array<double^,2> ^Coefs1 = gcnew array<double^,2>(MAXORDER +4, 4);
array<double^,2> ^Coefs2 = gcnew array<double^,2>(MAXORDER +4, 4);
array<double^,2> ^Coefs3 = gcnew array<double^,2>(MAXORDER +4, 4);
array<double^,2> ^Curve = gcnew array<double^,2>(36, 4);
int minSz = LowE->indx;
int midSz = MedE->indx;
int maxSz = HighE->indx;
double Vol = (Convert::ToDouble(tbx_Volume->Text));
array<double^,2> ^minData, ^medData, ^maxData;
Args1[0] = (Convert::ToDouble(tbx_Min1->Text));
Args1[1] = (Convert::ToDouble(tbx_Max1->Text));
Args1[2] = (Convert::ToDouble(tbx_Order1->Text));
minData = fillData(minSz, Args1, LowE);
Coefs1 = makeCoefs(minData,Args1);
Args2[0] = (Convert::ToDouble(tbx_Min2->Text));
Args2[1] = (Convert::ToDouble(tbx_Max2->Text));
Args2[2] = (Convert::ToDouble(tbx_Order2->Text));
medData = fillData(minSz, Args2, MedE);
Coefs2 = makeCoefs(medData,Args1);
Args3[0] = (Convert::ToDouble(tbx_Min3->Text));
Args3[1] = (Convert::ToDouble(tbx_Max3->Text));
Args3[2] = (Convert::ToDouble(tbx_Order3->Text));
maxData = fillData(minSz, Args3, HighE);
Coefs3 = makeCoefs(maxData,Args1);
Curve = makeCurve(Coefs1,Coefs2,Coefs3,Vol);
array<String^,2> ^calFile = gcnew array<String^,2>(36,4);
double tempDouble;
String ^myfile = "";
saveFileDialog1->ShowDialog() ;
myfile = saveFileDialog1->FileName;
try {
FileStream ^outFile = gcnew FileStream(myfile, FileMode::Create, FileAccess::Write);
StreamWriter ^streamOut = gcnew StreamWriter(outFile);
for(i=0; i<36; i++){
tempDouble = *Curve[i,0];
calFile[i,0] = tempDouble.ToString("F2");
tempDouble = *Curve[i,1];
calFile[i,1] = tempDouble.ToString("F0");
tempDouble = *Curve[i,2];
calFile[i,2] = tempDouble.ToString("F2");
tempDouble = *Curve[i,3];
calFile[i,3] = tempDouble.ToString("F2");
streamOut->WriteLine( "{0}\t{1}\t{2}\t{3}\t{1}\t{1}\t{1}\t{1}\t{1}\t{1}\t{1}\t{1}",calFile[i,0], calFile[i,1], calFile[i,2],calFile[i,3] );
}
streamOut->Close();
}
catch(IOException ^)
{
MessageBox::Show("File Not Written\n Please Check the File\n and Try Again");
}
}
};
array<double^,2> ^makeCurve(array<double^,2> ^Coef1, array<double^,2> ^Coef2, array<double^,2> ^Coef3, double Vol) {
array<double^,2> ^Curve = gcnew array<double^,2>(36, 4);
array<double^,3> ^Funct = gcnew array<double^,3>(3,4,36);
array<double^> ^LLmin = gcnew array<double^>(3);
array<double^> ^LLmax = gcnew array<double^>(3);
array<int^> ^Order = gcnew array<int^>(3);
LLmin[0] = *Coef1[0,0];
LLmin[1] = *Coef2[0,0];
LLmin[2] = *Coef3[0,0];
LLmax[0] = *Coef1[1,0];
LLmax[1] = *Coef2[1,0];
LLmax[2] = *Coef3[1,0];
Order[0] = (int) *Coef1[2,0];
Order[1] = (int) *Coef2[2,0];
Order[2] = (int) *Coef3[2,0];
double maxLLcut = 0.0;
double minLLcut = *LLmax[0];
for(int n=0; n<3; n++) {
if( maxLLcut < *LLmax[n]) maxLLcut = *LLmax[n];
if( minLLcut > *LLmax[n]) minLLcut = *LLmax[n];
}
int npts = 36;
if(maxLLcut != minLLcut){
npts = 35;
}
double LL = 0.05;
double DeltaLL;
double LLOrd = 1.0;
DeltaLL = minLLcut/((float) npts - 1.0);
for(int i=1; i < npts ; i++) {
Curve[i,0] = LL;
for (int n = 0; n < 4 ; n++) {
// Use polynomial coefs to calculate Volume
LLOrd = 1.0;
for(int k=3; k < *Coef1[2,n]+3; k++) {
Funct[0,n,i] = *Funct[0,n,i] +*Coef1[k,n] * LLOrd;
LLOrd = LLOrd *LL;
}
LLOrd = 1.0;
for(int k=3; k < *Coef2[2,n]+3; k++) {
Funct[1,n,i] = *Funct[1,n,i] +*Coef2[k,n] * LLOrd;
LLOrd = LLOrd *LL;
}
LLOrd = 1.0;
for(int k=3; k < *Coef3[2,n]+3; k++) {
Funct[2,n,i] = *Funct[2,n,i] +*Coef3[k,n] * LLOrd;
LLOrd = LLOrd *LL;
}
}
double BurstPerNl = 0.0;
double BurstInt = 0.0;
for(int j = 0; j<4; j++) {
if(*Funct[iL,j+1,i] == *Funct[iH,j+1,i]){
Curve[i,j+1] = *Funct[iCr,j+1,i];
}else{
BurstPerNl = (*Funct[iL,j+1,i] - *Funct[iH,j+1,i])/(*Funct[iL,0,i] - *Funct[iH,0,i]);
BurstInt = *Funct[iCr,1,i] - BurstPerNl * *Funct[iCr,j+1,i];
Curve[i,j+1] = BurstPerNl * (Vol - *Funct[iCr,0,i]) + *Funct[iCr,j+1,i];
}
}
LL = LL + DeltaLL;
}
if (npts < 36){
Curve[35,0] = maxLLcut;
for (int l = 1; l<4; l++) {
Curve[35,l] = ((*Curve[34,l] - *Curve[32,l])/(*Curve[34,0] - *Curve[32,0])) *(*Curve[35,0] - *Curve[34,0]) + *Curve[34,l];
}
}
return Curve;
}
array<double^,2> ^makeCoefs(array<double^, 2> ^Data, array<double^> ^Args) {
array<double^> ^tempCoefs = gcnew array<double^>(MAXORDER +1);
array<double^,2> ^Coefs = gcnew array<double^,2>(MAXORDER +4, 4);
int Size;
Size = Data->Length / 8;
array<double^,2> ^tempE = gcnew array<double^,2>(Size+100,2);
for(int k=0; k<Size; k++){
tempE[k,0] = 0.0;
tempE[k,1] = 0.0;
}
int m;
for(int j=0; j < 4; j++) {
for(int i = 0; i < Size; i++) {
m = j*2;
tempE[i,0] = (double) *Data[i,m];
tempE[i,1] = (double) *Data[i,m+1];
}
int k = j+2;
int Order = (int) *Args[k];
tempCoefs = polyfit(tempE, Size-1, Order);
Coefs[0,j] = *Args[0];
Coefs[1,j] = *Args[1];
Coefs[2,j] = *Args[j+2];
for(int k = 0; k < *Args[j+2]; k++) {
Coefs[3+k, j] = *tempCoefs[k];
}
}
return Coefs;
}
array<double^,2> ^fillData(int Num, array<double^> ^Args, runData ^rawData) {
// Create data sets to be fit based on cuts
int j1 = 0;
double MeasuredVolume;
array<double^,2> ^Data = gcnew array<double^,2>(Num,8);
for(int i=1; i<Num; i++) {
if(*rawData->fData1[i,0] > *Args[0] && *rawData->fData1[i,0] < *Args[1]){
MeasuredVolume = ( *rawData->fData1[i,6])/( *rawData->iData1[i,4]);
if(MeasuredVolume > -1.0*MAXVOLUME && MeasuredVolume < MAXVOLUME) {
Data[j1,0] = *rawData->fData1[i,0];
Data[j1,1] = ( *rawData->fData1[i,6])/( *rawData->iData1[i,4]);
Data[j1,2] = *rawData->fData1[i,0];
Data[j1,3] = *rawData->fData1[i,3];
Data[j1,4] = *rawData->fData1[i,0];
Data[j1,5] = *rawData->fData1[i,2];
Data[j1,6] = *rawData->fData1[i,0];
Data[j1,7] = *rawData->fData1[i,4];
j1++;
}
}
}
j1 = j1 - 1;
array<double^,2> ^newData = gcnew array<double^,2>(j1,8);
// newData = *データ;
for(int k=0; k<j1; k++){
for(int i = 0; i<8; i++){
newData[k,i] = *Data[k,i];
}
}
return newData;
}
runData ^LoadData(array<String^> ^ rawData)
{
int numLines = 0;
int numCols = 0;
int indx = 0;
int drops = 0;
array<String^,2> ^staFile1;
double WPcoefs[MAXORDER+1]; // [ = gcnew array<double^>(MAXORDER+1);
numLines = rawData->Length;
array<String^> ^Header=rawData[0]->Split(',');
numCols = Header->Length;
staFile1 = gcnew array<String^,2>(numLines,numCols);
double temp_d;
int temp_i;
runData ^filledData = gcnew runData;
// runData 塗りつぶされたデータ; // = (新しい runData);
double vol, LL, deltaV;
for(int i=0;i<numLines;i++)
{
array<String^> ^lineSplit=rawData[i]->Split(',');
for(int j=0;j<numCols;j++){
staFile1[i,j] = lineSplit[j];
}
if(staFile1[i,8] != "11" && staFile1[i,8] != "15") {
if(i>0){
filledData->fData1[indx,1] = double::Parse(staFile1[i,27]);
filledData->fData1[indx,2] = double::Parse(staFile1[i,28]);
filledData->fData1[indx,3] = double::Parse(staFile1[i,29]);
array<String^> ^SptFreq = staFile1[i,31]->Split(':');
filledData->fData1[indx,4] = double::Parse(SptFreq[0]);
filledData->drops = (double::Parse(staFile1[i,33]));
filledData->iData1[indx,4] = filledData->drops;
LL = *filledData->fData1[indx,0];
double LLOrd = 1.0;
vol = 0.0;
for(int k=0; k <= MAXORDER; k++) {
vol = vol + *filledData->WPcoefs[k] * LLOrd;
LLOrd = LLOrd * LL;
}
filledData->fData1[indx,5] = vol;
if(indx >= 1) {
deltaV = *filledData->fData1[indx-1,5] - *filledData->fData1[indx,5];
filledData->fData1[indx-1,6] = deltaV * 1000.0;
if(*filledData->iData1[indx,4] > 0){
double Vol = ((*filledData->fData1[indx-1,6] / *filledData->iData1[indx,4]));
if(Vol > -1.0*MAXVOLUME && Vol < MAXVOLUME){
indx++;
}
}
}else{
indx++;
}
}
}
}
filledData->numLines = numLines;
filledData->numCols = numCols;
filledData->drops = *filledData->iData1[1,4];
filledData->indx = indx;
return filledData;
}
うまくいけば、これで十分な情報です。
問題は、2 番目のファイルをロードするボタンが押されたときに、クラス インスタンス LowE が MedE で上書きされることです。