www.pudn.com > Genecircus20070919.rar > ParamentDialog.cpp


#include "ParamentDialog.h" 
#include "wx_pch.h" 
#define maxX 1280.0 
#define maxY 800.0 
IMPLEMENT_DYNAMIC_CLASS(ParamentDialog, wxDialog) 
BEGIN_EVENT_TABLE(ParamentDialog,wxDialog) 
	 EVT_BUTTON(wxID_OK1,ParamentDialog::OnOK) 
END_EVENT_TABLE() 
using namespace boost;//("^select ([a-zA-Z]*) from ([a-zA-Z]*)"); 
//boost::regex expression("select([0-9])from([0-9])"); 
#define szNumber "[0-9]*" 
const boost::regex reNumber(szNumber,boost::regbase::normal|boost::regbase::icase); 
 
#define szNumber1 "[0-9]*[.][0-9]*" 
const boost::regex reNumber1(szNumber1,boost::regbase::normal|boost::regbase::icase); 
 
#define szNumber2 "[-][0-9]*[.][0-9]*" 
const boost::regex reNumber2(szNumber2,boost::regbase::normal|boost::regbase::icase); 
 
ParamentDialog::ParamentDialog(void) 
{ 
   type = 0; 
   index = -100; 
} 
 
ParamentDialog::ParamentDialog(wxWindow* parent,wxWindowID id,int type1,int index1)  
: wxDialog(parent, wxID_ANY, wxString(_T("Set Parameter")),wxPoint(420,100),wxSize(600,380),wxDEFAULT_FRAME_STYLE) 
{ 
	wxScreenDC dc1; 
	wxCoord w,h; 
	dc1.GetSize(&w,&h); 
	type = type1; 
	index = index1; 
	double scaleX=(double)(w/maxX); 
	double scaleY=(double)(h/maxY); 
	(void) new wxStaticText(this,wxID_SIM_GENE_M_RNA_T, wxT("Init_number_m_RNA:"), 
            wxPoint(10*scaleX, 10), wxSize(150*scaleX,16)); 
	wxWindow * temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_M_RNA, wxT(""), 
            wxPoint(10*scaleX, 40), wxSize(150*scaleX,16)); 
	gene.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_GENE_P_T, wxT("Init_number_P:"), 
            wxPoint(10*scaleX, 70), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_P, wxT(""), 
            wxPoint(10*scaleX, 100), wxSize(150*scaleX,16)); 
	//gene.push_back(temp_wxwindow); 
	gene.push_back(temp_wxwindow); 
	/* 
	(void) new wxStaticText(this,wxID_SIM_GENE_D_T, wxT("probability distributing:"), 
            wxPoint(10*scaleX, 130), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_D, wxT(""), 
            wxPoint(10*scaleX, 160),wxSize(150*scaleX,16));//wxID_OK_PARA 
			*/ 
	gene.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_GENE_D_CT, wxT("Reaction constant:"), 
            wxPoint(10*scaleX, 130), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_CT, wxT(""), 
            wxPoint(10*scaleX, 160),wxSize(150*scaleX,16));//wxID_OK_PARA 
	ct.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_LINE_D_CT, wxT("Protein unite:"), 
            wxPoint(10*scaleX, 190), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_LINE_CT, wxT(""), 
            wxPoint(10*scaleX, 220),wxSize(150*scaleX,16));//wxID_OK_PARA 
	line.push_back(temp_wxwindow); 
    (void) new wxButton(this, wxID_OK1, wxT("OK"), 
            wxPoint(10*scaleX, 310), wxSize(150*scaleX,16)); 
	//// 
	(void) new wxStaticText(this,wxID_SIM_GENE_M_RNA_T1, wxT("The rate of mRNA degradation:"), 
            wxPoint(180*scaleX, 10), wxSize(250*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_M_RNA1, wxT(""), 
            wxPoint(180*scaleX, 40), wxSize(150*scaleX,16)); 
	gene.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_GENE_P_T1, wxT("The rate of mRNA synthesize:"), 
            wxPoint(180*scaleX, 70), wxSize(250*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_P1, wxT(""), 
            wxPoint(180*scaleX, 100), wxSize(150*scaleX,16)); 
    gene.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_GENE_P_T3, wxT("mRNA delay time:"), 
            wxPoint(180*scaleX, 130), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_P3, wxT(""), 
            wxPoint(180*scaleX, 160), wxSize(150*scaleX,16)); 
    gene.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_GENE_D_T1, wxT("The rate of Protein decay:"), 
            wxPoint(180*scaleX, 190), wxSize(200*scaleX,16));	 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_D1, wxT(""), 
            wxPoint(180*scaleX, 220),wxSize(150*scaleX,16));//wxID_OK_PARA 
	gene.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_GENE_D_T2, wxT("The rate of Protein synthesize:"), 
            wxPoint(180*scaleX, 250), wxSize(250*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_GENE_D2, wxT(""), 
            wxPoint(180*scaleX, 280),wxSize(150*scaleX,16));//wxID_OK_PARA 
	gene.push_back(temp_wxwindow); 
	/* 
	(void) new wxStaticText(this,wxID_SIM_LINE_FUN_CT, wxT("Line function:"), 
            wxPoint(180*scaleX, 310), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_LINE_FUN, wxT(""), 
            wxPoint(180*scaleX, 340),wxSize(150*scaleX,16));//wxID_OK_PARA 
			*/ 
	line.push_back(temp_wxwindow); 
	(void) new wxStaticText(this,wxID_SIM_NAME_CT, wxT("Name:"), 
            wxPoint(10*scaleX, 250), wxSize(150*scaleX,16)); 
	temp_wxwindow = (wxWindow *) new wxTextCtrl(this, wxID_SIM_NAME, wxT(""), 
            wxPoint(10*scaleX, 280),wxSize(150*scaleX,16));//wxID_OK_PARA 
	gene.push_back(temp_wxwindow); 
 
