void ODi_Frame_ListenerState::_drawInlineImage (const gchar** ppAtts) { const gchar* pWidth = NULL; const gchar* pHeight = NULL; UT_String dataId; m_inlinedImage = true; if(!m_rAbiData.addImageDataItem(dataId, ppAtts)) { UT_DEBUGMSG(("ODT import: no suitable image importer found\n")); return; } UT_String propsBuffer; pWidth = m_rElementStack.getStartTag(0)->getAttributeValue("svg:width"); UT_ASSERT(pWidth); pHeight = m_rElementStack.getStartTag(0)->getAttributeValue("svg:height"); UT_ASSERT(pHeight); UT_String_sprintf(propsBuffer, "width:%s; height:%s", pWidth, pHeight); m_mPendingImgProps["props"] = propsBuffer.c_str(); m_mPendingImgProps["dataid"] = dataId.c_str(); // don't write the image out yet as we might get more properties, for // example alt descriptions from the <svg:desc> tag m_bInlineImagePending = true; }
IEFileType IE_Imp::fileTypeForSuffixes(const char * suffixList) { IEFileType ieft = IEFT_Unknown; if (!suffixList) return ieft; UT_String utSuffix (suffixList); const size_t len = strlen(suffixList); size_t i = 0; while (true) { while (i < len && suffixList[i] != '.') i++; // will never have all-space extension const size_t start = i; while (i < len && suffixList[i] != ';') i++; if (i <= len) { UT_String suffix (utSuffix.substr(start, i-start).c_str()); UT_DEBUGMSG(("DOM: suffix: %s\n", suffix.c_str())); ieft = fileTypeForSuffix (suffix.c_str()); if (ieft != IEFT_Unknown || i == len) return ieft; i++; } } return ieft; }
//======================== FUNCTION DECLARATION ===================== // FCT NAME : UT_A2W //--------------------------------------------------------------------- /// \param pSrc /// \return //--------------------------------------------------------------------- // DESCRIPTION : /// Convert ascii to a 'wstring'. //===================================================================== void UT_A2W( const char *pSrc, UT_String &dst) { #if defined(TARGET_IOS) || defined(TARGET_MACOS) CFStringRef strref = CFStringCreateWithCStringNoCopy( 0, pSrc, CFStringGetSystemEncoding(), kCFAllocatorNull ); dst = UT_String( strref ); CFRelease( strref ); size_t uLen = strlen( pSrc ); dst.resize( uLen ); UT_String::iterator it = dst.begin(); while( *pSrc ) { *it = wchar_t( *pSrc ); ++it; ++pSrc; } #else dst = UT_String(); if (!pSrc) return; while (*pSrc) { dst.push_back(UniChar_t(*pSrc)); ++pSrc; } #endif }
int ROP_SceneCacheWriter::startRender( int nframes, fpreal s, fpreal e ) { UT_String value; evalString( value, pRootObject.getToken(), 0, 0 ); try { SceneInterface::Path emptyPath; m_liveScene = new IECoreHoudini::HoudiniScene( value, emptyPath, emptyPath ); } catch ( IECore::Exception &e ) { addError( ROP_MESSAGE, e.what() ); return false; } evalString( value, pFile.getToken(), 0, 0 ); std::string file = value.toStdString(); try { m_outScene = SceneInterface::create( file, IndexedIO::Write ); } catch ( IECore::Exception &e ) { addError( ROP_MESSAGE, ( "Could not create a writable IECore::SceneInterface at \"" + file + "\"" ).c_str() ); return false; } return true; }
void AP_UnixDialog_FormatTOC::s_NumType_changed(GtkWidget * wid, AP_UnixDialog_FormatTOC * me ) { GtkTreeIter iter; GtkComboBox * combo = GTK_COMBO_BOX(wid); gtk_combo_box_get_active_iter(combo, &iter); GtkTreeModel *store = gtk_combo_box_get_model(combo); UT_UTF8String sProp; if(wid == me->m_wLabelChoose) { sProp = "toc-label-type"; } else if (wid == me->m_wPageNumberingChoose) { sProp = "toc-page-type"; } else { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } char * value2; gtk_tree_model_get(store, &iter, 2, &value2, -1); UT_UTF8String sVal = value2; UT_String sNum = UT_String_sprintf("%d",me->getDetailsLevel()); sProp += sNum.c_str(); me->setTOCProperty(sProp,sVal); g_free(value2); }
static void _errorSAXFunc(void *xmlp, const char *msg, ...) { va_list args; va_start (args, msg); UT_String errorMessage; UT_String_vprintf (errorMessage,msg, args); va_end (args); // Handle 'nbsp' here UT_XML * pXML = reinterpret_cast<UT_XML *>(xmlp); pXML->incMinorErrors(); char * szErr = g_strdup(errorMessage.c_str() ); if(strstr(szErr,"'nbsp' not defined") != NULL) { UT_DEBUGMSG(("nbsp found in stream errs %d \n",pXML->getNumMinorErrors())); pXML->incRecoveredErrors(); const char buffer []= { (char)0xa0}; pXML->charData(buffer,1); } else if(strstr(szErr,"not defined") != NULL) { pXML->incRecoveredErrors(); } else { UT_DEBUGMSG(("SAX function error here \n")); UT_DEBUGMSG(("%s", errorMessage.c_str())); // This is a runtime error, an ASSERT is out of place. // UT_ASSERT(UT_SHOULD_NOT_HAPPEN); } FREEP(szErr); }
// // URLDict_invoke // ------------------- // This is the function that we actually call to invoke the on-line dictionary. // It should be called when the user selects from the context menu // static bool URLDict_invoke(AV_View* /*v*/, EV_EditMethodCallData * /*d*/) { // Get the current view that the user is in. XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame(); FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView()); // If the user is on a word, but does not have it selected, we need // to go ahead and select that word so that the search/replace goes // correctly. pView->moveInsPtTo(FV_DOCPOS_EOW_MOVE); pView->moveInsPtTo(FV_DOCPOS_BOW); pView->extSelTo(FV_DOCPOS_EOW_SELECT); // Now we will figure out what word to look up when we open our dialog. UT_String url ("http://www.dict.org/bin/Dict?Form=Dict1&Database=*&Strategy=*&Query="); if (!pView->isSelectionEmpty()) { // We need to get the Ascii version of the current word. UT_UCS4Char *ucs4ST; pView->getSelectionText(*&ucs4ST); char* search = _ucsToAscii( ucs4ST ); url += search; DELETEPV(search); FREEP(ucs4ST); } XAP_App::getApp()->openURL( url.c_str() ); return true; }
void AP_UnixDialog_FormatTOC::event_Apply(void) { UT_DEBUGMSG(("Doing apply \n")); // Heading Text GtkWidget * pW = _getWidget("edHeadingText"); UT_UTF8String sVal; sVal = gtk_entry_get_text(GTK_ENTRY(pW)); setTOCProperty("toc-heading",sVal.utf8_str()); // Text before and after pW = _getWidget("edTextAfter"); sVal = gtk_entry_get_text(GTK_ENTRY(pW)); UT_UTF8String sProp; sProp = static_cast<const char *> (g_object_get_data(G_OBJECT(pW),"toc-prop")); UT_String sNum = UT_String_sprintf("%d",getDetailsLevel()); sProp += sNum.c_str(); setTOCProperty(sProp,sVal); pW = _getWidget("edTextBefore"); sVal = gtk_entry_get_text(GTK_ENTRY(pW)); sProp = static_cast<const char *> (g_object_get_data(G_OBJECT(pW),"toc-prop")); sProp += sNum.c_str(); setTOCProperty(sProp,sVal); Apply(); }
bool doRegistration(void) { // Get XAP_Prefs object for retrieving/storing image editor and related preferences UT_return_val_if_fail(prefs != NULL, false); if ((prefsScheme = prefs->getPluginScheme(szAbiPluginSchemeName)) == NULL) { // it may not exist so try creating & adding it. prefs->addPluginScheme(new XAP_PrefsScheme(prefs, szAbiPluginSchemeName)); // if it still isn't there then fail if ((prefsScheme = prefs->getPluginScheme(szAbiPluginSchemeName)) == NULL) return false; // go ahead and set our default values UT_String szProgramName; bool bLeaveImageAsPNG; getDefaultApp(szProgramName, bLeaveImageAsPNG); prefsScheme->setValue(ABIPAINT_PREF_KEY_szProgramName.c_str(), szProgramName.c_str()); prefsScheme->setValueBool(ABIPAINT_PREF_KEY_bLeaveImageAsPNG, bLeaveImageAsPNG); } // Add the image editor to AbiWord's menus. addToMenus(amo, NUM_MENUITEMS, AP_MENU_ID_TOOLS_WORDCOUNT, AP_MENU_ID_FMT_IMAGE); return true; }
// // AbiPaint specify image editor // ------------------- // This is the function sets which image editor will (at least attempted) be invoked. // // parameters are: // AV_View* v // EV_EditMethodCallData *d) // static DECLARE_ABI_PLUGIN_METHOD(specify) { UT_UNUSED(v); UT_UNUSED(d); // get current value UT_String szProgramName = ""; prefsScheme->getValue(ABIPAINT_PREF_KEY_szProgramName, szProgramName); // Get a frame in case we need to show an error message XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame(); { const char * szDescList[3]; const char * szSuffixList[3]; int ft[3]; szDescList[0] = szProgramsDesc; szSuffixList[0] = szProgramSuffix; szDescList[1] = szSuffixList[1] = NULL; ft[0] = ft[1] = ft[2] = IEGFT_Unknown; if (getFileName(szProgramName, pFrame, XAP_DIALOG_ID_FILE_OPEN, szDescList, szSuffixList, ft)) return false; UT_DEBUGMSG(("ABIPAINT: szProgramName to use is %s\n", szProgramName.c_str())); } // now write it to the preference prefsScheme->setValue(ABIPAINT_PREF_KEY_szProgramName.c_str(), szProgramName.c_str()); return true; }
/*! * Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in" * Return the value of the property sProp or NULL if it is not present. * This UT_String * should be deleted by the calling programming after it is finished with it. */ UT_String UT_String_getPropVal(const UT_String & sPropertyString, const UT_String & sProp) { UT_String sWork(sProp); sWork += ":"; const char * szWork = sWork.c_str(); const char * szProps = sPropertyString.c_str(); const char * szLoc = strstr(szProps,szWork); if(szLoc == NULL) { return UT_String(); } // // Look if this is the last property in the string. // const char * szDelim = strchr(szLoc,';'); if(szDelim == NULL) { // // Remove trailing spaces // UT_sint32 iSLen = strlen(szProps); while(iSLen > 0 && szProps[iSLen-1] == ' ') { iSLen--; } // // Calculate the location of the substring // UT_sint32 offset = static_cast<UT_sint32>(reinterpret_cast<size_t>(szLoc) - reinterpret_cast<size_t>(szProps)); offset += strlen(szWork); return UT_String(sPropertyString.substr(offset,(iSLen - offset))); } else { szDelim = strchr(szLoc,';'); if(szDelim == NULL) { // // bad property string // UT_ASSERT(UT_SHOULD_NOT_HAPPEN); return UT_String(); } // // Remove trailing spaces. // while(*szDelim == ';' || *szDelim == ' ') { szDelim--; } // // Calculate the location of the substring // UT_sint32 offset = static_cast<UT_sint32>(reinterpret_cast<size_t>(szLoc) - reinterpret_cast<size_t>(szProps)); offset += strlen(szWork); UT_sint32 iLen = static_cast<UT_sint32>(reinterpret_cast<size_t>(szDelim) - reinterpret_cast<size_t>(szProps)) + 1; return UT_String(sPropertyString.substr(offset,(iLen - offset))); } }
void XAP_UnixDialog_FileOpenSaveAs::fileTypeChanged(GtkWidget * w) { if (!m_bSave) return; UT_sint32 nFileType = XAP_comboBoxGetActiveInt(GTK_COMBO_BOX(w)); UT_DEBUGMSG(("File type widget is %p filetype number is %d \n",w,nFileType)); // I have no idea for 0, but XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO // definitely means "skip this" if((nFileType == 0) || (nFileType == XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO)) { return; } gchar * filename = gtk_file_chooser_get_filename(m_FC); UT_String sFileName = filename; FREEP(filename); UT_String sSuffix = m_szSuffixes[nFileType-1]; sSuffix = sSuffix.substr(1,sSuffix.length()-1); UT_sint32 i = 0; bool bFoundComma = false; for(i=0; i< static_cast<UT_sint32>(sSuffix.length()); i++) { if(sSuffix[i] == ';') { bFoundComma = true; break; } } if(bFoundComma) { sSuffix = sSuffix.substr(0,i); } // // Hard code a suffix // if(strstr(sSuffix.c_str(),"gz") != NULL) { sSuffix = ".zabw"; } bool bFoundSuffix = false; for(i= sFileName.length()-1; i> 0; i--) { if(sFileName[i] == '.') { bFoundSuffix = true; break; } } if(!bFoundSuffix) { return; } sFileName = sFileName.substr(0,i); sFileName += sSuffix; gtk_file_chooser_set_current_name(m_FC, UT_basename(sFileName.c_str())); }
UT_Error _runConversion(const UT_String& pdf_on_disk, const UT_String& output_on_disk, size_t which) { UT_Error rval = UT_ERROR; const char * pdftoabw_argv[4]; int argc = 0; pdftoabw_argv[argc++] = pdf_conversion_programs[which].conversion_program; pdftoabw_argv[argc++] = pdf_on_disk.c_str (); pdftoabw_argv[argc++] = output_on_disk.c_str (); pdftoabw_argv[argc++] = NULL; // run conversion if (g_spawn_sync (NULL, (gchar **)pdftoabw_argv, NULL, (GSpawnFlags)(G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL), NULL, NULL, NULL, NULL, NULL, NULL)) { char * uri = UT_go_filename_to_uri (output_on_disk.c_str ()); if (uri) { // import the document rval = IE_Imp::loadFile (getDoc (), uri, IE_Imp::fileTypeForSuffix (pdf_conversion_programs[which].extension)); g_free (uri); } } return rval; }
bool fp_FieldTOCListLabelRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; // // First get owning TOC. // UT_ASSERT(getLength() == 0); fl_TOCLayout * pTOCL = static_cast<fl_TOCLayout *>(getBlock()->myContainingLayout()); UT_ASSERT(pTOCL->getContainerType() == FL_CONTAINER_TOC); UT_String str = pTOCL->getTOCListLabel(getBlock()).utf8_str(); if(str.size() == 0) { sz_ucs_FieldValue[0] = 0; return _setValue(sz_ucs_FieldValue); } UT_sint32 i = 0; bool bStop = false; for(i=0; (i<FPFIELD_MAX_LENGTH) && !bStop; i++) { sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(str[i]); if(str[i] == 0) { bStop = true; } } return _setValue(sz_ucs_FieldValue); }
int ROP_partio::startRender(int nframes, fpreal tstart, fpreal tend) { int rcode = 1; myEndTime = tend; myStartTime = tstart; UT_String filename; OUTPUTRAW(filename, 0); if(filename.isstring()==0) { addError(ROP_MESSAGE, "ROP can't write to invalid path"); return ROP_ABORT_RENDER; } if (INITSIM()) { initSimulationOPs(); OPgetDirector()->bumpSkipPlaybarBasedSimulationReset(1); } if (error() < UT_ERROR_ABORT) { if( !executePreRenderScript(tstart) ) return 0; } return rcode; }
void IE_Imp_WordPerfect::openEndnote(const WPXPropertyList & /*propList*/) { if (m_bHdrFtrOpenCount) return; // HACK const gchar** propsArray = NULL; UT_String endnoteId; UT_String_sprintf(endnoteId,"%i",UT_rand()); propsArray = static_cast<const gchar **>(UT_calloc(7, sizeof(gchar *))); propsArray [0] = "type"; propsArray [1] = "endnote_ref"; propsArray [2] = "endnote-id"; propsArray [3] = endnoteId.c_str(); propsArray [4] = NULL; propsArray [5] = NULL; propsArray [6] = NULL; X_CheckDocumentError(appendObject(PTO_Field, propsArray)); const gchar * attribs[3] ={"endnote-id", endnoteId.c_str(), NULL}; X_CheckDocumentError(appendStrux(PTX_SectionEndnote,attribs)); X_CheckDocumentError(appendStrux(PTX_Block,NULL)); m_bRequireBlock = false; propsArray = static_cast<const gchar **>(UT_calloc(7, sizeof(gchar *))); propsArray [0] = "type"; propsArray [1] = "endnote_anchor"; propsArray [2] = "endnote-id"; propsArray [3] = endnoteId.c_str(); propsArray [4] = NULL; propsArray [5] = NULL; propsArray [6] = NULL; X_CheckDocumentError(appendObject(PTO_Field, propsArray)); }
OP_ERROR SOP_SceneCacheSource::cookMySop( OP_Context &context ) { flags().setTimeDep( true ); std::string file; if ( !ensureFile( file ) ) { addError( SOP_ATTRIBUTE_INVALID, ( file + " is not a valid .scc" ).c_str() ); gdp->clearAndDestroy(); return error(); } std::string path = getPath(); Space space = getSpace(); UT_String shapeFilterStr; evalString( shapeFilterStr, pShapeFilter.getToken(), 0, 0 ); UT_StringMMPattern shapeFilter; shapeFilter.compile( shapeFilterStr ); UT_String p( "P" ); UT_String attributeFilter; evalString( attributeFilter, pAttributeFilter.getToken(), 0, 0 ); if ( !p.match( attributeFilter ) ) { attributeFilter += " P"; } ConstSceneInterfacePtr scene = this->scene( file, path ); if ( !scene ) { addError( SOP_ATTRIBUTE_INVALID, ( path + " is not a valid location in " + file ).c_str() ); gdp->clearAndDestroy(); return error(); } MurmurHash hash; hash.append( file ); hash.append( path ); hash.append( space ); hash.append( shapeFilterStr ); hash.append( attributeFilter ); if ( !m_loaded || m_hash != hash ) { gdp->clearAndDestroy(); } Imath::M44d transform = ( space == World ) ? worldTransform( file, path, context.getTime() ) : Imath::M44d(); SceneInterface::Path rootPath; scene->path( rootPath ); loadObjects( scene, transform, context.getTime(), space, shapeFilter, attributeFilter.toStdString(), rootPath.size() ); m_loaded = true; m_hash = hash; return error(); }
static UT_String _getPassword (XAP_Frame * pFrame) { UT_String password ( "" ); if ( pFrame ) { pFrame->raise (); XAP_DialogFactory * pDialogFactory = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory()); XAP_Dialog_Password * pDlg = static_cast<XAP_Dialog_Password*>(pDialogFactory->requestDialog(XAP_DIALOG_ID_PASSWORD)); UT_return_val_if_fail(pDlg,password); pDlg->runModal (pFrame); XAP_Dialog_Password::tAnswer ans = pDlg->getAnswer(); bool bOK = (ans == XAP_Dialog_Password::a_OK); if (bOK) password = pDlg->getPassword ().utf8_str(); UT_DEBUGMSG(("SDW: Password is %s\n", password.c_str())); pDialogFactory->releaseDialog(pDlg); } return password; }
OP_ERROR GusdSOP_usdimport::_Cook(OP_Context& ctx) { fpreal t = ctx.getTime(); UT_String traversal; evalString( traversal, "import_traversal", 0, t ); ErrorChoice errorMode = static_cast<ErrorChoice>(evalInt("missingframe", 0, t )); auto lockedMgr = getLockedErrorManager(); GusdUT_ErrorManager errMgr(*lockedMgr); GusdUT_ErrorContext errContext(errMgr, errorMode == MISSINGFRAME_WARN ? UT_ERROR_WARNING : UT_ERROR_ABORT); const GusdUSD_Traverse* trav = NULL; if(traversal != _NOTRAVERSE_NAME) { const auto& table = GusdUSD_TraverseTable::GetInstance(); trav = table.FindTraversal(traversal); if(!trav) { UT_WorkBuffer buf; buf.sprintf("Failed locating traversal '%s'", traversal.c_str()); return errContext.AddError(buf.buffer()); } } return getInput(0) ? _ExpandPrims(ctx, trav, errContext) : _CreateNewPrims(ctx, trav, errContext); }
void XAP_Dialog_FontChooser::setFontDecoration(bool bUnderline, bool bOverline, bool bStrikeOut, bool bTopline, bool bBottomline) { m_bUnderline = bUnderline; m_bOverline = bOverline; m_bStrikeout = bStrikeOut; m_bTopline = bTopline; m_bBottomline = bBottomline; static gchar s[50]; UT_String decors; decors.clear(); if(bUnderline) decors += "underline "; if(bStrikeOut) decors += "line-through "; if(bOverline) decors += "overline "; if(bTopline) decors += "topline "; if(bBottomline) decors += "bottomline "; if(!bUnderline && !bStrikeOut && !bOverline && !bTopline && !bBottomline) decors = "none"; sprintf(s,"%s",decors.c_str()); addOrReplaceVecProp("text-decoration",(const gchar *) s); }
bool fp_AnnotationRun::_setValue(void) { UT_uint32 pos = getBlock()->getDocLayout()->getAnnotationVal(getPID()) + 1; UT_String tmp; UT_String_sprintf(tmp,"(%d)",pos); m_sValue = tmp.c_str(); return true; }
/*! Set the color and style of the toggled button */ void AP_Dialog_FormatFrame::toggleLineType(toggle_button btn, bool enabled) { UT_String cTmp = UT_String_sprintf("%02x%02x%02x", m_borderColor.m_red, m_borderColor.m_grn, m_borderColor.m_blu); UT_String sTmp = UT_String_sprintf("%d", (enabled ? m_lineStyle : LS_OFF)); switch (btn) { case toggle_left: { m_borderLineStyleLeft = enabled ? LS_NORMAL : LS_OFF; m_borderColorLeft = m_borderColor; setBorderThicknessLeft(m_sBorderThickness); m_vecProps.addOrReplaceProp("left-style", sTmp.c_str()); m_vecProps.addOrReplaceProp("left-color", cTmp.c_str()); m_vecProps.addOrReplaceProp("left-thickness",m_sBorderThickness.utf8_str()); } break; case toggle_right: { m_borderLineStyleRight = enabled ? LS_NORMAL : LS_OFF; m_borderColorRight = m_borderColor; setBorderThicknessRight(m_sBorderThickness); m_vecProps.addOrReplaceProp("right-style", sTmp.c_str()); m_vecProps.addOrReplaceProp("right-color", cTmp.c_str()); m_vecProps.addOrReplaceProp("right-thickness",m_sBorderThickness.utf8_str()); } break; case toggle_top: { m_borderLineStyleTop = enabled ? LS_NORMAL : LS_OFF; m_borderColorTop = m_borderColor; setBorderThicknessTop(m_sBorderThickness); m_vecProps.addOrReplaceProp("top-style", sTmp.c_str()); m_vecProps.addOrReplaceProp("top-color", cTmp.c_str()); m_vecProps.addOrReplaceProp("top-thickness",m_sBorderThickness.utf8_str()); } break; case toggle_bottom: { m_borderLineStyleBottom = enabled ? LS_NORMAL : LS_OFF; m_borderColorBottom = m_borderColor; setBorderThicknessBottom(m_sBorderThickness); m_vecProps.addOrReplaceProp("bot-style", sTmp.c_str()); m_vecProps.addOrReplaceProp("bot-color", cTmp.c_str()); m_vecProps.addOrReplaceProp("bot-thickness",m_sBorderThickness.utf8_str()); } break; default: // should not happen break; } m_bLineToggled = true; m_bSettingsChanged = true; }
int UT_W2Int( const UT_String &s ) { string as; for ( UT_String::const_iterator it = s.begin(); it != s.end(); ++it ) { as.insert( as.end(), (char)*it ); } return atoi( as.c_str() ); }
// When mantra determines that the bounding box needs to be rendered, the // render method is called. At this point, the procedural can either // generate geometry (VRAY_Procedural::openGeometryObject()) or it can // generate further procedurals (VRAY_Procedural::openProceduralObject()). void VRAY_ieProcedural::render() { initialisePython(); ParameterisedProceduralPtr parameterisedProcedural = 0; ScopedGILLock giLock; try { object ieCore = g_mainModuleNamespace["IECore"]; object classLoader = ieCore.attr( "ClassLoader" ).attr( "defaultProceduralLoader" )(); object procedural = classLoader.attr( "load" )( m_className.buffer(), m_classVersion )(); boost::python::list params; UT_WorkArgs argv; if (m_parameterString.tokenize(argv, ",")) { // The Cortex Mantra Inject otl parses the parameters of a // SOP_ProceduralHolder and replaces empty values with a '!' // character to make them easier to parse here. // // This hack is upsetting, a pure python procedural in the style // of IECoreRI iePython.dso could parse these parameters correctly // like python/IECoreRI/ExecuteProcedural.py for (int i = 0; i < argv.getArgc(); i++) { std::string s(argv[i]); if (s == "!") { params.append(std::string("")); } else { params.append(s); } } } object parameterParser = ieCore.attr( "ParameterParser" )(); parameterParser.attr( "parse" )( params, procedural.attr( "parameters" )() ); parameterisedProcedural = extract<ParameterisedProceduralPtr>( procedural ); } catch( const error_already_set &e ) { PyErr_Print(); } catch( const std::exception &e ) { msg( Msg::Error, "VRAY_ieProcedural", e.what() ); } catch( ... ) { msg( Msg::Error, "VRAY_ieProcedural", "Caught unknown exception" ); } if( parameterisedProcedural ) { IECoreMantra::RendererPtr renderer = new IECoreMantra::Renderer( this ); parameterisedProcedural->render( renderer.get(), false, false, true, true ); } }
void AP_Dialog_FormatFrame::setBorderColorLeft (const UT_RGBColor & clr) { m_borderColorLeft = clr; UT_String s = UT_String_sprintf("%02x%02x%02x", clr.m_red, clr.m_grn, clr.m_blu); m_vecProps.addOrReplaceProp("left-color", s.c_str()); m_bSettingsChanged = true; }
std::string getStringParam(OP_Parameters& node, OP_Context &context, const std::string& label, bool trimspace) { UT_String s; node.evalString(s, label.c_str(), 0, context.getTime()); if(trimspace) s.trimSpace(); return s.toStdString(); }
std::string GusdGetErrors(UT_ErrorManager* mgr, UT_ErrorSeverity sev) { std::string err; if(mgr && mgr->getSeverity() >= SYSmin(sev, UT_ERROR_MESSAGE)) { UT_String msg; mgr->getErrorMessages(msg, sev, /*headerflag*/ 0); err = msg.toStdString(); } return err; }
char * XAP_Dialog_History::getListValue(UT_uint32 item, UT_uint32 column) const { UT_return_val_if_fail(m_pDoc, NULL); UT_String S; time_t tT; struct tm * tM; char * s; switch(column) { case 0: UT_String_sprintf(S,"%d",m_pDoc->getHistoryNthId(item)); return g_strdup(S.c_str()); case 1: { tT = m_pDoc->getHistoryNthTimeStarted(item); tM = localtime(&tT); s = (char*)g_try_malloc(30); if(!s) return NULL; size_t len = strftime(s,30,"%c",tM); if(!len) { FREEP(s); return NULL; } return s; } case 2: { UT_return_val_if_fail(m_pSS, NULL); const char * pszS; if(m_pDoc->getHistoryNthAutoRevisioned(item)) pszS = m_pSS->getValue(XAP_STRING_ID_DLG_MB_Yes); else pszS = m_pSS->getValue(XAP_STRING_ID_DLG_MB_No); UT_return_val_if_fail(pszS, NULL); return g_strdup(pszS); } default:; } UT_ASSERT(UT_SHOULD_NOT_HAPPEN); return NULL; }
OP_ERROR SOP_Cleave::cookMySop(OP_Context &context) { const GA_PrimitiveGroup *polyGroup; GEO_Primitive *prim; GQ_Detail *gqd; int i,j,k; UT_Vector4 np,p; // Before we do anything, we must lock our inputs. Before returning, // we have to make sure that the inputs get unlocked. if (lockInputs(context) >= UT_ERROR_ABORT) return error(); float now = context.getTime(); duplicateSource(0, context, 0, 1); // Here we determine which groups we have to work on. We only // handle poly groups. UT_String groups; getGroups(groups); if (groups.isstring()) polyGroup = parsePrimitiveGroups(groups); else polyGroup = 0; if (error() >= UT_ERROR_ABORT) { unlockInputs(); return error(); } UT_Interrupt* boss = UTgetInterrupt(); // Start the interrupt server boss->opStart("Cleaving Polys"); // separate out all polys to be cleaved GA_PrimitiveGroup* cleave_group = gdp->newPrimitiveGroup("cleave",1); GA_PrimitiveGroup* not_cleave_group = gdp->newPrimitiveGroup("not_cleave",1); if (polyGroup) { GA_FOR_ALL_PRIMITIVES(gdp,prim) { if ( (prim->getTypeId()==GEO_PRIMPOLY) && (polyGroup->contains(prim)!=0)) cleave_group->add(prim); else not_cleave_group->add(prim); } } else {
inline static void _catPath(UT_String& st, const char* st2) { if (st.size() > 0) { if (st[st.size() - 1] != '/') st += '/'; } else st += '/'; st += st2; }