//--------------------------------------------------------------
void testApp::setup(){    
    //setup initial ip addresses
    iPadIP = "";
    iPhoneIP = "";
    osxIP = "";
    
    ofSetFrameRate(24);
    
    count = 0;
    
    debug = false;
    sendOSC = false;
    
    setupUI();
    setupVideo();
    
    CGDisplayHideCursor(NULL);
    
    gotJSON = false;

    ss << "No video information received yet" << endl;
    
    //load json
    loadJSON();
    
}
Esempio n. 2
0
int SettingRegistry::loadJSONsettings(std::string filename, SettingsBase* settings_base, bool warn_base_file_duplicates)
{
    rapidjson::Document json_document;
    
    log("Loading %s...\n", filename.c_str());

    int err = loadJSON(filename, json_document);
    if (err) { return err; }

    if (json_document.HasMember("inherits") && json_document["inherits"].IsString())
    {
        std::string child_filename;
        bool found = getDefinitionFile(json_document["inherits"].GetString(), filename, child_filename);
        if (!found)
        {
            return -1;
        }
        err = loadJSONsettings(child_filename, settings_base, warn_base_file_duplicates); // load child first
        if (err)
        {
            return err;
        }
        err = loadJSONsettingsFromDoc(json_document, settings_base, false);
    }
    else 
    {
        err = loadJSONsettingsFromDoc(json_document, settings_base, warn_base_file_duplicates);
    }

    if (json_document.HasMember("metadata") && json_document["metadata"].IsObject())
    {
        const rapidjson::Value& json_metadata = json_document["metadata"];
        if (json_metadata.HasMember("machine_extruder_trains") && json_metadata["machine_extruder_trains"].IsObject())
        {
            const rapidjson::Value& json_machine_extruder_trains = json_metadata["machine_extruder_trains"];
            for (rapidjson::Value::ConstMemberIterator extr_train_iterator = json_machine_extruder_trains.MemberBegin(); extr_train_iterator != json_machine_extruder_trains.MemberEnd(); ++extr_train_iterator)
            {
                int extruder_train_nr = atoi(extr_train_iterator->name.GetString());
                if (extruder_train_nr < 0)
                {
                    continue;
                }
                const rapidjson::Value& json_id = extr_train_iterator->value;
                if (!json_id.IsString())
                {
                    continue;
                }
                const char* id = json_id.GetString();
                if (extruder_train_nr >= (int) extruder_train_ids.size())
                {
                    extruder_train_ids.resize(extruder_train_nr + 1);
                }
                extruder_train_ids[extruder_train_nr] = std::string(id);
            }
        }
    }

    return err;
}
Esempio n. 3
0
bool Style::load(const std::string &url, unsigned long projectId)
{
    std::string response;
    if(loadJSON(url, response))
    {
        return _parse(response, projectId);
    }
    return false;
}
// Uses chrono::system_clock::from_time_t(0) as an invalid value.
SimulationAnimationPatch::SimulationAnimationPatch(const JSONNode data)
: m_worker(NULL), m_startPoint(chrono::system_clock::from_time_t(0)),
    m_mode(SimulationAnimationMode::STOPPED), 
	m_mem_frameManager(new ArnoldMemoryFrameManager()), m_file_frameManager(NULL) {
    // TODO: type for frame manager
	//m_mem_frameManager = new ArnoldMemoryFrameManager();
	//m_file_frameManager = NULL;
    loadJSON(data);
}
Esempio n. 5
0
  void load( const std::string& url,
             const Callback& callback,
             const std::string& texturePath ) {

    onLoadStart();

    loadJSON( *this, url, callback, texturePath );

  }
  // Uses chrono::system_clock::from_time_t(0) as an invalid value.
