JS小工具_字符串转16进制数组_01

1、主要用于将 Qt5.3.2中使用到的js字符串 转换成 const的16进制数组

  QWebElement::evaluateJavaScript(...)

2、

3、

4、

5、intfVC.cpp中

  5.1、TintfVC::PointTransformed(...)中

    QString str = "var eleThis = this;";
           str += "function PointTransformed()";
           str += "{";
           str += "     var svg = document.rootElement;";
           str += "     var ctmSVG = svg.getScreenCTM();";
           str += "     var ctmEle = eleThis.getScreenCTM();";
           str += "     var pt = svg.createSVGPoint();";
           str += "     pt.x = "+QString::number(_dptIn->dX)+";";
           str += "     pt.y = "+QString::number(_dptIn->dY)+";";
           str += "     pt = pt.matrixTransform(ctmSVG.inverse().multiply(ctmEle));";
           str += "     return pt;";
           str += "} PointTransformed();";

    ZC:修改一下:

            var str = "var eleThis = this;";
            str += "function PointTransformed(_dX, _dY)";
            str += "{";
            str += "     var svg = document.rootElement;";
            str += "     var ctmSVG = svg.getScreenCTM();";
            str += "     var ctmEle = eleThis.getScreenCTM();";
            str += "     var pt = svg.createSVGPoint();";
            str += "     pt.x = _dX;";
            str += "     pt.y = _dY;";
            str += "     pt = pt.matrixTransform(ctmSVG.inverse().multiply(ctmEle));";
            str += "     return pt;";
            str += "}";
            str += "PointTransformed("+QString::number(_dptIn->dX)+", "+QString::number(_dptIn->dY)+");";

  5.2、TintfVC::WebElement_PointTransformed(...)中

    QString str = "var eleThis = this;";
           str += "function PointTransformed()";
           str += "{";
           str += "     var svg = document.rootElement;";
           str += "     var ctmSVG = svg.getScreenCTM();";
           str += "     var ctmEle = eleThis.getScreenCTM();";
           str += "     var pt = svg.createSVGPoint();";
           str += "     pt.x = "+QString::number(_dptIn->dX)+";";
           str += "     pt.y = "+QString::number(_dptIn->dY)+";";
           str += "     pt = pt.matrixTransform(ctmSVG.inverse().multiply(ctmEle));";
           str += "     return pt;";
           str += "} PointTransformed();";

  5.3、TintfVC::WebElement_Move(...)

    QString str = "var eleThis = this;";
           str += "var svg = document.rootElement;";
           str += "var tfm = svg.createSVGTransform();";
           str += "tfm.setTranslate("+QString::number(_x)+", "+QString::number(_y)+");";

           str += "var baseTfm = eleThis.transform.baseVal;";
           str += "baseTfm.consolidate();";
           str += "baseTfm.insertItemBefore(tfm, 0);";

    ZC:修改一下:

            str0503  = "var eleThis = this;";
            str0503 += "function PointMove(_dX, _dY)"
            str0503 += "{";
            str0503 += "    var svg = document.rootElement;";
            str0503 += "    var tfm = svg.createSVGTransform();";
            str0503 += "    tfm.setTranslate(_dX, _dY);";
            str0503 += "    var baseTfm = eleThis.transform.baseVal;";
            str0503 += "    baseTfm.consolidate();";
            str0503 += "    baseTfm.insertItemBefore(tfm, 0);";
            str0503 += "}";
            //str0503 += "PointMove("+QString::number(_x)+", "+QString::number(_y)+");";

  5.4、TintfVC::WebElement_Add(...)

        QString strJS = "";
        strJS += "function Add_FindById()";
        strJS += "{";
        strJS += "    var doceleFind = document.getElementById(‘"+strId+"‘);";
        strJS += "    if (doceleFind)";
        strJS += "        return true;";
        strJS += "    return false;";
        strJS += "}";
        strJS += "Add_FindById();";

    ZC:修改一下:

            str0504  = "function Add_FindById(_strId)";
            str0504 += "{";
            str0504 += "    var doceleFind = document.getElementById(_strId);";
            str0504 += "    if (doceleFind)";
            str0504 += "        return true;";
            str0504 += "    return false;";
            str0504 += "}";
            //str0504 += "Add_FindById(‘"+strId+"‘);";

    (1)、DrSvgExe 的情况下 也使用到了

  5.5、TintfVC::Draw_UpdatePt(...)

QString str = "g_intfQt532.Draw_UpdatePt(‘"+strId+"‘, "+QString::number(_iIdx)+", "+QString::number(_dX)+", "+QString::number(_dY)+");";

    ZC:貌似 这个现在不在使用??

  5.6、TintfVC::Draw_PointAdd(...)

QString str = "g_intfQt532.Draw_PointAdd(‘"+strId+"‘, "+QString::number(_dX)+", "+QString::number(_dY)+");";

    ZC:貌似 这个现在不在使用??

  5.7、TintfVC::Draw_PointDel(...)

