/*! */ void DiaOutputDev::_fill (GfxState *state, bool winding) { GArray *points = g_array_new (FALSE, FALSE, sizeof(BezPoint)); DiaObject *obj = NULL; GfxPath *path = state->getPath(); bool haveClose = true; if (doPath (points, state, path, haveClose) && points->len > 2) { if (path->getNumSubpaths() == 1 && haveClose) obj = create_standard_beziergon (points->len, &g_array_index (points, BezPoint, 0)); else obj = create_standard_path (points->len, &g_array_index (points, BezPoint, 0)); applyStyle (obj, true); if (this->pattern) { ObjectChange *change = dia_object_set_pattern (obj, this->pattern); if (change) { change->free (change); g_free (change); } } } g_array_free (points, TRUE); if (obj) { // Useful for debugging but high performance penalty // dia_object_set_meta (obj, "fill-rule", winding ? "winding" : "even-odd"); addObject (obj); } }
void lvDCOMInterface::getLabviewValue(const char* param, T* value) { if (value == NULL) { throw std::runtime_error("getLabviewValue failed (NULL)"); } if (param == NULL || *param == '\0') { throw std::runtime_error("getLabviewValue: param is NULL"); } CComVariant v; char vi_name_xpath[MAX_PATH_LEN], control_name_xpath[MAX_PATH_LEN]; _snprintf(vi_name_xpath, sizeof(vi_name_xpath), "/lvinput/section[@name='%s']/vi/@path", m_configSection.c_str()); _snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param[@name='%s']/read/@target", m_configSection.c_str(), param); CComBSTR vi_name(doPath(vi_name_xpath).c_str()); CComBSTR control_name(doXPATH(control_name_xpath).c_str()); if (vi_name.Length() == 0 || control_name.Length() == 0) { throw std::runtime_error("getLabviewValue: vi or control is NULL"); } getLabviewValue(vi_name, control_name, &v); if ( v.ChangeType(CVarTypeInfo<T>::VT) == S_OK ) { *value = v.*(CVarTypeInfo<T>::pmField); } else { throw std::runtime_error("getLabviewValue failed (ChangeType)"); } }
void lvDCOMInterface::getLabviewValue(const char* param, T* value, size_t nElements, size_t& nIn) { if (value == NULL) { throw std::runtime_error("getLabviewValue failed (NULL)"); } if (param == NULL || *param == '\0') { throw std::runtime_error("getLabviewValue: param is NULL"); } CComVariant v; char vi_name_xpath[MAX_PATH_LEN], control_name_xpath[MAX_PATH_LEN]; _snprintf(vi_name_xpath, sizeof(vi_name_xpath), "/lvinput/section[@name='%s']/vi/@path", m_configSection.c_str()); _snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param[@name='%s']/read/@target", m_configSection.c_str(), param); CComBSTR vi_name(doPath(vi_name_xpath).c_str()); CComBSTR control_name(doXPATH(control_name_xpath).c_str()); if (vi_name.Length() == 0 || control_name.Length() == 0) { throw std::runtime_error("getLabviewValue: vi or control is NULL"); } getLabviewValue(vi_name, control_name, &v); if ( v.vt != (VT_ARRAY | CVarTypeInfo<T>::VT) ) { throw std::runtime_error("getLabviewValue failed (type mismatch)"); } CComSafeArray<T> sa; sa.Attach(v.parray); nIn = ( sa.GetCount() > nElements ? nElements : sa.GetCount() ); for(LONG i=0; i<nIn; ++i) { value[i] = sa.GetAt(i); } sa.Detach(); }
/*! */ void DiaOutputDev::_fill (GfxState *state, bool winding) { GArray *points = g_array_new (FALSE, FALSE, sizeof(BezPoint)); DiaObject *obj = NULL; GfxPath *path = state->getPath(); bool haveClose = true; if (doPath (points, state, path, haveClose)) { if (path->getNumSubpaths() == 1 && haveClose) obj = create_standard_beziergon (points->len, &g_array_index (points, BezPoint, 0)); else obj = create_standard_path (points->len, &g_array_index (points, BezPoint, 0)); applyStyle (obj, true); } g_array_free (points, TRUE); if (obj) { dia_object_set_meta (obj, "fill-rule", winding ? "winding" : "even-odd"); addObject (obj); } }
/*! * \brief create a _Bezierline or _StdPath from the graphics state */ void DiaOutputDev::stroke (GfxState *state) { GArray *points = g_array_new (FALSE, FALSE, sizeof(BezPoint)); DiaObject *obj = NULL; GfxPath *path = state->getPath(); bool haveClose = false; if (doPath (points, state, path, haveClose) && points->len > 1) { if (path->getNumSubpaths() == 1) { if (!haveClose) obj = create_standard_bezierline (points->len, &g_array_index (points, BezPoint, 0), NULL, NULL); else obj = create_standard_beziergon (points->len, &g_array_index (points, BezPoint, 0)); } else { obj = create_standard_path (points->len, &g_array_index (points, BezPoint, 0)); } applyStyle (obj, false); } g_array_free (points, TRUE); if (obj) addObject (obj); }
/// \param[in] configSection @copydoc initArg1 /// \param[in] configFile @copydoc initArg2 /// \param[in] host @copydoc initArg3 /// \param[in] options @copydoc initArg4 /// \param[in] progid @copydoc initArg5 /// \param[in] username @copydoc initArg6 /// \param[in] password @copydoc initArg7 lvDCOMInterface::lvDCOMInterface(const char *configSection, const char* configFile, const char* host, int options, const char* progid, const char* username, const char* password) : m_configSection(configSection), m_pidentity(NULL), m_pxmldom(NULL), m_options(options), m_progid(progid != NULL? progid : ""), m_username(username != NULL? username : ""), m_password(password != NULL ? password : ""), m_mac_env(NULL) { epicsThreadOnce(&onceId, initCOM, NULL); if (host != NULL && host[0] != '\0') { m_host = host; } else { // char name_buffer[MAX_COMPUTERNAME_LENGTH + 1]; // DWORD name_size = MAX_COMPUTERNAME_LENGTH + 1; // if ( GetComputerNameEx(ComputerNameNetBIOS, name_buffer, &name_size) != 0 ) // { // m_host = name_buffer; // } // else // { // m_host = "localhost"; // } m_host = "localhost"; } if (macCreateHandle(&m_mac_env, NULL) != 0) { throw std::runtime_error("Cannot create mac handle"); } // load current environment into m_mac_env, this is so we can create a macEnvExpand() equivalent // but tied to the environment at a specific time. It is useful if we want to load the same // XML file twice but with a macro defined differently in each case for(char** cp = environ; *cp != NULL; ++cp) { char* str_tmp = strdup(*cp); char* equals_loc = strchr(str_tmp, '='); // split name=value string if (equals_loc != NULL) { *equals_loc = '\0'; macPutValue(m_mac_env, str_tmp, equals_loc + 1); } free(str_tmp); } // m_doc = new TiXmlDocument; // if ( !m_doc->LoadFile(configFile) ) // { // delete m_doc; // m_doc = NULL; // throw std::runtime_error("Cannot load " + std::string(configFile) + ": load failure"); // } // m_root = m_doc->RootElement(); DomFromCOM(); short sResult = FALSE; char* configFile_expanded = envExpand(configFile); m_configFile = configFile_expanded; HRESULT hr = m_pxmldom->load(_variant_t(configFile_expanded), &sResult); free(configFile_expanded); if(FAILED(hr)) { throw std::runtime_error("Cannot load XML \"" + m_configFile + "\" (expanded from \"" + std::string(configFile) + "\"): load failure"); } if (sResult != VARIANT_TRUE) { throw std::runtime_error("Cannot load XML \"" + m_configFile + "\" (expanded from \"" + std::string(configFile) + "\"): load failure"); } std::cerr << "Loaded XML config file \"" << m_configFile << "\" (expanded from \"" << configFile << "\")" << std::endl; m_extint = doPath("/lvinput/extint/@path").c_str(); epicsAtExit(epicsExitFunc, this); if (m_progid.size() > 0) { if ( CLSIDFromProgID(CT2W(m_progid.c_str()), &m_clsid) != S_OK ) { throw std::runtime_error("Cannot find progId " + m_progid); } } else { m_clsid = LabVIEW::CLSID_Application; wchar_t* progid_str = NULL; if ( ProgIDFromCLSID(m_clsid, &progid_str) == S_OK ) { m_progid = CW2CT(progid_str); CoTaskMemFree(progid_str); } else { m_progid = "LabVIEW.Application"; } } wchar_t* clsid_str = NULL; if ( StringFromCLSID(m_clsid, &clsid_str) == S_OK ) { std::cerr << "Using ProgID \"" << m_progid << "\" CLSID " << CW2CT(clsid_str) << std::endl; CoTaskMemFree(clsid_str); } else { std::cerr << "Using ProgID \"" << m_progid << "\" but StringFromCLSID() failed" << std::endl; } }