ArnoldAnimationPatch::ArnoldAnimationPatch(const JSONNode data)
	: SimulationAnimationPatch() {
  // TODO: type for frame manager
#ifdef USE_ARNOLD
  m_mem_frameManager = new ArnoldMemoryFrameManager();
#endif

  loadJSON(data);
	m_preview_samples = m_interface->getSamples();
	m_render_samples = m_interface->getSamples();
}
Esempio n. 7
0
bool TextureManager::load(std::string key,
                          std::string pathJSON,
                          std::string pathIMG,
                          SDL_Renderer *ren) {
  json_t *tmpJSON = NULL;
  SDL_Texture *tmpTex = NULL;

  tmpTex = loadImage(pathIMG.c_str(), ren);
  tmpJSON = loadJSON(pathJSON.c_str());

  Texture* t = new Texture(tmpTex, tmpJSON);

  m_textureMap[key] = t;

  return true;
}
Esempio n. 8
0
bool Rig::load(string filename) {
  stop();

  // Check to see if we can load the file.
  ifstream data;
  data.open(filename, ios::in | ios::binary | ios::ate);

  if (data.is_open()) {
    reset();

    // "+ 1" for the ending
    streamoff size = data.tellg();
    char* memblock = new char[(unsigned int)size + 1];

    data.seekg(0, ios::beg);

    stringstream ss;
    ss << "Loading " << size << " bytes from " << filename;
    Logger::log(INFO, ss.str());

    data.read(memblock, size);
    data.close();

    // It's not guaranteed that the following memory after memblock is blank.
    // C-style string needs an end.
    memblock[size] = '\0';
      
    JSONNode n = libjson::parse(memblock);

	// Pass in json path with the original json nodes.
	n.push_back(JSONNode("jsonPath", filename));

    // This could get to be a large function, so let's break off into a helper.
    loadJSON(n);

    delete memblock;
    return true;
  }
  else {
    stringstream ss;
    ss << "Error opening " << filename;
    Logger::log(ERR, ss.str());

    return false;
  }
}
int SettingRegistry::loadJSONsettings(std::string filename)
{
    rapidjson::Document json_document;
    
    int err = loadJSON(filename, json_document);
    if (err) { return err; }
    
    if (json_document.HasMember("inherits"))
    {
        std::string filename_copy = std::string(filename.c_str()); // copy the string because dirname(.) changes the input string!!!
        char* filename_cstr = (char*)filename_copy.c_str();
        int err = loadJSONsettings(std::string(dirname(filename_cstr)) + std::string("/") + json_document["inherits"].GetString());
        if (err) { return err; }
        return loadJSONsettingsFromDoc(json_document, false);
    }
    else 
    {
        return loadJSONsettingsFromDoc(json_document, true);
    }
    
}
Esempio n. 10
0
//--------------------------------------------------------------
void ofApp::setup(){
    //setup initial ip addresses
    iPadIP = "";
    iPhoneIP = "";
    osxIP = "";
    
    //set framerate
    ofSetFrameRate(24);
    
    //set count
    count = 0;
    
    //set debug and sendosc
    debug = false;
    sendOSC = false;
    
    //setup ui and our first video
    setupUI();
    setupVideo();
    
    //setup osc
    setupOSC();
    
    //hide cursor
    CGDisplayHideCursor(NULL);
    
    //set gotjson
    gotJSON = false;
    
    //set ss
    ss << "No video information received yet" << endl;
    
    //load json
    loadJSON();
    
    ofRegisterURLNotification(this);
    videosDownloaded = 0;

}
Esempio n. 11
0
Programmer::Programmer(Rig* rig, JSONNode data) : m_rig(rig) {
  loadJSON(data);
}
Esempio n. 12
0
AnalysisJSONLoadResult loadJSON(std::istream& json) {
  return loadJSON(toString(json));
}
Esempio n. 13
0
bool Loader::load()
{
    QString fn = m_fileName.path();

    if ( fn.endsWith( ".nii.gz" ) || fn.endsWith( ".nii" ) || fn.endsWith( ".hdr" ) || fn.endsWith( ".ima" ) || fn.endsWith( ".img" ) )
    {

        return loadNifti();
    }

    if ( m_fileName.path().endsWith( ".fib" ) )
    {
        return loadVTK();
    }

    if ( m_fileName.path().endsWith( ".tck" ) )
    {
        return loadMRtrix();
    }

    if ( m_fileName.path().endsWith( ".vtk" ) )
    {
        return loadVTK();
    }

    if ( m_fileName.path().endsWith( ".json" ) )
    {
        return loadJSON();
    }

    if ( m_fileName.path().endsWith( ".asc" ) )
    {
        //TODO: Deal with offsets: Check if orig is always the same size?
        return loadASC( QVector3D( 128, 128, 128 ) );
    }

    if ( m_fileName.path().endsWith( ".set" ) )
    {
        return loadSet();
    }

    if ( m_fileName.path().endsWith( ".glyphset" ) )
    {
        return loadGlyphset();
    }

    if ( m_fileName.path().endsWith( ".cons" ) || m_fileName.path().endsWith( ".cxls" ) )
    {
        return loadCons();
    }

    if ( m_fileName.path().endsWith( ".meg" ) )
    {
        return loadMEG();
    }

    if ( m_fileName.path().endsWith( ".htree" ) )
    {
        return loadTree();
    }

    if ( m_fileName.path().endsWith( ".rgb" ) )
    {
        return loadRGB();
    }

    if ( m_fileName.path().endsWith( ".1D" ) )
    {
        return load1D();
    }

    if ( m_fileName.path().endsWith( ".png" ) || m_fileName.path().endsWith( ".jpg" ) )
    {
        return loadPNG();
    }

    return false;
}
Esempio n. 14
0
PlayCardMessage::PlayCardMessage(const json &newJSON)
{
    loadJSON(newJSON);
    cardTag = getDataMember("cardTag");
}