QString str = "g_intfQt532.Draw_PointDel(‘"+strId+"‘, "+QString::number(_iDelIdx)+", 1);";

    ZC:貌似 这个现在不在使用??

  5.8、TintfVC::Translate(...)

QString str = "g_intfQt532.Translate_byDocEle(this, "+QString::number(_dX)+", "+QString::number(_dY)+");";

    ZC:貌似 这个现在不在使用??

  5.9、TintfVC::Scale(...)

QString str = "g_intfQt532.Scale_byDocEle(this, "+QString::number(_dX)+", "+QString::number(_dY)+");";

    ZC:貌似 这个现在不在使用??

  5.10、TintfVC::Rotate(...)

QString str = "g_intfQt532.Rotate_byDocEle(this, "+QString::number(_dAngle)+", "+QString::number(_dCenterX)+", "+QString::number(_dCenterY)+");";

    ZC:貌似 这个现在不在使用??

6、classSvgDraw.cpp

  6.1、TdrawSvg::PointTransformed(...)

    QString str = "var eleThis = this;";
           str += "function PointTransformed()";
           str += "{";
           str += "     var svg = document.rootElement;";
           str += "     var ctmSVG = svg.getScreenCTM();";
           str += "     var ctmEle = eleThis.getScreenCTM();";
           str += "     var pt = svg.createSVGPoint();";
           str += "     pt.x = "+QString::number(_dptIn->dX)+";";
           str += "     pt.y = "+QString::number(_dptIn->dY)+";";
           str += "     pt = pt.matrixTransform(ctmSVG.inverse().multiply(ctmEle));";
           str += "     return pt;";
           str += "} PointTransformed();";

  6.2、TdrawSvg::Transform_Forward(...)

    QString str = "";
    str += "function Forward(_SVGElement, _dX, _dY)";
    str += "{";
    str += "    var svgPoint = g_svg.createSVGPoint();";
    str += "    svgPoint.x = _dX;";
    str += "    svgPoint.y = _dY;";

    str += "    var svgMatrix_Root = g_svg.getScreenCTM();";

    str += "    var svgMatrix = _SVGElement.getScreenCTM();";
    str += "    svgPoint = svgPoint.matrixTransform(svgMatrix_Root.inverse().multiply(svgMatrix));";
    str += "    return svgPoint;";
    str += "}";
    str += "Forward(this, "+QString::number(_dXin)+", "+QString::number(_dYin)+");";

  6.3、TdrawSvg::Transform_Backward(...)

    QString str = "";
    str += "function Inverse(_SVGElement, _dX, _dY)";
    str += "{";
    str += "    var svgPoint = g_svg.createSVGPoint();";
    str += "    svgPoint.x = _dX;";
    str += "    svgPoint.y = _dY;";
    str += "    var svgMatrix_Root = g_svg.getScreenCTM();";
    str += "    var svgMatrix = _SVGElement.getScreenCTM();";
    str += "    svgPoint = svgPoint.matrixTransform(svgMatrix.inverse().multiply(svgMatrix_Root));";
    str += "    return svgPoint;";
    str += "}";
    str += "Inverse(this, "+QString::number(_dXin)+", "+QString::number(_dYin)+");";

  6.4、TdrGraphAttr_Q::TransformSet_Q_single(...)

    (1)、

        QString strTransform( "" );
        strTransform += "function RotateQt(_svgElement, _angle)";
        strTransform += "{";

        strTransform += "    var rt = _svgElement.getBBox();";
        strTransform += "    var fXcenter = rt.x + rt.width / 2;";
        strTransform += "    var fYcenter = rt.y + rt.height / 2;";

        strTransform += "    if (_svgElement.tagName.toLowerCase() == ‘use‘)";
        strTransform += "    {";
        strTransform += "        var strX = _svgElement.getAttribute(‘x‘);";
        strTransform += "        var strY = _svgElement.getAttribute(‘y‘);";
        strTransform += "        var fX = parseFloat(strX);";
        strTransform += "        var fY = parseFloat(strY);";
        strTransform += "        fXcenter += fX;";
        strTransform += "        fYcenter += fY;";
        strTransform += "    }";

            strTransform += "var svgPoint = g_svg.createSVGPoint();";
            strTransform += "svgPoint.x = fXcenter;";
            strTransform += "svgPoint.y = fYcenter;";
            strTransform += "var svgMatrix_Root = g_svg.getScreenCTM();";
            strTransform += "var svgMatrix = _svgElement.getScreenCTM();";
            strTransform += "svgPoint = svgPoint.matrixTransform(svgMatrix_Root.inverse().multiply(svgMatrix));";

        strTransform += "    var new01 = g_svg.createSVGTransform();";
        strTransform += "    new01.setRotate(_angle, svgPoint.x, svgPoint.y);";

        strTransform += "    var list01 = _svgElement.transform;";
        strTransform += "    var list02 = list01.baseVal;";
        strTransform += "    list02.insertItemBefore(new01, 0);";
        strTransform += "    list02.consolidate();";

        strTransform += "}";
        strTransform += "RotateQt(this, "+QString::number(_d0)+");";

    (2)、

        QString strTransform( "" );
        strTransform += "function TranslateQt(_svgElement, _x, _y)";
        strTransform += "{";
        strTransform += "    var new01 = g_svg.createSVGTransform();";
        strTransform += "    new01.setTranslate(_x, _y);";
        strTransform += "    var list01 = _svgElement.transform;";
        strTransform += "    var list02 = list01.baseVal;";
        strTransform += "    list02.insertItemBefore(new01, 0);";
        strTransform += "    list02.consolidate();";
        strTransform += "}";
        strTransform += "TranslateQt(this, "+QString::number(_d0)+", "+QString::number(_d1)+");";

    (3)、

        QString strTransform( "" );
        strTransform += "function ScaleQt(_svgElement, _x, _y)";
        strTransform += "{";
        strTransform += "    var new01 = g_svg.createSVGTransform();";
        strTransform += "    new01.setScale(_x, _y);";
        strTransform += "    var list01 = _svgElement.transform;";
        strTransform += "    var list02 = list01.baseVal;";
        strTransform += "    list02.insertItemBefore(new01, 0);";
        strTransform += "    list02.consolidate();";
        strTransform += "}";
        strTransform += "ScaleQt(this, "+QString::number(_d0)+", "+QString::number(_d1)+");";