////draw gene_promotor 
	myCanvas_1 * par; 
	par = (myCanvas_1 *)GetParent(); 
 
	wxColour colour; 
    colour.Set(180,180,180); 
 
	//par->blackboard->genes1[index].promotor.l.clear(); 
	//par->blackboard->genes[index].promotor.l.clear(); 
 
    if(type == 1 && par->blackboard->genes1[index].promotor.l.size() != 0){ 
	   grid = new wxGrid(this, 
						 wxID_ANY, 
						 wxPoint(260,20), 
						 wxSize(375,540)); 
	   int u = 0; 
	   for(u = 0;u < 3;u++){ 
		   if(u == 0) 
		      grid->SetColLabelValue(u,"site #1"); 
		   if(u == 1) 
		      grid->SetColLabelValue(u,"site #2"); 
		   if(u == 2) 
		      grid->SetColLabelValue(u,"Function"); 
	   } 
	   grid->CreateGrid(0,0); 
	   grid->AppendRows(par->blackboard->genes1[index].promotor.l.size()); 
	   grid->AppendCols(3); 
       promotorlaw p; 
	   for(int e = 0; e < par->blackboard->genes1[index].promotor.l.size();e++){ 
	       p = par->blackboard->genes1[index].promotor.l[e]; 
		   grid->SetCellValue(e,0,p.one); 
		   grid->SetReadOnly(e,0); 
		   grid->SetCellBackgroundColour(e,0,colour); 
           grid->SetCellValue(e,1,p.two); 
		   grid->SetReadOnly(e,1); 
		   grid->SetCellBackgroundColour(e,1,colour); 
		   grid->SetCellValue(e,2,boost::lexical_cast(p.function).c_str()); 
	   } 
	} 
 
	if(type == 1 && par->blackboard->genes1[index].promotor.l.size() == 0){ 
 
		int num0 = 0; 
		int num1 = 0; 
 
        for(int i = 0;i< par->blackboard->lc.size();i++){ 
			 if( par->blackboard->lc[i].type == 3 
				&& 
				 par->blackboard->lc[i].line_end == index){ 
                num0++; 
			 } 
			 if( par->blackboard->lc[i].type == 31 
				&& 
				 par->blackboard->lc[i].line_end == index){ 
			    num1++; 
			 } 
		} 
 
		grid = new wxGrid( this, 
						   wxID_ANY, 
						   wxPoint( 260, 20 ), 
						   wxSize( 375, 540 )); 
		grid->CreateGrid( 0, 0 ); 
 
		if(num0 != 0 && num1 != 0){// 
		   grid->AppendRows(num0*(num1+1)+num1); 
		} 
		else if(num0 != 0 && num1 == 0){ 
		   grid->AppendRows(num0); 
		} 
		else if(num0 == 0 && num1 != 0){ 
           grid->AppendRows(num1); 
		} 
		grid->AppendCols(3); 
 
		int u = 0; 
		for(u = 0;u < 3;u++){ 
			if(u == 0) 
			   grid->SetColLabelValue(u,"site #1"); 
			if(u == 1) 
			   grid->SetColLabelValue(u,"site #2"); 
			if(u == 2) 
			   grid->SetColLabelValue(u,"Function"); 
		} 
 
		u = 0; 
		int j0 = 0; 
		if(num0 != 0){			 
			for(u = 0; u < 1;u++){ 
				for(int t = 0;t < par->blackboard->lc.size();t++){ 
					if(par->blackboard->lc[t].type == 3 
					   && 
					   par->blackboard->lc[t].line_end == index 
					   && 
					   par->blackboard->lc[t].if_effect == 1){ 
						   if(par->blackboard->lc[t].if_complex){ 
				              grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
				              grid->SetReadOnly(u+j0,1); 
							  grid->SetCellBackgroundColour(u+j0,1,colour); 
							  grid->SetReadOnly(u+j0,0); 
							  grid->SetCellBackgroundColour(u+j0,0,colour); 
							  j0++; 
							  if(num1 != 0){ 
							      bool okj = false; 
								  for(int t1 = 0;t1 < par->blackboard->lc.size();t1++){ 
                                     if(par->blackboard->lc[t1].type == 31 
									    && 
										par->blackboard->lc[t1].line_end == index){ 
										if(par->blackboard->lc[t1].if_complex){ 
										   grid->SetCellValue(u+j0,0,par->blackboard->lc[t1].name.c_str()); 
										   grid->SetReadOnly(u+j0,0); 
										   grid->SetCellBackgroundColour(u+j0,0,colour); 
										   grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
                                           grid->SetReadOnly(u+j0,1); 
										   grid->SetCellBackgroundColour(u+j0,1,colour); 
										   j0++; 
										   grid->SetCellValue(u+j0,0,par->blackboard->lc[t1].name.c_str()); 
										   grid->SetReadOnly(u+j0,0); 
										   grid->SetCellBackgroundColour(u+j0,0,colour); 
										   //grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
                                           grid->SetReadOnly(u+j0,1); 
										   grid->SetCellBackgroundColour(u+j0,1,colour); 
										   j0++; 
										   okj = true; 
										} 
										else{ 
                                             for(int t2 = 0;t2 < par->blackboard->lc.size();t2++){ 
												 for(int t3 = 0;t3blackboard->lc.size();t3++){ 
													 if(par->blackboard->lc[t2].type == 1 
														&& 
														par->blackboard->lc[t2].line_end == par->blackboard->lc[t3].line_begin 
														&& 
														par->blackboard->lc[t3].type == 31 
														&& 
														par->blackboard->lc[t3].line_end == index 
														&& 
														par->blackboard->lc[t3].if_complex != true){ 
														grid->SetCellValue(u+j0,0,par->blackboard->genes[par->blackboard->lc[t2].line_begin].name.c_str()); 
														grid->SetReadOnly(u+j0,0); 
														grid->SetCellBackgroundColour(u+j0,0,colour); 
														grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
														grid->SetReadOnly(u+j0,1); 
														grid->SetCellBackgroundColour(u+j0,1,colour); 
														j0++; 
														grid->SetCellValue(u+j0,0,par->blackboard->genes[par->blackboard->lc[t2].line_begin].name.c_str()); 
														grid->SetReadOnly(u+j0,0); 
														grid->SetCellBackgroundColour(u+j0,0,colour); 
														//grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
														grid->SetReadOnly(u+j0,1); 
														grid->SetCellBackgroundColour(u+j0,1,colour); 
														j0++; 
														okj = true; 
													 } 
												 } 
												 for(int t3 = 0;t3blackboard->lc.size();t3++){ 
													 if(par->blackboard->lc[t2].type == 2 
														&& 
														par->blackboard->lc[t2].line_end == par->blackboard->lc[t3].line_begin 
														&& 
														par->blackboard->lc[t3].type == 31 
														&& 
														par->blackboard->lc[t3].line_end == index 
														&& 
														par->blackboard->lc[t3].if_complex != true){ 
														grid->SetCellValue(u+j0,0,par->blackboard->otf[par->blackboard->lc[t2].line_begin].name.c_str()); 
														grid->SetReadOnly(u+j0,0); 
														grid->SetCellBackgroundColour(u+j0,0,colour); 
														grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
														grid->SetReadOnly(u+j0,1); 
														grid->SetCellBackgroundColour(u+j0,1,colour); 
														j0++; 
														grid->SetCellValue(u+j0,0,par->blackboard->otf[par->blackboard->lc[t2].line_begin].name.c_str()); 
														grid->SetReadOnly(u+j0,0); 
														grid->SetCellBackgroundColour(u+j0,0,colour); 
														//grid->SetCellValue(u+j0,1,par->blackboard->lc[t].name.c_str()); 
														grid->SetReadOnly(u+j0,1); 
														grid->SetCellBackgroundColour(u+j0,1,colour); 
														j0++; 
														okj = true; 
													 } 
												 } 
											 } 
										} 
									 }		 
									 if(okj == true) 
										break;							 
								 } 
							  } 
						   } 
						   else{ 
							   for(int t0 = 0;t0 < par->blackboard->lc.size();t0++){ 
								   for(int r = 0;r < par->blackboard->lc.size();r++){ 
									   wxString name; 
										  if(par->blackboard->lc[t0].type == 1 
											 && 
											 par->blackboard->lc[t0].line_end == par->blackboard->lc[r].line_begin 
											 && 
											 par->blackboard->lc[r].type == 3 
											 && 
											 par->blackboard->lc[r].line_end == index 
											 && 
											 r == t 
											 && 
											 par->blackboard->lc[r].if_complex != true){ 
											  grid->SetCellValue(u+j0,1,par->blackboard->genes[par->blackboard->lc[t0].line_begin].name.c_str()); 
											  grid->SetReadOnly(u+j0,1); 
											  grid->SetCellBackgroundColour(u+j0,1,colour); 
											  grid->SetReadOnly(u+j0,0); 
											  grid->SetCellBackgroundColour(u+j0,0,colour); 
											  j0++; 
											  name = par->blackboard->genes[par->blackboard->lc[t0].line_begin].name.c_str(); 
											  if(num1 != 0){ 
												 for(int t1 = 0;t1 < par->blackboard->lc.size();t1++){ 
													 if(par->blackboard->lc[t1].type == 31 
														&& 
														par->blackboard->lc[t1].line_end == index){ 
														if(par->blackboard->lc[t1].if_complex){ 
														   grid->SetCellValue(u+j0,0,par->blackboard->lc[t1].name.c_str()); 
														   grid->SetReadOnly(u+j0,0); 
														   grid->SetCellBackgroundColour(u+j0,0,colour); 
														   grid->SetCellValue(u+j0,1,name); 
														   grid->SetReadOnly(u+j0,1); 
														   grid->SetCellBackgroundColour(u+j0,1,colour); 
														   j0++; 
														} 
														else{ 
															 for(int t2 = 0;t2 < par->blackboard->lc.size();t2++){ 
																 for(int t3 = 0;t3blackboard->lc.size();t3++){ 
																	 if(par->blackboard->lc[t2].type == 1 
																		&& 
																		par->blackboard->lc[t2].line_end == par->blackboard->lc[t3].line_begin 
																		&& 
																		par->blackboard->lc[t3].type == 31 
																		&& 
																		par->blackboard->lc[t3].line_end == index 
																		&& 
																		par->blackboard->lc[t3].if_complex != true){ 
																		grid->SetCellValue(u+j0,0,par->blackboard->genes[par->blackboard->lc[t2].line_begin].name.c_str()); 
																		grid->SetReadOnly(u+j0,0); 
																		grid->SetCellBackgroundColour(u+j0,0,colour); 
																		grid->SetCellValue(u+j0,1,name); 
																		grid->SetReadOnly(u+j0,1); 
																		grid->SetCellBackgroundColour(u+j0,1,colour); 
																		j0++; 
																	 } 
																 } 
																 for(int t3 = 0;t3blackboard->lc.size();t3++){ 
																	 if(par->blackboard->lc[t2].type == 2 
																		&& 
																		par->blackboard->lc[t2].line_end == par->blackboard->lc[t3].line_begin 
																		&& 
																		par->blackboard->lc[t3].type == 31 
																		&& 
																		par->blackboard->lc[t3].line_end == index 
																		&& 
																		par->blackboard->lc[t3].if_complex != true){ 
																		grid->SetCellValue(u+j0,0,par->blackboard->otf[par->blackboard->lc[t2].line_begin].name.c_str()); 
																		grid->SetReadOnly(u+j0,0); 
																		grid->SetCellBackgroundColour(u+j0,0,colour); 
																		grid->SetCellValue(u+j0,1,name); 
																		grid->SetReadOnly(u+j0,1); 
																		grid->SetCellBackgroundColour(u+j0,1,colour); 
																		j0++; 
																	 } 
																 } 
															 } 
														} 
													 }										 
												 } 
											  } 
								           } 
								  } 
							   } 
							   for(int t0 = 0;t0 < par->blackboard->lc.size();t0++){ 
								   for(int r = 0;r < par->blackboard->lc.size();r++){ 
									   wxString name; 
										  if(par->blackboard->lc[t0].type == 2 
											 && 
											 par->blackboard->lc[t0].line_end == par->blackboard->lc[r].line_begin 
											 && 
											 par->blackboard->lc[r].type == 3 
											 && 
											 par->blackboard->lc[r].line_end == index 
											 && 
											 r == t 
											 && 
											 par->blackboard->lc[r].if_complex != true){ 
											  grid->SetCellValue(u+j0,1,par->blackboard->otf[par->blackboard->lc[t0].line_begin].name.c_str()); 
											  grid->SetReadOnly(u+j0,1); 
											  grid->SetCellBackgroundColour(u+j0,1,colour); 
											  grid->SetReadOnly(u+j0,0); 
											  grid->SetCellBackgroundColour(u+j0,0,colour); 
											  j0++; 
											  name = par->blackboard->otf[par->blackboard->lc[t0].line_begin].name.c_str(); 
											  if(num1 != 0){ 
												 for(int t1 = 0;t1 < par->blackboard->lc.size();t1++){ 
													 if(par->blackboard->lc[t1].type == 31 
														&& 
														par->blackboard->lc[t1].line_end == index){ 
														if(par->blackboard->lc[t1].if_complex){ 
														   grid->SetCellValue(u+j0,0,par->blackboard->lc[t1].name.c_str()); 
														   grid->SetReadOnly(u+j0,0); 
														   grid->SetCellBackgroundColour(u+j0,0,colour); 
														   grid->SetCellValue(u+j0,1,name); 
														   grid->SetReadOnly(u+j0,1); 
														   grid->SetCellBackgroundColour(u+j0,1,colour); 
														   j0++; 
														} 
														else{ 
															 for(int t2 = 0;t2 < par->blackboard->lc.size();t2++){ 
																 for(int t3 = 0;t3blackboard->lc.size();t3++){ 
																	 if(par->blackboard->lc[t2].type == 1 
																		&& 
																		par->blackboard->lc[t2].line_end == par->blackboard->lc[t3].line_begin 
																		&& 
																		par->blackboard->lc[t3].type == 31 
																		&& 
																		par->blackboard->lc[t3].line_end == index 
																		&& 
																		par->blackboard->lc[t3].if_complex != true){ 
																		grid->SetCellValue(u+j0,0,par->blackboard->genes[par->blackboard->lc[t2].line_begin].name.c_str()); 
																		grid->SetReadOnly(u+j0,0); 
																		grid->SetCellBackgroundColour(u+j0,0,colour); 
																		grid->SetCellValue(u+j0,1,name); 
																		grid->SetReadOnly(u+j0,1); 
																		grid->SetCellBackgroundColour(u+j0,1,colour); 
																		j0++; 
																	 } 
																 } 
																 for(int t3 = 0;t3blackboard->lc.size();t3++){ 
																	 if(par->blackboard->lc[t2].type == 2 
																		&& 
																		par->blackboard->lc[t2].line_end == par->blackboard->lc[t3].line_begin 
																		&& 
																		par->blackboard->lc[t3].type == 31 
																		&& 
																		par->blackboard->lc[t3].line_end == index 
																		&& 
																		par->blackboard->lc[t3].if_complex != true){ 
																		grid->SetCellValue(u+j0,0,par->blackboard->otf[par->blackboard->lc[t2].line_begin].name.c_str()); 
																		grid->SetReadOnly(u+j0,0); 
                                                                        grid->SetCellBackgroundColour(u+j0,0,colour); 
																		grid->SetCellValue(u+j0,1,name); 
																		grid->SetReadOnly(u+j0,1); 
																		grid->SetCellBackgroundColour(u+j0,1,colour); 
																		j0++; 
																	 } 
																 } 
															 } 
														} 
													 }										 
												 } 
											  } 
										  } 
								      } 
							   } 
 
							  } 
 
						   } 
 
					} 
                                   /// 
							   goto a; 
							       /// 
				} 
		  } 
		  else{ 
a:		  for(int e = 0; e < 1;e++){ 
				  if(u != 0) 
					 j0--; 
				  for(int t = 0;tblackboard->lc.size();t++){ 
					  int t1 = 0; 
					  for(t1 = 0;t1 < par->blackboard->lc.size();t1++){ 
						  if(par->blackboard->lc[t].type == 31 
							 && 
							 par->blackboard->lc[t1].line_end == par->blackboard->lc[t].line_begin 
							 && 
							 par->blackboard->lc[t].if_complex != true 
							 && 
							 par->blackboard->lc[t1].type == 2 
							 && 
							 par->blackboard->lc[t].line_end == index){ 
							  
							 grid->SetCellValue(u+j0,0,par->blackboard->otf[par->blackboard->lc[t1].line_begin].name.c_str()); 
							 grid->SetReadOnly(u+j0,0); 
							 grid->SetCellBackgroundColour(u+j0,0,colour); 
							 grid->SetReadOnly(u+j0,1); 
							 grid->SetCellBackgroundColour(u+j0,1,colour); 
							 j0++; 
							 break; 
						  }/* 
						  if(par->blackboard->lc[t].type == 3 
							 && 
							 par->blackboard->lc[t1].line_end == par->blackboard->lc[t].line_begin 
							 && 
							 par->blackboard->lc[t].if_complex != true 
							 && 
							 par->blackboard->lc[t1].type == 2 
							 && 
							 par->blackboard->lc[t].line_end == index){ 
							  
							 grid->SetCellValue(u+j0,1,par->blackboard->otf[par->blackboard->lc[t1].line_begin].name.c_str()); 
							 grid->SetReadOnly(u+j0,0); 
							 grid->SetCellBackgroundColour(u+j0,0,colour); 
							 grid->SetReadOnly(u+j0,1); 
							 grid->SetCellBackgroundColour(u+j0,1,colour); 
							 j0++; 
							 break; 
						  }*/ 
					  } 
					  if(t1 != par->blackboard->lc.size()) 
						  break; 
				  } 
				  for(int t = 0;tblackboard->lc.size();t++){ 
					  int t1 = 0; 
					  for(t1 = 0;t1 < par->blackboard->lc.size();t1++){ 
						  if(par->blackboard->lc[t].type == 31 
							 && 
							 par->blackboard->lc[t1].line_end == par->blackboard->lc[t].line_begin 
							 && 
							 par->blackboard->lc[t].if_complex != true 
							 && 
							 par->blackboard->lc[t1].type == 1 
							 && 
							 par->blackboard->lc[t].line_end == index){ 
							  
							 grid->SetCellValue(u+j0,0,par->blackboard->genes[par->blackboard->lc[t1].line_begin].name.c_str()); 
							 grid->SetReadOnly(u+j0,0); 
							 grid->SetCellBackgroundColour(u+j0,0,colour); 
							 grid->SetReadOnly(u+j0,1); 
							 grid->SetCellBackgroundColour(u+j0,1,colour); 
							 j0++; 
							 break; 
						  }/* 
						  if(par->blackboard->lc[t].type == 3 
							 && 
							 par->blackboard->lc[t1].line_end == par->blackboard->lc[t].line_begin 
							 && 
							 par->blackboard->lc[t].if_complex != true 
							 && 
							 par->blackboard->lc[t1].type == 1 
							 && 
							 par->blackboard->lc[t].line_end == index){ 
							  
							 grid->SetCellValue(u+j0,1,par->blackboard->genes[par->blackboard->lc[t1].line_begin].name.c_str()); 
							 grid->SetReadOnly(u+j0,0); 
							 grid->SetCellBackgroundColour(u+j0,0,colour); 
							 grid->SetReadOnly(u+j0,1); 
							 grid->SetCellBackgroundColour(u+j0,1,colour); 
							 j0++; 
							 break; 
						  }*/ 
					  } 
					  if(t1 != par->blackboard->lc.size()) 
						  break; 
				  } 
				 // for(int t = 0;tblackboard->lc.size();t++){ 
					  int t1 = 0; 
					  for(t1 = 0;t1 < par->blackboard->lc.size();t1++){ 
						  if(par->blackboard->lc[t1].type == 31 
							 && 
							 par->blackboard->lc[t1].if_complex == true 
							 && 
							 par->blackboard->lc[t1].line_end == index){ 
							  
							 grid->SetCellValue(u+j0,0,par->blackboard->lc[t1].name.c_str()); 
							 grid->SetReadOnly(u+j0,0); 
							 grid->SetCellBackgroundColour(u+j0,0,colour); 
							 grid->SetReadOnly(u+j0,1); 
							 grid->SetCellBackgroundColour(u+j0,1,colour); 
							 j0++; 
							// break; 
						  } 
						  /* 
						  if(par->blackboard->lc[t1].type == 3 
							 && 
							 par->blackboard->lc[t1].if_complex == true 
							 && 
							 par->blackboard->lc[t1].line_end == index){ 
							  
							 grid->SetCellValue(u+j0,1,par->blackboard->lc[t1].name.c_str()); 
							 grid->SetReadOnly(u+j0,0); 
							 grid->SetCellBackgroundColour(u+j0,0,colour); 
							 grid->SetReadOnly(u+j0,1); 
							 grid->SetCellBackgroundColour(u+j0,1,colour); 
							 j0++; 
							// break; 
						  }*/ 
					  } 
					  if(t1 != par->blackboard->lc.size()) 
						  break; 
				 // } 
			  } 
			} 
		  } 
