Exemple #1
0
void PMSlope::restoreMemento( PMMemento* s )
{
   PMMementoDataIterator it( s );
   PMMementoData* data;

   for( ; it.current( ); ++it )
   {
      data = it.current( );
      if( data->objectType( ) == s_pMetaObject )
      {
         switch( data->valueID( ) )
         {
            case PMSlopeID:
               setSlope( data->doubleData( ) );
               break;
            case PMHeightID:
               setHeight( data->doubleData( ) );
               break;
            default:
               kdError( PMArea ) << "Wrong ID in PMSlope::restoreMemento\n";
               break;
         }
      }
   }
   Base::restoreMemento( s );
}
void Pattern::setParameters(int height, int width, int line_width, int slope)
{
    setHeight(height);
    setWidth(width);
    setLineWidth(line_width);
    setSlope(slope);
}
Exemple #3
0
/** @brief SDHys
  *
  * @todo: constructor
  */
SDHys::SDHys(double inverse, double up, double down): EPSILON(0.5)
{
	ahys_ = 0;
	setInverse(inverse);
	setSlope(up, down);
	setParams(1.1, 10., 2);
}
    void VolumeModel::init(const ModelInfo::Params & params) {
        AbstractModelWithPoints::init(params);

        VolumeInfo::PhysicalSize physicalSize = params["physicalSize"].value<VolumeInfo::PhysicalSize>();
        VolumeInfo::Size size = params["size"].value<VolumeInfo::Size>();
        VolumeInfo::Scaling scaling = params["scaling"].value<VolumeInfo::Scaling>();

        scale(scaling);

        setSlope(params["slope"].value<VolumeInfo::Slope>());
        setIntercept(params["intercept"].value<VolumeInfo::Intercept>());

        setWindowCenter(params["windowCenter"].value<VolumeInfo::WindowCenter>());
        setWindowWidth(params["windowWidth"].value<VolumeInfo::WindowWidth>());

        setHuRange(params["huRange"].value<VolumeInfo::HuRange>());
        setValueRange(params["valueRange"].value<VolumeInfo::ValueRange>());

        ModelInfo::VerticesVTPtr vertices = new ModelInfo::VerticesVT;
        ModelInfo::IndicesPtr indices = new ModelInfo::Indices;

        GLfloat scalingFactor = (GLfloat) scene()->scalingFactor();

        GLfloat zCurrent = - physicalSize.z() * scaling.z() / scalingFactor / 2.0f;
        
        GLfloat step = - (zCurrent * 2.0f) / size.z();
        GLfloat stepTexture = 1.0f / size.z();

        GLfloat zCurrentTexture = 0.0f;

        GLfloat w = physicalSize.x() / 2.0f * scaling.x() / scalingFactor;
        GLfloat h = physicalSize.y() / 2.0f * scaling.y() / scalingFactor;

        for (int i = 0; i != (int) size.z(); ++ i) {
            vertices->push_back(ModelInfo::VertexVT(- w, - h, zCurrent, 0.0f, 1.0f, zCurrentTexture));
            vertices->push_back(ModelInfo::VertexVT(- w, h, zCurrent, 0.0f, 0.0f, zCurrentTexture));
            vertices->push_back(ModelInfo::VertexVT(w, h, zCurrent, 1.0f, 0.0f, zCurrentTexture));
            vertices->push_back(ModelInfo::VertexVT(w, - h, zCurrent, 1.0f, 1.0f, zCurrentTexture));

            indices->push_back(4 * i);
            indices->push_back(4 * i + 2);
            indices->push_back(4 * i + 1);
            indices->push_back(4 * i);
            indices->push_back(4 * i + 3);
            indices->push_back(4 * i + 2);

            zCurrent += step;
            zCurrentTexture += stepTexture;
        };

        ModelInfo::BuffersVT buffers;

        buffers.vertices = ModelInfo::VerticesVTPointer(vertices);
        buffers.indices = ModelInfo::IndicesPointer(indices);
        
        fillBuffers<ModelInfo::BuffersVT>(buffers);
    }