7、

8、

9、

原文地址:https://www.cnblogs.com/h5skill/p/9545958.html

时间: 2024-10-11 06:01:25

JS小工具_字符串转16进制数组_01的相关文章

Java字符串转16 进制工具类Hex.java

原文:Java字符串转16 进制工具类Hex.java 源代码下载地址:http://www.zuidaima.com/share/1550463378410496.htm Java 字符串转 16 进制工具类 Hex.java 实现 16进制 0xfecd .. 和 java 字符串之间的互转换! 如果做开发,通常用户登陆密码都会 mad5(salt + pwd) 然后再将 md 之后的数据 hex 一下. 这个工具类,就是实现此效果的. /* * */ package com.zuidaim

js 字符串和16进制的互相转换

字符串转16进制 function strToHexCharCode(str) { if(str === "") return ""; var hexCharCode = []; hexCharCode.push("0x"); for(var i = 0; i < str.length; i++) { hexCharCode.push((str.charCodeAt(i)).toString(16)); } return hexCharCo

字节流、字符串、16进制字符串转换__Java(转)

Java代码   /** * @Package: * @ClassName:TypeConversion * @Description:字节流.字符串.16进制字符串转换 * @author:xk * @date:Jan 8, 2013 5:00:08 PM */ public class TypeConversion { /** * @Title:bytes2HexString * @Description:字节数组转16进制字符串 * @param b *            字节数组 *

超过16位的字符串装16进制

在编写程序时遇到一个问题,需要把一个19为的字符串转换为16进制.不想使用分段转换,想一次性的全部转换. C#中支持9种整型:sbyte,byte,short,ushort,int,uint,long,ulong和char. Sbyte:代表有符号的8位整数,数值范围从-128 - 127 Byte:代表无符号的8位整数,数值范围从0-255 Short:代表有符号的16位整数,范围从-32768 - 32767 ushort:代表有符号的16位整数,范围从0 到 65,535 Int:代表有符

js字符串与16进制互相转换

<script type="text/javascript"> function JavaDe() { var monyer = new Array(); var s = document.getElementById('code').value.split("\\"); for (i = 1; i < s.length; i++) { s[i] = s[i].replace('x', ''); monyer += String.fromCharC

【python】字符串、16进制等数据处理

最近做一个socket server,需要接收组播报文,并进行分析处理.其中涉及的一个问题是,待发送的报文是字符串形式,类似"hello world". 从wireshark截取的报文看,都是16进制数据,以为必须转为该种类型才能发送,需要转换为16进制字符串,类似"0x\a00x\c30x\b4"等. 但后来发现,直接发送数据也是ok的,应该是数据发送时自己会进行转码. 不了解的时候,网上查了下,发现大家推荐用到的模块是binascii,查看help 几个方法如下

字符串和16进制字符串的相互转化

我们在工作中,有时候会需要将字符串转化为16进制字符串给用户,因为ASCII中有些字符,当我们使用printf("%s",p_ch);输出时会杂乱无章,如果采用16进制,会好很多. 因此编写程序,代码如下: #include <stdio.h> #include <string.h> int strToHex(char *ch, char *hex); int hexToStr(char *hex, char *ch); int hexCharToValue(c

C#字符串和16进制字符串之间的转换

将字符串编码成 16进制 字符串表示: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net; namespace ConsoleApplication1{ class Program { static void Main(string[] args) { // 将字符串转换成16进制表示: // 先将字符串转换成 byte 数组: // (1).如果是

字符串转16进制

-(NSString*)str2HexStr:(NSString*)str{ NSString* hexStr= @""; NSString* hex = @"0123456789ABCDEF"; NSString* str4Up = [str uppercaseString]; //   补绝对0 0x00 而非字符‘0’ 所以要先转16进制补0,再转回 for (int i =0 ; i<[str4Up length]; i++) { char dd =