//// 
 
	wxString temp; 
	string temp1; 
 
	if(type == 1){ 
	   for(int i = 0;i < ct.size();i++){ 
		  (*ct[i]).Enable(false); 
	   } 
	   for(int i = 0;i < line.size();i++){ 
		  (*line[i]).Enable(false); 
	   } 
	   if(par->blackboard->genes1[index].mrna.number != -1){ 
	      int a = par->blackboard->genes1[index].mrna.number; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_M_RNA))->SetValue(temp1.c_str()); 
	   }	 
	   if(par->blackboard->genes1[index].mrna.life_time != -1){ 
	      double a = par->blackboard->genes1[index].mrna.life_time; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P1))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->genes1[index].mrna.decay != -1){ 
	      double a = par->blackboard->genes1[index].mrna.decay; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_M_RNA1))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->genes1[index].mrna.delay_time != -1){ 
	      double a = par->blackboard->genes1[index].mrna.delay_time; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P3))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->genes1[index].pro.number != -1){ 
	      int a = par->blackboard->genes1[index].pro.number; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P))->SetValue(temp1.c_str()); 
	   }	 
	   if(par->blackboard->genes1[index].pro.life_time != -1){ 
	      double a = par->blackboard->genes1[index].pro.life_time; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_D2))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->genes1[index].pro.decay != -1){ 
	      double a = par->blackboard->genes1[index].pro.decay; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_D1))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->genes1[index].promotor.number_active_postive != -1.0){ 
	      double a = par->blackboard->genes1[index].promotor.number_active_postive; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->genes1[index].name != ""){ 
	      ((wxTextCtrl*)this->FindWindow(wxID_SIM_NAME))->SetValue((wxString)(par->blackboard->genes1[index].name.c_str())); 
	   } 
	} 
	if(type == 2){ 
	    for(int i = 0; iblackboard->otf1[index].init_number != -1){ 
	      int a = par->blackboard->otf1[index].init_number; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->otf1[index].name != ""){ 
	      string a = par->blackboard->otf1[index].name; 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_NAME))->SetValue(a.c_str()); 
	   } 
	} 
	if(type == 3){//ct 
	    for(int i = 0; iblackboard->ct1[index].c != 0.0){ 
	      double a = par->blackboard->ct1[index].c; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->SetValue(temp1.c_str()); 
	   }	    
	} 
	if(type == 4){//line 
	    for(int i = 0; iblackboard->lc1[index].if_complex)){ 
				(*gene[i]).Enable(true); 
			}// 
			if((*gene[i]).GetId() == wxID_SIM_NAME && (par->blackboard->lc1[index].if_complex)){ 
				(*gene[i]).Enable(true); 
			} 
		} 
		for(int i = 0;i < ct.size();i++){ 
			//if(!par->blackboard->lc1[index].if_complex)// && !((*ct[i]).GetId() == wxID_SIM_GENE_CT) 
			   (*ct[i]).Enable(false); 
		} 
		for(int i = 0;i < ct.size();i++){//wxID_SIM_GENE_CT 
			if(par->blackboard->lc1[index].if_complex && par->blackboard->lc1[index].type == 3)// && !((*ct[i]).GetId() == wxID_SIM_GENE_CT) 
			   (*ct[i]).Enable(true); 
            if(par->blackboard->lc1[index].if_complex && par->blackboard->lc1[index].type == 31)// && !((*ct[i]).GetId() == wxID_SIM_GENE_CT) 
			   (*ct[i]).Enable(true); 
			if((*ct[i]).GetId() == wxID_SIM_GENE_CT && par->blackboard->lc1[index].type == 5 
			   || 
			   (*ct[i]).GetId() == wxID_SIM_GENE_CT && par->blackboard->lc1[index].type == 6 
			   || 
			   (*ct[i]).GetId() == wxID_SIM_GENE_CT && par->blackboard->lc1[index].type == 7 
			   || 
			   (*ct[i]).GetId() == wxID_SIM_GENE_CT && par->blackboard->lc1[index].type == 4) 
			   //|| 
			   //(*ct[i]).GetId() == wxID_SIM_GENE_CT && par->blackboard->lc1[index].type == 31) 
			   (*ct[i]).Enable(true); 
		} 
		for(int i = 0;i < otf.size();i++){ 
			(*otf[i]).Enable(false); 
		} 
		for(int i = 0;i < line.size();i++){ 
		   (*line[i]).Enable(false); 
		} 
		for(int i = 0;i < line.size();i++){ 
			if((*line[i]).GetId() == wxID_SIM_LINE_CT && par->blackboard->lc1[index].type != 2 && par->blackboard->lc1[index].if_complex != true 
			   || 
			   (*line[i]).GetId() == wxID_SIM_LINE_FUN && par->blackboard->lc1[index].type == 3 
			   || 
			   (*line[i]).GetId() == wxID_SIM_LINE_FUN && par->blackboard->lc1[index].type == 5 
			   || 
			   (*line[i]).GetId() == wxID_SIM_LINE_FUN && par->blackboard->lc1[index].type == 6 
			   || 
			   (*line[i]).GetId() == wxID_SIM_LINE_FUN && par->blackboard->lc1[index].type == 7) 
			   (*line[i]).Enable(true); 
		} 
	   if(par->blackboard->lc1[index].c != 0.0){ 
	      int a = par->blackboard->lc1[index].c; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_LINE_CT))->SetValue(temp1.c_str()); 
	   }	 
	   if(par->blackboard->lc1[index].c != 0.0){ 
	      double a = par->blackboard->lc1[index].function; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_LINE_FUN))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->lc1[index].number != 0.0 && par->blackboard->lc1[index].if_complex){ 
	      int a = par->blackboard->lc1[index].number; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->lc1[index].constant != 0.0 && par->blackboard->lc1[index].if_complex){ 
	      double a = par->blackboard->lc1[index].constant; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->lc1[index].constant != 0.0 && par->blackboard->lc1[index].type == 5 
		  || 
		  par->blackboard->lc1[index].constant != 0.0 && par->blackboard->lc1[index].type == 6 
		  || 
		  par->blackboard->lc1[index].constant != 0.0 && par->blackboard->lc1[index].type == 7){ 
	      double a = par->blackboard->lc1[index].constant; 
	      temp1 = boost::lexical_cast(a); 
          ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->SetValue(temp1.c_str()); 
	   } 
	   if(par->blackboard->lc1[index].name != "" && par->blackboard->lc1[index].type == 4 
		  || 
		  par->blackboard->lc1[index].name != "" && par->blackboard->lc1[index].type == 3 
		  || 
		  par->blackboard->lc1[index].name != "" && par->blackboard->lc1[index].type == 31){ 
	      ((wxTextCtrl*)this->FindWindow(wxID_SIM_NAME))->SetValue(par->blackboard->lc1[index].name.c_str()); 
	   } 
	} 
} 
 
