コード例 #1
0
void lggBeamMapFloater::onClickSave(void* data)
{
	
	lggBeamMapFloater* self = (lggBeamMapFloater*)data;
	LLRect r  = self->getChild<LLPanel>("beamshape_draw")->getRect();
	
	LLFilePicker& picker = LLFilePicker::instance();
	
	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beams", ""));
				
	std::string filename=path_name2 + "myNewBeam.xml";
	if(!picker.getSaveFile( LLFilePicker::FFSAVE_BEAM, filename ) )
	{return;
	}	
	
	filename = path_name2 +gDirUtilp->getBaseFileName(picker.getFirstFile());

	
	LLSD main;
	main["scale"] = 8.0f/(r.getWidth());
	main["data"]=self->getMyDataSerialized();
  
	llofstream export_file;
	export_file.open(filename);
	LLSDSerialize::toPrettyXML(main, export_file);
	export_file.close();
	gSavedSettings.setString("PhoenixBeamShape",gDirUtilp->getBaseFileName(filename,true));

	if(self->empanel)
	{

		self->empanel->refresh();
	}
	
}
コード例 #2
0
ファイル: lggbeammaps.cpp プロジェクト: VirtualReality/Viewer
LLColor4U lggBeamMaps::getCurrentColor(LLColor4U agentColor)
{

    static LLCachedControl<std::string> ssettingName(gSavedSettings, "PhoenixBeamColorFile");
    std::string settingName = std::string(ssettingName);
    if(settingName == "===OFF===") return agentColor;

    if(settingName != lastColorFileName)
    {
        lastColorFileName = settingName;

        std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", ""));
        std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", ""));
        std::string filename = path_name + settingName + ".xml";
        if(gDirUtilp->fileExists(filename))
        {
        } else
        {
            filename = path_name2 + settingName + ".xml";
            if(!gDirUtilp->fileExists(filename))
            {
                return agentColor;
            }
        }

        lastColorsData = lggBeamsColors::fromLLSD(getPic(filename));
    }
    agentColor = beamColorFromData(lastColorsData);

    return agentColor;
}
コード例 #3
0
LLColor4U lggBeamMaps::getCurrentColor(LLColor4U agentColor)
{

	static std::string* settingName = rebind_llcontrol<std::string >("EmeraldBeamColorFile", &gSavedSettings, true);

	if(*settingName == "===OFF===") return agentColor;

	if(*settingName != lastColorFileName)
	{
		lastColorFileName = *settingName;
	
		std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", ""));
		std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", ""));
		std::string filename = path_name + *settingName + ".xml";
		if(gDirUtilp->fileExists(filename))
		{
		}else
		{
			filename = path_name2 + *settingName + ".xml";
			if(!gDirUtilp->fileExists(filename))
			{
				return agentColor;
			}
		}

		lastColorsData = lggBeamsColors::fromLLSD(getPic(filename));
	}
	agentColor = beamColorFromData(lastColorsData);
	
	return agentColor;
}
コード例 #4
0
void lggBeamColorMapFloater::onClickSave(void* data)
{
	
	lggBeamColorMapFloater* self = (lggBeamColorMapFloater*)data;
	LLFilePicker& picker = LLFilePicker::instance();
	
	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", ""));
				
	std::string filename=path_name2 + "myNewBeamColor.xml";
	if(!picker.getSaveFile( LLFilePicker::FFSAVE_BEAM, filename ) )
	{return;
	}	
	
	filename = path_name2 +gDirUtilp->getBaseFileName(picker.getFirstFile());

	
	LLSD main= self->getMyDataSerialized();
  
	llofstream export_file;
	export_file.open(filename);
	LLSDSerialize::toPrettyXML(main, export_file);
	export_file.close();

	gSavedSettings.setString("PhoenixBeamColorFile",gDirUtilp->getBaseFileName(filename,true));

	if(self->empanel != NULL)
	{
		self->empanel->refresh();
	}
	self->close();
}
コード例 #5
0
void LLPanelEmerald::onBeamColorDelete(void* data)
{
	LLPanelEmerald* self = (LLPanelEmerald*)data;

	LLComboBox* comboBox = self->getChild<LLComboBox>("BeamColor_combo");

	if(comboBox != NULL) 
	{
		std::string filename = comboBox->getValue().asString()+".xml";
		std::string path_name1(gDirUtilp->getExpandedFilename( LL_PATH_APP_SETTINGS , "beamsColors", filename));
		std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", filename));

		if(gDirUtilp->fileExists(path_name1))
		{
			LLFile::remove(path_name1);
			gSavedSettings.setString("EmeraldBeamColorFile","===OFF===");
		}
		if(gDirUtilp->fileExists(path_name2))
		{
			LLFile::remove(path_name2);
			gSavedSettings.setString("EmeraldBeamColorFile","===OFF===");
		}
	}
	self->refresh();
}
コード例 #6
0
ファイル: lggbeammaps.cpp プロジェクト: gabeharms/firestorm
LLColor4U lggBeamMaps::getCurrentColor(const LLColor4U& agentColor)
{
	static LLCachedControl<std::string> settingName(gSavedSettings, "FSBeamColorFile");
	std::string setName(settingName);

	if (setName.empty())
	{
		return agentColor;
	}

	if (setName != mLastColorFileName)
	{
		mLastColorFileName = settingName;
	
		std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", ""));
		std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beamsColors", ""));
		std::string filename = path_name + setName + ".xml";
		if (!gDirUtilp->fileExists(filename))
		{
			filename = path_name2 + setName + ".xml";
			if (!gDirUtilp->fileExists(filename))
			{
				return agentColor;
			}
		}

		mLastColorsData = lggBeamsColors::fromLLSD(getPic(filename));
	}
	
	return beamColorFromData(mLastColorsData);
}
コード例 #7
0
ファイル: lggbeammaps.cpp プロジェクト: gabeharms/firestorm
string_vec_t lggBeamMaps::getColorsFileNames()
{
	string_vec_t names;
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", ""));
	bool found = true;

	while (found)
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name);
		if (found)
		{
			name = name.erase(name.length() - 4);
			names.push_back(unescape_name(name));
		}
	}

	std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "beamsColors", ""));
	found = true;

	while (found)
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name);
		if (found)
		{
			name = name.erase(name.length() - 4);
			names.push_back(unescape_name(name));
		}
	}
	return names;
}
コード例 #8
0
F32 lggBeamMaps::setUpAndGetDuration()
{
	static LLCachedControl<std::string> settingNameCached(gSavedSettings, "FSBeamShape");
	std::string settingName(settingNameCached);
	if(settingName != lastFileName)
	{
		lastFileName = settingName;
		if( settingName != "===OFF===" && settingName != "")
		{

			std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", ""));
			std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beams", ""));
			std::string filename = path_name + settingName + ".xml";
			if (!gDirUtilp->fileExists(filename))
			{
				filename =path_name2 + settingName +".xml";
			}
			LLSD mydata = getPic(filename);
			scale = (F32)mydata["scale"].asReal()/10.0f;
			LLSD myPicture = mydata["data"];	
			dots.clear();
			for (int i = 0; i < myPicture.size(); i++)
			{
				LLSD beamData = myPicture[i];
				lggBeamData dot;
				
				dot.p = LLVector3d(beamData["offset"]);
				// <FS:PP> Attempt to speed up things a little
				// dot.p *= (gSavedSettings.getF32("FSBeamShapeScale")*2.0f);
				static LLCachedControl<F32> FSBeamShapeScale(gSavedSettings, "FSBeamShapeScale");
				dot.p *= (FSBeamShapeScale*2.0f);
				// </FS:PP>
				LLColor4 color = LLColor4(beamData["color"]);
				dot.c = LLColor4U(color);
				dots.push_back(dot);
			}
			
			// <FS:PP> Attempt to speed up things a little
			// F32 maxBPerQS = gSavedSettings.getF32("FSMaxBeamsPerSecond") / 4.0f;
			static LLCachedControl<F32> FSMaxBeamsPerSecond(gSavedSettings, "FSMaxBeamsPerSecond");
			F32 maxBPerQS = FSMaxBeamsPerSecond / 4.0f;
			// </FS:PP>
			duration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f;
			llinfos << "reading it all now size is " << myPicture.size() << " and duration is " << duration << llendl;
		
		}
		else
		{
			dots.clear();
			scale = 0.0f;//used as a flag too
			duration = 0.25f;
		}
		
	}
	//llinfos << "sent final dur of " << duration << llendl;
		
	return duration;
}
コード例 #9
0
std::vector<std::string> lggBeamMaps::getColorsFileNames()
{

	std::vector<std::string> names;	
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", ""));
	bool found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);
		if(found)
		{

			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			names.push_back(name);

			//LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			//loadPreset(unescaped_name,FALSE);
		}
	}
	std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "beamsColors", ""));
	found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false);
		if(found)
		{

			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			names.push_back(name);

			//LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			//loadPreset(unescaped_name,FALSE);
		}
	}
	return names;



}
コード例 #10
0
void LLWaterParamManager::loadAllPresets(const std::string& file_name)
{
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL;
			
	bool found = true;			
	LLDirIterator app_settings_iter(path_name, "*.xml");
	while(found) 
	{
		std::string name;
		found = app_settings_iter.next(name);
		if(found)
		{

			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

	// And repeat for user presets, note the user presets will modify any system presets already loaded

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL;
			
	found = true;			
	LLDirIterator user_settings_iter(path_name2, "*.xml");
	while(found) 
	{
		std::string name;
		found = user_settings_iter.next(name);
		if(found)
		{
			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

}
コード例 #11
0
F32 lggBeamMaps::setUpAndGetDuration()
{
	static std::string* settingName = rebind_llcontrol<std::string>("EmeraldBeamShape", &gSavedSettings, true);
	if(*settingName != lastFileName)
	{
		lastFileName = *settingName;
		if( *settingName != "===OFF===" && *settingName != "")
		{

			std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", ""));
			std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beams", ""));
			std::string filename = path_name + *settingName + ".xml";
			if(gDirUtilp->fileExists(filename))
			{
			}else
			{
				filename =path_name2 + *settingName +".xml";
			}
			LLSD mydata = getPic(filename);
			scale = (F32)mydata["scale"].asReal()/10.0f;
			LLSD myPicture = mydata["data"];	
			dots.clear();
			for(int i = 0; i < myPicture.size(); i++)
			{
				LLSD beamData = myPicture[i];
				lggBeamData dot;
				dot.p = beamData["offset"];
				dot.p *= (gSavedSettings.getF32("EmeraldBeamShapeScale")*2.0f);
				LLColor4 color = beamData["color"];
				
				dot.c = LLColor4U(color);
				
				dots.push_back(dot);
			}
			
			F32 maxBPerQS = gSavedSettings.getF32("EmeraldMaxBeamsPerSecond") / 4.0f;
			duration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f;
			llinfos << "reading it all now size is " << myPicture.size() << " and duration is " << duration << llendl;
		
		}else
		{
			dots.clear();
			scale = 0.0f;//used as a flag too
			duration = 0.25f;
		}
		
	}
	//llinfos << "sent final dur of " << duration << llendl;
		
	return duration;
	
}
コード例 #12
0
void AscentDayCycleManager::loadPresets(const std::string& file_name)
{
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading Default Day Cycle preset from " << path_name << LL_ENDL;
			
	bool found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);
		if(found)
		{

			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

	// And repeat for user presets, note the user presets will modify any system presets already loaded

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading User Daycycle preset from " << path_name2 << LL_ENDL;
			
	found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false);
		if(found)
		{
			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

}
コード例 #13
0
ファイル: lggbeammaps.cpp プロジェクト: gabeharms/firestorm
F32 lggBeamMaps::setUpAndGetDuration()
{
	static LLCachedControl<std::string> settingNameCached(gSavedSettings, "FSBeamShape");
	std::string settingName(settingNameCached);

	if (settingName != mLastFileName)
	{
		mLastFileName = settingName;
		if (!settingName.empty())
		{
			std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", ""));
			std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beams", ""));
			std::string filename = path_name + settingName + ".xml";
			if (!gDirUtilp->fileExists(filename))
			{
				filename = path_name2 + settingName + ".xml";
			}

			LLSD mydata = getPic(filename);
			mScale = (F32)mydata["scale"].asReal() / 10.0f;
			LLSD myPicture = mydata["data"];
			mDots.clear();
			for (LLSD::array_iterator it = myPicture.beginArray(); it != myPicture.endArray(); ++it)
			{
				LLSD beamData = *it;
				lggBeamData dot;
				
				dot.p = LLVector3d(beamData["offset"]);
				static LLCachedControl<F32> FSBeamShapeScale(gSavedSettings, "FSBeamShapeScale");
				dot.p *= (FSBeamShapeScale * 2.0f);
				LLColor4 color = LLColor4(beamData["color"]);
				dot.c = LLColor4U(color);
				mDots.push_back(dot);
			}
			
			static LLCachedControl<F32> FSMaxBeamsPerSecond(gSavedSettings, "FSMaxBeamsPerSecond");
			F32 maxBPerQS = FSMaxBeamsPerSecond / 4.0f;
			mDuration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f;
			LL_INFOS("LGG_Beams") << "reading it all now size is " << myPicture.size() << " and duration is " << mDuration << LL_ENDL;
		}
		else
		{
			mDots.clear();
			mScale = 0.0f; //used as a flag too
			mDuration = 0.25f;
		}
	}

	return mDuration;
}
コード例 #14
0
void LLWaterParamManager::loadAllPresets(const std::string& file_name)
{
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
	LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading Default water settings from " << path_name << LL_ENDL;
			
	bool found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);
		if(found)
		{

			name=name.erase(name.length()-4);

			std::string unescaped_name = LLCurl::unescapeSafe(name);

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

	// And repeat for user presets, note the user presets will modify any system presets already loaded

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", ""));
	LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading User water settings from " << path_name2 << LL_ENDL;
			
	found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false);
		if(found)
		{
			name=name.erase(name.length()-4);

			std::string unescaped_name = LLCurl::unescapeSafe(name);

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

}
コード例 #15
0
void lggFloaterIrcEdit::onClickSave(void* data)
{
	llinfos << "lggPanelIRCedit::save" << llendl;
	
	lggFloaterIrcEdit* self = (lggFloaterIrcEdit*)data;
	//LLFilePicker& picker = LLFilePicker::instance();
	lggIrcData dat(
	self->childGetValue("PhoenixIRC_server"),	
	self->childGetValue("PhoenixIRC_tag"),
	self->childGetValue("PhoenixIRC_port"),
	self->childGetValue("PhoenixIRC_nick"),	
	self->childGetValue("PhoenixIRC_channel"),
	self->childGetValue("PhoenixIRC_password"),
	self->childGetValue("PhoenixIRC_ChanPassword"),
	self->childGetValue("PhoenixIRC_ServerPassword"),
	self->childGetValue("PhoenixIRC_AutoConnect").asBoolean(),
	LLUUID::generateNewID());

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_PER_SL_ACCOUNT , "IRCGroups", ""));
				
	std::string filename=path_name2 + dat.name+".xml";
		
	
	
	LLSD main=dat.toLLSD();
	llofstream export_file;
	export_file.open(filename);
	LLSDSerialize::toPrettyXML(main, export_file);
	export_file.close();
	//lggPanelIRC* instance = (lggPanelIRC*)caller;	if(instance)	instance.refresh();
	
	//gSavedSettings.setString("PhoenixBeamShape",gDirUtilp->getBaseFileName(filename,true));
	if(self->caller)
	{
		self->caller->newList();
	}
	
	self->close();
}
コード例 #16
0
ファイル: fspanelprefs.cpp プロジェクト: gabeharms/firestorm
void FSPanelPrefs::onBeamDelete()
{
	LLComboBox* comboBox = findChild<LLComboBox>("FSBeamShape_combo");

	if (comboBox)
	{
		std::string filename = comboBox->getValue().asString() + ".xml";
		std::string path_name1(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", filename));
		std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "beams", filename));
		
		if (gDirUtilp->fileExists(path_name1))
		{
			LLFile::remove(path_name1);
			gSavedSettings.setString("FSBeamShape", "");
		}
		if (gDirUtilp->fileExists(path_name2))
		{
			LLFile::remove(path_name2);
			gSavedSettings.setString("FSBeamShape", "");
		}
	}
	refreshBeamLists();
}
コード例 #17
0
void PanelPreferenceFirestorm::onBeamColorDelete()
{
	LLComboBox* comboBox = getChild<LLComboBox>("BeamColor_combo");

	if(comboBox != NULL) 
	{
		std::string filename = comboBox->getValue().asString()+".xml";
		std::string path_name1(gDirUtilp->getExpandedFilename( LL_PATH_APP_SETTINGS , "beamsColors", filename));
		std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", filename));

		if(gDirUtilp->fileExists(path_name1))
		{
			LLFile::remove(path_name1);
			gSavedSettings.setString("FSBeamColorFile","===OFF===");
		}
		if(gDirUtilp->fileExists(path_name2))
		{
			LLFile::remove(path_name2);
			gSavedSettings.setString("FSBeamColorFile","===OFF===");
		}
	}
	refreshBeamLists();
}
コード例 #18
0
ファイル: cancer_plot.c プロジェクト: voliynyk/BMDS_Module
int main(int argc, char *argv[])
{
  double *DVECTOR(int n1, int n2);
  void FREE_DVECTOR (double *v, int n1, int n2);

  char name1[CNLENGTH];  /* contains the string: BMD_flag */
  char name2[CNLENGTH];  /* contains the string: Nosb */
  char name3[CNLENGTH];  /* contains the string: nparm */
  char name4[CNLENGTH];  /* contains the string: Con_lev */
  char name4a[CNLENGTH]; /* contains the string: RiskType */
  char name4b[CNLENGTH]; /* contains the string: Effect */
  char name8[CNLENGTH];  /* contains the string: Data */
  char name9[CNLENGTH];  /* contains the string: Max_Min_dose */
  char name10[CNLENGTH]; /* contains the string: BMDL_comput_ind */
  char name11[CNLENGTH]; /* contains the string: RSL */
  char name12[CNLENGTH]; /* contains the string: BMD */
  char name13[CNLENGTH]; /* contains the string: BMDL */
  char name14[CNLENGTH]; /* contains the string: BMD_line */ 
  char name15[CNLENGTH]; /* contains the string: BMDL_line */
  char name16[CNLENGTH]; /* contains the string: BMDL_Curve_flag */
  char name17[CNLENGTH]; /* contains the string: smooth_opt */
  char name18[CNLENGTH]; /* contains the string: BMDL_curve */
  char name19[CNLENGTH]; /* contains the string: Check_result */
  char name[CNLENGTH];   /* variable for reading in parameter names */

  int flag1;       /* flag for computing BMD, 1 = yes */
  int flag2;       /* flag for computing BMDL, 1 = yes */
  int flag3;       /* flag for BMDL curve, 1 = yes */
  int smooth;      /* flag for smooth option, 1=unique, 0=C-spline */
  int nparm;       /* number of parameters */
  int nobs;        /* number of observations */
  int result;      /* flag for Check_result, 1 = yes */
  int i, icount, k; /* iteration variables */
  double value;    /* temp variable for storing parameter values */
  double conf;     /* confidence level, .95 is default */
  int rtype;    /* risk type: 0=extra, 1=added */
  double xmin;     /* min dose level, can change to smallest "x" value */ 
  double xmax;     /* max dose level, can change to largest "x" value */
  double ymin;     /* min of all responses and lower confidence limits */
  double ymax;     /* max of all responses and upper confidence limits */
  double rsl;      /* rsl = BMR*back1+back, see cancer.c program */
  double bmd;      /* BMD */
  double bmdl;     /* BMDL */
  double xleft;    /* xmin - xrange/10 */ 
  double xright;   /* xmax + xrange/10 */
  double ybottom;  /* ymin - yrange/10 */
  double ytop;     /* ymax + yrange/10 */
  double xrange;   /* xmax - xmin */ 
  double yrange;   /* ymax - ymin */
  double xlabel;   /* xmin - xrange/12 */
  double ylabel;   /* ymin - yrange/15 */
  double tdose;    /* temp variable for dose */ 
  double tmean;    /* temp variable for response */
  double tmlb;     /* temp variable for lower confidence limit */
  double tmup;     /* temp variable for upper confidence limit */
  double bmd11;    /* xmin - xmax/100 */ 
  double bmd12;    /* same as rsl */
  double bmd21;    /* BMD */
  double bmd22;    /* rsl */
  double bmd31;    /* BMD */
  double bmd32;    /* -0.1 */
  double bmdL11;   /* BMDL */ 
  double bmdL12;   /* -0.1 */
  double bmdL21;   /* BMDL */
  double bmdL22;   /* rsl */
  double *dose;    /* vector for dose levels */
  double *mean;    /* vector of responses */
  double *mlb;     /* vector of lower confidence limits */
  double *mup;     /* vector of upper confidence limits */
  double *ldose;   /* vector of BMR's */
  double *lmean;   /* vector of BMDL's */
  double *beta;    /* vector of parameters */
  char long_path_name[FLENGTH];
  char *extpoint;
  char *pcRiskType = NULL;	/* Risk type for plot title */
  double effect = 0;		/* BMR specified effect */

  /* allocate memory for arrays */
  ldose=DVECTOR(1, 6);
  lmean=DVECTOR(1, 6);
  /* Allow spaces in path name */
  if (argc > 2)
    {
      path_name2(argc, argv, long_path_name);
      argv[1] = long_path_name;
    } /* end if */
  /* open the input file (has a 002 extension) */
  fp_in=fopen(argv[1], "r");
  /* copy argv[1] to fout */
  strcpy(fout, argv[1]);

  extpoint = strrchr(fout,(int) '.');
  if (extpoint != (char *) NULL)
    {
      *extpoint = '\0';
    }
  strcat(fout, ".plt");
 
  /* open the output file */
  fp_out=fopen(fout, "w");
  if (fp_in==NULL || fp_out==NULL)
    {
      printf("Error in opening input and/or output files. \n");
      printf("...now exiting the system... \n");
      fprintf(fp_out, "Error in opening input and/or output files. \n");
      fprintf(fp_out, "...now exiting the system... \n");
      exit(1);
    } /* end if */

  /*** Read the input data ***/
  fscanf(fp_in, "%s %d", name1, &flag1);
  fscanf(fp_in, "%s %d", name2, &nobs);
  fscanf(fp_in, "%s %d", name3, &nparm);
  fscanf(fp_in, "%s %lg", name4, &conf);
  fscanf(fp_in, "%s %d", name4a, &rtype);
  fscanf(fp_in, "%s %lg", name4b, &effect);
  switch (rtype) {
  case 0:
    pcRiskType = "Extra Risk";
    break;
  case 1:
    pcRiskType = "Added Risk";
    break;

  /* Future risk types would go here before the default case */
  default:
    pcRiskType = "Unknown Risk Type";
    break;
  } /* end switch */

  beta = DVECTOR(0,nparm-1);

  for (k=0; k<=nparm-1; k++)
    { 
      fscanf(fp_in, "%s %lg", name, &value);
      beta[k] = value;
    } /* end for */
  fscanf(fp_in, "%s", name8);
  /* allocate memory */
  dose=DVECTOR(1, nobs);
  mean=DVECTOR(1, nobs);
  mlb=DVECTOR(1, nobs);
  mup=DVECTOR(1, nobs);

  /** Find the max and min of x and y values **/
  ymin=1.0e+66;
  ymax=-1.0e+66;
  for (i=1; i<=nobs; i++)
    {
      fscanf(fp_in, "%lg %lg %lg %lg", &tdose, &tmean, &tmlb, &tmup);
      dose[i]=tdose;
      mean[i]=tmean;
      mlb[i]=tmlb;
      mup[i]=tmup;
      if (tmean < ymin)  ymin=tmean;
      if (tmlb < ymin)   ymin=tmlb;
      if (tmean > ymax)  ymax=tmean;
      if (tmup > ymax)   ymax=tmup;
    } /* end for */

  fscanf(fp_in, "%s", name9);
  fscanf(fp_in, "%lg %lg", &xmax, &xmin);

  if (flag1 == 1) /* if BMD calculation was selected */
    {
      fscanf(fp_in, "%s %lg", name11, &rsl);
      fscanf(fp_in, "%s %lg", name12, &bmd);
      fscanf(fp_in, "%s", name14);
      fscanf(fp_in, "%lg %lg", &bmd11, &bmd12);
      fscanf(fp_in, "%lg %lg", &bmd21, &bmd22);
      fscanf(fp_in, "%lg %lg", &bmd31, &bmd32);
    } /* end if */
  fscanf(fp_in, "%s %d", name10, &flag2);
  if (flag2 == 1) /* if BMDL was computed */
    {
      fscanf(fp_in, "%s %lg", name13, &bmdl);
      if (rsl > ymax) ymax=rsl;
      if (rsl < ymin) ymin=rsl;
      if (bmd > xmax) xmax=bmd;
      if (bmdl < xmin) xmin=bmdl;
      fscanf(fp_in, "%s", name15);
      fscanf(fp_in, "%lg %lg", &bmdL11, &bmdL12);
      fscanf(fp_in, "%lg %lg", &bmdL21, &bmdL22);
      fscanf(fp_in, "%s %d", name16, &flag3);
    } /* end if */

  if (flag3 == 1) /* if all BMDL's were calculated */
    {
      fscanf(fp_in, "%s %d", name17, &smooth);
      fscanf(fp_in, "%s", name18);
      icount=0;
      for (i=1; i<=6; i++)
	{
	  fscanf(fp_in, "%lg %lg", &tdose, &tmean);
	  if (tdose >= 0)
	    {
	      icount++;
	      ldose[icount]=tdose;
	      lmean[icount]=tmean;
	      if (tdose < xmin) xmin=tdose;
	      if (tdose > xmax) xmax=tdose;
	      if (tmean > ymax) ymax=tmean;
	      if (tmean < ymin) ymin=tmean;
	    } /* end if */
	} /* end for */
	
      fscanf(fp_in, "%s %d", name19, &result);
    } /* end  if (flag3 == 1) */
    
  /*** Start to produce the output file ***/

  if (argv[2] == NULL)
    fprintf(fp_out, 
#ifndef TERM_X11
	    "set terminal windows dashed\n"
#else
	    "set terminal x11\n"
#endif
	    );
  else
    {
      fprintf(fp_out, "set terminal postscript monochrome \n");
      fprintf(fp_out, "set output \"Multista.ps\" \n");
    } /* end else */
  fprintf(fp_out, "reset\n");
  fprintf(fp_out, "set time \"\%%H:\%%M \%%m/\%%d \%%Y\" \n");
  fprintf(fp_out, "set bar 3 \n");
  fprintf(fp_out, "set style line 6 linecolor rgb \"black\"\n");
  fprintf(fp_out, "set style line 7 linecolor rgb \"dark-blue\"\n");
  fprintf(fp_out, "set style line 16 linecolor rgb \"forest-green\" pt 12\n");
  fprintf(fp_out, "set key top left \n");
  fprintf(fp_out, "set xlabel 'dose' \n");
  fprintf(fp_out, "set ylabel 'Fraction Affected' \n");
  fprintf(fp_out, "set mxtics 10 \n");
  fprintf(fp_out, "set mytics 10 \n");
  if (flag1 == 1)
    {
      fprintf(fp_out, "set title 'Multistage Cancer Model, with BMR of %lg%% %s for the BMD and %lg Lower Confidence Limit for the BMDL' \n",
	      effect*100., pcRiskType, conf);
      fprintf(fp_out, "rl = %g \n", rsl);
      fprintf(fp_out, "bmd = %g \n", bmd);
    } /* end if */
  if (flag2 == 1)
    fprintf(fp_out, "bmdl = %g \n", bmdl);
  else
    fprintf(fp_out, "set title 'Multistage Cancer Model' \n");

  for (k=0; k<=nparm-1; k++)
    fprintf(fp_out, "beta%d = %g \n", k, beta[k]);

  fprintf(fp_out, "f(x)= beta0 + (x>0?( (1- beta0)*(1 - exp(");
  for (k=1; k<=nparm-1; k++)
    fprintf(fp_out, "-beta%d*(x**%d)", k, k);
  fprintf(fp_out, "))) : 0) \n"); 

  xrange=xmax-xmin;
  yrange=ymax-ymin;
  xleft=xmin-xrange/10.0;
  xright=xmax+xrange/10.0;
  ybottom=ymin-yrange/10.0;
  ytop=ymax+yrange/10.0;
  xlabel=xmin-xrange/12.0;
  ylabel=ymin-yrange/15.0;
  fprintf(fp_out, "set offsets %g, %g, 0, 0\n",xrange/20.0, xrange/20.0);
  if (flag1 == 1)
    {
      fprintf(fp_out, "set label 'BMD' at bmd, %g left \n", ylabel);
    }  /* end if */
  if (flag2 ==1)
    {
      fprintf(fp_out, "set label 'BMDL' at bmdl, %g right \n", ylabel);
      fprintf(fp_out, "set label '   ' at %g, rl left \n", xlabel);
    } /* end if */

  if (flag1 == 1 && flag2 == 1 && flag3 == 1)
    {
      fprintf(fp_out, "plot [x=%f:%f] [%f:%f] f(x) title 'Multistage Cancer',\\", 
	      xmin>0?0:xmin, xmax, ybottom, ytop);
      fprintf(fp_out, "\n     '-' using 1:2:3:4 notitle with errorbars ls 16,\\");
      fprintf(fp_out, "\n     '-' using 1:2 notitle with lines ls 6,\\");
      fprintf(fp_out, "\n     '-' using 1:2 notitle with lines ls 6,\\");
	  //Q.H. 11/7/04 To add Linear extrapolation to Multistage Cancer model
	  fprintf(fp_out, "\n     '-' using 1:2 title 'Linear extrapolation' with lines ls 7,\\");
   
      if (smooth == 1)
		fprintf(fp_out, "\n     '-' using 1:2 smooth csplines title 'BMD Lower Bound' with lines ls 3,\\");
      else
		fprintf(fp_out, "\n     '-' using 1:2 smooth unique title 'BMD Lower Bound' with lines ls 3,\\");
      fprintf(fp_out, "\n     '-' using 1:2 notitle with points");

    } /* end if */

  else 
    if (flag1 == 1 && flag2 == 1)
      {
		fprintf(fp_out, "plot [x=%f:%f] [%f:%f] f(x) title 'Multistage Cancer',\\", 
		xmin>0?0:xmin, xmax, ybottom, ytop);
		fprintf(fp_out, "\n     '-' using 1:2:3:4 notitle with errorbars ls 16,\\");
		fprintf(fp_out, "\n     '-' using 1:2 notitle with lines ls 6,\\");
		fprintf(fp_out, "\n     '-' using 1:2 notitle with lines ls 6,\\");
		//Q.H. 11/7/04 To add Linear extrapolation to Multistage Cancer model
		fprintf(fp_out, "\n     '-' using 1:2 title 'Linear extrapolation' with lines ls 7");
      } /* end if */

    else
      if (flag1 == 1)
	{
	  fprintf(fp_out, "plot [x=%f:%f] [%f:%f] f(x) title 'Multistage Cancer',\\", 
		  xmin, xmax, ybottom, ytop);
	  fprintf(fp_out, "\n     '-' using 1:2:3:4 notitle with errorbars ls 16,\\");
	  fprintf(fp_out, "\n     '-' using 1:2 notitle with lines ls 6");
	} /* end if */

      else
	{
	  fprintf(fp_out, "plot [x=%f:%f] [%f:%f] f(x) title 'Multistage Cancer',\\", 
		  xmin, xmax, ybottom, ytop);
	  fprintf(fp_out, "\n     '-' using 1:2:3:4 notitle with errorbars ls 16");
	} /* end else */

  for (i=1; i<=nobs; i++)
    fprintf(fp_out, "\n %f %f %f %f", dose[i], mean[i], mlb[i], mup[i]);
  fprintf(fp_out, "\n e");

  bmd11=xleft;   /* to adjust the positions of the BMD and BMDL lines */
  bmd32=bmdL12=ybottom;

  if (flag1 == 1) 
    {
      fprintf(fp_out, "\n %f %f", bmd11, bmd12);
      fprintf(fp_out, "\n %f %f", bmd21, bmd22);
      fprintf(fp_out, "\n %f %f", bmd31, bmd32);
      fprintf(fp_out, "\n e");
    } /* end if */
  if (flag1 == 1 && flag2 == 1)
    {
      fprintf(fp_out, "\n %f %f", bmdL11, bmdL12);
      fprintf(fp_out, "\n %f %f", bmdL21, bmdL22);
      fprintf(fp_out, "\n e");
	  //Q.H. 11/7/04 To add Linear extrapolation to Multistage Cancer model
	  double x0 = 0.0;
	  fprintf(fp_out, "\n %f %f", x0, beta[0]); // when x == 0, f(x) = beta0 Q.H. 11/07/04
	  fprintf(fp_out, "\n %f %f", bmdL21, bmdL22);
	  fprintf(fp_out, "\n e");
    } /* end if */

  if (flag1 == 1 && flag2 == 1 && flag3 == 1)
    {

      for (i=1; i<=icount; i++)
		fprintf(fp_out, "\n %f %f", ldose[i], lmean[i]);
      fprintf(fp_out, "\n e");
      for (i=1; i<=icount; i++)
		fprintf(fp_out, "\n %f %f", ldose[i], lmean[i]);
      fprintf(fp_out, "\n e");

    } /* end if */

  /* free memory */
  FREE_DVECTOR(dose, 1, nobs);
  FREE_DVECTOR(mean, 1, nobs);
  FREE_DVECTOR(mlb, 1, nobs);
  FREE_DVECTOR(mup, 1, nobs);
  FREE_DVECTOR(ldose, 1, 6);
  FREE_DVECTOR(lmean, 1, 6);
  FREE_DVECTOR(beta, 0,nparm-1);

  if (fclose (fp_in) != 0 || fclose (fp_out) != 0 )
    ERRORPRT ("Error in closing opened files.");
  return 0;

} /* end of main */