void stateMachine(uint8_t inCode){
	
uint8_t newVal;
uint8_t lastVal;
uint8_t count=0;

	inCode &= 0x07; // ensure clean
	
	
	
	// Switch to the state
	switch (state){
		
		case STATE_IDLE:
				IDLE_LED_ON;
				PRGM_LED_OFF;
				if (inCode == BUTTON_PROG) state=STATE_PROGRAM;
				break;
			
		case STATE_PROGRAM:
				IDLE_LED_OFF;
				PRGM_LED_ON; 
				if(inCode==BUTTON_UP)setSlope(1);
				if(inCode==BUTTON_DOWN)setSlope(0);
				if(inCode==BUTTON_ENTER){
					 state=STATE_SAVE;
					 //state=STATE_IDLE;
					 //IDLE_LED_ON;
					 //PRGM_LED_OFF;
				}
				break;
		case STATE_SAVE:
				IDLE_LED_ON;
				PRGM_LED_ON;
				flagSaveParameters++;
				//wait to be saved and exit
				state=STATE_IDLE;
				break;
			
		default:
				
			break;	
	}
}
Exemple #6
0
void RenderParams::update(ConstCDLOpDataRcPtr & cdl)
{
    double slope[4], offset[4], power[4];
    cdl->getSlopeParams().getRGBA(slope);
    cdl->getOffsetParams().getRGBA(offset);
    cdl->getPowerParams().getRGBA(power);

    const float saturation = (float)cdl->getSaturation();
    const CDLOpData::Style style = cdl->getStyle();

    m_isReverse
        = (style == CDLOpData::CDL_V1_2_REV)
        || (style == CDLOpData::CDL_NO_CLAMP_REV);

    m_isNoClamp
        = (style == CDLOpData::CDL_NO_CLAMP_FWD)
        || (style == CDLOpData::CDL_NO_CLAMP_REV);

    if (isReverse())
    {
        // Reverse render parameters
        setSlope(Reciprocal((float)slope[0]),
                 Reciprocal((float)slope[1]),
                 Reciprocal((float)slope[2]),
                 Reciprocal((float)slope[3]));
   
        setOffset((float)-offset[0], (float)-offset[1], (float)-offset[2], (float)-offset[3]);
   
        setPower(Reciprocal((float)power[0]),
                 Reciprocal((float)power[1]),
                 Reciprocal((float)power[2]),
                 Reciprocal((float)power[3]));
       
        setSaturation(Reciprocal(saturation));
    }
    else
    {
        // Forward render parameters
        setSlope((float)slope[0], (float)slope[1], (float)slope[2], (float)slope[3]);
        setOffset((float)offset[0], (float)offset[1], (float)offset[2], (float)offset[3]);
        setPower((float)power[0], (float)power[1], (float)power[2], (float)power[3]);
        setSaturation(saturation);
    }
}
Exemple #7
0
Thing::Thing(float x, float y, float width, float height, float depth) {
  type = THING;
  name = NOWEAPON;
  held = false;
  flipped = false;
  setPos(x, y);
  setSize(width, height);
  renderSize = Vector2f(width, height);
  this->depth = depth;
  noRender = false;
  deletable = false;
  setSlope(0, 1);
}
Exemple #8
0
 void Sigmoid::configure(const std::string& parameters) {
     if (parameters.empty()) return;
     std::vector<std::string> values = Op::split(parameters, " ");
     std::size_t required = 2;
     if (values.size() < required) {
         std::ostringstream ex;
         ex << "[configuration error] term <" << className() << ">"
                 << " requires <" << required << "> parameters";
         throw fl::Exception(ex.str(), FL_AT);
     }
     setInflection(Op::toScalar(values.at(0)));
     setSlope(Op::toScalar(values.at(1)));
 }
Exemple #9
0
Maths::Regression::Linear::Linear(double m_b_arg, double m_a_arg, double m_coeff_arg)
{
	//! Returns the slope of the regression line

	setSlope(m_b_arg);

	//! Returns the intercept on the Y axis of the regression line

	setIntercept(m_a_arg);

	//! Returns the linear regression coefficient

	setCoefficient(m_coeff_arg);
}
Exemple #10
0
 void Bell::configure(const std::string& parameters) {
     if (parameters.empty()) return;
     std::vector<std::string> values = Op::split(parameters, " ");
     std::size_t required = 3;
     if (values.size() < required) {
         std::ostringstream ex;
         ex << "[configuration error] term <" << className() << ">"
                 << " requires <" << required << "> parameters";
         throw Exception(ex.str(), FL_AT);
     }
     setCenter(Op::toScalar(values.at(0)));
     setWidth(Op::toScalar(values.at(1)));
     setSlope(Op::toScalar(values.at(2)));
     if (values.size() > required)
         setHeight(Op::toScalar(values.at(required)));
 }
Exemple #11
0
//! Constructor for Sqlite
//! \deprecated For now, this constructor is deprecated!
clsSpecificOutput::clsSpecificOutput(string projectPath,string databasePath,clsRasterData* templateRasterData,string outputID)
{
	m_outputID = outputID;
	string path = databasePath + File_HydroClimateDB;
	string tableName = TableNameFromOutputID(outputID);
	if(tableName.length() == 0)
		throw ModelException(	"clsSpecificOutput","clsSpecificOutput",
		"The output id "+ outputID + " can't output specific cells.");
	if(!DBManager::IsTableExist(path,tableName))
		throw ModelException(	"clsSpecificOutput","clsSpecificOutput",
								"The database " + path + 
								" dose not exist or the table "+tableName+" does not exist in this database.");

	if(templateRasterData == NULL)
		throw ModelException(	"clsSpecificOutput","clsSpecificOutput",
						"The templateRasterData is null.");
	
	m_templateRasterData = templateRasterData;

	utils util;
	DBManager db;
	DBManager dbman;
	try
	{
		// open the hydroclimate database
		dbman.Open(path);
		// if there is no error
		if (!dbman.IsError())
		{
			// create the query for the data table
			// Use the start date and end date to limit the time series data
			string strSQL = "SELECT TIME, Longitude, Latitude, ID, MEASURED FROM " + tableName + " order by TIME";
			// run the query
			slTable* tbl = dbman.Load(strSQL);
			// if the query is successful
			if (tbl != NULL)
			{			
				// read in the data
				for (int idx=1; idx<=tbl->nRows; idx++)
				{
					time_t time= util.ConvertToTime(tbl->FieldValue(idx,0), "%4d-%2d-%2d", false);
					float nrow = (float)(atof(tbl->FieldValue(idx,1).c_str()));
					float ncol = (float)(atof(tbl->FieldValue(idx,2).c_str()));

					int position = templateRasterData->getPosition(nrow,ncol);
					if(position > -1) 
					{
						m_times.push_back(time);
						m_positions.push_back(position);
						m_values.push_back(-99.0f);
						m_slope.push_back(-99.0f);
						m_curvature.push_back(-99.0f);
						m_landuse.push_back(-99.0f);
						m_ids.push_back(tbl->FieldValue(idx,3));

						//the measurement is added for convenient comparison
						m_measurement.push_back((float)(atof(tbl->FieldValue(idx,4).c_str())));
					}
				}

				setSlope(projectPath);
				setCurvature(projectPath);
				setLanduse(projectPath);

				delete tbl;
			}
			tbl = NULL;
			dbman.Close();
		}	
	}
	catch (...)
	{
		dbman.Close();
		throw;
	}
}