ParamentDialog::~ParamentDialog(void) 
{ 
    gene.clear(); 
	ct.clear(); 
	line.clear(); 
	otf.clear(); 
//	delete grid; 
} 
 
void ParamentDialog::OnOK(wxCommandEvent& event) 
{ 
    int number;double number1;int a8; 
	string temp; 
	string temp1; 
    boost::smatch what; 
	myCanvas_1 * parent; 
	parent = (myCanvas_1 *)GetParent(); 
	wxPaintEvent event1; 
	event1.SetEventObject(parent); 
	if(type == 1){//gene's paramentary 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_M_RNA))->GetValue();//mrna number 
	   if(temp != "" && boost::regex_match(temp, what,reNumber)){ 
	      number = boost::lexical_cast(temp); 
		  parent->blackboard->genes[index].mrna.number = number; 
		  parent->blackboard->genes1[index].mrna.number = number; 
	   } 
	   else{ 
		  wxMessageBox("Please input:mRNA initial number or the input is error!"); 
		  return;	       
	   } 
	    
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P))->GetValue();//pro number 
	   if(temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].pro.number = number; 
		   parent->blackboard->genes1[index].pro.number = number; 
	   } 
	   else{ 
		  wxMessageBox("Please input:Protein initial number or the input is error!"); 
		  return; 
	   } 
 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P1))->GetValue();//mrna life time 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number1 = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].mrna.life_time = number1; 
		   parent->blackboard->genes[index].mrna.native_active = number1; 
		   parent->blackboard->genes1[index].mrna.life_time = number1; 
		   parent->blackboard->genes1[index].mrna.native_active = number1; 
	   } 
	   else{ 
		  wxMessageBox("Please input:mRNA life time or the input is error!"); 
		  return; 
	   } 
 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_M_RNA1))->GetValue();//mrna decay 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number1 = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].mrna.decay = number1; 
		   parent->blackboard->genes1[index].mrna.decay = number1; 
	   } 
	   else{ 
		  wxMessageBox("Please input:mRNA decay or the input is error!"); 
		  return; 
	   } 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_D2))->GetValue();//pro life time 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number1 = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].pro.life_time = number1; 
		   parent->blackboard->genes1[index].pro.life_time = number1; 
	   } 
	   else{ 
		  wxMessageBox("Please input:Protein life time or the input is error!"); 
		  return; 
	   } 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P3))->GetValue();//mrna delay time 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number1 = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].mrna.delay_time = number1; 
		   parent->blackboard->genes1[index].mrna.delay_time = number1; 
	   } 
	   else{ 
		  wxMessageBox("Please input:mRNA delay time or the input is error!"); 
		  return; 
	   } 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_D1))->GetValue();//mrna delay time 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number1 = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].pro.decay = number1; 
		   parent->blackboard->genes1[index].pro.decay = number1; 
	   } 
	   else{ 
		  wxMessageBox("Please input:Protein decay rate or the input is error!"); 
		  return; 
	   }/* 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->GetValue();//Reaction constant 
	   if(temp != ""){ 
		   number1 = boost::lexical_cast(temp); 
		   parent->blackboard->genes[index].promotor.number_active_postive = number1; 
	   } 
	   else{ 
		   wxMessageBox("Please input: Reaction constant"); 
		   return; 
	   }*/ 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_NAME))->GetValue();//name 
	   int q; 
	   for(q = 0; q < parent->blackboard->genes.size() ;q++){ 
           if(parent->blackboard->genes[q].name == temp) 
		      break; 
	   } 
	   if(q == parent->blackboard->genes.size()){ 
	      parent->blackboard->genes[index].name = temp; 
	      parent->blackboard->genes1[index].name = temp; 
		  parent->OnPaint(event1); 
	   } 
	   else if(q != parent->blackboard->genes.size() 
		       && 
			   index != q){ 
	      wxMessageBox("Please change the name of this gene!"); 
	   } 
	} 
	if(type == 2){ 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P))->GetValue();//pro number 
	   if(temp != "" && boost::regex_match(temp, what,reNumber)){ 
		   number = boost::lexical_cast(temp); 
		   parent->blackboard->otf[index].init_number = number; 
		   parent->blackboard->otf1[index].init_number = number; 
	   } 
	   else{ 
		   wxMessageBox("Please input: Otf number or the input is error!"); 
		   return; 
	   } 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_NAME))->GetValue();//pro number 
	   if(temp != ""){ 
		   int q; 
		   for(q = 0; q < parent->blackboard->otf.size() ;q++){ 
			   if(parent->blackboard->otf[q].name == temp) 
				  break; 
		   } 
		   if(q == parent->blackboard->otf.size()){ 
			   parent->blackboard->otf[index].name = temp; 
			   parent->blackboard->otf1[index].name = temp; 
			   parent->OnPaint(event1); 
		   } 
	       else if(q != parent->blackboard->otf.size() 
		           && 
			       index != q){ 
			       wxMessageBox("Please change the name of this protein!"); 
		   } 
	   } 
	   else{ 
		   wxMessageBox("Please input: Otf's name or the input is error!"); 
		   return; 
	   } 
	} 
	if(type == 3){ 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->GetValue();//pro number 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){ 
	      double number1 = boost::lexical_cast(temp); 
	      parent->blackboard->ct[index].c = number1;    
		  parent->blackboard->ct1[index].c = number1; 
	   } 
	   else{ 
		   wxMessageBox("Please input: Control constant or the input is error!"); 
		   return; 
	   } 
	} 
	if(type == 4){//line 
	   if(parent->blackboard->lc[index].type == 5 || parent->blackboard->lc[index].type == 6 || parent->blackboard->lc[index].type == 7){ 
		   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->GetValue();//pro number 
		   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
			  || 
			  temp != "" && boost::regex_match(temp, what,reNumber)){ 
			  double n = boost::lexical_cast(temp); 
			  parent->blackboard->lc[index].constant = n;	 
			  parent->blackboard->lc1[index].constant = n; 
		   } 
		   else{ 
			   wxMessageBox("Please input: Line reaction constant or the input is error!"); 
			   return; 
		   }       
	   } 
	   if(parent->blackboard->lc[index].type == 1){ 
		  temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_LINE_CT))->GetValue();//pro number 
		  if(temp != "" && boost::regex_match(temp, what,reNumber)){ 
		     number = boost::lexical_cast(temp); 
			 parent->blackboard->lc[index].c = number;  
			 parent->blackboard->lc1[index].c = number;  
		  } 
		  else{ 
			   wxMessageBox("Please input: Line constant or the input is error!"); 
			   return; 
		  } 
	   } 
	   if(parent->blackboard->lc[index].type == 3 && !parent->blackboard->lc[index].if_complex 
		  || 
		  parent->blackboard->lc[index].type == 31 && !parent->blackboard->lc[index].if_complex){ 
		  parent->blackboard->genes[parent->blackboard->lc[index].line_end].promotor.number_active_postive = parent->blackboard->ct1[parent->blackboard->lc[index].line_begin].c; 
		  parent->blackboard->genes1[parent->blackboard->lc[index].line_end].promotor.number_active_postive = parent->blackboard->ct1[parent->blackboard->lc[index].line_begin].c; 
		  //parent->updatagenepromotorrule(); 
		  parent->blackboard->genes[parent->blackboard->lc[index].line_end].promotor.l.clear(); 
		  parent->blackboard->genes1[parent->blackboard->lc[index].line_end].promotor.l.clear(); 
	   } 
	   if(parent->blackboard->lc[index].if_complex){ 
		   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->GetValue();//pro number 
		   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
			  || 
			  temp != "" && boost::regex_match(temp, what,reNumber)){ 
			  double n = boost::lexical_cast(temp); 
			  parent->blackboard->lc[index].constant = n;	 
			  parent->blackboard->lc1[index].constant = n; 
		   } 
		   else{ 
			   wxMessageBox("Please input: Line reaction constant or the input is error!"); 
			   return; 
		   }//wxID_SIM_GENE_P 
		   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_P))->GetValue();// 
		   if(temp != ""&&boost::regex_match(temp, what,reNumber)){ 
			  int n = boost::lexical_cast(temp); 
			  parent->blackboard->lc[index].number = n;		 
			  parent->blackboard->lc1[index].number = n;	 
			  a8 = n; 
		   } 
		   else{ 
			   wxMessageBox("Please input: Protein complex's initial number or the input is error!"); 
			   return; 
		   } 
		   int t = parent->blackboard->lc1[index].line_begin; 
			   for(int y = 0;y < parent->blackboard->lc.size();y++){ 
				   if(parent->blackboard->lc[y].type == 4 
					  && 
					  parent->blackboard->lc[y].line_begin == t 
					  && 
					  y != index 
					  || 
					  parent->blackboard->lc[y].type == 3 
					  && 
					  parent->blackboard->lc[y].line_begin == t 
					  && 
					  y != index 
					  || 
					  parent->blackboard->lc[y].type == 31 
					  && 
					  parent->blackboard->lc[y].line_begin == t 
					  && 
					  y != index){ 
                                  if(parent->blackboard->lc[y].if_complex == true){ 
                                                                            parent->blackboard->lc[y].number = a8;		 
			                                                                parent->blackboard->lc1[y].number = a8; 
								  } 
				   } 
			   } 
		   //} 
		   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_NAME))->GetValue();// 
		   if(temp.c_str() != ""){ 
			  parent->blackboard->lc[index].name = temp.c_str();		 
			  parent->blackboard->lc1[index].name = temp.c_str();	 
			  int a; 
			  for(a = 0;a < parent->blackboard->lc1.size();a++){ 
				  if(parent->blackboard->lc1[index].line_begin == parent->blackboard->lc1[a].line_begin 
					 && 
					 parent->blackboard->lc1[a].if_complex == true 
                     && 
					 a != index){ 
						         parent->blackboard->lc1[a].name = temp.c_str(); 
								 parent->blackboard->lc[a].name = temp.c_str(); 
					 } 
			  } 
		   } 
		   else{ 
			   wxMessageBox("Please input: Protein complex's name or the input is error!"); 
			   return; 
		   } 
		   if(parent->blackboard->lc[index].type == 3 || parent->blackboard->lc[index].type == 31){ 
			  temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_GENE_CT))->GetValue();//Reaction constant 
			  if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
				 || 
				 temp != "" && boost::regex_match(temp, what,reNumber)){ 
				 number1 = boost::lexical_cast(temp); 
				 parent->blackboard->genes[parent->blackboard->lc[index].line_end].promotor.number_active_postive = number1; 
				 parent->blackboard->genes1[parent->blackboard->lc[index].line_end].promotor.number_active_postive = number1; 
			  } 
			  else{ 
				   wxMessageBox("Please input: Reaction constant or the input is error!"); 
				   return; 
			  } 
		   } 
	   } 
 
	   temp = ((wxTextCtrl*)this->FindWindow(wxID_SIM_LINE_FUN))->GetValue();//pro number 
	   if(temp != ""&&boost::regex_match(temp, what,reNumber1) 
		  || 
		  temp != "" && boost::regex_match(temp, what,reNumber)){//function 只能大于0,当>1时是促进 
		   double n = boost::lexical_cast(temp); 
		   if(n != 0){ 
		      parent->blackboard->lc[index].function = n;   
			  parent->blackboard->lc1[index].function = n; 
			  if(parent->blackboard->lc[index].type != 5) 
		         parent->DrawLineC(parent->blackboard->lc[index].ptbegin,parent->blackboard->lc[index].ptend,parent->blackboard->lc[index].function); 
			  else 
                 parent->DrawLineC1(parent->blackboard->lc[index].ptbegin,parent->blackboard->lc[index].ptend,parent->blackboard->lc[index].function); 
			  parent->OnPaint(event1); 
		   } 
		   else{ 
		      wxMessageBox("Please input: Line function do not equal to zero!"); 
			  return; 
		   } 
	   } 
	   else{ 
		   wxMessageBox("Please input: Line function or the input is error!"); 
		   return; 
	   } 
	} 
 
	if(type == 1){ 
	   parent->blackboard->genes[index].promotor.l.clear(); 
	   parent->blackboard->genes1[index].promotor.l.clear(); 
       int col = grid->GetNumberCols(); 
	   int row = grid->GetNumberRows(); 
        
	   for(int i = 0;i < row;i++){ 
		   promotorlaw p; 
		   p.one = grid->GetCellValue(i,0); 
		   p.two = grid->GetCellValue(i,1); 
		   string temp = grid->GetCellValue(i,2).c_str(); 
		   if(temp != "" && boost::regex_match(temp, what,reNumber1) 
			  || 
			  temp != "" && boost::regex_match(temp, what,reNumber)){ 
		      p.function = boost::lexical_cast(grid->GetCellValue(i,2).c_str()); 
			  parent->blackboard->genes[index].promotor.l.push_back(p); 
	          parent->blackboard->genes1[index].promotor.l.push_back(p); 
		   } 
		   else{ 
		      parent->blackboard->genes[index].promotor.l.clear(); 
	          parent->blackboard->genes1[index].promotor.l.clear(); 
		      wxMessageBox("Please input: The Gene's Promotor rule! or input is error!"); 
			  return; 
		   } 
	   } 
	} 
	/* 
    parent->blackboard->genes1.clear(); 
    parent->blackboard->ct1.clear(); 
    parent->blackboard->otf1.clear(); 
    parent->blackboard->lc1.clear(); 
	parent->blackboard->genes1 =parent->blackboard->genes; 
	parent->blackboard->ct1 = parent->blackboard->ct; 
	parent->blackboard->otf1 = parent->blackboard->otf; 
	parent->blackboard->lc1 = parent->blackboard->lc;*/ 
	//wxPaintEvent event1; 
	//event1.SetEventObject( parent ); 
    //this->m_eventHandler->ProcessEvent(event1); 
	wxDialog::OnOK(event); 
} 
 
