|
var history = new Array();
|
var cStep = -1;
|
var ctest = 0;
|
|
var x, y, endX, endY;
|
//所有对象集合
|
var TagActivities = [];
|
//当前要绘制的
|
var Cur_sTagActivitie = [];
|
//当前要绘制的
|
var Cur_eTagActivitie = [];
|
//所用线集合
|
var Tagtransitions = [];
|
//当前要绘制的
|
var Cur_Tagtransition = [];
|
|
var activities = [];
|
var transitions = [];
|
//增加标注函数
|
function AddTagActivitiesTag() {
|
var sindex = ++cStep;
|
|
//Cur_sTagActivitie[0] = new HH.Libra.StartActivity({ 'id': sindex, 'position': { x: ex + 60, y: ey + 200 }, 'title': '' })
|
//TagActivities[sindex] = Cur_sTagActivitie;
|
|
var eindex = ++cStep;
|
//Cur_eTagActivitie[0] = new HH.Libra.Text({ 'id': eindex, 'position': { x: ex + 300, y: ex + 100 }, 'title': name });
|
//TagActivities[eindex] = Cur_eTagActivitie;
|
|
//Cur_Tagtransition[0] = new HH.Libra.Transition({ 'id': sindex + "-" + eindex, 'from': sindex, 'fromAngle': 0, 'to': eindex, 'toAngle': 0, 'title': '' });
|
//Tagtransitions.push(Cur_Tagtransition);
|
|
activities = [
|
new HH.Libra.StartActivity({ 'id': sindex, 'position': { x: 188, y: 160 }, 'title': ' ' }),
|
new HH.Libra.ManualActivity({ 'id': eindex, 'position': { x: 88, y: 66 }, 'title': '[请输入…]' })
|
];
|
|
transitions = [
|
new HH.Libra.Transition({ 'id': sindex + "-" + eindex, 'from': sindex, 'fromAngle': -5, 'to': eindex, 'toAngle': -1, 'title': '无条件' })
|
];
|
|
}
|
|
|
function GetRandomNum(Min, Max) {
|
var Range = Max - Min;
|
var Rand = Math.random();
|
return (Min + Math.round(Rand * Range));
|
}
|
|
//增加文本函数
|
function AddTextActivitiesTag(ex, ey, name) {
|
var eindex = ++cStep;
|
var obj = new HH.Libra.Text({ 'id': eindex, 'position': { x: ex + 300, y: ex + 100 }, 'title': name });
|
return obj;
|
|
}
|
|
var graph;
|
|
function requireInit() {
|
require([
|
'zrender',
|
'zrender/tool/color',
|
'zrender/Group',
|
'zrender/shape/Circle',
|
'zrender/shape/Rectangle',
|
'zrender/shape/Polygon',
|
'zrender/shape/Polyline',
|
'zrender/shape/Text',
|
'zrender/shape/Line',
|
'zrender/shape/Image'
|
],
|
function (zrender, color, Group, Circle, Rectangle, Polygon, Polyline, Text, Line, Image) {
|
// 初始化画板
|
var canvas = $('preview');
|
var createOptions = {
|
canvas: {
|
element: canvas
|
}
|
};
|
var type = {
|
zrender: zrender,
|
tool: {
|
color: color
|
},
|
Group: Group,
|
Shape: {
|
Rectangle: Rectangle,
|
Circle: Circle,
|
Polygon: Polygon,
|
Polyline: Polyline,
|
Text: Text,
|
Line: Line,
|
Image: Image
|
}
|
};
|
graph = new HH.Libra.Graph(type, createOptions);
|
|
LoadHotList();;//此处放置页面初始化时间实属无赖之举,因为必须在graph绘制后初始化,才能正常显示图片
|
initHot();//此处放置页面初始化时间实属无赖之举,因为必须在graph绘制后初始化,才能正常显示图片
|
|
|
//*********************
|
// graph.init("500", ""); //此处画布初始化,放在HotPictureEdit.cshtml页面加载水印信息函数中,因为初始化需要先获取大图宽度尺寸来初始化画布
|
//*********************
|
|
|
|
//1.增加标注
|
addTag = function () {
|
//graph.addActivity(AddTagActivitiesTag(20 + cStep, 30 + cStep, "tag-" + cStep));
|
//graph.init();
|
//graph.render();
|
//var activityObj = AddTagActivitiesTag(20 + cStep, 30 + cStep, "tag-" + cStep);
|
//graph.addActivity(activityObj);
|
//activityObj.addTo(graph);
|
AddTagActivitiesTag();
|
activities.each(function (activity) {
|
graph.addActivity(activity);
|
activity.addTo(graph);
|
});
|
transitions.each(function (transition) {
|
graph.addTransition(transition);
|
transition.addTo(graph);
|
});
|
///graph.init();
|
// graph.render();
|
|
|
|
}
|
|
//2.增加文本
|
addText = function (zrenderX, zrenderY) {
|
var img2 = document.getElementById('ImgPic2');
|
|
if (img2.src == "") {
|
parent.ShowMsg("请先上传热点图!");
|
return false;
|
}
|
|
var tagActivities = graph.getAllActivity();
|
//console.log(tagActivities);
|
var havecount = 0;
|
for (var key in tagActivities) {
|
if (tagActivities[key].object != null) {
|
if (parseInt(key) > havecount)
|
havecount = parseInt(key);
|
}
|
// havecount++;
|
}
|
var titleindex = havecount + 1;
|
var activityObj = new HH.Libra.Text({ 'id': titleindex, 'position': { x: zrenderX, y: zrenderY }, 'title': titleindex });
|
graph.addActivity(activityObj);
|
activityObj.addTo(graph);
|
changeRowColor(titleindex, 1);
|
}
|
|
//修改时,重绘热点位置
|
initText = function (id, posX, posY, note, desc) {
|
|
var activityObj = new HH.Libra.Text({ 'id': id, 'position': { x: posX, y: posY }, 'title': note + "$" + desc });
|
//var activityObj = new HH.Libra.Text({ 'id': id, 'position': { x: posX, y: posY }, 'title': note + "$" + desc, 'style': { color: colorFont, textFont: sizeFont + "px" + " " + nameFont + " ", brushType: "", textPosition: "", lineWidth: 0 } });
|
graph.addActivity(activityObj);
|
activityObj.addTo(graph);
|
|
//changeRowColor();
|
//ActivityObj.refresh(graph);
|
|
}
|
|
|
//3.增加图片
|
addImg = function (imgSrc) {
|
|
var img = new Image({
|
zlevel: 0,
|
style: {
|
x: 0,
|
y: 0,
|
image: imgSrc
|
},
|
draggable: false,
|
hoverable: false
|
});
|
graph.addShape(img);
|
}
|
|
//合成图片,获取base64流
|
getBase64 = function () {
|
var composePic = graph.GetImgUrl();
|
return composePic;
|
}
|
}
|
);
|
}
|
|
|
|
|
|
//function save() {
|
// TagActivities = graph.getAllActivity();
|
// for (var key in TagActivities) {
|
// alert("id=" + TagActivities[key].object.id + ";title=" + TagActivities[key].object.title + ";x=" + TagActivities[key].object.position.x + ";y=" + TagActivities[key].object.position.y);
|
// }
|
//}
|
|
//function showtoImage() {
|
// alert(type.zrender)
|
// type.zrender.ShowtoImage();
|
//}
|