/* 
		 int num0 = 0; 
		 int num1 = 0; 
 
         for(int i = 0;i< parent->blackboard->lc.size();i++){ 
			 if(parent->blackboard->lc[i].type == 3 
				&& 
				parent->blackboard->lc[i].line_end == index){ 
                num0++; 
			 } 
			 if(parent->blackboard->lc[i].type == 31 
				&& 
				parent->blackboard->lc[i].line_end == index){ 
			    num1++; 
			 } 
		 } 
 
		 if(num0 == 0 || num1 == 0){ 
			 for(int i = 0;i< parent->blackboard->lc.size();i++){//填充该基因promotor的生理规则 
				 if(parent->blackboard->lc[i].type == 3 
					&& 
					parent->blackboard->lc[i].line_end == index 
					|| 
					parent->blackboard->lc[i].type == 31 
					&& 
					parent->blackboard->lc[i].line_end == index){ 
						promotorlaw p; 
						if(parent->blackboard->lc[i].type == 3){						    
						   if(parent->blackboard->lc[i].if_complex){ 
						      p.two = parent->blackboard->lc[i].name; 
							  //p.function = ; 
						   } 
						   else{ 
							   for(int o = 0;o< parent->blackboard->lc.size();o++){ 
								   if(parent->blackboard->lc[o].type == 1 
									  && 
									  parent->blackboard->lc[o].line_end == parent->blackboard->lc[i].line_begin){ 
									  p.two = parent->blackboard->genes[parent->blackboard->lc[o].line_begin].name.c_str(); 
									  //p.function = ; 
									  break; 
								   } 
							   } 
						   }						    
                           parent->blackboard->genes[index].promotor.l.push_back(p); 
						} 
						else{ 
						   if(parent->blackboard->lc[i].if_complex){ 
						      p.one = parent->blackboard->lc[i].name; 
							  //p.function = ; 
						   } 
						   else{ 
							   for(int o = 0;o< parent->blackboard->lc.size();o++){ 
								   if(parent->blackboard->lc[o].type == 1 
									  && 
									  parent->blackboard->lc[o].line_end == parent->blackboard->lc[i].line_begin){ 
									  p.one = parent->blackboard->genes[parent->blackboard->lc[o].line_begin].name.c_str(); 
									  //p.function = ; 
									  break; 
								   } 
							   } 
						   }						    
                           parent->blackboard->genes[index].promotor.l.push_back(p); 
						} 
				 } 
			 } 
		 } 
		 else{ 
			 for(int i = 0;i< parent->blackboard->lc.size();i++){//填充该基因promotor的生理规则 
				 if(parent->blackboard->lc[i].type == 3 
					&& 
					parent->blackboard->lc[i].line_end == index 
					|| 
					parent->blackboard->lc[i].type == 31 
					&& 
					parent->blackboard->lc[i].line_end == index){ 
						promotorlaw p; 
						if(parent->blackboard->lc[i].type == 3){ 
						   if(parent->blackboard->lc[i].if_complex){ 
						      p.two = parent->blackboard->lc[i].name; 
							  //p.function = ; 
						   } 
						   else{ 
							   for(int o = 0;o< parent->blackboard->lc.size();o++){ 
								   if(parent->blackboard->lc[o].type == 1 
									  && 
									  parent->blackboard->lc[o].line_end == parent->blackboard->lc[i].line_begin){ 
									  p.two = parent->blackboard->genes[parent->blackboard->lc[o].line_begin].name.c_str(); 
									  //p.function = ; 
									  break; 
								   } 
							   } 
						   } 
						   for(int o = 0;o < num1;o++){ 
							   if( o != num1-1){ 
                                   p.one = ""; 
								   //p.function = ; 
							   } 
							   else{ 
                                    for(int z = 0;z< parent->blackboard->lc.size();z++){ 
										if(parent->blackboard->lc[z].type == 31 
										   && 
										   parent->blackboard->lc[z].line_end == index){ 
																if(parent->blackboard->lc[z].if_complex){ 
																					 p.one = parent->blackboard->lc[z].name; 
																					 } 
																else{ 
																				   for(int z1 = 0;z1< parent->blackboard->lc.size();z1++){ 
																					   if(parent->blackboard->lc[z1].type == 1 
																						  && 
																						  parent->blackboard->lc[z1].line_end == parent->blackboard->lc[z].line_begin){ 
																						  p.one = parent->blackboard->genes[parent->blackboard->lc[z1].line_begin].name.c_str(); 
																						  break; 
																					   } 
																				   }																    
																} 
										} 
									} 
							   } 
						   } 
						} 
						else{//type == 31 
						   if(parent->blackboard->lc[i].if_complex){ 
						      p.one = parent->blackboard->lc[i].name; 
							  //p.function = parent->blackboard->lc[i].function; 
						   } 
						   else{ 
							   for(int o = 0;o< parent->blackboard->lc.size();o++){ 
								   if(parent->blackboard->lc[o].type == 1 
									  && 
									  parent->blackboard->lc[o].line_end == parent->blackboard->lc[i].line_begin){ 
									  p.one = parent->blackboard->genes[parent->blackboard->lc[o].line_begin].name.c_str(); 
									  //p.function = ; 
									  break; 
								   } 
							   } 
						   } 
						   for(int o = 0;o< num0;o++){ 
							   if( o != num1-1){ 
                                   p.two = ""; 
								   //p.function = ; 
							   } 
							   else{//不填写,因为在type == 3 中已经算过这种情况了 
								   /* 
                                    for(int z = 0;z< parent->blackboard->lc.size();z++){ 
										if(parent->blackboard->lc[z].type == 3 
										   && 
										   parent->blackboard->lc[z].line_end == j){ 
																if(parent->blackboard->lc[z].if_complex){ 
																					 p.two = parent->blackboard->lc[z].name; 
																					 } 
																else{ 
																				   for(int z1 = 0;z1< parent->blackboard->lc.size();z1++){ 
																					   if(parent->blackboard->lc[z1].type == 1 
																						  && 
																						  parent->blackboard->lc[z1].line_end == parent->blackboard->lc[z].line_begin){ 
																						  p.two = parent->blackboard->gene[parent->blackboard->lc[z1].line_begin].name; 
																						  break; 
																					   } 
																				   }																    
																} 
										} 
									}*/ 
							 //  } 
						 //  } 
					//	} 
				// } 
			// } 
		// }	*/