Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
commit 8d1b059f85
  1. 2
      Sankore_3.1.pro
  2. 15
      resources/forms/mainWindow.ui
  3. 12
      resources/library/interactive/Geogebra.wgt/config.xml
  4. BIN
      resources/library/interactive/Geogebra.wgt/icon.png
  5. BIN
      resources/library/interactive/Geogebra.wgt/images/loading.gif
  6. 71
      resources/library/interactive/Geogebra.wgt/index.html
  7. 392
      resources/library/interactive/Graphme.wgt/Grapheur.xhtml
  8. 196
      resources/library/interactive/Graphme.wgt/Guide_Utilisateur.html
  9. 32
      resources/library/interactive/Graphme.wgt/JavaScript/AffichageUniboard.js
  10. 26
      resources/library/interactive/Graphme.wgt/JavaScript/Etude.js
  11. 4
      resources/library/interactive/Graphme.wgt/JavaScript/Interface.js
  12. 4
      resources/library/interactive/Graphme.wgt/JavaScript/Sauvegardes.js
  13. 98
      resources/library/interactive/iCell.wgt/js/textes_descriptifs.js
  14. 2
      src/adaptors/UBImportPDF.cpp
  15. 2
      src/adaptors/adaptors.pri
  16. 164
      src/adaptors/publishing/UBCapturePublisher.cpp
  17. 61
      src/adaptors/publishing/UBCapturePublisher.h
  18. 54
      src/board/UBBoardPaletteManager.cpp
  19. 1
      src/board/UBBoardPaletteManager.h
  20. 1758
      src/board/UBBoardView.cpp
  21. 1
      src/core/UBPreferencesController.cpp
  22. 121
      src/desktop/UBDesktopAnnotationController.cpp
  23. 18
      src/desktop/UBDesktopAnnotationController.h
  24. 9
      src/desktop/UBDesktopPalette.cpp
  25. 1
      src/desktop/UBDesktopPalette.h
  26. 43
      src/domain/UBAbstractWidget.cpp
  27. 25
      src/domain/UBAbstractWidget.h
  28. 32
      src/domain/UBGraphicsScene.cpp
  29. 3
      src/domain/UBGraphicsScene.h
  30. 50
      src/domain/UBW3CWidget.cpp
  31. 80
      src/gui/UBDockPalette.cpp
  32. 16
      src/gui/UBDockPalette.h
  33. 1
      src/gui/UBFloatingPalette.cpp
  34. 1
      src/gui/UBFloatingPalette.h
  35. 1
      src/gui/UBLibNavigatorWidget.cpp
  36. 5
      src/gui/UBLibPalette.cpp
  37. 3
      src/gui/UBLibPalette.h
  38. 926
      src/gui/UBLibPathViewer.cpp
  39. 3
      src/gui/UBNavigatorPalette.cpp
  40. 1
      src/gui/UBToolWidget.cpp
  41. 4
      src/pdf/PDFRenderer.cpp
  42. 2
      src/pdf/PDFRenderer.h
  43. 124
      src/pdf/XPDFRenderer.cpp
  44. 2
      src/pdf/XPDFRenderer.h
  45. 578
      src/tools/UBGraphicsTriangle.cpp
  46. 126
      src/tools/UBGraphicsTriangle.h

@ -7,7 +7,7 @@ CONFIG += debug_and_release \
no_include_pwd no_include_pwd
VERSION_MAJ = 1 VERSION_MAJ = 1
VERSION_MIN = 13 VERSION_MIN = 15
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
VERSION_PATCH = 00 VERSION_PATCH = 00

@ -1551,21 +1551,6 @@
<enum>QAction::TextHeuristicRole</enum> <enum>QAction::TextHeuristicRole</enum>
</property> </property>
</action> </action>
<action name="actionShareItemOnWeb">
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/addItemToLibrary.svg</normaloff>:/images/addItemToLibrary.svg</iconset>
</property>
<property name="text">
<string>Share Item on the Web</string>
</property>
<property name="toolTip">
<string>Share Capture on the Web</string>
</property>
<property name="visible">
<bool>true</bool>
</property>
</action>
<action name="actionDesktopTools"> <action name="actionDesktopTools">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://uniboard.mnemis.com/widgets/geogebra"
version="1.0"
width="800"
height="500"
ub:resizable="true"
ub:roles="tool cMAC cUNIX">
<name>Geogebra</name>
<content src="index.html"/>
</widget>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@ -0,0 +1,71 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<BODY>
<DIV id=applet1></DIV>
<SCRIPT type=text/javascript>
function ggbOnInit()
{
alert("Geogebra applet is initialized");
}
var width=0;
var height=0;
setWidthHeight();
if (height < 500) height=500;
if (width < 800) width=800;
var applet1=document.getElementById('applet1');
applet1.innerHTML=geogebra_applet(0.95*width,height*0.95,"",true,true,true,false,true,true,true,true,true,true,true,true);
function geogebra_applet(width,height,filename,framePossible,enableRightClick,enableShiftDragZoom,showResetIcon,showMenuBar,showToolBar,showToolBarHelp,showAlgebraInput,enableLabelDrags,showSpreadsheet,showAlgebraView) {
ret = '<applet name="ggbApplet" code="geogebra.GeoGebraApplet" codebase="./bin/" archive="geogebra.jar" height="'+height+'" width="'+width+'">';
ret +='<param name="image" value="./images/loading.gif"/><param name="boxborder" value="false"/><param name="centerimage" value="true">';
ret +='<param name="java_arguments" value="-Xmx512m">';
if (filename != "") ret+='<param name="filename" value="'+filename+'">';
ret+='<param name="framePossible" value="'+framePossible+'">';
ret+='<param name="enableRightClick" value="'+enableRightClick+'">';
ret+='<param name="enableShiftDragZoom" value="'+enableShiftDragZoom+'">';
ret+='<param name="enableLabelDrags" value="'+enableLabelDrags+'">';
ret+='<param name="showSpreadsheet" value="'+showSpreadsheet+'">';
ret+='<param name="showAlgebraView" value="'+showAlgebraView+'">';
ret+='<param name="showResetIcon" value="'+showResetIcon+'">';
ret+='<param name="showMenuBar" value="'+showMenuBar+'">';
ret+='<param name="showToolBar" value="'+showToolBar+'">';
ret+='<param name="showToolBarHelp" value="'+showToolBarHelp+'">';
ret+='<param name="showAlgebraInput" value="'+showAlgebraInput+'">';
ret+='Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and activated.';
ret+='(<a href="http://java.sun.com/getjava">click here to install Java now</a>)';
ret+='</applet>';
return ret;
}
function setWidthHeight() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
//window.alert( 'Width = ' + myWidth );
//window.alert( 'Height = ' + myHeight );
width=myWidth;
height=myHeight;
}
</SCRIPT>
</BODY></HTML>

@ -6,7 +6,7 @@
<meta name="description" content="Traceur de fonctions mathématiques en JavaScript"/> <meta name="description" content="Traceur de fonctions mathématiques en JavaScript"/>
<meta name="author" content="Yannick Vessaz"/> <meta name="author" content="Yannick Vessaz"/>
<meta name="revised" content="2010/09/25"/> <meta name="revised" content="2010/09/25"/>
<title>Traceur de fonctions mathématiques</title> <title>Graphics</title>
<link rel="stylesheet" type="text/css" href="Style/default.css"/> <link rel="stylesheet" type="text/css" href="Style/default.css"/>
<script type="text/javascript" src="JavaScript/ColorPicker.js"></script> <script type="text/javascript" src="JavaScript/ColorPicker.js"></script>
<script type="text/javascript" src="JavaScript/Etude.js"></script> <script type="text/javascript" src="JavaScript/Etude.js"></script>
@ -28,7 +28,7 @@
var ligne = new Array() var ligne = new Array()
var j = 0 var j = 0
var interdit = new Array(";", "interdit", "'", '"', "eval", "new", "uniboard", "=", "document", "window", "alert") var interdit = new Array(";", "interdit", "'", '"', "eval", "new", "sankore", "=", "document", "window", "alert")
var menuActuel = "" var menuActuel = ""
var mouseDown = false var mouseDown = false
@ -89,7 +89,7 @@
// Cette fonction permet de choisir la méthode d'affichage entre: // Cette fonction permet de choisir la méthode d'affichage entre:
// 1) Image au format XPM // 1) Image au format XPM
// 2) Affichage directe dans uniboard // 2) Affichage directe dans sankore
// 3) Autres Méthodes d'affichages (svg ou canvas) // 3) Autres Méthodes d'affichages (svg ou canvas)
function evaluer(eq){ function evaluer(eq){
if(check(eq)){ if(check(eq)){
@ -109,7 +109,7 @@
else if(document.getElementById("selectMethodeAffichage").value == "xpm"){ else if(document.getElementById("selectMethodeAffichage").value == "xpm"){
evaluerXPM(eq) evaluerXPM(eq)
} }
else if(document.getElementById("selectMethodeAffichage").value == "uniboard"){ else if(document.getElementById("selectMethodeAffichage").value == "sankore"){
evaluerUniboard(eq) evaluerUniboard(eq)
} }
else if(document.getElementById("selectMethodeAffichage").value == "canvas" || document.getElementById("selectMethodeAffichage").value == "canvas2"){ else if(document.getElementById("selectMethodeAffichage").value == "canvas" || document.getElementById("selectMethodeAffichage").value == "canvas2"){
@ -270,8 +270,8 @@
<body onload="evaluer(1000);checkCouleurs3D();loadOptions();majAuto()" onkeypress="keyPress(event)"> <body onload="evaluer(1000);checkCouleurs3D();loadOptions();majAuto()" onkeypress="keyPress(event)">
<!-- ..... Haut du Widget ..... --> <!-- ..... Haut du Widget ..... -->
<span id="haut"> <span id="haut">
<span id="texteFonction">Fonction : </span><input id="inputEq" onkeypress='if(event.keyCode==13) evaluer(this.value)' onkeyup="document.getElementById('fonctionActuelle').innerHTML = this.value"/> <span id="texteFonction">Function: </span><input id="inputEq" onkeypress='if(event.keyCode==13) evaluer(this.value)' onkeyup="document.getElementById('fonctionActuelle').innerHTML = this.value"/>
<input type="button" onclick='evaluer(document.getElementById("inputEq").value)' value="Afficher"/><input type="button" style="width:21px;" onclick="menuFonctions()" value="+"/> <input type="button" onclick='evaluer(document.getElementById("inputEq").value)' value="Display"/><input type="button" style="width:21px;" onclick="menuFonctions()" value="+"/>
</span> </span>
<!--<div id="miniMax" onclick="miniMax()">-</div> ▶▼ --> <!--<div id="miniMax" onclick="miniMax()">-</div> ▶▼ -->
<div id="boutonAgrandir" class="miniBouton" onclick="agrandirAffichage()">^</div> <div id="boutonAgrandir" class="miniBouton" onclick="agrandirAffichage()">^</div>
@ -283,34 +283,34 @@
<div id="affichage" onmousedown="sourisDown()" onmouseup="sourisUp()" onmousemove="sourisMove(event)" ondblclick="doubleClick(event.ctrlKey)"></div> <div id="affichage" onmousedown="sourisDown()" onmouseup="sourisUp()" onmousemove="sourisMove(event)" ondblclick="doubleClick(event.ctrlKey)"></div>
<!-- Zone de boutons gauche --> <!-- Zone de boutons gauche -->
<div id="gauche"> <div id="gauche">
Axe des X de: <br/> X-axis: <br/>
<input id="borneXGauche" class="smallInput" value="-5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> à <input id="borneXDroite" class="smallInput" value="5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> <br/> <input id="borneXGauche" class="smallInput" value="-5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> à <input id="borneXDroite" class="smallInput" value="5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> <br/>
Axe des Y de: <br/> Y-axis: <br/>
<input id="borneYGauche" class="smallInput" value="-5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> à <input id="borneYDroite" class="smallInput" value="5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> <input id="borneYGauche" class="smallInput" value="-5" onkeypress='if(event.keyCode==13) actualiserGraph()'/> à <input id="borneYDroite" class="smallInput" value="5" onkeypress='if(event.keyCode==13) actualiserGraph()'/>
<br/>Zoom: <br/> <br/>Zoom: <br/>
<input type="button" style="width:45%;" onclick='zoom(1.25)' value="-"/><input type="button" style="width:45%; position:relative; left: 9px;" onclick='zoom(0.8)' value="+"/><br/><br/> <input type="button" style="width:45%;" onclick='zoom(1.25)' value="-"/><input type="button" style="width:45%; position:relative; left: 9px;" onclick='zoom(0.8)' value="+"/><br/><br/>
Couleur: <br/> Color: <br/>
<div id="buttonColor" title="couleurFonction" onclick="colorPicker(this.id); afficherMenu('menuCouleur')"></div> <div id="buttonColor" title="couleurFonction" onclick="colorPicker(this.id); afficherMenu('menuCouleur')"></div>
<br/><br/> <br/><br/>
<hr/> <hr/>
<br/> <br/>
Menus: Menus:
<input type="button" class="boutonGauche" onclick='document.getElementById("etudeFct").innerHTML = document.getElementById("inputEq").value;afficherMenu("menuOutils")' value="Outils"/> <input type="button" class="boutonGauche" onclick='document.getElementById("etudeFct").innerHTML = document.getElementById("inputEq").value;afficherMenu("menuOutils")' value="Tools"/>
<input type="button" class="boutonGauche" onclick='afficherMenu("menuOptions")' value="Options"/> <input type="button" class="boutonGauche" onclick='afficherMenu("menuOptions")' value="Options"/>
<input type="button" class="boutonGauche" onclick='afficherMenu("menuAide")' value="Aide"/> <input type="button" class="boutonGauche" onclick='afficherMenu("menuAide")' value="Help"/>
<input type="button" class="boutonGauche" onclick='afficherMenu("menuCredits")' value="À propos"/> <input type="button" class="boutonGauche" onclick='afficherMenu("menuCredits")' value="About"/>
<!-- ..... Menus ..... --> <!-- ..... Menus ..... -->
<div id="menu" class="menu"> <div id="menu" class="menu">
<div id="contenuMenu" class="contenuMenu"></div> <div id="contenuMenu" class="contenuMenu"></div>
<div class="barreBasMenu"> <div class="barreBasMenu">
<input type="button" onclick='cacherMenu()' value="Fermer"/> <input type="button" onclick='cacherMenu()' value="Cancel"/>
</div> </div>
</div> </div>
</div> </div>
<div id="gauche3D"> <div id="gauche3D">
<input type="button" class="boutonGauche3D" onclick='afficherMenu("menuCredits")' value="À propos"/> <input type="button" class="boutonGauche3D" onclick='afficherMenu("menuCredits")' value="About"/>
<input type="button" class="boutonGauche3D" onclick='afficherMenu("menuAide")' value="Aide"/> <input type="button" class="boutonGauche3D" onclick='afficherMenu("menuAide")' value="Help"/>
<input type="button" class="boutonGauche3D" onclick='afficherMenu("menuOptions")' value="Options"/> <input type="button" class="boutonGauche3D" onclick='afficherMenu("menuOptions")' value="Options"/>
<input type="button" style="width:30px;" onclick='zoom3D(0.8)' value="-"/><input type="button" style="width:30px;" onclick='zoom3D(1.25)' value="+"/> <input type="button" style="width:30px;" onclick='zoom3D(0.8)' value="-"/><input type="button" style="width:30px;" onclick='zoom3D(1.25)' value="+"/>
</div> </div>
@ -325,26 +325,26 @@
</tr> </tr>
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<h3>Options du widget</h3> <h3>Widget options</h3>
Thème du widget : <select id="selectTheme" onchange="changerTheme(this.value)"> Themes of widget: <select id="selectTheme" onchange="changerTheme(this.value)">
<option value="noir">Noir</option> <option value="noir">Black</option>
<option value="bleu">Bleu</option> <option value="bleu">Blue</option>
<option value="blanc">Blanc</option> <option value="blanc">White</option>
</select><br/> </select><br/>
<br/><br/><br/> <br/><br/><br/>
<span class="gras">Gèrer les options :</span><br/> <span class="gras">Control options:</span><br/>
<input type="button" class="boutonSauvegarde" onclick="saveOptions()" value="Sauvegarder"/><input type="button" class="boutonSauvegarde" onclick="loadOptions()" value="Charger"/> <input class="boutonSauvegarde2" type="button" onclick="delOptions()" value="Supprimer"/><input class="boutonSauvegarde2" type="button" onclick="alertOptions()" value="Afficher"/><br/> <input type="button" class="boutonSauvegarde" onclick="saveOptions()" value="Save"/><input type="button" class="boutonSauvegarde" onclick="loadOptions()" value="Load"/> <input class="boutonSauvegarde2" type="button" onclick="delOptions()" value="Delete"/><input class="boutonSauvegarde2" type="button" onclick="alertOptions()" value="Display"/><br/>
<span class="texteSecondaire">Sauvegarder les options du widget dans les cookies, charger les options depuis les cookies ou supprimer les options actuellement enregistrées.</span> <span class="texteSecondaire">Save a widget options in cookies or load an options from cookies or delete a registered options.</span>
<br/><br/> <br/><br/>
<label for="checkMaJ">Mise à jour automatique à l'ouverture du widget</label> <input type="checkbox" id="checkMaJ" onclick="checkboxMaJ()"/> <label for="checkMaJ">Automatically update when a widget opening.</label> <input type="checkbox" id="checkMaJ" onclick="checkboxMaJ()"/>
<br/> <br/>
<div id="cacheCookies"><br/><br/><h1>Les cookies sont désactivés, impossible de sauvegarder les options...</h1></div> <div id="cacheCookies"><br/><br/><h1>Cookies are disabled. You cannot save an options...</h1></div>
<div id="cacheMaJ">Vous utilisez la dernière version du widget en ligne.</div> <div id="cacheMaJ">You are using the last version of this widget.</div>
<input type="button" onclick='reset()' value="Recharger le widget" style="position:absolute; bottom:20px; width:140px; height:32px;"/> <input type="button" onclick='reset()' value="Reload widget" style="position:absolute; bottom:20px; width:140px; height:32px;"/>
<input type="button" onclick='miseAjour()' value="Mise à jour" style="position:absolute; bottom:20px; left:160px; width:140px; height:32px;"/> <input type="button" onclick='miseAjour()' value="Updated" style="position:absolute; bottom:20px; left:160px; width:140px; height:32px;"/>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick="cacherMenu(); actualiserGraph()" value="Valider"/></div> <div class="barreBasMenu"><input type="button" onclick="cacherMenu(); actualiserGraph()" value="Check"/></div>
</div> </div>
<div id="menuOptions2D" class="menu"> <div id="menuOptions2D" class="menu">
@ -357,34 +357,34 @@
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<h3>Options 2D</h3> <h3>Options 2D</h3>
Méthode d'affichage du graphique :<select id="selectMethodeAffichage"> The graphical method displaying:<select id="selectMethodeAffichage">
<option value="canvas">canvas (lignes)</option> <option value="canvas">canvas (lines)</option>
<option value="canvas2">canvas (points)</option> <option value="canvas2">canvas (points)</option>
<option value="svg">svg</option> <option value="svg">svg</option>
<option value="svg2">svg (1 image)</option> <option value="svg2">svg (1 image)</option>
<option value="xpm">xpm</option> <option value="xpm">xpm</option>
<option value="uniboard">uniboard</option> <option value="sankore">sankore</option>
</select> <br/> </select> <br/>
Zoom par défaut: Zoom default:
<input value="5" class="smallInput" id="zoomDefaut"/> <input value="5" class="smallInput" id="zoomDefaut"/>
<input type="button" onclick='reinitialiserZoom(document.getElementById("zoomDefaut").value)' value="Réinitialiser le zoom"/> <br/> <input type="button" onclick='reinitialiserZoom(document.getElementById("zoomDefaut").value)' value="Reset zoom"/> <br/>
<br/> <br/>
<input type="checkbox" id="checkGrille" checked="true" onclick="actualiserGraph()"/><label for="checkGrille"> Afficher la grille</label> <br/> <input type="checkbox" id="checkGrille" checked="true" onclick="actualiserGraph()"/><label for="checkGrille">Show grid</label> <br/>
<input type="checkbox" id="checkAxes" checked="true" onclick="actualiserGraph()"/><label for="checkAxes"> Afficher les axes</label> <br/> <input type="checkbox" id="checkAxes" checked="true" onclick="actualiserGraph()"/><label for="checkAxes">Show axis</label> <br/>
<input type="checkbox" id="checkEchelle" checked="true" onclick="actualiserGraph()"/><label for="checkEchelle"> Afficher l'échelle</label> <br/> <input type="checkbox" id="checkEchelle" checked="true" onclick="actualiserGraph()"/><label for="checkEchelle">Scale</label> <br/>
Épaisseur de la fonction: <input id="inputTaille" class="smallInput" value="3" onkeypress='if(event.keyCode==13) actualiserGraph()' style=""/> Thickness: <input id="inputTaille" class="smallInput" value="3" onkeypress='if(event.keyCode==13) actualiserGraph()' style=""/>
<div class="boutonPlus" type="button" onclick="boutonPlus('inputTaille', 1); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputTaille', 1); actualiserGraph()">-</div> <br/> <div class="boutonPlus" type="button" onclick="boutonPlus('inputTaille', 1); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputTaille', 1); actualiserGraph()">-</div> <br/>
<br/> <br/>
Décalage du graphique: Offset diagram:
x=<input value="0" class="smallInput" id="inputDecalageX" onkeyup="decalageX = parseFloat(this.value)"/> x=<input value="0" class="smallInput" id="inputDecalageX" onkeyup="decalageX = parseFloat(this.value)"/>
y=<input value="0" class="smallInput" id="inputDecalageY" onkeyup="decalageY = parseFloat(this.value)"/> y=<input value="0" class="smallInput" id="inputDecalageY" onkeyup="decalageY = parseFloat(this.value)"/>
<br/> <br/>
Précision des calculs du graphique: Accuracy graph:
<input value="0.02" class="smallInput" id="inputPrecision" onkeyup="precision = parseFloat(this.value)"/> <input value="0.02" class="smallInput" id="inputPrecision" onkeyup="precision = parseFloat(this.value)"/>
<div class="boutonPlus" type="button" onclick="boutonPlus('inputPrecision', 0.01); precision = parseFloat(document.getElementById('inputPrecision').value); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputPrecision', 0.01); precision = parseFloat(document.getElementById('inputPrecision').value); actualiserGraph()">-</div> <br/> <div class="boutonPlus" type="button" onclick="boutonPlus('inputPrecision', 0.01); precision = parseFloat(document.getElementById('inputPrecision').value); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputPrecision', 0.01); precision = parseFloat(document.getElementById('inputPrecision').value); actualiserGraph()">-</div> <br/>
<br/> <br/>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu(); actualiserGraph()' value="Valider"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu(); actualiserGraph()' value="Check"/></div>
</div> </div>
<div id="menuOptions3D" class="menu"> <div id="menuOptions3D" class="menu">
@ -397,121 +397,121 @@
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<h3>Options 3D</h3> <h3>Options 3D</h3>
Style d'affichage : Show the style:
<select id="selectAffichage3D"> <select id="selectAffichage3D">
<option value="surfaces"> surfaces </option> <option value="surfaces"> surfaces </option>
<option value="points"> points </option> <option value="points"> points </option>
</select> <input type="button" onclick='reinitialiserZoom(5)' value="Réinitialiser l'affichage"/> <br/> </select> <input type="button" onclick='reinitialiserZoom(5)' value="Reset display"/> <br/>
<br/> <br/>
Précision de la fonction : <input value="0.2" class="smallInput" id="inputPrecision3D" onkeyup="precisionFonction3D = parseFloat(this.value)"/> Accuracy function: <input value="0.2" class="smallInput" id="inputPrecision3D" onkeyup="precisionFonction3D = parseFloat(this.value)"/>
<div class="boutonPlus" type="button" onclick="boutonPlus('inputPrecision3D', 0.1); precisionFonction3D = parseFloat(document.getElementById('inputPrecision3D').value); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputPrecision3D', 0.1); precisionFonction3D = parseFloat(document.getElementById('inputPrecision3D').value); actualiserGraph()">-</div> <br/> <div class="boutonPlus" type="button" onclick="boutonPlus('inputPrecision3D', 0.1); precisionFonction3D = parseFloat(document.getElementById('inputPrecision3D').value); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputPrecision3D', 0.1); precisionFonction3D = parseFloat(document.getElementById('inputPrecision3D').value); actualiserGraph()">-</div> <br/>
<br/> <br/>
Utilisation des couleurs<br/> Use the color:<br/>
rouge : red:
<select onchange="checkCouleurs3D()" id="selectRouge3D"> <select onchange="checkCouleurs3D()" id="selectRouge3D">
<option value="plus">valeur positive</option> <option value="plus">positive value</option>
<option value="moins">valeur négative</option> <option value="moins">negative value</option>
<option value="tout">valeur générale</option> <option value="tout">general value</option>
</select> </select>
<br/> <br/>
vert : green :
<select onchange="checkCouleurs3D()" id="selectVert3D"> <select onchange="checkCouleurs3D()" id="selectVert3D">
<option value="moins">valeur négative</option> <option value="moins">negative value</option>
<option value="plus">valeur positive</option> <option value="plus">positive value</option>
<option value="tout">valeur générale</option> <option value="tout">general value</option>
</select> </select>
<br/> <br/>
bleu : blue :
<select onchange="checkCouleurs3D()" id="selectBleu3D"> <select onchange="checkCouleurs3D()" id="selectBleu3D">
<option value="tout">valeur générale</option> <option value="tout">general value</option>
<option value="plus">valeur positive</option> <option value="plus">positive value</option>
<option value="moins">valeur négative</option> <option value="moins">negative value</option>
</select> </select>
<br/> <br/>
Valeur générale : <input class="smallInput" id="couleur3Dgenerale" type="texte" value="0" onkeyup="checkCouleurs3D()"/> (entre 0 et 255) General value : <input class="smallInput" id="couleur3Dgenerale" type="texte" value="0" onkeyup="checkCouleurs3D()"/> (from 0 to 255)
<br/> <br/>
<span id="apercuCouleur3D"></span> <span id="apercuCouleur3D"></span>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu(); actualiserGraph()' value="Valider"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu(); actualiserGraph()' value="Check"/></div>
</div> </div>
<!-- Aide --> <!-- Aide -->
<div id="menuAide" class="menu"> <div id="menuAide" class="menu">
<table class="ongletMenu"> <table class="ongletMenu">
<tr> <tr>
<td class="ongletMenuActuel" onclick='afficherMenu("menuAide")'>Utilisation</td> <td class="ongletMenuActuel" onclick='afficherMenu("menuAide")'>Using</td>
<td onclick='afficherMenu("menuAideExemples")'>Exemples</td> <td onclick='afficherMenu("menuAideExemples")'>Examples</td>
<td onclick='afficherMenu("menuAideAutres")'>Autres</td> <td onclick='afficherMenu("menuAideAutres")'>Other</td>
</tr> </tr>
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<h1>Fonctionnement</h1> <h1>How it work.</h1>
<p>Ce widget vous permet de dessiner des fonctions mathématiques. Entrez une fonction dans le champ en haut du widget et cliquez sur le bouton "Afficher". </p> <p>This widget allow to draw mathematical function. Enter function in the field in the top part of widget and press "Show".</p>
<p>Vous pouvez saisir les fonctions mathématiques suivantes : <br/> <p>You can enter following mathematical function:<br/>
<h2>Les opérations de base</h2> <h2>Basic operations</h2>
<ul> <ul>
<li>Addition -> <span class="gras">+</span></li> <li>Plus -> <span class="gras">+</span></li>
<li>Soustraction -> <span class="gras">-</span></li> <li>Minus -> <span class="gras">-</span></li>
<li>Multiplication -> <span class="gras">*</span></li> <li>Multiplication -> <span class="gras">*</span></li>
<li>Division -> <span class="gras">/</span></li> <li>Division -> <span class="gras">/</span></li>
<li>Modulo -> <span class="gras">%</span></li> <li>Mod -> <span class="gras">%</span></li>
</ul> </ul>
<h2>Les fonctions trigonométriques</h2> <h2>Trigonometric functions</h2>
<ul> <ul>
<li>Sinus -> <span class="gras">sin(x)</span></li> <li>Sine -> <span class="gras">sin(x)</span></li>
<li>Cosinus -> <span class="gras">cos(x)</span></li> <li>Cosine -> <span class="gras">cos(x)</span></li>
<li>Tangente -> <span class="gras">tan(x)</span></li> <li>Tangent -> <span class="gras">tan(x)</span></li>
<li>Cotangente -> <span class="gras">cot(x)</span></li> <li>Cotangent -> <span class="gras">cot(x)</span></li>
<li>Secante -> <span class="gras">sec(x)</span></li> <li>Secant -> <span class="gras">sec(x)</span></li>
<li>Cosecante -> <span class="gras">csc(x)</span></li> <li>Cosecant -> <span class="gras">csc(x)</span></li>
</ul> </ul>
<ul> <ul>
<li>Arcsinus -> <span class="gras">arcsin(x)</span> ou <span class="gras">asin(x)</span></li> <li>Arc sine -> <span class="gras">arcsin(x)</span> ou <span class="gras">asin(x)</span></li>
<li>Arccosinus -> <span class="gras">arccos(x)</span> ou <span class="gras">acos(x)</span></li> <li>Arc cosine -> <span class="gras">arccos(x)</span> ou <span class="gras">acos(x)</span></li>
<li>Arctangente -> <span class="gras">arctan(x)</span> ou <span class="gras">atan(x)</span></li> <li>Arc tangent -> <span class="gras">arctan(x)</span> ou <span class="gras">atan(x)</span></li>
<li>Arccotangente -> <span class="gras">arccot(x)</span> ou <span class="gras">acot(x)</span></li> <li>Arc cotangent -> <span class="gras">arccot(x)</span> ou <span class="gras">acot(x)</span></li>
</ul> </ul>
<h2>Les fonctions hyperboliques</h2> <h2>Hyperbolic functions</h2>
<ul> <ul>
<li>Sinus hyp -> <span class="gras">sinh(x)</span></li> <li>Hyperbolic sine -> <span class="gras">sinh(x)</span></li>
<li>Cosinus hyp -> <span class="gras">cosh(x)</span></li> <li>Hyperbolic cosine -> <span class="gras">cosh(x)</span></li>
<li>Tangente hyp -> <span class="gras">tanh(x)</span></li> <li>Hyperbolic tangent -> <span class="gras">tanh(x)</span></li>
<li>Cotangente hyp -> <span class="gras">coth(x)</span></li> <li>Hyperbolic cotangent -> <span class="gras">coth(x)</span></li>
<li>Secante hyp -> <span class="gras">sech(x)</span></li> <li>Hyperbolic secant -> <span class="gras">sech(x)</span></li>
<li>Cosecante hyp -> <span class="gras">csch(x)</span></li> <li>Hyperbolic cosecant -> <span class="gras">csch(x)</span></li>
</ul> </ul>
<ul> <ul>
<li>Arcsinus hyp -> <span class="gras">arcsinh(x)</span> ou <span class="gras">asinh(x)</span></li> <li>Hyperbolic arc sine -> <span class="gras">arcsinh(x)</span> or <span class="gras">asinh(x)</span></li>
<li>Arccosinus hyp -> <span class="gras">arccosh(x)</span> ou <span class="gras">acosh(x)</span></li> <li>Hyperbolic arc cosine -> <span class="gras">arccosh(x)</span> or <span class="gras">acosh(x)</span></li>
<li>Arctangente hyp -> <span class="gras">arctanh(x)</span> ou <span class="gras">atanh(x)</span></li> <li>Hyperbolic arc tangent -> <span class="gras">arctanh(x)</span> or <span class="gras">atanh(x)</span></li>
<li>Arccotangente hyp -> <span class="gras">arccoth(x)</span> ou <span class="gras">acoth(x)</span></li> <li>Hyperbolic arc cotangent -> <span class="gras">arccoth(x)</span> or <span class="gras">acoth(x)</span></li>
</ul> </ul>
<h2>Les racines et les puissances</h2> <h2>Square roots and degrees</h2>
<ul> <ul>
<li>Racine carrée -> <span class="gras">sqrt(x)</span></li> <li>Square root -> <span class="gras">sqrt(x)</span></li>
<li>Puissances -> <span class="gras">pow(x, y)</span> <span class="texteSecondaire">Élève x à une puissance y</span></li> <li>Degree -> <span class="gras">pow(x, y)</span> <span class="texteSecondaire">Variable x to the power y</span></li>
<li>Racines -> <span class="gras">root(x, y)</span> <span class="texteSecondaire">Racine y<span style="vertical-align:super;">ème</span> d'un nombre x</span></li> <li>Root -> <span class="gras">root(x, y)</span> <span class="texteSecondaire">Root y of x</span></li>
</ul> </ul>
<h2>Les exponentielles et logarithmes</h2> <h2>Exponential and logarithm</h2>
<ul> <ul>
<li>e<span style="vertical-align:super;">x</span> -> <span class="gras">exp(x)</span></li> <li>e<span style="vertical-align:super;">x</span> -> <span class="gras">exp(x)</span></li>
<li>logarithme naturel -> <span class="gras">ln(x)</span></li> <li>Natural logarithm -> <span class="gras">ln(x)</span></li>
<li>logarithme de base 10 -> <span class="gras">log(x)</span></li> <li>Decimal logarithm -> <span class="gras">log(x)</span></li>
</ul> </ul>
<h2>La valeur absolue d'un nombre</h2> <h2>Absolute number value</h2>
<ul> <ul>
<li>|x| -> <span class="gras">abs(x)</span></li> <li>|x| -> <span class="gras">abs(x)</span></li>
</ul> </ul>
<h2>Les arrondis</h2> <h2>Rounding</h2>
<ul> <ul>
<li><span class="gras">round(x)</span> -> arrondit à l'entier le plus proche</li> <li><span class="gras">round(x)</span> -> rounding to the nearest whole number</li>
<li><span class="gras">ceil(x)</span> -> arrondit à l'entier supérieur</li> <li><span class="gras">ceil(x)</span> -> rounding to the nearest whole number in a big way</li>
<li><span class="gras">floor(x)</span> -> arrondit à l'entier inférieur</li> <li><span class="gras">floor(x)</span> -> rounding to the nearest whole number the smaller side</li>
</ul> </ul>
</p> <br/> </p> <br/>
<hr/> <hr/>
<h1>Constantes</h1> <h1>Constants</h1>
<p>Quelques constantes sont aussi disponibles : <br/> <p>Also are available some constants:<br/>
<ul> <ul>
<li><span class="gras">pi</span> = 4 * atan(1) ≈ 3,141592653589793</li> <li><span class="gras">pi</span> = 4 * atan(1) ≈ 3,141592653589793</li>
<li><span class="gras">e</span> = exp(1) ≈ 2.718281828459045</li> <li><span class="gras">e</span> = exp(1) ≈ 2.718281828459045</li>
@ -519,34 +519,34 @@
</p> </p>
<br/> <br/>
<hr/> <hr/>
<h1>Touches clavier</h1> <h1>Keyboard keys</h1>
<p style="font-size:90%;"> <p style="font-size:90%;">
esc (échap) -> recharger le widget <br/> esc -> reset widget <br/>
ctrl + flèche gauche -> déplacer le graphique à gauche <br/> ctrl + left arrow -> graph will be moved left<br/>
ctrl + flèche haut -> déplacer le graphique en haut <br/> ctrl + top arrow -> graph will be moved top<br/>
ctrl + flèche droite -> déplacer le graphique à droite <br/> ctrl + right arrow -> graph will be moved right<br/>
ctrl + flèche bas -> déplacer le graphique en bas <br/> ctrl + bottom arrow -> graph will be moved bottom<br/>
<br/> <br/>
</p> </p>
<br/> <br/>
<input type="button" value="Guide d'utilisation" onclick="navigateur('Guide_Utilisateur.html')" style="position:absolute;bottom:0px;left:0px;"/> <input type="button" value="User's guide" onclick="navigateur('Guide_Utilisateur.html')" style="position:absolute;bottom:0px;left:0px;"/>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<div id="menuAideExemples" class="menu"> <div id="menuAideExemples" class="menu">
<table class="ongletMenu"> <table class="ongletMenu">
<tr> <tr>
<td onclick='afficherMenu("menuAide")'>Utilisation</td> <td onclick='afficherMenu("menuAide")'>Using</td>
<td class="ongletMenuActuel" onclick='afficherMenu("menuAideExemples")'>Exemples</td> <td class="ongletMenuActuel" onclick='afficherMenu("menuAideExemples")'>Examples</td>
<td onclick='afficherMenu("menuAideAutres")'>Autres</td> <td onclick='afficherMenu("menuAideAutres")'>Other</td>
</tr> </tr>
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<span class="texteSecondaire">(Vous pouvez cliquer sur un exemple pour l'afficher. Pensez à ajuster la précision du graphique dans les options si nécessaire)</span> <span class="texteSecondaire">(You can view example. Do not forget to set accuracy in options if necessary.)</span>
<br/><br/> <br/><br/>
<hr/> <hr/>
<h1>Fonctions 2D</h1> <h1>Functions 2D</h1>
<p> <p>
<span class="survol" onclick="document.getElementById('inputEq').value = '0.5*x+1' ; actualiserGraph()">0.5*x+1</span> <br/> <span class="survol" onclick="document.getElementById('inputEq').value = '0.5*x+1' ; actualiserGraph()">0.5*x+1</span> <br/>
<span class="survol" onclick="document.getElementById('inputEq').value = 'pow(x,2)-3' ; actualiserGraph()">pow(x,2)-3</span> <br/> <span class="survol" onclick="document.getElementById('inputEq').value = 'pow(x,2)-3' ; actualiserGraph()">pow(x,2)-3</span> <br/>
@ -561,7 +561,7 @@
</p> </p>
<br/><br/> <br/><br/>
<hr/> <hr/>
<h1>Fonctions 3D</h1> <h1>Functions 3D</h1>
<p> <p>
<span class="survol" onclick="document.getElementById('inputEq').value = 'sin(x)+cos(y)' ; actualiserGraph()">sin(x)+cos(y)</span> <br/> <span class="survol" onclick="document.getElementById('inputEq').value = 'sin(x)+cos(y)' ; actualiserGraph()">sin(x)+cos(y)</span> <br/>
<span class="survol" onclick="document.getElementById('inputEq').value = 'sqrt(10-x*x)' ; actualiserGraph()">sqrt(10-x*x)</span> <br/> <span class="survol" onclick="document.getElementById('inputEq').value = 'sqrt(10-x*x)' ; actualiserGraph()">sqrt(10-x*x)</span> <br/>
@ -569,27 +569,25 @@
</p> </p>
<br/> <br/>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<div id="menuAideAutres" class="menu"> <div id="menuAideAutres" class="menu">
<table class="ongletMenu"> <table class="ongletMenu">
<tr> <tr>
<td onclick='afficherMenu("menuAide")'>Utilisation</td> <td onclick='afficherMenu("menuAide")'>Using</td>
<td onclick='afficherMenu("menuAideExemples")'>Exemples</td> <td onclick='afficherMenu("menuAideExemples")'>Examples</td>
<td class="ongletMenuActuel" onclick='afficherMenu("menuAideAutres")'>Autres</td> <td class="ongletMenuActuel" onclick='afficherMenu("menuAideAutres")'>Other</td>
</tr> </tr>
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<h4>Enregistrer le graphique</h4> <h4>Save graph</h4>
Dans certains navigateurs, lorsque vous utilisez la méthode d'affichage "Canvas", vous pouvez sauvegarder le graphique en cliquant avec le bouton de droite de la souris sur celui-ci et en séléctionnant "Enregistrer l'image". In some browsers when used display method "Canvas" you can save graph by clicking it with right mouse button and selecting "Save image". Also you can save 3D-graphs.
Vous pouvez aussi sauvegarder le graphique 3D.
<br/><br/> <br/><br/>
<h4>Décalage</h4> <h4>Offset</h4>
Si le graphique n'est pas à la bonne place (il dépasse de la zone prévue), ajustez le "décalage du graphique" dans le menu des options. If graph isn't in the right place (larger than canvas) then can you set necessary parameters graph displaying in settings menu.
Pour Konqueror, il faut utiliser un décalage de x=122 et y=48.
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<!-- Crédits --> <!-- Crédits -->
@ -600,7 +598,7 @@
<tr> <tr>
<td> <td>
<img src="icon.png"/> <img src="icon.png"/>
<h3>Widget réalisé par</h3> <h3>Widget is developed by</h3>
Yannick Vessaz <br/> Yannick Vessaz <br/>
<a href='mailto:yannick.vessaz@gmail.com'>yannick.vessaz@gmail.com</a> <a href='mailto:yannick.vessaz@gmail.com'>yannick.vessaz@gmail.com</a>
</td> </td>
@ -608,105 +606,105 @@
</table> </table>
<span class="texteSecondaire"> <span class="texteSecondaire">
<br/><br/> <br/><br/>
Si vous voulez rapporter un bug, avez une suggestion par rapport au widget ou voulez simplement poser une question, merci de me contacter par <a href='mailto:yannick.vessaz@gmail.com'>e-mail</a>. If you want to inform about bug, make a proposal or just ask some questions then you can contact to me at the following e-mail: <a href='mailto:yannick.vessaz@gmail.com'>e-mail</a>.
<br/><br/> <br/><br/>
Les images d'arrière-plan du widget on été tirées des thèmes du bureau "plasma-desktop" de l'environnement <a href="http://kde.org">KDE</a>. If you want to change background design then you can contact at following address: <a href="http://kde.org">KDE</a>.
</span> </span>
<span id="version" class="texteSecondaire" style="position:absolute;bottom:10px;left:15px;">version 1.3</span> <span id="version" class="texteSecondaire" style="position:absolute;bottom:10px;left:15px;">version 1.3</span>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<!-- Outils --> <!-- Outils -->
<div id="menuOutils" class="menu"> <div id="menuOutils" class="menu">
<div class="contenuMenu"> <div class="contenuMenu">
<h3 style="margin-top:0px; margin-bottom:15px;">Outils</h3> <h3 style="margin-top:0px; margin-bottom:15px;">Tools</h3>
Action de la souris:<br/> Mouse events:<br/>
<input type="button" class="choixOutil" onclick="choixOutil('deplacement');cacherMenu()" value="Déplacement"/> <input type="button" class="choixOutil" onclick="choixOutil('deplacement');cacherMenu()" value="Moving"/>
<input type="button" class="choixOutil" onclick="choixOutil('tangente');cacherMenu()" value="Tangente"/> <input type="button" class="choixOutil" onclick="choixOutil('tangente');cacherMenu()" value="Tangente"/>
<input type="button" class="choixOutil" onclick="choixOutil('point');cacherMenu()" value="Point"/> <input type="button" class="choixOutil" onclick="choixOutil('point');cacherMenu()" value="Point"/>
<br/><br/> <br/><br/>
Dessiner la dérivée de la fonction:<br/> Derivative:<br/>
<label for="checkDerivee"> f'(x) </label><input type="checkbox" id="checkDerivee" onclick="actualiserGraph()"/><label for="checkDerivee2"> f''(x) </label><input type="checkbox" id="checkDerivee2" onclick="actualiserGraph()"/> <label for="checkDerivee"> f'(x) </label><input type="checkbox" id="checkDerivee" onclick="actualiserGraph()"/><label for="checkDerivee2"> f''(x) </label><input type="checkbox" id="checkDerivee2" onclick="actualiserGraph()"/>
<br/><br/> <br/><br/>
Aire sous la fonction:<br/> Square under function:<br/>
De <input value="-5" class="smallInput" id="aireG"/> à <input value="5" class="smallInput" id="aireD"/> <input type="button" onclick='calculerAire()' value="Calculer"/> <span id="outputAire"></span> From <input value="-5" class="smallInput" id="aireG"/> to <input value="5" class="smallInput" id="aireD"/> <input type="button" onclick='calculerAire()' value="Calculate"/> <span id="outputAire"></span>
<div style="float: right;"><label for="checkAire">Dessiner </label><input type="checkbox" id="checkAire" onclick="actualiserGraph()"/></div> <div style="float: right;"><label for="checkAire">Draw </label><input type="checkbox" id="checkAire" onclick="actualiserGraph()"/></div>
<br/><br/> <br/><br/>
Calculer un point de la fonction:<br/> Calculate the point on the function:<br/>
x=<input value="0" class="smallInput" id="inputX" onkeypress='if(event.keyCode==13) execute(document.getElementById("inputEq").value)'/> x=<input value="0" class="smallInput" id="inputX" onkeypress='if(event.keyCode==13) execute(document.getElementById("inputEq").value)'/>
<input type="button" onclick='execute(document.getElementById("inputEq").value)' value="Évaluer"/> <input type="button" onclick='execute(document.getElementById("inputEq").value)' value="Estimate"/>
<span id="outputX"></span> <span id="outputX"></span>
<br/><br/> <br/><br/>
Étudier la fonction : <br/> Analysis of function: <br/>
f(x) = <span id="etudeFct"></span> <input type="button" value="Démarrer l'étude" onclick='etudier(document.getElementById("inputEq").value);afficherMenu("menuEtude")'/> f(x) = <span id="etudeFct"></span> <input type="button" value="Start to analysis" onclick='etudier(document.getElementById("inputEq").value);afficherMenu("menuEtude")'/>
<br/><br/> <br/><br/>
Tests d'affichage<br/> Display test:<br/>
<input type="button" onclick='cacherMenu(); testXPM()' value="Test XPM"/><input type="button" onclick='cacherMenu(); testSVG()' value="Test SVG"/><input type="button" onclick='cacherMenu(); testCanvas()' value="Test Canvas"/> <input type="button" onclick='cacherMenu(); testXPM()' value="Test XPM"/><input type="button" onclick='cacherMenu(); testSVG()' value="Test SVG"/><input type="button" onclick='cacherMenu(); testCanvas()' value="Test Canvas"/>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<!--Etude de fonction --> <!--Etude de fonction -->
<div id="menuEtude" class="menu"> <div id="menuEtude" class="menu">
<div class="contenuMenu"> <div class="contenuMenu">
<h3>Étude de fonction</h3> <h3>Analysis of function in the</h3>
Ensemble de définition : <span id="etudeEDF">...</span> <br/> Set of definitions : <span id="etudeEDF">...</span> <br/>
Parité : <span id="etudeParite">...</span> <br/> Parity : <span id="etudeParite">...</span> <br/>
Zéros de la fonction : <span id="etudeZeros">...</span> <br/> Zeros of functions : <span id="etudeZeros">...</span> <br/>
<table> <table>
<tr id="etudeSigne"> <tr id="etudeSigne">
<td>Signe : ...</td> <td>Sign : ...</td>
</tr> </tr>
</table> </table>
Asymptotes <br/> Asymptotes <br/>
AH gauche : <span id="etudeAHG">...</span> <br/> AH left : <span id="etudeAHG">...</span> <br/>
AH droite : <span id="etudeAHD">...</span> <br/> AH right : <span id="etudeAHD">...</span> <br/>
AV : <span id="etudeAV">...</span> AV : <span id="etudeAV">...</span>
<span id="etudeMin">...</span> <span id="etudeMin">...</span>
<span id="etudeMax">...</span> <span id="etudeMax">...</span>
<span id="etudeI">...</span> <br/><br/> <span id="etudeI">...</span> <br/><br/>
<span class="texteSecondaire" style="font-size:10px;">L'outil permettant d'étudier les fonctions n'est pas fiable à 100%. Pensez à vérifier les résultats de l'étude avant d'en faire une quelconque utilisation.</span> <span class="texteSecondaire" style="font-size:10px;">Tool for analysis of function is not reliable on 100%. Don't forget check results of analysis before use it.</span>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick="etudier(document.getElementById('inputEq').value)" value="Actualiser" style="position:relative;right:310px;"/> <input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick="etudier(document.getElementById('inputEq').value)" value="Actualize" style="position:relative;right:310px;"/> <input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<!-- Fonctions multiples --> <!-- Fonctions multiples -->
<div id="menuFonctions" class="menu"> <div id="menuFonctions" class="menu">
<table class="ongletMenu"> <table class="ongletMenu">
<tr> <tr>
<td class="ongletMenuActuel" onclick='afficherMenu("menuFonctions")'>Fonctions</td> <td class="ongletMenuActuel" onclick='afficherMenu("menuFonctions")'>Functions</td>
<td onclick='afficherMenu("menuHistorique")'>Historique</td> <td onclick='afficherMenu("menuHistorique")'>History</td>
</tr> </tr>
</table> </table>
<div class="contenuMenu avecBordures"> <div class="contenuMenu avecBordures">
<em>Actuelle</em><br/> <em>Current</em><br/>
f(x) = <span id="fonctionActuelle">x</span> <input type="button" value="+" onclick="ajouterFonction(document.getElementById('fonctionActuelle').innerHTML)"/> f(x) = <span id="fonctionActuelle">x</span> <input type="button" value="+" onclick="ajouterFonction(document.getElementById('fonctionActuelle').innerHTML)"/>
<br/><br/> <br/><br/>
<em>Supplémentaires</em><br/> <em>Additional</em><br/>
<span id="fonctionsSupp">aucune ...</span> <span id="fonctionsSupp">n/a ...</span>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<!-- Historique --> <!-- Historique -->
<div id="menuHistorique" class="menu"> <div id="menuHistorique" class="menu">
<table class="ongletMenu"> <table class="ongletMenu">
<tr> <tr>
<td onclick='afficherMenu("menuFonctions")'>Fonctions</td> <td onclick='afficherMenu("menuFonctions")'>Functions</td>
<td class="ongletMenuActuel" onclick='afficherMenu("menuHistorique")'>Historique</td> <td class="ongletMenuActuel" onclick='afficherMenu("menuHistorique")'>History</td>
</tr> </tr>
</table> </table>
<div class="contenuMenu avecBordures" id="divHistorique"> <div class="contenuMenu avecBordures" id="divHistorique">
<span id="spanHistorique"></span> <span id="spanHistorique"></span>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Fermer"/></div> <div class="barreBasMenu"><input type="button" onclick='cacherMenu()' value="Cancel"/></div>
</div> </div>
<!-- Couleur --> <!-- Couleur -->
<div id="menuCouleur" class="menu"> <div id="menuCouleur" class="menu">
<div class="contenuMenu"> <div class="contenuMenu">
<em>Choix de la couleur:</em> <br/><br/> <em>Choosing the color:</em> <br/><br/>
<div id="colorSV" onmousemove="if(mouseDown==true){colorSV(event)}" onmousedown="colorSV(event); mouseDown = true" onmouseup="mouseDown = false"> <div id="colorSV" onmousemove="if(mouseDown==true){colorSV(event)}" onmousedown="colorSV(event); mouseDown = true" onmouseup="mouseDown = false">
<svg:svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> <svg:svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<svg:defs id="defs1"> <svg:defs id="defs1">
@ -802,36 +800,36 @@
</div> </div>
<table id="colorValues"> <table id="colorValues">
<tr> <tr>
<td>Teinte: </td><td><input id="inputTeinte" class="smallInput" value="0" onkeypress=''/></td> <td>Color: </td><td><input id="inputTeinte" class="smallInput" value="0" onkeypress=''/></td>
</tr><tr> </tr><tr>
<td>Valeur: </td><td><input id="inputValeur" class="smallInput" value="0" onkeypress=''/></td> <td>Value: </td><td><input id="inputValeur" class="smallInput" value="0" onkeypress=''/></td>
</tr><tr> </tr><tr>
<td>Saturation: </td><td><input id="inputSaturation" class="smallInput" value="0" onkeypress=''/></td> <td>Saturation: </td><td><input id="inputSaturation" class="smallInput" value="0" onkeypress=''/></td>
</tr><tr> </tr><tr>
<td>Rouge: </td><td><input id="inputRouge" class="smallInput" value="255" onkeypress=''/></td> <td>Red: </td><td><input id="inputRouge" class="smallInput" value="255" onkeypress=''/></td>
</tr><tr> </tr><tr>
<td>Vert: </td><td><input id="inputVert" class="smallInput" value="0" onkeypress=''/></td> <td>Green: </td><td><input id="inputVert" class="smallInput" value="0" onkeypress=''/></td>
</tr><tr> </tr><tr>
<td>Bleu: </td><td><input id="inputBleu" class="smallInput" value="0" onkeypress=''/></td> <td>Blue: </td><td><input id="inputBleu" class="smallInput" value="0" onkeypress=''/></td>
</tr><tr> </tr><tr>
<td>Opacité: </td><td><input id="inputOpacity" class="smallInput" value="1" onkeypress=''/></td> <td>Opacity: </td><td><input id="inputOpacity" class="smallInput" value="1" onkeypress=''/></td>
</tr><!--<tr> </tr><!--<tr>
<td><input id="inputCouleur" style="width: 70%" value="cyan" onkeypress='couleurFonction = this.value; if(event.keyCode==13) actualiserGraph()'/></td> <td><input id="inputCouleur" style="width: 70%" value="cyan" onkeypress='couleurFonction = this.value; if(event.keyCode==13) actualiserGraph()'/></td>
</tr>--> </tr>-->
</table> </table>
<div id="apercuCouleur" title="Nouvelle Couleur"></div><div id="apercuCouleur2" title="Ancienne Couleur"></div> <div id="apercuCouleur" title="New Color"></div><div id="apercuCouleur2" title="Old Color"></div>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick="if(idColor=='buttonColor'){cacherMenu()}else{afficherMenu('menuFonctions')}; actualiserGraph()" value="Valider"/></div> <div class="barreBasMenu"><input type="button" onclick="if(idColor=='buttonColor'){cacherMenu()}else{afficherMenu('menuFonctions')}; actualiserGraph()" value="Check"/></div>
</div> </div>
<!-- Erreurs Fonctions interdites --> <!-- Erreurs Fonctions interdites -->
<div id="fctInterdite" class="miniMenu"> <div id="fctInterdite" class="miniMenu">
<br/> <br/>
<h1>------- Erreur -------</h1> <h1>------- Error -------</h1>
<br/> <br/>
Impossible de dessiner la fonction ... Impossible to draw the function ...
<br/><br/> <br/><br/>
Expression ou carractère invalide : <br/> Error in expression or unexpected char: <br/>
<span id="spanFctInterdite" style="font-style:italic;"></span> <span id="spanFctInterdite" style="font-style:italic;"></span>
<br/><br/> <br/><br/>
<input type="button" onclick="cacherMenu()" value="Ok"/> <input type="button" onclick="cacherMenu()" value="Ok"/>
@ -839,34 +837,31 @@
<!-- Autres erreurs --> <!-- Autres erreurs -->
<div id="erreurFct" class="miniMenu"> <div id="erreurFct" class="miniMenu">
<h1>------- Erreur -------</h1> <h1>------- Error -------</h1>
Une erreur s'est produite pendant les calculs nécessaires à afficher la fonction. Vérifiez la fonction que vous vouliez dessiner et appuyez à nouveau sur "afficher". Runtime error! Check your function and try to draw it again.
<br/> <br/>
Une description ainsi que des exemples des différentes fonctions que vous pouvez entrer se trouve dans l'aide. Description and parameters various functions which are available to help.
<br/><br/> <br/><br/>
<input type="button" onclick="afficherMenu('menuAide')" value="Aide"/> <input type="button" onclick="afficherMenu('menuAide')" value="Help"/>
<input type="button" onclick="cacherMenu()" value="Ok"/> <input type="button" onclick="cacherMenu()" value="Ok"/>
</div> </div>
<!-- Menu des mises à jour --> <!-- Menu des mises à jour -->
<div id="mAj" class="menu"> <div id="mAj" class="menu">
<h1>Mise à jour</h1> <h1>Updated</h1>
Version en cours d'utilisation : <br/><span id="thisVersion"></span><br/> Current version: <br/><span id="thisVersion"></span><br/>
Dernière version disponible en ligne : <br/><span id="newVersion"></span><br/> The last on-line version: <br/><span id="newVersion"></span><br/>
<br/> <br/>
Ce widget est également utilisable dans un navigateur internet sur le site : <em>http://gyb.educanet2.ch/tm-widgets/yannick</em><br/> This widget is available to using on web-site: <em>http://gyb.educanet2.ch/tm-widgets/yannick</em><br/>
<br/> <br/>
Vous pouvez remplacer la version en cours d'utilisation par la version du widget en ligne. Notez que ceci ne met pas à jour le widget. Il faudra réitérer cette procédure la prochaine fois que vous l'utiliserez.<br/>
<input type="button" onclick="document.location.href='http://gyb.educanet2.ch/tm-widgets/yannick/GraphMe.wgt/Grapheur.xhtml'" value="Utiliser la dernière version"/><br/>
<input type="button" onclick="cacherMenu()" value="Garder ma version"/>
</div> </div>
<!-- Erreur mise à jour --> <!-- Erreur mise à jour -->
<div id="erreurMaJ" class="miniMenu"> <div id="erreurMaJ" class="miniMenu">
<br/> <br/>
<h1>------- Erreur -------</h1> <h1>------- Error -------</h1>
<br/><br/> <br/><br/>
Il est impossible de mettre à jour le widget vers la version en ligne car vous utilisez déjà la version en ligne. Update to latest version is not available because you already use the latest version.
<br/><br/><br/> <br/><br/><br/>
<input type="button" onclick="cacherMenu()" value="Ok"/> <input type="button" onclick="cacherMenu()" value="Ok"/>
</div> </div>
@ -874,23 +869,12 @@
<!-- Info options sauvegardées --> <!-- Info options sauvegardées -->
<div id="infoSauvegarde" class="alertMenu"> <div id="infoSauvegarde" class="alertMenu">
<br/> <br/>
<h1>Options sauvegardées!</h1> <h1>Options saved!</h1>
<br/> <br/>
<input type="button" onclick="document.getElementById('infoSauvegarde').style.display = 'none'" value="Ok"/> <input type="button" onclick="document.getElementById('infoSauvegarde').style.display = 'none'" value="Ok"/>
</div> </div>
<!-- Demande mise à jour auto --> <!-- ..... Flèches de déplacement ..... -->
<div id="demandeMaJ" class="miniMenu">
<br/>
<h1>Mise à jour automatique</h1>
<br/><br/>
Voulez-vous vraiment utiliser la dernière version du widget disponible ?
<br/><br/><br/>
<input type="button" onclick="cacherMenu()" value="Non"/>
<input type="button" onclick="document.location.href='http://gyb.educanet2.ch/tm-widgets/yannick/GraphMe.wgt/Grapheur.xhtml'" value="Oui"/>
</div>
<!-- ..... Flèches de déplacement ..... -->
<div class="flecheDeplacement" id="flecheHaut" onclick="if(fonction3D){zoom3D(1.25)}else{deplacerY(1)}" onmousemove="sourisMove(event)"></div> <div class="flecheDeplacement" id="flecheHaut" onclick="if(fonction3D){zoom3D(1.25)}else{deplacerY(1)}" onmousemove="sourisMove(event)"></div>
<div class="flecheDeplacement" id="flecheGauche" onclick="deplacerX(-1)" onmousemove="sourisMove(event)"></div> <div class="flecheDeplacement" id="flecheGauche" onclick="deplacerX(-1)" onmousemove="sourisMove(event)"></div>
<div class="flecheDeplacement" id="flecheBas" onclick="if(fonction3D){zoom3D(0.8)}else{deplacerY(-1)}" onmousemove="sourisMove(event)"></div> <div class="flecheDeplacement" id="flecheBas" onclick="if(fonction3D){zoom3D(0.8)}else{deplacerY(-1)}" onmousemove="sourisMove(event)"></div>

@ -2,199 +2,199 @@
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>GraphMe - Guide utilisateur</title> <title>GraphMe - User's guide.</title>
<link rel="stylesheet" type="text/css" href="Style/Guide_Utilisateur.css"/> <link rel="stylesheet" type="text/css" href="Style/Guide_Utilisateur.css"/>
</head> </head>
<body> <body>
<h1>GraphMe</h1> <h1>GraphMe</h1>
<img src="Images/GraphMe.png"/> <img src="Images/GraphMe.png"/>
<h1>Guide d'utilisation</h1> <h1>User's guide</h1>
<ol id="Sommaire"> <ol id="Sommaire">
<li><a href="#Introduction">Introduction</a></li> <li><a href="#Introduction">Introduction</a></li>
<li><a href="#Installation">Installation</a></li> <li><a href="#Installation">Installation</a></li>
<li><a href="#AfficherLeWidget">Afficher le widget</a></li> <li><a href="#AfficherLeWidget">Review widget</a></li>
<li><a href="#PresentationAffichage">Présentation de l'affichage</a></li> <li><a href="#PresentationAffichage">View presentation</a></li>
<li><a href="#DessinerFonction">Dessiner une fonction</a></li> <li><a href="#DessinerFonction">Drawing the function</a></li>
<li><a href="#DeplacerAffichage">Se déplacer à travers la fonction</a></li> <li><a href="#DeplacerAffichage">Offset function</a></li>
<li><a href="#MenuOptions">Le menu des options</a></li> <li><a href="#MenuOptions">The options menu</a></li>
<li><a href="#MenuOutils">Le menu des outils</a></li> <li><a href="#MenuOutils">the tools menu</a></li>
<li><a href="#PlusieursFonctions">Dessiner plusieurs fonctions</a></li> <li><a href="#PlusieursFonctions">Drawing some functions</a></li>
<li><a href="#MaJ">Mettre à jour GraphMe</a></li> <li><a href="#MaJ">GraphMe update</a></li>
<li><a href="#Contact">Contact</a></li> <li><a href="#Contact">Contact</a></li>
</ol> </ol>
<h2 id="Introduction">1. Introduction</h2> <h2 id="Introduction">1. Introduction</h2>
<p> <p>
GraphMe est un traceur de fonctions mathématiques que j'ai programmé dans le cadre du travail de maturité gymnasiale. Il est codé en HTML, CSS et JavaScript. Ce grapheur est disponible sur un cd-rom accompagnant mon travail de maturité ainsi que sur internet à la page <a href="http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15">http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15</a>. Ce document a pour but d'expliquer comment utiliser GraphMe. Il présente ses différentes fonctions ainsi que quelques astuces utiles à l'utilisateur. GraphMe is a app that is developed using html, javascript and css. It can be used for drawing graphs. This document must explain how to use GraphMe. This app have a different functions and some useful advices for users.
</p> </p>
<h2 id="Installation">2. Installation</h2> <h2 id="Installation">2. Installation</h2>
<p> <p>
Le widget que vous pouvez télécharger sur internet est compressé au format zip. Avant de l'utiliser, il est nécessaire de le décompresser. Si vous n'avez aucuns programmes permettant d'ouvrir les fichiers zip, vous pouvez télécharger 7zip sur <a href="http://www.7-zip.org/">http://www.7-zip.org/</a>. GraphMe a été conçu pour s'utiliser dans un navigateur internet ou s'intégrer à Uniboard. Pour l'ajouter aux widgets d'Uniboard, il faut copier le dossier « GraphMe.wgt » dans « library/interactive/ ». Par exemple, sous Windows, le widget doit être dans : « C:/Program Files/Uniboard 4/library/interactive/GraphMe.wgt ». Si vous n'avez pas Uniboard, vous pouvez l'obtenir sur <a href="http://getuniboard.com">http://getuniboard.com/</a>. This widget can be downloaded from the Internet in a packed format. Before using it must be unpacked. GraphMe was developed for using in web-browsers and integration in Sankore. To add this app in Sankore you should copy folder named "GraphMe.wgt" in "../library/interactive/". For example, on "windows OS" GraphMe must be in folder with following path: "C: / Program Files / Sankore 4/library/interactive/GraphMe.wgt". If you have no Sankore then you can get it on <a href="http://getuniboard.com">http://getuniboard.com/</a>.
</p> </p>
<h2 id="AfficherLeWidget">3. Afficher le widget</h2> <h2 id="AfficherLeWidget">3. Review widget</h2>
<div class="droite"><img src="Images/Guide_Navigateur.png"/>Image de GraphMe dans un navigateur internet</div> <div class="droite"><img src="Images/Guide_Navigateur.png"/>Display GraphMe in browsers</div>
<p> <p>
A) Pour afficher le widget dans un navigateur, il faut simplement ouvrir le fichier « Grapheur.xhtml » qui se trouve dans le dossier « GraphMe.wgt » avec votre navigateur internet. Toutefois, certains navigateurs n'arrivent pas à afficher le widget. La liste suivante contient les navigateurs sur lesquels le widget a été testé : A) To display this app in browser just enough to open the file named "Grapheur.xhtml" (it's in root folder) with your browser. But some browsers can not display app correctly. Below is the list of browsers that are able to display app:
</p> </p>
<ul> <ul>
<li>Mozilla Firefox (3.5) : tout fonctionne très bien.</li> <li>Mozilla Firefox (3.5) : Everything works fine.</li>
<li>Internet Explorer (8.0) : impossible d'ouvrir le widget, le format .xhtml n'est pas reconnu.</li> <li>Internet Explorer (8.0) : Cannot open a widget, because .xhtml format is not recognized.</li>
<li>Internet Explorer (pré-version 9.0) : le widget est ouvrable mais seul l'affichage utilisant SVG fonctionne, « canvas » n'est toujours pas supporté.</li> <li>Internet Explorer (pré-version 9.0) : Widget works but just using SVG. Canvas not supported yet.</li>
<li>Konqueror (4.3.4) : le widget s'ouvre mais il y a quelques problèmes d'affichage. Il est quand même utilisable en sélectionnant la méthode d'affichage « canvas » dans les options.</li> <li>Konqueror (4.3.4) : Widget can be opened but there is some problems with displaying. It still occur when choosed display method "canvas".</li>
<li>Opera (10.51) : le widget est parfaitement utilisable</li> <li>Opera (10.51) : Widget quite useful.</li>
<li>Google Chrome (4.1) : tout fonctionne également. L'affichage 3D est même très rapide comparé à d'autres navigateurs.</li> <li>Google Chrome (4.1) : Everything works very nice! 3D-display is faster as compared with other browsers.</li>
</ul> </ul>
<p> <p>
B) Pour ouvrir le widget dans Uniboard, il faut tout d'abord cliquer sur le bouton « Bibliothèque » en haut de la fenêtre. Ensuite, allez dans l'onglet « Interactif » ou autrement, selon les version d'Uniboard, dans l'onglet « Applications ». Cliquez sur l'icône correspondant à « Traceur de fonctions mathématiques » et finalement sur « Ajouter à la page ». B) To open widget in Sankore you should first open folder "Application" that is at the left of the screen. Then you must find this app and add it to the page.
</p> </p>
<div class="gauche"><img src="Images/Guide_Uniboard.png"/>Image de GraphMe dans Uniboard</div> <div class="gauche"><img src="Images/Guide_Uniboard.png"/>Display GraphMe in Sankore</div>
<img src="Images/Guide_AjouterWidget.png"/> <img src="Images/Guide_AjouterWidget.png"/>
<h2 id="PresentationAffichage">4. Présentation de l'affichage</h2> <h2 id="PresentationAffichage">4. View presentation</h2>
<ol> <ol>
<li>Champ permettant de définir la fonction à afficher.</li> <li>Place for functions display.</li>
<li>Bouton affichant la fonction.</li> <li>Button for beginning the work.</li>
<li>Bouton servant à ajouter une nouvelle fonction ou à accéder à l'historique des fonctions.</li> <li>Button for adding new function or for getting access to functions history.</li>
<li>Zone d'affichage.</li> <li>Display.</li>
<li>Options d'affichage permettant de définir la partie de la fonction à afficher.</li> <li>Parameters that define the part of graph that will be displayed.</li>
<li>Boutons de zoom.</li> <li>Buttons for zoom.</li>
<li>Bouton servant à changer la couleur.</li> <li>Button for color changing.</li>
<li>Boutons accédant aux différents menus.</li> <li>Buttons for access to menu.</li>
<li>Onglet choisissant entre les fonctions 2D et 3D.</li> <li>Tab-button that toggles 2D and 3D modes.</li>
<li>Bouton de maximisation du widget.</li> <li>Button for maximize the widget.</li>
</ol> </ol>
<img src="Images/Guide_Presentation.png"/> <img src="Images/Guide_Presentation.png"/>
<h2 id="DessinerFonction">5. Dessiner une fonction</h2> <h2 id="DessinerFonction">5. Drawing the function</h2>
<p> <p>
Pour dessiner une fonction mathématique, il suffit d'entrer celle-ci dans le champ en haut du widget et de cliquer sur le bouton « Afficher ». On peut utiliser différentes fonctions et constantes prédéfinies: To draw mathematical function just enter it at the top of widget and press button "Display". You can use different functions and predefined constants.
</p> </p>
<h4>Les opérations de base</h4> <h4>Basic operations:</h4>
<ul> <ul>
<li>l'addition → +</li> <li>Addition → +</li>
<li>la soustraction → -</li> <li>Subtraction → -</li>
<li>la multiplication → *</li> <li>Multiplication → *</li>
<li>la division → /</li> <li>Division → /</li>
<li>le modulo → %</li> <li>Mod → %</li>
</ul> </ul>
<h4>Les fonctions trigonométriques</h4> <h4>Trigonometric functions</h4>
<ul> <ul>
<li>sin(x), cos(x), tan(x), cot(x)</li> <li>sin(x), cos(x), tan(x), cot(x)</li>
<li>asin(x), acos(x), atan(x), acot(x) ( ou arcsin(x), arccos(x), arctan(x), arccot(x) )</li> <li>asin(x), acos(x), atan(x), acot(x) ( ou arcsin(x), arccos(x), arctan(x), arccot(x) )</li>
</ul> </ul>
<h4>Les racines et les puissances</h4> <h4>Square roots and degrees</h4>
<ul> <ul>
<li>sqrt(x) fait la racine carrée de x</li> <li>sqrt(x) is square root from x</li>
<li>pow(x, y) élève un nombre x à une puissance y, par exemple :<br/>x² → pow(x, 2)<br/>(x+3)⁵ → pow((x+3), 5)</li> <li>pow(x, y). Variable x to the power y. For examle:<br/>x² → pow(x, 2)<br/>(x+3)⁵ → pow((x+3), 5)</li>
<li>root(x, y) fait la racine yème d'un nombre x</li> <li>root(x, y). Root y of x</li>
</ul> </ul>
<h4>Les exponentielles et logarithmes</h4> <h4>Exponential and logarithm</h4>
<ul> <ul>
<li>exp(x)</li> <li>exp(x)</li>
<li>ln(x) est le logarithme naturel</li> <li>ln(x) is natural logarithm.</li>
<li>log(x) est le logarithme de base 10</li> <li>log(x) is decimal logarithm.</li>
</ul> </ul>
<h4>Les arrondis</h4> <h4>Rounding</h4>
<ul> <ul>
<li>round(x) → arrondit à l'entier le plus proche</li> <li>round(x) → rounding to the nearest whole number</li>
<li>ceil(x) → arrondit à l'entier supérieur</li> <li>ceil(x) → rounding to the nearest whole number in a big way</li>
<li>floor(x) → arrondit à l'entier inférieur</li> <li>floor(x) → rounding to the nearest whole number the smaller side</li>
</ul> </ul>
<h4>Autres fonctions prédéfinies</h4> <h4>Other predefined function</h4>
<ul> <ul>
<li>abs(x) → la valeur absolue d'un nombre</li> <li>abs(x) → Absolute number value</li>
<li>random() → retourne un nombre aléatoire entre 0 et 1</li> <li>random() → Return random number between 0 and 1</li>
</ul> </ul>
<h4>Les constantes</h4> <h4>Also are available some constants:</h4>
<ul> <ul>
<li>pi = 4 * atan(1) ≈ 3.141592653589793</li> <li>pi = 4 * atan(1) ≈ 3.141592653589793</li>
<li>e = exp(1) ≈ 2.718281828459045 </li> <li>e = exp(1) ≈ 2.718281828459045 </li>
</ul> </ul>
<p> <p>
Il n'est pas toujours facile de comprendre comment écrire la fonction désirée. En effet, une petite faute et elle ne s'affichera pas. De plus, il ne faut pas oublier de mettre un « * » entre les thermes à multiplier et d'utiliser le point « . » pour écrire des nombres à virgule. Not always it's easy to understand how to record a required function. Really if anywhere you err then graph will not displayed. Also do not forget about "*" (multiply) to multiply and "." (decimal point) to write point.
</p> </p>
<p> <p>
Les fonctions en deux dimensions s'écrivent sous la forme : y=[...] et les fonctions en trois dimensions sous la forme : z=[...]. D'autres exemples sont disponibles dans le menu « aide » du widget si vous avez de la peine à entrer une fonction. The two-dimensional function must be written as y=[...] and the three-dimensional function nust be written as z=[...]. Other examples are available to use in menu "Help" if you have some difficulties with function definition.
</p> </p>
<h2 id="DeplacerAffichage">6. Se déplacer à travers la fonction</h2> <h2 id="DeplacerAffichage">6. Offset function</h2>
<p> <p>
Parfois, lorsqu'on dessine une fonction, la zone visible n'est pas très intéressante. Pour cela, il est utile de déplacer l'affichage ou de définir soi-même la zone à afficher. Sometimes when you draw the function you don't see all necessary information about this function. In this case you can change position of graph.
</p> </p>
<img src="Images/Guide_Deplacement.png"/> <img src="Images/Guide_Deplacement.png"/>
<p> <p>
Pour déplacer la fonction, il suffit d'utiliser les flèches de navigation situées dans les quatre bords de l'affichage ou l'outil de déplacement à la souris (dans le menu « Outils »). To move the function graph just use a navigation arrows that are in the four edges of the display or mouse move tool (menu Service).
</p> </p>
<p> <p>
Pour définir la zone à afficher, il faut entrer des valeurs personnalisées dans les champs à gauche du widget. La valeur de gauche doit obligatoirement être plus petite que la valeur de droite. Dans le cas contraire, la fonction ne se dessinera pas. To define place to display you should enter a custom values in the left side of the widget. The left value must be less than the right value. In other case graph will not displayed.
</p> </p>
<p> <p>
Il est possible de zoomer ou dé-zoomer l'affichage en utilisant les boutons du menu de gauche pour voir une plus grande partie de la fonction. Le zoom peut être réinitialisé dans les options. On peut également cliquer deux fois sur le graphique pour zoomer ainsi que dé-zoomer en maintenant la touche « ctrl » appuyée et en cliquant deux fois. You can increase or decrease the scale of displaying using buttons that are in the left menu. So you'll see more information about function. Zoom can be reset in options.
</p> </p>
<h2 id="MenuOptions">7. Le menu des options</h2> <h2 id="MenuOptions">7. The options menu</h2>
<p> <p>
Cliquez sur le bouton « Options » à gauche du widget pour ouvrir ce menu. En cliquant à nouveau sur le bouton, cela ferme le menu. Plusieurs onglets permettent de naviguer entre les différentes options. Description des options : To open the menu you should click a button "Options" that is in the left of the widget. If you click on this button again then menu will close. There are some buttons for navigation between options. Their short description:
</p> </p>
<ul> <ul>
<li>Le thème du widget change l'image de fond ainsi que différentes couleurs. Dans Uniboard, changer le thème permet de rendre le widget plus visible selon qu'il se trouve sur un fond noir ou un fond blanc.</li> <li>Changing a background image and color. In Sankore changing background theme used for displaying widget on black and white background.</li>
<li>La méthode d'affichage permet de définir la façon dont le graphique de la fonction sera dessiné. Il y a le choix entre six possibilités : <br/> <li>Display-method used for defining displaying function. There are 6 possibilities: <br/>
<ol> <ol>
<li>SVG est un format d'image vectoriel qui peut être intégré dans une page HTML. Il est compatible dans la plupart des navigateurs Internet et est très bien supporté par Uniboard, c'est pourquoi il est choisi par défaut.</li> <li>SVG is a vector format of image and it can be built in HTML-page. It's compatible in most of browsers and Sankore support it very well so is it selected default.</li>
<li>« SVG (une image) » ne présente que peu de différence avec la méthode d'affichage « SVG ». A moins d'un problème de compatibilité, il n'est pas très utile de la choisir.</li> <li>There is a big difference between SVG (image) and display method SVG. If you have a compatibility problems then you should not use this method.</li>
<li>Canvas est une nouvelle balise présente depuis HTML 5.0. Elle permet de définir une zone dans laquelle on peut faire des dessins. Cette méthode d'affichage est plus rapide que d'utiliser du SVG, cependant, elle n'est pas complètement compatible dans Uniboard. Il est conseillé de choisir cette option si vous utilisez le widget ailleurs que dans Uniboard.</li> <li>"Canvas" is a new tag that used in HTML 5.0. It define a area in which you can place some images. This display-method is faster than SVG-method, but Sankore does not fully support it. It's desirable to choose this method when you use no Sankore widget.</li>
<li>Canvas (point) utilise aussi canvas, mais dessine des points à la place de lignes.</li> <li>"Canvas" (point) also uses a canvas but draws a points instead of lines.</li>
<li>XPM est un format d'image très peu connu. De ce fait, il est compatible qu'avec une minorité de navigateur.</li> <li>XPM format is little known so it's compatible just with a minority of browsers.</li>
<li>La méthode d'affichage « Uniboard » permet de dessiner directement sur la page d'Uniboard avec les outils de dessins.</li> <li>Display method "Uniboard" allows to draw directly on the page using Sankore drawing.</li>
</ol> </ol>
<img src="Images/Guide_Options.png"/> <img src="Images/Guide_Options.png"/>
</li> </li>
<li>Le zoom par défaut ainsi que le bouton « réinitialiser le zoom » permettent de remettre l'affichage à l'état qu'il était à l'ouverture du widget. Cela permet aussi de centrer l'affichage sur l'origine.</li> <li>Default zoom button returns display into original state. It helps alsoto return to the origin.</li>
<li>Les options d'affichage permettent d'afficher ou non la grille, les axes ainsi que l'échelle. Elles sont utiles pour rendre l'affichage plus lisible. Il est également possible de modifier l'épaisseur du trait de la fonction.</li> <li>Display options allow to display or not a grid, axis and scale. They make a mapping more readable. Also you can change the thickness of function line.</li>
<li>Le décalage du graphique n'a en principe pas besoin d'être utilisé. Il permet de déplacer tout l'affichage dans un sens ou dans l'autre, s'il n'est pas centré à la bonne place. Cela peut arriver avec certains navigateurs Internet.</li> <li>Offset of graph not used usually. But if you use it then you can move a mapping in any direction when a center isn't in the right place. It's avaliable in some browsers.</li>
<li>La précision des calculs du graphique permet d'augmenter ou de diminuer le nombre de points calculés. Plus le nombre est petit, plus la précision est grande. Il est utile de mettre cette valeur à « 0.01 » si vous dessinez des fonctions ressemblant à 0.5*sin(10*x*x).</li> <li>The accuracy of calculations of the graph will increase or decrease the number of points calculated. The higher the number, the more accuracy. It is useful to set this value to "0.01" if you draw functions like 0.5 * sin (10 * x * x).</li>
<li>Dans les options 3D, le style d'affichage permet de choisir comment la fonction est dessinée : avec des petits points ou avec des polygones (surfaces). La plupart des fonctions sont plus jolies en dessinant la surface entre les points calculés. Toutefois, c'est mieux de dessiner des points pour des fonctions comme la demi-sphère : sqrt(12-x*x-y*y).</li> <li>Options in 3D, the display style to choose how the function is designed: with small points or polygons (areas). Most functions are prettier drawing surface between the points calculated. However, it is better to draw points for functions such as the hemisphere: sqrt (12 - x*x - y*y).</li>
<li>Dans le dernier onglet, vous pouvez modifier d'autres options 3D, comme la précision des calculs ainsi que la couleur de la fonction.</li> <li>In the last tab you can change such options 3D, as the accuracy of the calculations and the color of the function.</li>
</ul> </ul>
<h2 id="MenuOutils">8. Le menu des outils</h2> <h2 id="MenuOutils">8. The tools menu.</h2>
<p> <p>
Ce menu permet tout d'abord de choisir l'action de la souris sur le graphique. Il y a le choix entre trois possibilités : This menu allows you to choose first action of the mouse on the graph. There is a choice of three options:
</p> </p>
<ul> <ul>
<li>L'outil sélectionné par défaut est le point. En bougeant la souris, un point se déplace sur la fonction et les coordonnées de ce point sont indiquées en haut à gauche de l'affichage.</li> <li>The selected tool is the default. By moving the mouse, a point moves on the function and the coordinates of this point are shown in the top left of the display.</li>
<li>Le deuxième outil est le déplacement. Il permet de déplacer le graphique avec la souris. Il suffit de tenir cliqué sur l'affichage et de bouger la souris. Malheureusement, cet outil peut être lent sur certains navigateurs.</li> <li>The second tool is moving. It allows you to move the chart with the mouse. Just keep clicking on the display and move the mouse. Unfortunately, this tool can be slow on some browsers.</li>
<li>Le troisième outil est la tangente. Cet outil dessine la tangente à la fonction au point où se trouve la souris.</li> <li>The third tool is the tangent. This tool draws the tangent to the function at the point where is a mouse cursor.</li>
</ul> </ul>
<p> <p>
Ensuite, ce menu permet aussi de calculer un point de la fonction. Il faut simplement entrer la coordonnée « x » du point dont on veut trouver la coordonnée « y », et appuyer sur le bouton « Évaluer ». Par exemple, si la fonction est « x*x » et qu'on défini « x=2 », alors le point dont la coordonnée sur l'axe des X est « 2 » aura comme coordonnée sur l'axe des Y « 4 ». Then, this menu also allows to calculate a point of the function. Simply enter the coordinate "x" from the point where we want to find the coordinate "y" and press the "Evaluate". For example, if the function is "x * x" and that defined "x = 2", then the point whose coordinate on the X axis is "2" will be to coordinate on the Y axis "4".
</p> </p>
<p> <p>
Un autre outil très utile est l'étude de fonction. Pour étudier la fonction entrée dans le champ en haut du widget, cliquez sur « démarrer l'étude ». Les études de fonction de ce widget ne sont pas fiables à 100% mais servent de complément à une étude de fonction que l'on fait soi-même. Il se peut que cet outil soit amélioré dans une prochaine version du widget. Another useful tool is the analysis of function. To analyse the function click on "start the analysis". Analyses based on this widget are not 100% reliable, but are complementary to a analysis of function that you are doing yourself. It may be that this tool will be improved in a future version of the widget.
</p> </p>
<p> <p>
Dans ce menu, on trouve également des tests d'affichage. Ils permettent d'essayer les différentes méthodes d'affichage et de voir si elles fonctionnent sur le navigateur internet utilisé. In this menu there are also tests the display. They can try different methods to display and see if they work on the browser used.
</p> </p>
<h2 id="PlusieursFonctions">9. Dessiner plusieurs fonctions</h2> <h2 id="PlusieursFonctions">9. Drawing some functions</h2>
<p> <p>
Pour dessiner plusieurs fonctions simultanément, cliquez sur le petit bouton « + » qui se situe à droite du bouton « Afficher » (point 1). Ensuite, un menu apparaît. To draw multiple functions simultaneously, click the small "+" button which is located to the right of "View" (point 1). Then, a menu appears.
</p> </p>
<img src="Images/Guide_Plus.png"/> <img src="Images/Guide_Plus.png"/>
<p> <p>
Dans ce menu, des onglets permettent d'aller à l'historique ou aux fonctions supplémentaires (point 2). Pour ajouter une fonction, cliquez sur le bouton à droite de la fonction actuelle (point 3). En dessous, une liste contient toutes les fonctions affichées (point 4). Pour supprimer une fonction, il faut simplement cliquer sur le bouton « - » à coté de celle-ci. Il est également possible de modifier la couleur de chaque fonction séparément. The tabs in this menu can go to the history or the additional features (point 2). To add a function click the button to the right of the current function (point 3). Below is a list that contains all the displayed functions (point 4). To remove a function, just click on the "-" button next to it. It is also possible to change the color of each function separately.
</p> </p>
<p> <p>
L'historique permet de revoir toutes les fonctions qui ont déjà été dessinées. Lorsque l'on clique sur une fonction de l'historique, celle qui est dessinée actuellement est remplacée par la fonction de l'historique. History can review all the functions that have already been drawn. When you click on a function of history current function replaced by the function of history.
</p> </p>
<p> <p>
Dessiner plusieurs fonctions simultanément est uniquement possible avec la méthode d'affichage « canvas » en deux dimensions. Par contre, l'historique est utilisable avec toutes les méthodes d'affichage. "Drawing several functions simultaneously" mode is only possible with the display method "canvas" in two dimensions, but the history can be used with all methods of display.
</p> </p>
<h2 id="MaJ">10. Mettre à jour GraphMe</h2> <h2 id="MaJ">10. GraphMe update</h2>
<p> <p>
La dernière version du widget est téléchargeable sur la page suivante : <a href="http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15">http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15</a>. Pour mettre à jour GraphMe, vous pouvez aussi cliquer sur le bouton "Mise à jour" dans le menu des options. The latest version of the widget can be downloaded from the following page: <a href="http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15">http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15</a>. To update GraphMe, you can also click on "Update" in the options menu.
</p> </p>
<h2 id="Contact">11. Contact</h2> <h2 id="Contact">11. Contact</h2>
<p> <p>
Si vous voulez rapporter un bug, avez une suggestion par rapport au widget ou voulez simplement poser une question, merci de me contacter par e-mail à l'adresse : <a href="mailto:yannick.vessaz@gmail.com">yannick.vessaz@gmail.com</a>. If you want to report a bug, have a suggestion from the widget or just want to ask a question, please contact me by e-mail at: <a href="mailto:yannick.vessaz@gmail.com">yannick.vessaz@gmail.com</a>.
</p> </p>
</body> </body>
</html> </html>

@ -1,5 +1,5 @@
// -------------------- Uniboard -------------------- // -------------------- sankore --------------------
// Ces fonctions permettent de dessiner le graphique directement dans Uniboard. // Ces fonctions permettent de dessiner le graphique directement dans sankore.
// Calcule tous les points de la fonction mathématique et les place dans des tableaux. // Calcule tous les points de la fonction mathématique et les place dans des tableaux.
function evaluerUniboard(eq) { function evaluerUniboard(eq) {
@ -28,33 +28,33 @@
// Regarde chaque coordonnées stockées dans le tableau et dessine le graphique // Regarde chaque coordonnées stockées dans le tableau et dessine le graphique
function calculerGraphUniboard(fin){ function calculerGraphUniboard(fin){
document.getElementById("affichage").innerHTML = "" document.getElementById("affichage").innerHTML = ""
uniboard.setTool('pen') sankore.setTool('pen')
uniboard.moveTo(pointX[2]+decalageX, pointY[2]+decalageY) sankore.moveTo(pointX[2]+decalageX, pointY[2]+decalageY)
for (i=3; i<fin; i++){ for (i=3; i<fin; i++){
if ((pointY[i]<0) || (pointY[i]>hauteur)){ if ((pointY[i]<0) || (pointY[i]>hauteur)){
uniboard.moveTo(pointX[i+1]+decalageX,pointY[i+1]+decalageY) sankore.moveTo(pointX[i+1]+decalageX,pointY[i+1]+decalageY)
continue continue
} }
uniboard.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth) sankore.drawLineTo(pointX[i]+decalageX, pointY[i]+decalageY, lineWidth)
} }
//dessiner le cadre //dessiner le cadre
uniboard.moveTo(0+decalageX,0+decalageY) sankore.moveTo(0+decalageX,0+decalageY)
uniboard.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth) sankore.drawLineTo(largeur+decalageX, 0+decalageY, lineWidth)
uniboard.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth) sankore.drawLineTo(largeur+decalageX, hauteur+decalageY, lineWidth)
uniboard.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth) sankore.drawLineTo(0+decalageX, hauteur+decalageY, lineWidth)
uniboard.drawLineTo(0+decalageX, 0+decalageY, lineWidth) sankore.drawLineTo(0+decalageX, 0+decalageY, lineWidth)
//dessiner les axes //dessiner les axes
uniboard.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY) sankore.moveTo((-borneXGauche*multiplicateurX)+decalageX, 0+decalageY)
uniboard.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth) sankore.drawLineTo((-borneXGauche*multiplicateurX)+decalageX, hauteur+decalageY, lineWidth)
uniboard.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY) sankore.moveTo(0+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY)
uniboard.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth) sankore.drawLineTo(largeur+decalageX, (hauteur-(-borneYGauche*multiplicateurY))+decalageY, lineWidth)
decalageX += 250 decalageX += 250
decalageY += 200 decalageY += 200
largeur -= 100 largeur -= 100
hauteur -= 100 hauteur -= 100
uniboard.setTool('arrow') sankore.setTool('arrow')
} }

@ -136,13 +136,13 @@ function pariteFct(){
} }
} }
if(paire){ if(paire){
document.getElementById("etudeParite").innerHTML = "paire" document.getElementById("etudeParite").innerHTML = "even"
} }
else if(impaire){ else if(impaire){
document.getElementById("etudeParite").innerHTML = "impaire" document.getElementById("etudeParite").innerHTML = "uneven"
} }
else{ else{
document.getElementById("etudeParite").innerHTML = "aucune" document.getElementById("etudeParite").innerHTML = "n/a"
} }
} }
@ -272,7 +272,7 @@ function signeFct(fct){
listeZeros.splice((aSupprimer[i]-i), 1) listeZeros.splice((aSupprimer[i]-i), 1)
} }
if(listeZeros==""){ if(listeZeros==""){
texteZeros = "aucuns" texteZeros = "n/a"
} }
document.getElementById("etudeZeros").innerHTML = texteZeros+listeZeros document.getElementById("etudeZeros").innerHTML = texteZeros+listeZeros
} }
@ -282,32 +282,32 @@ function asymptotes(){
if(Math.abs(limGauche[0])<1000){ if(Math.abs(limGauche[0])<1000){
var limRound = Math.round(limGauche[0]*100)/100 var limRound = Math.round(limGauche[0]*100)/100
if(limGauche[0]<limRound){ if(limGauche[0]<limRound){
document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessous de l'AH)</span>" document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is higher than a l'AH)</span>"
} }
else if(limGauche[0]>limRound){ else if(limGauche[0]>limRound){
document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessus de l'AH)</span>" document.getElementById("etudeAHG").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is lower than a l'AH)</span>"
} }
else{ else{
document.getElementById("etudeAHG").innerHTML = "y = "+limRound document.getElementById("etudeAHG").innerHTML = "y = "+limRound
} }
} }
else{ else{
document.getElementById("etudeAHG").innerHTML = "aucune" document.getElementById("etudeAHG").innerHTML = "n/a"
} }
if(Math.abs(limDroite[0])<1000){ if(Math.abs(limDroite[0])<1000){
var limRound = Math.round(limDroite[0]*100)/100 var limRound = Math.round(limDroite[0]*100)/100
if(limDroite[0]<limRound){ if(limDroite[0]<limRound){
document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessous de l'AH)</span>" document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is lower than a l'AH)</span>"
} }
else if(limDroite[0]>limRound){ else if(limDroite[0]>limRound){
document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(courbe au-dessus de l'AH)</span>" document.getElementById("etudeAHD").innerHTML = "y = "+limRound +" <span class='texteSecondaire'>(curve is higher than a l'AH)</span>"
} }
else{ else{
document.getElementById("etudeAHD").innerHTML = "y = "+limRound document.getElementById("etudeAHD").innerHTML = "y = "+limRound
} }
} }
else{ else{
document.getElementById("etudeAHD").innerHTML = "aucune" document.getElementById("etudeAHD").innerHTML = "n/a"
} }
// Verticales // Verticales
var texteAV = "" var texteAV = ""
@ -318,7 +318,7 @@ function asymptotes(){
} }
} }
if(texteAV==""){ if(texteAV==""){
texteAV = "aucune <br/>" texteAV = "n/a <br/>"
} }
document.getElementById("etudeAV").innerHTML = texteAV document.getElementById("etudeAV").innerHTML = texteAV
} }
@ -343,8 +343,8 @@ function courbure(){
} }
} }
} }
if(texteMin==""){texteMin = "<br/>Aucun Minimum";} if(texteMin==""){texteMin = "<br/>No minimum";}
if(texteMax==""){texteMax = "<br/>Aucun Maximum";} if(texteMax==""){texteMax = "<br/>No maximum";}
if(texteI==""){texteI = "<br/>Aucun I";} if(texteI==""){texteI = "<br/>Aucun I";}
document.getElementById("etudeMin").innerHTML = texteMin; document.getElementById("etudeMin").innerHTML = texteMin;
document.getElementById("etudeMax").innerHTML = texteMax; document.getElementById("etudeMax").innerHTML = texteMax;

@ -28,7 +28,7 @@ function cacherMenu(){
menuActuel = "" menuActuel = ""
} }
// ---- Minimiser ou Maximiser le widget (pour Uniboard) ---- // ---- Minimiser ou Maximiser le widget (pour sankore) ----
function miniMax(){ function miniMax(){
if (maximise){ if (maximise){
maximise = false maximise = false
@ -99,7 +99,7 @@ function changerTheme(){
// Affiche un message d'erreur // Affiche un message d'erreur
function error(err){ function error(err){
alert(" Erreur sur la page...\n\n Description: " + err.description + "\n\n Cliquez sur OK pour continuer.\n\n") alert(" Error has occurred on the page ...\n\n Description: " + err.description + "\n\n Click 'OK' to continue.\n\n")
} }

@ -88,7 +88,7 @@ function loadOptions(){
} }
else{ else{
if(document.cookie!=""){ if(document.cookie!=""){
alert("Impossible de charger les options enregistrées..."); alert("It's can't be downloaded ...");
} }
} }
} }
@ -115,5 +115,5 @@ function checkOptions(){
} }
function alertOptions(){ function alertOptions(){
alert("Options actuellement sauvegardées\n------------------------------------------------------------\n"+document.cookie); alert("Now parameters will be saved\n------------------------------------------------------------\n"+document.cookie);
} }

@ -1,63 +1,63 @@
/* Pour info, les span étaient une tentative de mise en forme via CSS mais j'ai trouvé plus pratique, et je les ai laissés au cas où... */ /* Pour info, les span йtaient une tentative de mise en forme via CSS mais j'ai trouvй plus pratique, et je les ai laissйs au cas oщ... */
var txt_vesicule = "<h2>Vésicule<br/>Transporteurs</h2>"+ var txt_vesicule = "<h2>Vesicle<br/>Transporter</h2>"+
"<h4>Structure:</h4><span><p>Bicouche phospholipidique</p></span>"+ "<h4>Structure:</h4><span><p>Phospholipid bilayer</p></span>"+
"<h4>Rôle:</h4><span><p>Transport de protéines ou d'autres éléments à l'intérieur de la cellule, vers l'extérieur (exocytose) ou vers l'intérieur (endocytose).</p></span>"+ "<h4>Role:</h4><span><p>Transport of proteins and other components inside the cell to the exterior (exocytosis) or inward (endocytosis).</p></span>"+
'<h4>Fonctionnement:</h4><span><p>Transporteur "remorqué" par des protéines prenant appui sur le cytosquelette.</p></span>' '<h4>Operation:</h4><span><p>Transport "towed" by Protein building on the cytoskeleton.</p></span>'
var txt_lysosome = "<h2>Lysosome<br/>Estomacs cellulaires</h2>"+ var txt_lysosome = "<h2>Lysosome<br/>A stomach cell.</h2>"+
"<h4>Structure:</h4><span><p>Bicouche phospholipidique</p></span>"+ "<h4>Structure:</h4><span><p>Phospholipid bilayer</p></span>"+
"<h4>Rôle:</h4><span><p>Digestion intra-cellulaire à l'aide d'enzymes</p></span>"+ "<h4>Role:</h4><span><p>А intracellular digestion with enzymes.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Absorption de nutriments par endocytose ou d'éléments cellulaires abimés, digestion de ceux-ci, puis distribution des résultats de la réaction chimique dans la cellule et enfin expulsion des déchets par exocytose.</p></span>" "<h4>Operation:</h4><span><p>Absorbes nutrient uptake or damaged cellular components by endocytosis, digest them and then distributes the results of the chemical reaction in the cell and finally expels of waste by exocytosis.</p></span>"
var txt_mitoch = "<h2>Mitochondrie<br/>Piles</h2>"+ var txt_mitoch = "<h2>Mitochondrie<br/>Batteries</h2>"+
"<h4>Structure:</h4><span><p>Deux bichouches phospholipidiques appelées membranes mitochondriales, une externe et une interne. La mitochondrie contient des ribosomes, de l'ATP de l'ADN et bien d'autres molécules.</p></span>"+ "<h4>Structure:</h4><span><p>Two phospholipid bilayers called mitochondrial membranes, one external and one internal. The mitochondria contain ribosomes, ATP of DNA and other molecules.</p></span>"+
"<h4>Rôle:</h4><span><p>Centrale énergétique de la cellule.</p></span>"+ "<h4>Role:</h4><span><p>Powerhouse of the cell.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>L'énergie - sous forme d'ATP (adénosine triphosphate) - est issue de différentes étapes de réactions chimique partant d'une molécule de glucose.</p></span>" "<h4>Operation:</h4><span><p>Energy - in the form of ATP (adenosine triphosphate) - comes from various stages of chemical reactions starting from a glucose molecule.</p></span>"
var txt_golgi = "<h2>Appareil de Golgi<br/>Usines miniatures</h2>"+ var txt_golgi = "<h2>Apparatus golgi<br/>Miniature plants</h2>"+
"<h4>Structure:</h4><span><p>Formé d'un empilement de saccules membranaires applatis.</p></span>"+ "<h4>Structure:</h4><span><p>Has a stack of flattened membrane saccules.</p></span>"+
"<h4>Rôle:</h4><span><p>Modification de certaines protéines au cours d'un cheminement au travers de ses saccules.</p></span>"+ "<h4>Role:</h4><span><p>Modification of proteins during a journey through its saccules.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Suite de réactions chimiques, notamment par glycosilation.</p></span>" "<h4>Operation:</h4><span><p>Chemical reactions, including glycosylation.</p></span>"
var txt_rer = "<h2>Réticulum endoplasmique rugueux - Tunnel</h2>"+ var txt_rer = "<h2>Rough endoplasmic reticulum - Tunnel</h2>"+
"<h4>Structure:</h4><span><p>Composé d'une bicouche phospholipidique piquetée de ribosomes (d'un aspect <i>rugueux</i>) délimitant la lumière, un espace interne pouvant être comparé à un tunnel.</p></span>"+ "<h4>Structure:</h4><span><p>Consists of a phospholipid bilayer studded with ribosomes (an aspect <i> rough </ i>) define the light, an internal space that can be compared to a tunnel.</p></span>"+
"<h4>Rôle:</h4><span><p>Plus spécialisé que le REL, il participe au transport et à la finalisation des protéines, qui sont synthétisées par les ribosomes.</p></span>"+ "<h4>Role:</h4><span><p>More specialized than the real, he participated in the transport and а finalizing the proteins that are synthesized by ribosomes.</p></span>"+
'<h4>Fonctionnement:</h4><span><p>Les protéines "tombent" dans la lumière du RER où elles sont modifiées et déplacées. Elles quittent le RER dans une vésucule issue de la membrane de ce dernier.</p></span>' '<h4>Operation:</h4><span><p>Proteins "fall" in the light of the RER where they are modified and displaced. They leave the RER in a vesicle membrane after it.</p></span>'
var txt_noy = "<h2>Noyau - Le coffre-fort</h2>"+ var txt_noy = "<h2>Core - The safe</h2>"+
"<h4>Structure:</h4><span><p>Entouré par une double membrane appelée enveloppe nucléaire en lien par endroits avec le RER. Ces deux membranes fusionnent à intervalles réguliers pour former les pores nucléaires. À l'intérieur se trouvent le nucléole et l'ADN, sous forme de chromatine ou de chomosomes.</p></span>"+ "<h4>Structure:</h4><span><p>Surrounded by a double membrane, that called the nuclear envelope, in places linked with the RER. These two membranes protect regular intervals formed nuclear pores. It located within the nucleolus and the DNA in the form of chromatin or chromosomes.</p></span>"+
"<h4>Rôle:</h4><span><p>Stockage de la totalité des informations génétiques nécessaires à la vie de la cellule.</p></span>"+ "<h4>Role:</h4><span><p>Storing all the genetic information necessary for a life of the cell.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Site de la transcription (copie de l'information génétique sur des ARNm).</p></span>" "<h4>Operation:</h4><span><p>Copying of genetic information on mRNA.</p></span>"
var txt_rel = "<h2>Réticulum endoplasmique lisse - REL</h2>"+ var txt_rel = "<h2>Smooth endoplasmic reticulum - REL</h2>"+
"<h4>Structure:</h4><span><p>Similaires à celle du RER, à la différence que sa membranne n'est pas parsemée de ribosomes, d'où son aspect <i>lisse</i>.</p></span>"+ "<h4>Structure:</h4><span><p>Like that of the RER, with the difference that the membrane is studded with ribosomes, as its smooth <i>appearance</i>.</p></span>"+
"<h4>Rôle:</h4><span><p>Sinthèse des phospholipides,stockage du calcium, transformation de certaines molécules extérieures (médicament, alcool, ...). Dans certaines cellules, le REL remplit aussi des fonctions supplémentaires, telles la production d'hormones, d'acides gastriques, etc.</p></span>"+ "<h4>Role:</h4><span><p>Phospholipid synthesis, calcium storage, transformation of certain molecules external (drugs, alcohol, ...). In some cells, the LRA also performs additional functions, such as the production of hormones, gastric acid, etc.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Il est le siège de beaucoup de réactions chimiques complexes (ex: détoxification, différentes synthèses).</p></span>" "<h4>Operation:</h4><span><p>It is the seat of many complex chemical reactions (eg detoxification, various syntheses).</p></span>"
var txt_adn = "<h2>ADN - Le livre de la vie</h2>"+ var txt_adn = "<h2>DNA - The Book of Life</h2>"+
"<h4>Structure:</h4><span><p>Échelle à la célèbre forme de double hélice composée de deux colonnes sucre-phosphate-sucre-phosphate-... et dont les échelons sont apellés bases azotées.</p></span>"+ "<h4>Structure:</h4><span><p>A scale in form of the famous double helix consists of two columns sugar-phosphate-sugar-phosphate ... and whose levels are called nitrogenous bases.</p></span>"+
"<h4>Rôle:</h4><span><p>L'ADN contient toutes les informations nécessaires à la vie.</p></span>"+ "<h4>Role:</h4><span><p>DNA contains all the information needed for a life.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Toutes les informations sont écrites à l'aide des quatre lettres A, T, G, et C. Grâce à ces combinaisons, il est possible d'écrire tout ce qui est utile à la cellule.</p></span>" "<h4>Operation:</h4><span><p>All information is written using the four letters A, T, G and C. Using these combinations, it is possible to write anything useful about cell.</p></span>"
var txt_centr= "<h2>Centrioles - Remorqueurs de choromosomes</h2>"+ var txt_centr= "<h2>Centrioles - Tug of chromosomes</h2>"+
"<h4>Structure:</h4><span><p>Neuf triplets de microtubules entourés par un certain nombre de protéines.</p></span>"+ "<h4>Structure:</h4><span><p>Nine triplets of microtubules surrounded by a some number of proteins.</p></span>"+
"<h4>Rôle:</h4><span><p>Séparer les différents chromosomes durant la division cellulaire.</p></span>"+ "<h4>Role:</h4><span><p>Separate the different chromosomes during cell division.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Les centrioles, une fois placés aux deux pôles de la cellule, déploient des microtubules vers les centromères des chromosomes et les tirent vers eux pour les séparer.</p></span>" "<h4>Operation:</h4><span><p>Centrioles, once placed at the two poles of the cell, deploy the microtubules to the centromeres of chromosomes and pull them to them to separate them.</p></span>"
var txt_rib = "<h2>Ribosome - Décodeurs</h2>"+ var txt_rib = "<h2>Ribosome - Decoders</h2>"+
"<h4>Structure:</h4><span><p>Formé par deux sous-unités composées d'ARN ribosomique et de protéines.</p></span>"+ "<h4>Structure:</h4><span><p>Formed by two subunits composed of ribosomal RNA and proteins.</p></span>"+
"<h4>Rôle:</h4><span><p>Le ribosome synthétise les protéines.</p></span>"+ "<h4>Role:</h4><span><p>The ribosome synthesizes proteins.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Un brin d'ARNm (messager) passe dans le ribosome et un ARNt (de transfert) entre dans la grande sous-unité si son codon (groupe de trois bases azotées) correspond à celui qui est en face sur l'ARNm. Cet ARNt porte avec lui un acide aminé spécifique qui est ajouté à la chaine déja assemblée.</p></span>" "<h4>Operation:</h4><span><p>A strand of mRNA (messenger) pass through the ribosome and tRNA (transfer) between the large subunit where the codon (group of three nitrogen bases) is one who is in front of the mRNA. This tRNA carries with it a specific amino acid that is added а chain already assembled.</p></span>"
var txt_arn = "<h2>ARN - Multifonction</h2>"+ var txt_arn = "<h2>RNA - Multifunction</h2>"+
"<h4>Structure:</h4><span><p>Très similaire à l'ADN à la différence qu'il ne possède qu'un brin et que la thymine (T) de l'ADN est remplacée par l'uracile (U). De plus, il est chimiquement plus instable que l'ADN, c'est pourquoi il n'est pas utilisé pour le stockage d'informations à long terme.</p></span>"+ "<h4>Structure:</h4><span><p>Very similar DNA with the difference it has only one strand and thymine (T) of DNA is replaced by uracil (U). In addition, it is chemically more stable than DNA, so it is not used for information storage, just if in long term.</p></span>"+
"<h4>Rôle:</h4><span><p>Multiples, il existe des ARN de transport, messagers, régulateus, guides, satellites, ...</p></span>"+ "<h4>Role:</h4><span><p>Multiple, there are RNA transport, passenger, cruise, guides, satellite ...</p></span>"+
"<h4>Fonctionnement:</h4><span><p>La copie d'informations génétiques se fait grâce à l'ouverture de la double-hélice d'ADN, puis la copie des codons sur l'ARN. Celui-ci peut alors sortir du noyau, ce que l'ADN ne peut pas faire.</p></span>" "<h4>Operation:</h4><span><p>Copying of genetic information, the opening of the double helix of DNA, and then copying the RNA codons. It can then exit the nucleus, the DNA can not do it.</p></span>"
var txt_nucl = "<h2>Nucléole - Fabrique d'ARN</h2>"+ var txt_nucl = "<h2>Nucleolus - Factory RNA</h2>"+
"<h4>Structure:</h4><span><p>Composé d'aucune membranne, c'est un agglomérat de protéines et d'ARN.</p></span>"+ "<h4>Structure:</h4><span><p>Composed of any membrane, a cluster of proteins and RNA.</p></span>"+
"<h4>Rôle:</h4><span><p>Lieu de la transcription d'ARN, nottament d'ARNr (ribosomiques) qui, associés avec des protéines, vont former les deux sous-unités des ribosomes.</p></span>"+ "<h4>Role:</h4><span><p>Location of the RNA transcripts, including RNA (ribosomal), which combines with protein, will form the two subunits of ribosomes.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Création d'un ribosome: Transcription des ARNr ainsi que des protéines nécessaires (cette étape est effectuée dans le cytoplasme par d'autres ribosomes) qui rentrent dans le noyau, association des molécules fraîchement formées en un nouveau ribosome, qui sort du noyau pour jouer son rôle.</p></span>" "<h4>Operation:</h4><span><p>Creation of a ribosome: Transcription of rRNA and protein needed (this step is performed in the cytoplasm by other ribosomes) that fall within the nucleus, association of molecules frankly formed a new ribosome, which leaves the nucleus to play its role.</p></span>"

@ -61,7 +61,7 @@ bool UBImportPDF::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFi
QString filepath = UBPersistenceManager::persistenceManager()->addPdfFileToDocument(pDocument, pFile.fileName(), uuid); QString filepath = UBPersistenceManager::persistenceManager()->addPdfFileToDocument(pDocument, pFile.fileName(), uuid);
PDFRenderer *pdfRenderer = PDFRenderer::rendererForUuid(uuid, pDocument->persistencePath() + "/" + filepath); // renderer is automatically deleted when not used anymore PDFRenderer *pdfRenderer = PDFRenderer::rendererForUuid(uuid, pDocument->persistencePath() + "/" + filepath, true); // renderer is automatically deleted when not used anymore
if (!pdfRenderer->isValid()) if (!pdfRenderer->isValid())
{ {

@ -17,7 +17,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\
src/adaptors/UBCFFSubsetAdaptor.h src/adaptors/UBCFFSubsetAdaptor.h
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \ HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \
src/adaptors/publishing/UBCapturePublisher.h \
src/adaptors/publishing/UBAbstractPublisher.h \ src/adaptors/publishing/UBAbstractPublisher.h \
src/adaptors/publishing/UBSvgSubsetRasterizer.h src/adaptors/publishing/UBSvgSubsetRasterizer.h
@ -42,7 +41,6 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\
src/adaptors/UBCFFSubsetAdaptor.cpp src/adaptors/UBCFFSubsetAdaptor.cpp
SOURCES += src/adaptors/publishing/UBDocumentPublisher.cpp \ SOURCES += src/adaptors/publishing/UBDocumentPublisher.cpp \
src/adaptors/publishing/UBCapturePublisher.cpp \
src/adaptors/publishing/UBAbstractPublisher.cpp \ src/adaptors/publishing/UBAbstractPublisher.cpp \
src/adaptors/publishing/UBSvgSubsetRasterizer.cpp src/adaptors/publishing/UBSvgSubsetRasterizer.cpp

@ -1,164 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBCapturePublisher.h"
#include "frameworks/UBStringUtils.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "gui/UBMainWindow.h"
#include "board/UBBoardController.h"
#include "network/UBServerXMLHttpRequest.h"
#include "network/UBNetworkAccessManager.h"
#include "domain/UBGraphicsScene.h"
#include "core/memcheck.h"
UBCapturePublisher::UBCapturePublisher(const QPixmap& pixmap, QObject *parent)
: UBAbstractPublisher(parent)
, mPixmap(pixmap)
{
connect(this, SIGNAL(authenticated(const QUuid&, const QString&))
, this, SLOT(postPixmap(const QUuid&, const QString&)));
}
void UBCapturePublisher::publish()
{
UBAbstractPublisher::authenticate();
}
void UBCapturePublisher::postPixmap(const QUuid& tokenUuid, const QString& encryptedBase64Token)
{
UBCapturePublishingDialog dialog(UBApplication::mainWindow);
QString defaultEMail = UBSettings::settings()->uniboardWebEMail->get().toString();
dialog.email->setText(defaultEMail);
QString defaultAuthor = UBSettings::settings()->uniboardWebAuthor->get().toString();
dialog.author->setText(defaultAuthor);
if (dialog.exec() == QDialog::Accepted)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
UBApplication::showMessage(tr("Preparing capture for upload..."), true);
QString title = dialog.title->text();
QString description = dialog.description->toPlainText();
QString email = dialog.email->text();
QString author = dialog.author->text();
QPixmap pix(mPixmap);
if (mPixmap.hasAlpha())
{
if (UBApplication::boardController->activeScene()->isDarkBackground())
pix.fill(Qt::black);
else
pix.fill(Qt::white);
QPainter p(&pix);
p.drawPixmap(0, 0, mPixmap);
}
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
pix.save(&buffer, "JPG", 80);
buffer.close();
QUrl publishingEndpoint = QUrl(UBSettings::settings()->capturesPublishingUrl);
mPublishImageOnWebUploadRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager()
, "application/octet-stream");
mPublishImageOnWebUploadRequest->setVerbose(true);
connect(mPublishImageOnWebUploadRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(publishImageOnWebUploadResponse(bool, const QByteArray&)));
mWebUploadPublishingUuid = QUuid::createUuid();
mPublishImageOnWebUploadRequest->addHeader("Publishing-UUID", UBStringUtils::toCanonicalUuid(mWebUploadPublishingUuid));
mPublishImageOnWebUploadRequest->addHeader("Document-Title", title);
mPublishImageOnWebUploadRequest->addHeader("Document-Author", author);
mPublishImageOnWebUploadRequest->addHeader("Document-AuthorEMail", email);
mPublishImageOnWebUploadRequest->addHeader("Document-Description", description);
mPublishImageOnWebUploadRequest->addHeader("Deletion-Token", UBStringUtils::toCanonicalUuid(QUuid::createUuid()));
mPublishImageOnWebUploadRequest->addHeader("Token-UUID", UBStringUtils::toCanonicalUuid(tokenUuid));
mPublishImageOnWebUploadRequest->addHeader("Token-Encrypted", encryptedBase64Token);
mPublishImageOnWebUploadRequest->post(publishingEndpoint, bytes);
}
else
{
UBApplication::showMessage(tr("Publication canceled ..."));
QApplication::restoreOverrideCursor();
}
}
void UBCapturePublisher::publishImageOnWebUploadResponse(bool success, const QByteArray& payload)
{
QUrl url(QString::fromUtf8(payload));
if (success && url.isValid())
{
UBApplication::showMessage(tr("Capture Published to the Web."));
}
else
{
UBApplication::showMessage(tr("Error Publishing Capture to the Web: %1").arg(QString::fromUtf8(payload)));
}
if (mPublishImageOnWebUploadRequest)
{
mPublishImageOnWebUploadRequest->deleteLater();
mPublishImageOnWebUploadRequest = 0;
}
QApplication::restoreOverrideCursor();
}
UBCapturePublishingDialog::UBCapturePublishingDialog(QWidget *parent)
: QDialog(parent)
{
Ui::capturePublishingDialog::setupUi(this);
connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject()));
connect(title, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&)));
connect(email, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&)));
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(false);
dialogButtons->button(QDialogButtonBox::Ok)->setText(tr("Publish"));
}
void UBCapturePublishingDialog::updateUIState(const QString& string)
{
Q_UNUSED(string);
bool ok = title->text().length() > 0
&& email->text().length() > 0;
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(ok);
}

@ -1,61 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBCAPTUREPUBLISHER_H
#define UBCAPTUREPUBLISHER_H
#include <QtGui>
#include "ui_capturePublishing.h"
#include "UBAbstractPublisher.h"
class UBServerXMLHttpRequest;
class UBCapturePublisher : public UBAbstractPublisher
{
Q_OBJECT
public:
explicit UBCapturePublisher(const QPixmap& pixmap, QObject *parent = 0);
void publish();
private slots:
void publishImageOnWebUploadResponse(bool success, const QByteArray& payload);
void postPixmap(const QUuid& tokenUuid, const QString& encryptedBase64Token);
private:
UBServerXMLHttpRequest *mPublishImageOnWebUploadRequest;
QUuid mWebUploadPublishingUuid;
QPixmap mPixmap;
};
class UBCapturePublishingDialog : public QDialog, public Ui::capturePublishingDialog
{
Q_OBJECT;
public:
UBCapturePublishingDialog(QWidget *parent = 0);
~UBCapturePublishingDialog(){}
private slots:
void updateUIState(const QString& string);
};
#endif // UBCAPTUREPUBLISHER_H

@ -1,8 +1,16 @@
/* /*
* UBBoardPaletteManager.cpp * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* *
* Created on: 3 nov. 2009 * This program is distributed in the hope that it will be useful,
* Author: Luc * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "UBBoardPaletteManager.h" #include "UBBoardPaletteManager.h"
@ -46,8 +54,6 @@
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
#include "adaptors/publishing/UBCapturePublisher.h"
#include "UBBoardController.h" #include "UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -155,7 +161,6 @@ void UBBoardPaletteManager::setupPalettes()
addItemActions << UBApplication::mainWindow->actionAddItemToCurrentPage; addItemActions << UBApplication::mainWindow->actionAddItemToCurrentPage;
addItemActions << UBApplication::mainWindow->actionAddItemToNewPage; addItemActions << UBApplication::mainWindow->actionAddItemToNewPage;
addItemActions << UBApplication::mainWindow->actionAddItemToLibrary; addItemActions << UBApplication::mainWindow->actionAddItemToLibrary;
addItemActions << UBApplication::mainWindow->actionShareItemOnWeb;
mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0); mAddItemPalette = new UBActionPalette(addItemActions, Qt::Horizontal, 0);
mAddItemPalette->setButtonIconSize(QSize(128, 128)); mAddItemPalette->setButtonIconSize(QSize(128, 128));
@ -309,7 +314,6 @@ void UBBoardPaletteManager::connectPalettes()
connect(UBApplication::mainWindow->actionAddItemToCurrentPage, SIGNAL(triggered()), this, SLOT(addItemToCurrentPage())); connect(UBApplication::mainWindow->actionAddItemToCurrentPage, SIGNAL(triggered()), this, SLOT(addItemToCurrentPage()));
connect(UBApplication::mainWindow->actionAddItemToNewPage, SIGNAL(triggered()), this, SLOT(addItemToNewPage())); connect(UBApplication::mainWindow->actionAddItemToNewPage, SIGNAL(triggered()), this, SLOT(addItemToNewPage()));
connect(UBApplication::mainWindow->actionAddItemToLibrary, SIGNAL(triggered()), this, SLOT(addItemToLibrary())); connect(UBApplication::mainWindow->actionAddItemToLibrary, SIGNAL(triggered()), this, SLOT(addItemToLibrary()));
connect(UBApplication::mainWindow->actionShareItemOnWeb, SIGNAL(triggered()), this, SLOT(shareItemOnWeb()));
connect(UBApplication::mainWindow->actionEraseItems, SIGNAL(triggered()), mErasePalette, SLOT(close())); connect(UBApplication::mainWindow->actionEraseItems, SIGNAL(triggered()), mErasePalette, SLOT(close()));
connect(UBApplication::mainWindow->actionEraseAnnotations, SIGNAL(triggered()), mErasePalette, SLOT(close())); connect(UBApplication::mainWindow->actionEraseAnnotations, SIGNAL(triggered()), mErasePalette, SLOT(close()));
@ -573,27 +577,27 @@ void UBBoardPaletteManager::addItemToLibrary()
mAddItemPalette->hide(); mAddItemPalette->hide();
} }
void UBBoardPaletteManager::shareItemOnWeb() //void UBBoardPaletteManager::shareItemOnWeb()
{ //{
QPixmap pixmap = mPixmap; // QPixmap pixmap = mPixmap;
if(mPixmap.isNull()) // if(mPixmap.isNull())
{ // {
pixmap = QPixmap(mItemUrl.toLocalFile()); // pixmap = QPixmap(mItemUrl.toLocalFile());
} // }
if(!pixmap.isNull()) // if(!pixmap.isNull())
{ // {
UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this); // UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this);
publisher->publish(); // publisher->publish();
} // }
else // else
{ // {
UBApplication::showMessage(tr("Error Publishing Image to the Web")); // UBApplication::showMessage(tr("Error Publishing Image to the Web"));
} // }
mAddItemPalette->hide(); // mAddItemPalette->hide();
} //}
void UBBoardPaletteManager::zoomButtonPressed() void UBBoardPaletteManager::zoomButtonPressed()

@ -118,7 +118,6 @@ class UBBoardPaletteManager : public QObject
void addItemToCurrentPage(); void addItemToCurrentPage();
void addItemToNewPage(); void addItemToNewPage();
void addItemToLibrary(); void addItemToLibrary();
void shareItemOnWeb();
void purchaseLinkActivated(const QString&); void purchaseLinkActivated(const QString&);

File diff suppressed because it is too large Load Diff

@ -451,6 +451,7 @@ void UBPreferencesController::toolbarPositionChanged(bool checked)
UBSettings* settings = UBSettings::settings(); UBSettings* settings = UBSettings::settings();
settings->appToolBarPositionedAtTop->set(mPreferencesUI->toolbarAtTopRadioButton->isChecked()); settings->appToolBarPositionedAtTop->set(mPreferencesUI->toolbarAtTopRadioButton->isChecked());
} }
void UBPreferencesController::toolbarOrientationVertical(bool checked) void UBPreferencesController::toolbarOrientationVertical(bool checked)

@ -1,8 +1,16 @@
/* /*
* UNWindowController.cpp * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* *
* Created on: Jan 15, 2009 * This program is distributed in the hope that it will be useful,
* Author: julienbachmann * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QDesktopWidget> #include <QDesktopWidget>
@ -90,6 +98,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
mKeyboardPalette->setParent(mTransparentDrawingView); mKeyboardPalette->setParent(mTransparentDrawingView);
connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
} }
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
@ -143,12 +152,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased())); connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased()));
connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased())); connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased()));
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
onDesktopPaletteMaximized(); onDesktopPaletteMaximized();
} }
void UBDesktopAnnotationController::showKeyboard(bool show) void UBDesktopAnnotationController::showKeyboard(bool show)
{ {
mKeyboardPalette->setVisible(show); mKeyboardPalette->setVisible(show);
updateMask(true);
// mDesktopPalette->showVirtualKeyboard(show); // mDesktopPalette->showVirtualKeyboard(show);
} }
@ -332,6 +345,10 @@ void UBDesktopAnnotationController::showWindow()
UBPlatformUtils::setDesktopMode(true); UBPlatformUtils::setDesktopMode(true);
mDesktopPalette->appear(); mDesktopPalette->appear();
#ifdef Q_WS_X11
updateMask(true);
#endif
} }
@ -343,7 +360,15 @@ void UBDesktopAnnotationController::close()
void UBDesktopAnnotationController::stylusToolChanged(int tool) void UBDesktopAnnotationController::stylusToolChanged(int tool)
{ {
Q_UNUSED(tool); UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
mDesktopPalette->notifySelectorSelection(UBStylusTool::Selector == eTool);
if(UBStylusTool::Selector != eTool)
{
UBApplication::mainWindow->actionVirtualKeyboard->setChecked(false);
mKeyboardPalette->setVisible(false);
}
updateBackground(); updateBackground();
} }
@ -356,6 +381,9 @@ void UBDesktopAnnotationController::updateBackground()
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector) || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{ {
newBrush = QBrush(Qt::transparent); newBrush = QBrush(Qt::transparent);
#ifdef Q_WS_X11
updateMask(true);
#endif
} }
else else
{ {
@ -363,6 +391,9 @@ void UBDesktopAnnotationController::updateBackground()
newBrush = QBrush(QColor(127, 127, 127, 15)); newBrush = QBrush(QColor(127, 127, 127, 15));
#else #else
newBrush = QBrush(QColor(127, 127, 127, 1)); newBrush = QBrush(QColor(127, 127, 127, 1));
#endif
#ifdef Q_WS_X11
updateMask(false);
#endif #endif
} }
@ -389,6 +420,8 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false); UBPlatformUtils::setDesktopMode(false);
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(true);
emit restoreUniboard(); emit restoreUniboard();
} }
@ -751,3 +784,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")"; // qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")";
mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height()); mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height());
} }
void UBDesktopAnnotationController::updateMask(bool bTransparent)
{
if(bTransparent)
{
// Here we have to generate a new mask. This method is certainly resource
// consuming but for the moment this is the only solution that I found.
mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height());
QPainter p;
p.begin(&mMask);
p.setPen(Qt::red);
p.setBrush(QBrush(Qt::red));
// Here we draw the widget mask
if(mDesktopPalette->isVisible())
{
p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height());
}
if(mKeyboardPalette->isVisible())
{
p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height());
}
if(mLibPalette->isVisible())
{
p.drawRect(mLibPalette->geometry().x(), mLibPalette->geometry().y(), mLibPalette->width(), mLibPalette->height());
}
p.end();
// Then we add the annotations. We create another painter because we need to
// apply transformations on it for coordinates matching
QPainter annotationPainter;
QTransform trans;
trans.translate(mTransparentDrawingView->width()/2, mTransparentDrawingView->height()/2);
annotationPainter.begin(&mMask);
annotationPainter.setPen(Qt::red);
annotationPainter.setBrush(Qt::red);
annotationPainter.setTransform(trans);
QList<QGraphicsItem*> allItems = mTransparentDrawingScene->items();
for(int i = 0; i < allItems.size(); i++)
{
QGraphicsItem* pCrntItem = allItems.at(i);
if(pCrntItem->isVisible())
{
QPainterPath crntPath = pCrntItem->shape();
QRectF rect = crntPath.boundingRect();
annotationPainter.drawRect(rect);
}
}
annotationPainter.end();
mTransparentDrawingView->setMask(mMask.createMaskFromColor(Qt::black));
}
else
{
// Remove the mask
QPixmap noMask(mTransparentDrawingView->width(), mTransparentDrawingView->height());
mTransparentDrawingView->setMask(noMask.mask());
}
}
void UBDesktopAnnotationController::refreshMask()
{
if(mIsFullyTransparent
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{
updateMask(true);
}
}

@ -1,8 +1,16 @@
/* /*
* UNWindowController.h * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* *
* Created on: Jan 15, 2009 * This program is distributed in the hope that it will be useful,
* Author: julienbachmann * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBUNINOTESWINDOWCONTROLLER_H_ #ifndef UBUNINOTESWINDOWCONTROLLER_H_
@ -94,10 +102,12 @@ class UBDesktopAnnotationController : public QObject
void onDesktopPaletteMaximized(); void onDesktopPaletteMaximized();
void onDesktopPaletteMinimize(); void onDesktopPaletteMinimize();
void onTransparentWidgetResized(); void onTransparentWidgetResized();
void refreshMask();
private: private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName); void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);
void togglePropertyPalette(UBActionPalette* palette); void togglePropertyPalette(UBActionPalette* palette);
void updateMask(bool bTransparent);
UBDesktopPalette *mDesktopPalette; UBDesktopPalette *mDesktopPalette;
UBKeyboardPalette *mKeyboardPalette; UBKeyboardPalette *mKeyboardPalette;
@ -126,6 +136,8 @@ class UBDesktopAnnotationController : public QObject
int mBoardStylusTool; int mBoardStylusTool;
int mDesktopStylusTool; int mDesktopStylusTool;
QPixmap mMask;
}; };
#endif /* UBUNINOTESWINDOWCONTROLLER_H_ */ #endif /* UBUNINOTESWINDOWCONTROLLER_H_ */

@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe()
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
actions << UBApplication::mainWindow->actionVirtualKeyboard; actions << UBApplication::mainWindow->actionVirtualKeyboard;
@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
return p; return p;
} }
void UBDesktopPalette::notifySelectorSelection(bool selected)
{
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(selected);
}

@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette
void disappearForCapture(); void disappearForCapture();
void appear(); void appear();
QPoint buttonPos(QAction* action); QPoint buttonPos(QAction* action);
void notifySelectorSelection(bool selected);
signals: signals:
void uniboardClick(); void uniboardClick();

@ -44,8 +44,8 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
, mInitialLoadDone(false) , mInitialLoadDone(false)
, mLoadIsErronous(false) , mLoadIsErronous(false)
, mIsFreezable(true) , mIsFreezable(true)
, mCanBeContent(true) , mCanBeContent(0)
, mCanBeTool(true) , mCanBeTool(0)
, mIsFrozen(false) , mIsFrozen(false)
, mIsTakingSnapshot(false) , mIsTakingSnapshot(false)
{ {
@ -74,12 +74,51 @@ UBAbstractWidget::UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent)
setMouseTracking(true); setMouseTracking(true);
} }
bool UBAbstractWidget::canBeContent()
{
// if we under MAC OS
#if defined(Q_OS_MAC)
return mCanBeContent & OSType::type_MAC;
#endif
// if we under UNIX OS
#if defined(Q_OS_UNIX)
return mCanBeContent & OSType::type_UNIX;
#endif
// if we under WINDOWS OS
#if defined(Q_OS_WIN)
return mCanBeContent & OSType::type_WIN;
#endif
}
bool UBAbstractWidget::canBeTool()
{
// if we under MAC OS
#if defined(Q_OS_MAC)
return mCanBeTool & OSType::type_MAC;
#endif
// if we under UNIX OS
#if defined(Q_OS_UNIX)
return mCanBeTool & OSType::type_UNIX;
#endif
// if we under WINDOWS OS
#if defined(Q_OS_WIN)
return mCanBeTool & OSType::type_WIN;
#endif
}
UBAbstractWidget::~UBAbstractWidget() UBAbstractWidget::~UBAbstractWidget()
{ {
// NOOP // NOOP
} }
void UBAbstractWidget::loadMainHtml()
{
QWebView::load(mMainHtmlUrl);
}
bool UBAbstractWidget::event(QEvent *event) bool UBAbstractWidget::event(QEvent *event)
{ {

@ -39,6 +39,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0); UBAbstractWidget(const QUrl& pWidgetUrl, QWidget *parent = 0);
virtual ~UBAbstractWidget(); virtual ~UBAbstractWidget();
void loadMainHtml();
QUrl mainHtml() QUrl mainHtml()
{ {
return mMainHtmlUrl; return mMainHtmlUrl;
@ -64,15 +66,8 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
return mNominalSize; return mNominalSize;
} }
bool canBeContent() const bool canBeContent();
{ bool canBeTool();
return mCanBeContent;
}
bool canBeTool() const
{
return mCanBeTool;
}
bool hasLoadedSuccessfully() const bool hasLoadedSuccessfully() const
{ {
@ -123,8 +118,16 @@ class UBAbstractWidget : public UBRoutedMouseEventWebView
bool mLoadIsErronous; bool mLoadIsErronous;
bool mIsFreezable; bool mIsFreezable;
bool mCanBeContent; int mCanBeContent;
bool mCanBeTool; int mCanBeTool;
enum OSType
{
type_NONE = 0, // 0000
type_WIN = 1, // 0001
type_MAC = 2, // 0010
type_UNIX = 4, // 0100
type_ALL = 7, // 0111
};
virtual void injectInlineJavaScript(); virtual void injectInlineJavaScript();
virtual void paintEvent(QPaintEvent * event); virtual void paintEvent(QPaintEvent * event);

@ -130,6 +130,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBApplication::applicationController->initialHScroll(), UBApplication::applicationController->initialHScroll(),
UBApplication::applicationController->initialVScroll())); UBApplication::applicationController->initialVScroll()));
} }
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
} }
@ -138,6 +141,29 @@ UBGraphicsScene::~UBGraphicsScene()
// NOOP // NOOP
} }
void UBGraphicsScene::selectionChangedProcessing()
{
QList<QGraphicsItem *> allItemsList = items();
for( int i = 0; i < allItemsList.size(); i++ )
{
QGraphicsItem *nextItem = allItemsList.at(i);
qreal zValue = nextItem->zValue();
nextItem->setZValue(qreal(1));
qDebug() << QString(" %1 ").arg(i) << QString(" %1 ").arg(zValue);
}
QList<QGraphicsItem *> selItemsList = selectedItems();
for( int i = 0; i < selItemsList.size(); i++ )
{
QGraphicsItem *nextItem = selItemsList.at(i);
qreal zValue = nextItem->zValue();
nextItem->setZValue(2);
qDebug() << QString(" >>> %1 <<< ").arg(i) << QString(" >>> %1 <<< ").arg(zValue);
}
}
// MARK: - // MARK: -
// MARK: Mouse/Tablet events handling // MARK: Mouse/Tablet events handling
@ -249,6 +275,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{ {
if (currentTool == UBStylusTool::Line) if (currentTool == UBStylusTool::Line)
{ {
// TODO: Verify this beautiful implementation and check if
// it is possible to optimize it
QLineF radius(mPreviousPoint, position); QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle(); qreal angle = radius.angle();
angle = qRound(angle / 45) * 45; angle = qRound(angle / 45) * 45;
@ -257,7 +285,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180), mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180),
mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180)); mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180));
QLineF chord(position, newPosition); QLineF chord(position, newPosition);
if (chord.length() < qMin((int)16, (int)(radiusLength / 20))) if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
position = newPosition; position = newPosition;
} }
@ -1074,6 +1102,8 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
if (graphicsWidget->widgetWebView()->canBeContent()) if (graphicsWidget->widgetWebView()->canBeContent())
{ {
graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->setSelected(true); graphicsWidget->setSelected(true);
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);

@ -271,6 +271,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setToolCursor(int tool); void setToolCursor(int tool);
void selectionChangedProcessing();
signals: signals:
void pageSizeChanged(); void pageSizeChanged();

@ -86,8 +86,51 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
QString roles = widgetElement.attribute("ub:roles", "content tool").trimmed().toLower(); QString roles = widgetElement.attribute("ub:roles", "content tool").trimmed().toLower();
mCanBeTool = roles == "" || roles.contains("tool"); //------------------------------//
mCanBeContent = roles == "" || roles.contains("content");
if( roles == "" || roles.contains("tool") )
{
mCanBeTool = UBAbstractWidget::OSType::type_ALL;
}
if( roles.contains("twin") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_WIN;
}
if( roles.contains("tmac") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_MAC;
}
if( roles.contains("tunix") )
{
mCanBeTool |= UBAbstractWidget::OSType::type_UNIX;
}
//---------//
if( roles == "" || roles.contains("content") )
{
mCanBeContent = UBAbstractWidget::OSType::type_ALL;
}
if( roles.contains("cwin") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_WIN;
}
if( roles.contains("cmac") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_MAC;
}
if( roles.contains("cunix") )
{
mCanBeContent |= UBAbstractWidget::OSType::type_UNIX;
}
//------------------------------//
QDomNodeList contentDomList = widgetElement.elementsByTagName("content"); QDomNodeList contentDomList = widgetElement.elementsByTagName("content");
@ -159,8 +202,6 @@ UBW3CWidget::UBW3CWidget(const QUrl& pWidgetUrl, QWidget *parent)
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared()));
QWebView::load(mMainHtmlUrl);
setFixedSize(QSize(width, height)); setFixedSize(QSize(width, height));
mNominalSize = QSize(width, height); mNominalSize = QSize(width, height);
@ -171,7 +212,6 @@ UBW3CWidget::~UBW3CWidget()
// NOOP // NOOP
} }
void UBW3CWidget::javaScriptWindowObjectCleared() void UBW3CWidget::javaScriptWindowObjectCleared()
{ {
UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0); UBWidgetUniboardAPI *uniboardAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene(), 0);

@ -19,9 +19,27 @@
#include "UBDockPalette.h" #include "UBDockPalette.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "frameworks/UBPlatformUtils.h" #include "frameworks/UBPlatformUtils.h"
#include "core/UBApplication.h"
#include "core/UBPreferencesController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/*
Note to myself: I will have to modify this implementation when we will
have to support mulitple tab. At this moment, a UBDockPalette
will be only the palette that manages the tabs. This
palette will maintain a list of tabs with icons and will
contain a QStackedWidget that will be contains the different
widget contents.
A click on a tab that is not related to the current widget
will show the related widget in the palette.
A click on a tab that is related to the current widget will
collapse the palette.
If the palette is collapsed, a click on any tab will expand it
and show the tab related widget.
*/
/** /**
* \brief The constructor * \brief The constructor
*/ */
@ -34,11 +52,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mResized(false) , mResized(false)
, mCollapseWidth(150) , mCollapseWidth(150)
, mLastWidth(-1) , mLastWidth(-1)
, mHTab(0)
{ {
setObjectName(name); setObjectName(name);
// We let 2 pixels in order to keep a small border for the resizing // We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(border() + 2); setMinimumWidth(2*border() + 2);
if (parent) if (parent)
{ {
@ -61,6 +80,10 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
// This is the only way to set the background as transparent! // This is the only way to set the background as transparent!
setStyleSheet("QWidget {background-color: transparent}"); setStyleSheet("QWidget {background-color: transparent}");
// Set the position of the tab
onToolbarPosUpdated();
connect(UBSettings::settings()->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(onToolbarPosUpdated()));
} }
/** /**
@ -206,9 +229,9 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
if(eUBDockOrientation_Left == mOrientation) if(eUBDockOrientation_Left == mOrientation)
{ {
if(mMousePressPos.x() >= width() - 2*border() && if(mMousePressPos.x() >= width() - 2*border() &&
mMousePressPos.y() >= border() && mMousePressPos.y() >= mHTab &&
mMousePressPos.x() <= width() && mMousePressPos.x() <= width() &&
mMousePressPos.y() <= border() + TABSIZE) mMousePressPos.y() <= mHTab + TABSIZE)
{ {
tabClicked(); tabClicked();
} }
@ -217,8 +240,8 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
{ {
if(mMousePressPos.x() >= 0 && if(mMousePressPos.x() >= 0 &&
mMousePressPos.x() <= 2*border() && mMousePressPos.x() <= 2*border() &&
mMousePressPos.y() >= border() && mMousePressPos.y() >= mHTab &&
mMousePressPos.y() <= border() + TABSIZE) mMousePressPos.y() <= mHTab + TABSIZE)
{ {
tabClicked(); tabClicked();
} }
@ -291,23 +314,32 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush); painter.setBrush(mBackgroundBrush);
if(eUBDockTabOrientation_Up == mTabsOrientation)
{
mHTab = border();
}
else
{
mHTab = height() - border() - TABSIZE;
}
if(mOrientation == eUBDockOrientation_Left) if(mOrientation == eUBDockOrientation_Left)
{ {
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-border(), height()); path.addRect(0.0, 0.0, width()-2*border(), height());
path.addRoundedRect(width()-2*border(), border(), 2*border(), TABSIZE, radius(), radius()); path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path); painter.drawPath(path);
painter.drawPixmap(width() - border() + 1, border() + 1 , border() - 4, TABSIZE - 2, mIcon); painter.drawPixmap(width() - border() + 1, mHTab + 1 , border() - 4, TABSIZE - 2, mIcon);
} }
else if(mOrientation == eUBDockOrientation_Right) else if(mOrientation == eUBDockOrientation_Right)
{ {
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
path.addRect(border(), 0.0, width()-border(), height()); path.addRect(2*border(), 0.0, width()-2*border(), height());
path.addRoundedRect(0.0, border(), 2*border(), TABSIZE, radius(), radius()); path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path); painter.drawPath(path);
painter.drawPixmap(2, border() + 1, border() - 3, TABSIZE - 2, mIcon); painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon);
} }
else else
{ {
@ -372,7 +404,7 @@ void UBDockPalette::tabClicked()
{ {
// The palette must be collapsed // The palette must be collapsed
mLastWidth = width(); mLastWidth = width();
resize(border(), height()); resize(2*border(), height());
} }
else else
{ {
@ -381,3 +413,27 @@ void UBDockPalette::tabClicked()
mLastWidth = -1; mLastWidth = -1;
} }
} }
void UBDockPalette::setTabsOrientation(eUBDockTabOrientation orientation)
{
mTabsOrientation = orientation;
}
void UBDockPalette::onToolbarPosUpdated()
{
// Get the position of the tab
if(UBSettings::settings()->appToolBarPositionedAtTop->get().toBool())
{
setTabsOrientation(eUBDockTabOrientation_Up);
}
else
{
setTabsOrientation(eUBDockTabOrientation_Down);
}
update();
}
int UBDockPalette::customMargin()
{
return 5;
}

@ -39,14 +39,22 @@ typedef enum
eUBDockOrientation_Bottom /** [to be implemented]Bottom dock */ eUBDockOrientation_Bottom /** [to be implemented]Bottom dock */
}eUBDockOrientation; }eUBDockOrientation;
typedef enum
{
eUBDockTabOrientation_Up, /** Up tabs */
eUBDockTabOrientation_Down /** Down tabs */
}eUBDockTabOrientation;
class UBDockPalette : public QWidget class UBDockPalette : public QWidget
{ {
Q_OBJECT
public: public:
UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette"); UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette");
~UBDockPalette(); ~UBDockPalette();
eUBDockOrientation orientation(); eUBDockOrientation orientation();
void setOrientation(eUBDockOrientation orientation); void setOrientation(eUBDockOrientation orientation);
void setTabsOrientation(eUBDockTabOrientation orientation);
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
@ -60,6 +68,7 @@ public:
protected: protected:
virtual int border(); virtual int border();
virtual int radius(); virtual int radius();
virtual int customMargin();
virtual void updateMaxWidth(); virtual void updateMaxWidth();
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
virtual int collapseWidth(); virtual int collapseWidth();
@ -86,6 +95,13 @@ protected:
QPoint mMousePressPos; QPoint mMousePressPos;
/** The palette icon */ /** The palette icon */
QPixmap mIcon; QPixmap mIcon;
/** The tab orientation */
eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */
int mHTab;
private slots:
void onToolbarPosUpdated();
private: private:
void tabClicked(); void tabClicked();

@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event)
{ {
moveInsideParent(event->globalPos() - mDragPosition); moveInsideParent(event->globalPos() - mDragPosition);
event->accept(); event->accept();
emit moving();
} }
else else
{ {

@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget
void minimizeStart(eMinimizedLocation location); void minimizeStart(eMinimizedLocation location);
void maximizeStart(); void maximizeStart();
void maximized(); void maximized();
void moving();
}; };

@ -39,6 +39,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget()); UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget());
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
// mLayout->setContentsMargins(20, 5, 5, 5);
setLayout(mLayout); setLayout(mLayout);
mPathViewer = new UBLibPathViewer(this); mPathViewer = new UBLibPathViewer(this);

@ -34,13 +34,13 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mIcon = QPixmap(":images/paletteLibrary.png"); mIcon = QPixmap(":images/paletteLibrary.png");
setAcceptDrops(true); setAcceptDrops(true);
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
setContentsMargins(border(), 0, 0, 0); setContentsMargins(border(), 0, 0, 0);
mCollapseWidth = 180; mCollapseWidth = 180;
mLastWidth = 300; mLastWidth = 300;
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
mLayout->setMargin(3); mLayout->setContentsMargins(20, customMargin(), customMargin(), customMargin());
setLayout(mLayout); setLayout(mLayout);
// Build the GUI // Build the GUI
@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
{ {
UBDockPalette::resizeEvent(event); UBDockPalette::resizeEvent(event);
UBSettings::settings()->libPaletteWidth->set(width()); UBSettings::settings()->libPaletteWidth->set(width());
emit resized();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

@ -55,6 +55,9 @@ public:
UBLibActionBar* actionBar(){return mActionBar;} UBLibActionBar* actionBar(){return mActionBar;}
signals:
void resized();
protected: protected:
void updateMaxWidth(); void updateMaxWidth();
void dragEnterEvent(QDragEnterEvent* pEvent); void dragEnterEvent(QDragEnterEvent* pEvent);

@ -12,466 +12,466 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QPixmap> #include <QPixmap>
#include <QDrag> #include <QDrag>
#include <QPainter> #include <QPainter>
#include "UBLibPathViewer.h" #include "UBLibPathViewer.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget
* @param name as the object name * @param name as the object name
*/ */
UBLibPathViewer::UBLibPathViewer(QWidget *parent, const char *name):QGraphicsView(parent) UBLibPathViewer::UBLibPathViewer(QWidget *parent, const char *name):QGraphicsView(parent)
, mpElems(NULL) , mpElems(NULL)
, mpScene(NULL) , mpScene(NULL)
, mpLayout(NULL) , mpLayout(NULL)
, mpContainer(NULL) , mpContainer(NULL)
{ {
setObjectName(name); setObjectName(name);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setAcceptDrops(true); setAcceptDrops(true);
setStyleSheet(QString("QGraphicsView{background:#EEEEEE; border-radius:10px; border:2px solid #999999;}")); setStyleSheet(QString("QGraphicsView{background:#EEEEEE; border-radius:10px; border:2px solid #999999;}"));
mpScene = new UBPathScene(this); mpScene = new UBPathScene(this);
setScene(mpScene); setScene(mpScene);
mpContainer = new QGraphicsWidget(); mpContainer = new QGraphicsWidget();
mpContainer->setMinimumWidth(width() - 20); mpContainer->setMinimumWidth(width() - 20);
mpScene->addItem(mpContainer); mpScene->addItem(mpContainer);
mpLayout = new QGraphicsLinearLayout(); mpLayout = new QGraphicsLinearLayout();
mpContainer->setLayout(mpLayout); mpContainer->setLayout(mpLayout);
connect(mpScene, SIGNAL(mouseClick(UBChainedLibElement*)), this, SLOT(onMouseClicked(UBChainedLibElement*))); connect(mpScene, SIGNAL(mouseClick(UBChainedLibElement*)), this, SLOT(onMouseClicked(UBChainedLibElement*)));
connect(mpScene, SIGNAL(elementsDropped(QList<QString>,UBLibElement*)), this, SLOT(onElementsDropped(QList<QString>,UBLibElement*))); connect(mpScene, SIGNAL(elementsDropped(QList<QString>,UBLibElement*)), this, SLOT(onElementsDropped(QList<QString>,UBLibElement*)));
connect(horizontalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(onSliderMoved(int))); connect(horizontalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(onSliderMoved(int)));
} }
/** /**
* \brief Destructor * \brief Destructor
*/ */
UBLibPathViewer::~UBLibPathViewer() UBLibPathViewer::~UBLibPathViewer()
{ {
if(NULL != mpContainer) if(NULL != mpContainer)
{ {
delete mpContainer; delete mpContainer;
mpContainer = NULL; mpContainer = NULL;
} }
//if(NULL != mpLayout) //if(NULL != mpLayout)
//{ //{
// delete mpLayout; // delete mpLayout;
// mpLayout = NULL; // mpLayout = NULL;
//} //}
if(NULL != mpElems) if(NULL != mpElems)
{ {
delete mpElems; delete mpElems;
mpElems = NULL; mpElems = NULL;
} }
if(NULL != mpScene) if(NULL != mpScene)
{ {
delete mpScene; delete mpScene;
mpScene = NULL; mpScene = NULL;
} }
} }
/** /**
* \brief Display the current path * \brief Display the current path
* @param elementsChain as the path to display * @param elementsChain as the path to display
*/ */
void UBLibPathViewer::displayPath(UBChainedLibElement *elementsChain) void UBLibPathViewer::displayPath(UBChainedLibElement *elementsChain)
{ {
if(NULL != elementsChain) if(NULL != elementsChain)
{ {
mpElems = elementsChain; mpElems = elementsChain;
refreshPath(); refreshPath();
} }
} }
/** /**
* \brief Refresh the current path * \brief Refresh the current path
*/ */
void UBLibPathViewer::refreshPath() void UBLibPathViewer::refreshPath()
{ {
if (mpScene && mpContainer) if (mpScene && mpContainer)
mpScene->removeItem(mpContainer); mpScene->removeItem(mpContainer);
if(mpContainer) if(mpContainer)
delete mpContainer; delete mpContainer;
mVItems.clear(); mVItems.clear();
mpScene->mapWidgetToChainedElem()->clear(); mpScene->mapWidgetToChainedElem()->clear();
mpContainer = new QGraphicsWidget(); mpContainer = new QGraphicsWidget();
mpScene->addItem(mpContainer); mpScene->addItem(mpContainer);
mpLayout = new QGraphicsLinearLayout(); mpLayout = new QGraphicsLinearLayout();
mpContainer->setLayout(mpLayout); mpContainer->setLayout(mpLayout);
mSceneWidth = 0; mSceneWidth = 0;
addItem(mpElems); addItem(mpElems);
mpLayout->addStretch(); mpLayout->addStretch();
updateScrolls(); updateScrolls();
} }
/** /**
* \brief Handle the slider moved event * \brief Handle the slider moved event
* @param value as the current slider position * @param value as the current slider position
*/ */
void UBLibPathViewer::onSliderMoved(int value) void UBLibPathViewer::onSliderMoved(int value)
{ {
Q_UNUSED(value); Q_UNUSED(value);
} }
/** /**
* \brief Update the scroll bar status * \brief Update the scroll bar status
*/ */
void UBLibPathViewer::updateScrolls() void UBLibPathViewer::updateScrolls()
{ {
int iLimit = mSceneWidth + 40; // 2x 20 pixels margin int iLimit = mSceneWidth + 40; // 2x 20 pixels margin
int iVp = viewport()->width(); int iVp = viewport()->width();
if(iLimit >= iVp) if(iLimit >= iVp)
{ {
int iDiff = iLimit - iVp; int iDiff = iLimit - iVp;
horizontalScrollBar()->setRange(0, iDiff); horizontalScrollBar()->setRange(0, iDiff);
} }
else else
{ {
horizontalScrollBar()->setRange(0, 0); horizontalScrollBar()->setRange(0, 0);
} }
} }
/** /**
* \brief Append an item to the path * \brief Append an item to the path
* @param elem as the element to add to the path * @param elem as the element to add to the path
*/ */
void UBLibPathViewer::addItem(UBChainedLibElement *elem) void UBLibPathViewer::addItem(UBChainedLibElement *elem)
{ {
if(NULL != elem) if(NULL != elem)
{ {
// Add the icon // Add the icon
QLabel* pIconLabel = new QLabel(); QLabel* pIconLabel = new QLabel();
pIconLabel->setStyleSheet(QString("background-color: transparent;")); pIconLabel->setStyleSheet(QString("background-color: transparent;"));
pIconLabel->setPixmap((QPixmap::fromImage(*elem->element()->thumbnail())).scaledToWidth(PATHITEMWIDTH)); pIconLabel->setPixmap((QPixmap::fromImage(*elem->element()->thumbnail())).scaledToWidth(PATHITEMWIDTH));
UBFolderPath* iconWidget = reinterpret_cast<UBFolderPath*>(mpScene->addWidget(pIconLabel)); UBFolderPath* iconWidget = reinterpret_cast<UBFolderPath*>(mpScene->addWidget(pIconLabel));
//iconWidget->setToolTip(elem->element()->name()); //iconWidget->setToolTip(elem->element()->name());
iconWidget->setWindowFlags(Qt::BypassGraphicsProxyWidget); iconWidget->setWindowFlags(Qt::BypassGraphicsProxyWidget);
mpLayout->addItem(iconWidget); mpLayout->addItem(iconWidget);
mVItems << iconWidget; mVItems << iconWidget;
mpScene->mapWidgetToChainedElem()->insert(iconWidget,elem); mpScene->mapWidgetToChainedElem()->insert(iconWidget,elem);
mSceneWidth += pIconLabel->pixmap()->width() + 4; // 2px border mSceneWidth += pIconLabel->pixmap()->width() + 4; // 2px border
if(NULL != elem->nextElement()) if(NULL != elem->nextElement())
{ {
// Add the arrow // Add the arrow
QLabel* pArrowLabel = new QLabel(); QLabel* pArrowLabel = new QLabel();
pArrowLabel->setStyleSheet(QString("background-color: transparent;")); pArrowLabel->setStyleSheet(QString("background-color: transparent;"));
pArrowLabel->setPixmap(QPixmap(":images/navig_arrow.png")); pArrowLabel->setPixmap(QPixmap(":images/navig_arrow.png"));
QGraphicsWidget* arrowWidget = mpScene->addWidget(pArrowLabel); QGraphicsWidget* arrowWidget = mpScene->addWidget(pArrowLabel);
mpLayout->addItem(arrowWidget); mpLayout->addItem(arrowWidget);
mVItems << arrowWidget; mVItems << arrowWidget;
mSceneWidth += pArrowLabel->pixmap()->width() + 4; // 2px border mSceneWidth += pArrowLabel->pixmap()->width() + 4; // 2px border
// Recursively call this method while a next item exists // Recursively call this method while a next item exists
addItem(elem->nextElement()); addItem(elem->nextElement());
} }
} }
} }
/** /**
* \brief Handles the resize event * \brief Handles the resize event
* @param event as the resize event * @param event as the resize event
*/ */
void UBLibPathViewer::resizeEvent(QResizeEvent *event) void UBLibPathViewer::resizeEvent(QResizeEvent *event)
{ {
if(event->oldSize() == event->size()) if(event->oldSize() == event->size())
event->ignore(); event->ignore();
else{ else{
if(NULL != mpContainer) if(NULL != mpContainer)
mpContainer->setMinimumWidth(width() - 20); mpContainer->setMinimumWidth(width() - 20);
viewport()->resize(width() - 10, viewport()->height()); viewport()->resize(width() - 10, viewport()->height());
updateScrolls(); updateScrolls();
event->accept(); event->accept();
} }
} }
void UBLibPathViewer::showEvent(QShowEvent *event) void UBLibPathViewer::showEvent(QShowEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
updateScrolls(); updateScrolls();
} }
/** /**
* \brief Handles the mouse move event * \brief Handles the mouse move event
* @param event as the mouse move event * @param event as the mouse move event
*/ */
void UBLibPathViewer::mouseMoveEvent(QMouseEvent *event) void UBLibPathViewer::mouseMoveEvent(QMouseEvent *event)
{ {
event->ignore(); event->ignore();
} }
void UBLibPathViewer::onMouseClicked(UBChainedLibElement *elem) void UBLibPathViewer::onMouseClicked(UBChainedLibElement *elem)
{ {
emit mouseClick(elem); emit mouseClick(elem);
} }
int UBLibPathViewer::widgetAt(QPointF p) int UBLibPathViewer::widgetAt(QPointF p)
{ {
int position = -1; int position = -1;
for(int i = 0; i < mVItems.size(); i++) for(int i = 0; i < mVItems.size(); i++)
{ {
QGraphicsWidget* pCrntWidget = mVItems.at(i); QGraphicsWidget* pCrntWidget = mVItems.at(i);
if(NULL != pCrntWidget) if(NULL != pCrntWidget)
{ {
QRectF r = pCrntWidget->rect(); QRectF r = pCrntWidget->rect();
QPointF wPos = pCrntWidget->scenePos(); QPointF wPos = pCrntWidget->scenePos();
int xMin = wPos.x() + r.x(); int xMin = wPos.x() + r.x();
int xMax = wPos.x() + r.x() + r.width(); int xMax = wPos.x() + r.x() + r.width();
int yMin = wPos.y() + r.y(); int yMin = wPos.y() + r.y();
int yMax = wPos.y() + r.y() + r.height(); int yMax = wPos.y() + r.y() + r.height();
if(p.x() >= xMin && if(p.x() >= xMin &&
p.x() <= xMax && p.x() <= xMax &&
p.y() >= yMin && p.y() >= yMin &&
p.y() <= yMax) p.y() <= yMax)
{ {
return i; return i;
} }
} }
} }
return position; return position;
} }
void UBLibPathViewer::onElementsDropped(QList<QString> elements, UBLibElement *target) void UBLibPathViewer::onElementsDropped(QList<QString> elements, UBLibElement *target)
{ {
emit elementsDropped(elements, target); emit elementsDropped(elements, target);
} }
UBFolderPath::UBFolderPath():QGraphicsProxyWidget() UBFolderPath::UBFolderPath():QGraphicsProxyWidget()
{ {
} }
UBFolderPath::~UBFolderPath() UBFolderPath::~UBFolderPath()
{ {
} }
/** /**
* \brief Handles the drag enter event * \brief Handles the drag enter event
* @param pEvent as the drag enter event * @param pEvent as the drag enter event
*/ */
void UBFolderPath::dragEnterEvent(QGraphicsSceneDragDropEvent *event) void UBFolderPath::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{ {
event->acceptProposedAction(); event->acceptProposedAction();
} }
/** /**
* \brief Handles the drop event * \brief Handles the drop event
* @param pEvent as the drop event * @param pEvent as the drop event
*/ */
void UBFolderPath::dropEvent(QDropEvent *pEvent) void UBFolderPath::dropEvent(QDropEvent *pEvent)
{ {
processMimeData(pEvent->mimeData()); processMimeData(pEvent->mimeData());
pEvent->acceptProposedAction(); pEvent->acceptProposedAction();
} }
/** /**
* \brief Handles the drag move event * \brief Handles the drag move event
* @param pEvent as the drag move event * @param pEvent as the drag move event
*/ */
void UBFolderPath::dragMoveEvent(QDragMoveEvent* pEvent) void UBFolderPath::dragMoveEvent(QDragMoveEvent* pEvent)
{ {
pEvent->acceptProposedAction(); pEvent->acceptProposedAction();
} }
/** /**
* \brief Process the given MIME data * \brief Process the given MIME data
* @param pData as the MIME data to process * @param pData as the MIME data to process
*/ */
void UBFolderPath::processMimeData(const QMimeData *pData) void UBFolderPath::processMimeData(const QMimeData *pData)
{ {
Q_UNUSED(pData); Q_UNUSED(pData);
} }
/** /**
* \brief Handles the mouse press event * \brief Handles the mouse press event
* @param event as the mouse press event * @param event as the mouse press event
*/ */
void UBFolderPath::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBFolderPath::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
} }
/** /**
* \brief Handles the mouse move event * \brief Handles the mouse move event
* @param event as the mouse move event * @param event as the mouse move event
*/ */
void UBFolderPath::mouseMoveEvent(QMouseEvent *event) void UBFolderPath::mouseMoveEvent(QMouseEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
} }
/** /**
* \brief Handles the mouse release event * \brief Handles the mouse release event
* @param event as the mouse release event * @param event as the mouse release event
*/ */
void UBFolderPath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBFolderPath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
} }
UBPathScene::UBPathScene(QWidget* parent):QGraphicsScene(parent) UBPathScene::UBPathScene(QWidget* parent):QGraphicsScene(parent)
{ {
} }
UBPathScene::~UBPathScene() UBPathScene::~UBPathScene()
{ {
} }
void UBPathScene::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBPathScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton) if(event->button() == Qt::LeftButton)
{ {
mDragStartPos = event->scenePos(); mDragStartPos = event->scenePos();
mClickTime = QTime::currentTime(); mClickTime = QTime::currentTime();
} }
} }
/** /**
* \brief Handles the mouse release event * \brief Handles the mouse release event
* @param event as the mouse release event * @param event as the mouse release event
*/ */
void UBPathScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBPathScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
int elapsedTimeSincePress = mClickTime.elapsed(); int elapsedTimeSincePress = mClickTime.elapsed();
if(elapsedTimeSincePress < STARTDRAGTIME) if(elapsedTimeSincePress < STARTDRAGTIME)
{ {
QGraphicsWidget* pGWidget = dynamic_cast<QGraphicsWidget*>(itemAt(event->pos())); QGraphicsWidget* pGWidget = dynamic_cast<QGraphicsWidget*>(itemAt(event->pos()));
if(NULL != pGWidget) if(NULL != pGWidget)
{ {
// We have only one view at a time // We have only one view at a time
UBLibPathViewer* pView = dynamic_cast<UBLibPathViewer*>(this->views().at(0)); UBLibPathViewer* pView = dynamic_cast<UBLibPathViewer*>(this->views().at(0));
if(NULL != pView) if(NULL != pView)
{ {
int iClickedItem = pView->widgetAt(event->scenePos()); int iClickedItem = pView->widgetAt(event->scenePos());
if(-1 != iClickedItem) if(-1 != iClickedItem)
{ {
QGraphicsWidget* pFolderW = dynamic_cast<QGraphicsWidget*>(pGWidget->layout()->itemAt(iClickedItem)); QGraphicsWidget* pFolderW = dynamic_cast<QGraphicsWidget*>(pGWidget->layout()->itemAt(iClickedItem));
if(NULL != pFolderW) if(NULL != pFolderW)
{ {
UBChainedLibElement* chElem = mMapWidgetToChainedElem[pFolderW]; UBChainedLibElement* chElem = mMapWidgetToChainedElem[pFolderW];
if(NULL != chElem) if(NULL != chElem)
{ {
emit mouseClick(chElem); emit mouseClick(chElem);
} }
} }
} }
} }
} }
} }
} }
/** /**
* \brief Handles the mouse move event * \brief Handles the mouse move event
* @param event as the mouse move event * @param event as the mouse move event
*/ */
void UBPathScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBPathScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton) if(event->button() == Qt::LeftButton)
{ {
if((event->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()) if((event->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance())
{ {
// The user is not doing a drag // The user is not doing a drag
return; return;
} }
// The user is performing a drag operation // The user is performing a drag operation
QDrag* drag = new QDrag(event->widget()); QDrag* drag = new QDrag(event->widget());
QMimeData* mimeData = new QMimeData(); QMimeData* mimeData = new QMimeData();
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->start(); drag->start();
} }
} }
void UBPathScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event) void UBPathScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{ {
event->accept(); event->accept();
} }
void UBPathScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event) void UBPathScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{ {
event->accept(); event->accept();
} }
void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event) void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{ {
const QMimeData* pMimeData = event->mimeData(); const QMimeData* pMimeData = event->mimeData();
qDebug() << " Drop source : " << event->source()->metaObject()->className(); qDebug() << " Drop source : " << event->source()->metaObject()->className();
if(0 == QString::compare(event->source()->metaObject()->className(), "UBLibraryWidget")) if(0 == QString::compare(event->source()->metaObject()->className(), "UBLibraryWidget"))
{ {
UBLibElement* pTargetElement = elementFromPos(event->scenePos()); UBLibElement* pTargetElement = elementFromPos(event->scenePos());
if(NULL != pTargetElement) if(NULL != pTargetElement)
{ {
if(eUBLibElementType_Folder == pTargetElement->type()) if(eUBLibElementType_Folder == pTargetElement->type())
{ {
// The drag comes from this application, we have now to get the list of UBLibElements* // The drag comes from this application, we have now to get the list of UBLibElements*
QList<QString> qlDroppedElems; QList<QString> qlDroppedElems;
foreach(QUrl url, pMimeData->urls()) foreach(QUrl url, pMimeData->urls())
qlDroppedElems << url.toString(); qlDroppedElems << url.toString();
if(!qlDroppedElems.empty()) if(!qlDroppedElems.empty())
{ {
// Send a signal with the target dir and the list of ublibelement* // Send a signal with the target dir and the list of ublibelement*
emit elementsDropped(qlDroppedElems, pTargetElement); emit elementsDropped(qlDroppedElems, pTargetElement);
} }
} }
} }
event->accept(); event->accept();
} }
else else
{ {
event->ignore(); event->ignore();
} }
} }
/** /**
* \brief Return the element related to the given position * \brief Return the element related to the given position
* @param p as the given position * @param p as the given position
* *
*/ */
UBLibElement* UBPathScene::elementFromPos(QPointF p) UBLibElement* UBPathScene::elementFromPos(QPointF p)
{ {
UBLibElement* pElem = NULL; UBLibElement* pElem = NULL;
QGraphicsWidget* pGWidget = dynamic_cast<QGraphicsWidget*>(itemAt(p)); QGraphicsWidget* pGWidget = dynamic_cast<QGraphicsWidget*>(itemAt(p));
if(NULL != pGWidget) if(NULL != pGWidget)
{ {
UBChainedLibElement* chElem = mMapWidgetToChainedElem[pGWidget]; UBChainedLibElement* chElem = mMapWidgetToChainedElem[pGWidget];
if(NULL != chElem) if(NULL != chElem)
{ {
return chElem->element(); return chElem->element();
} }
} }
return pElem; return pElem;
} }

@ -35,11 +35,10 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
mIcon = QPixmap(":images/paletteNavigator.png"); mIcon = QPixmap(":images/paletteNavigator.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300; mLastWidth = 300;
setContentsMargins(0, 0, border(), 0);
// Build the gui // Build the gui
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
mLayout->setMargin(3); mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
setLayout(mLayout); setLayout(mLayout);
mNavigator = new UBDocumentNavigator(this); mNavigator = new UBDocumentNavigator(this);

@ -72,6 +72,7 @@ UBToolWidget::UBToolWidget(UBAbstractWidget* pWidget, QWidget* pParent)
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
{ {
mToolWidget->setParent(this); mToolWidget->setParent(this);
mToolWidget->loadMainHtml();
initialize(); initialize();

@ -30,7 +30,7 @@ PDFRenderer::~PDFRenderer()
// NOOP // NOOP
} }
PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &filename) PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &filename, bool importingFile)
{ {
if (sRenderers.contains(uuid)) if (sRenderers.contains(uuid))
{ {
@ -38,7 +38,7 @@ PDFRenderer* PDFRenderer::rendererForUuid(const QUuid &uuid, const QString &file
} }
else else
{ {
PDFRenderer *newRenderer = new XPDFRenderer(filename); PDFRenderer *newRenderer = new XPDFRenderer(filename,importingFile);
newRenderer->setRefCount(0); newRenderer->setRefCount(0);
newRenderer->setFileUuid(uuid); newRenderer->setFileUuid(uuid);

@ -31,7 +31,7 @@ class PDFRenderer : public QObject
Q_OBJECT Q_OBJECT
public: public:
static PDFRenderer* rendererForUuid(const QUuid &uuid, const QString &filename); static PDFRenderer* rendererForUuid(const QUuid &uuid, const QString &filename, bool importingFile = false);
virtual ~PDFRenderer(); virtual ~PDFRenderer();
virtual bool isValid() const = 0; virtual bool isValid() const = 0;

@ -19,18 +19,11 @@
#include <frameworks/UBPlatformUtils.h> #include <frameworks/UBPlatformUtils.h>
#include <splash/SplashBitmap.h>
#include <xpdf/Object.h>
#include <xpdf/GlobalParams.h>
#include <xpdf/SplashOutputDev.h>
#include <xpdf/PDFDoc.h>
#include "core/memcheck.h" #include "core/memcheck.h"
QAtomicInt XPDFRenderer::sInstancesCount = 0; QAtomicInt XPDFRenderer::sInstancesCount = 0;
XPDFRenderer::XPDFRenderer(const QString &filename) XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
: mDocument(0) : mDocument(0)
{ {
if (!globalParams) if (!globalParams)
@ -44,7 +37,13 @@ XPDFRenderer::XPDFRenderer(const QString &filename)
mDocument = new PDFDoc(new GString(filename.toUtf8().data()), 0, 0, 0); // the filename GString is deleted on PDFDoc desctruction mDocument = new PDFDoc(new GString(filename.toUtf8().data()), 0, 0, 0); // the filename GString is deleted on PDFDoc desctruction
sInstancesCount.ref(); sInstancesCount.ref();
bThumbGenerated = !importingFile;
bPagesGenerated = false;
mPagesMap.clear();
mThumbs.clear();
mThumbMap.clear();
mScaleX = 0.0;
mScaleY = 0.0;
} }
XPDFRenderer::~XPDFRenderer() XPDFRenderer::~XPDFRenderer()
@ -135,47 +134,114 @@ int XPDFRenderer::pageRotation(int pageNumber) const
return 0; return 0;
} }
void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds) void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds)
{ {
if (isValid())
{
qreal xscale = p->worldTransform().m11();
qreal yscale = p->worldTransform().m22();
bool bZoomChanged = false;
bool bFirstThumbnail = false;
if(fabs(mScaleX - xscale) > 0.1 || fabs(mScaleY - yscale) > 0.1)
{
mScaleX = xscale;
mScaleY = yscale;
bZoomChanged = true;
}
// First verify if the thumbnails and the pages are generated
if(!bThumbGenerated)
{
if(pageNumber == 1)
{
bFirstThumbnail = true;
}
if(!mThumbMap[pageNumber - 1])
{
// Generate the thumbnail
mThumbs << *createPDFImage(pageNumber, xscale, yscale, bounds);
mThumbMap[pageNumber - 1] = true;
if(pageNumber == mDocument->getNumPages())
{
bThumbGenerated = true;
}
}
}
else if(!bPagesGenerated || bZoomChanged)
{
if(!mPagesMap[pageNumber - 1] || bZoomChanged)
{
// Generate the page
mNumPageToPageMap[pageNumber] = *createPDFImage(pageNumber, xscale, yscale, bounds);
mPagesMap[pageNumber - 1] = true;
if(mPagesMap.size() == mDocument->getNumPages())
{
bPagesGenerated = true;
}
}
}
QImage pdfImage;
if(!bThumbGenerated || bFirstThumbnail)
{
pdfImage = mThumbs.at(pageNumber - 1);
}
else
{
pdfImage = mNumPageToPageMap[pageNumber];
}
QTransform savedTransform = p->worldTransform();
p->resetTransform();
QTime t;
t.start();
p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), pdfImage);
//qDebug() << "XPDFRenderer::render(...) execution time: " << t.elapsed() << "ms";
p->setWorldTransform(savedTransform);
}
}
QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const qreal yscale, const QRectF &bounds)
{
QImage* img = new QImage();
if (isValid()) if (isValid())
{ {
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
SplashOutputDev splash(splashModeRGB8, 1, gFalse, paperColor); mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
splash.startDoc(mDocument->getXRef()); mSplash->startDoc(mDocument->getXRef());
int hResolution = 72; int hResolution = 72;
int vResolution = 72; int vResolution = 72;
int rotation = 0; // in degrees (get it from the worldTransform if we want to support rotation) int rotation = 0; // in degrees (get it from the worldTransform if we want to support rotation)
GBool useMediaBox = gFalse; GBool useMediaBox = gFalse;
GBool crop = gTrue; GBool crop = gTrue;
GBool printing = gFalse; GBool printing = gFalse;
const qreal xScale = p->worldTransform().m11(); const qreal xScale = xscale;
const qreal yScale = p->worldTransform().m22(); const qreal yScale = yscale;
qreal sliceX = 0.; mSliceX = 0.;
qreal sliceY = 0.; mSliceY = 0.;
if (bounds.isNull()) if (bounds.isNull())
{ {
mDocument->displayPage(&splash, pageNumber, hResolution * xScale, vResolution * yScale, mDocument->displayPage(mSplash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing); rotation, useMediaBox, crop, printing);
} }
else else
{ {
sliceX = bounds.x() * xScale; mSliceX = bounds.x() * xScale;
sliceY = bounds.y() * yScale; mSliceY = bounds.y() * yScale;
qreal sliceW = bounds.width() * xScale; qreal sliceW = bounds.width() * xScale;
qreal sliceH = bounds.height() * yScale; qreal sliceH = bounds.height() * yScale;
mDocument->displayPageSlice(&splash, pageNumber, hResolution * xScale, vResolution * yScale, mDocument->displayPageSlice(mSplash, pageNumber, hResolution * xScale, vResolution * yScale,
rotation, useMediaBox, crop, printing, sliceX, sliceY, sliceW, sliceH); rotation, useMediaBox, crop, printing, mSliceX, mSliceY, sliceW, sliceH);
} }
SplashBitmap *bitmap = splash.getBitmap(); mpSplashBitmap = mSplash->getBitmap();
QImage pdfImage(bitmap->getDataPtr(), bitmap->getWidth(), bitmap->getHeight(), bitmap->getWidth() * 3, QImage::Format_RGB888); img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888);
QTransform savedTransform = p->worldTransform();
p->resetTransform();
p->drawImage(QPointF(savedTransform.dx() + sliceX, savedTransform.dy() + sliceY), pdfImage);
p->setWorldTransform(savedTransform);
} }
} return img;
}

@ -30,7 +30,7 @@ class XPDFRenderer : public PDFRenderer
Q_OBJECT Q_OBJECT
public: public:
XPDFRenderer(const QString &filename); XPDFRenderer(const QString &filename, bool importingFile = false);
virtual ~XPDFRenderer(); virtual ~XPDFRenderer();
bool isValid() const; bool isValid() const;

@ -29,28 +29,28 @@ const UBGraphicsTriangle::UBGraphicsTriangleOrientation UBGraphicsTriangle::sDef
UBGraphicsTriangle::BottomLeft; UBGraphicsTriangle::BottomLeft;
UBGraphicsTriangle::UBGraphicsTriangle() UBGraphicsTriangle::UBGraphicsTriangle()
: QGraphicsPolygonItem() : QGraphicsPolygonItem()
, UBAbstractDrawRuler() , UBAbstractDrawRuler()
, mResizing1(false) , mResizing1(false)
, mResizing2(false) , mResizing2(false)
, mRotating(false) , mRotating(false)
, angle(0) , angle(0)
{ {
setRect(sDefaultRect, sDefaultOrientation); setRect(sDefaultRect, sDefaultOrientation);
create(*this); create(*this);
mHFlipSvgItem = new QGraphicsSvgItem(":/images/hflipTool.svg", this); mHFlipSvgItem = new QGraphicsSvgItem(":/images/hflipTool.svg", this);
mHFlipSvgItem->setVisible(false); mHFlipSvgItem->setVisible(false);
mHFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mHFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mVFlipSvgItem = new QGraphicsSvgItem(":/images/vflipTool.svg", this); mVFlipSvgItem = new QGraphicsSvgItem(":/images/vflipTool.svg", this);
mVFlipSvgItem->setVisible(false); mVFlipSvgItem->setVisible(false);
mVFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mVFlipSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mRotateSvgItem = new QGraphicsSvgItem(":/images/rotateTool.svg", this); mRotateSvgItem = new QGraphicsSvgItem(":/images/rotateTool.svg", this);
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
@ -89,10 +89,10 @@ UBGraphicsTriangle::~UBGraphicsTriangle()
UBItem* UBGraphicsTriangle::deepCopy(void) const UBItem* UBGraphicsTriangle::deepCopy(void) const
{ {
UBGraphicsTriangle* copy = new UBGraphicsTriangle(); UBGraphicsTriangle* copy = new UBGraphicsTriangle();
copy->setPos(this->pos()); copy->setPos(this->pos());
copy->setPolygon(this->polygon()); copy->setPolygon(this->polygon());
copy->setZValue(this->zValue()); copy->setZValue(this->zValue());
copy->setTransform(this->transform()); copy->setTransform(this->transform());
@ -104,11 +104,11 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation) void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation)
{ {
QPolygonF polygon; QPolygonF polygon;
polygon << QPointF(x, y) << QPoint(x, y + h) << QPoint(x+w, y + h); polygon << QPointF(x, y) << QPoint(x, y + h) << QPoint(x+w, y + h);
setPolygon(polygon); setPolygon(polygon);
setOrientation(orientation); setOrientation(orientation);
} }
void UBGraphicsTriangle::setOrientation(UBGraphicsTriangleOrientation orientation) void UBGraphicsTriangle::setOrientation(UBGraphicsTriangleOrientation orientation)
@ -123,7 +123,7 @@ void UBGraphicsTriangle::setOrientation(UBGraphicsTriangleOrientation orientatio
UBGraphicsScene* UBGraphicsTriangle::scene() const UBGraphicsScene* UBGraphicsTriangle::scene() const
{ {
return static_cast<UBGraphicsScene*>(QGraphicsPolygonItem::scene()); return static_cast<UBGraphicsScene*>(QGraphicsPolygonItem::scene());
} }
void UBGraphicsTriangle::calculatePoints(const QRectF& r) void UBGraphicsTriangle::calculatePoints(const QRectF& r)
@ -152,9 +152,9 @@ void UBGraphicsTriangle::calculatePoints(const QRectF& r)
break; break;
} }
C = sqrt(rect().width() * rect().width() + rect().height() * rect().height()); C = sqrt(rect().width() * rect().width() + rect().height() * rect().height());
qreal L = (C * d + rect().width() * d)/ rect().height(); qreal L = (C * d + rect().width() * d)/ rect().height();
qreal K = (C * d + rect().height() * d)/ rect().width(); qreal K = (C * d + rect().height() * d)/ rect().width();
switch(mOrientation) switch(mOrientation)
{ {
@ -179,8 +179,8 @@ void UBGraphicsTriangle::calculatePoints(const QRectF& r)
C2.setX(r.left() + L); C2.setY(r.bottom() - d); C2.setX(r.left() + L); C2.setY(r.bottom() - d);
break; break;
} }
W1 = rect().height() * d / C; W1 = rect().height() * d / C;
H1 = rect().width() * d / C; H1 = rect().width() * d / C;
switch(mOrientation) switch(mOrientation)
{ {
@ -202,69 +202,69 @@ void UBGraphicsTriangle::calculatePoints(const QRectF& r)
void UBGraphicsTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) void UBGraphicsTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{ {
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
QPolygonF polygon;
QLinearGradient gradient1(QPointF(A1.x(), 0), QPointF(A2.x(), 0));
gradient1.setColorAt(0, edgeFillColor());
gradient1.setColorAt(1, middleFillColor());
painter->setBrush(gradient1);
polygon << A1 << A2 << B2 << B1;
painter->drawPolygon(polygon);
polygon.clear();
QLinearGradient gradient2(QPointF(0, B1.y()), QPointF(0, B2.y()));
gradient2.setColorAt(0, edgeFillColor());
gradient2.setColorAt(1, middleFillColor());
painter->setBrush(gradient2);
polygon << B1 << B2 << C2 << C1;
painter->drawPolygon(polygon);
polygon.clear();
QLinearGradient gradient3(CC, C2);
gradient3.setColorAt(0, edgeFillColor());
gradient3.setColorAt(1, middleFillColor());
painter->setBrush(gradient3);
polygon << C1 << C2 << A2 << A1;
painter->drawPolygon(polygon);
polygon.clear();
QPolygonF polygon;
painter->setBrush(Qt::NoBrush); QLinearGradient gradient1(QPointF(A1.x(), 0), QPointF(A2.x(), 0));
painter->setPen(drawColor()); gradient1.setColorAt(0, edgeFillColor());
gradient1.setColorAt(1, middleFillColor());
painter->setBrush(gradient1);
polygon << A1 << A2 << B2 << B1;
painter->drawPolygon(polygon);
polygon.clear();
QLinearGradient gradient2(QPointF(0, B1.y()), QPointF(0, B2.y()));
gradient2.setColorAt(0, edgeFillColor());
gradient2.setColorAt(1, middleFillColor());
painter->setBrush(gradient2);
polygon << B1 << B2 << C2 << C1;
painter->drawPolygon(polygon);
polygon.clear();
QLinearGradient gradient3(CC, C2);
gradient3.setColorAt(0, edgeFillColor());
gradient3.setColorAt(1, middleFillColor());
painter->setBrush(gradient3);
polygon << C1 << C2 << A2 << A1;
painter->drawPolygon(polygon);
polygon.clear();
painter->setBrush(Qt::NoBrush);
painter->setPen(drawColor());
polygon << A1 << B1 << C1; polygon << A1 << B1 << C1;
painter->drawPolygon(polygon); painter->drawPolygon(polygon);
polygon.clear(); polygon.clear();
polygon << A2 << B2 << C2; polygon << A2 << B2 << C2;
painter->drawPolygon(polygon); painter->drawPolygon(polygon);
paintGraduations(painter); paintGraduations(painter);
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
QTransform antiScaleTransform; QTransform antiScaleTransform;
antiScaleTransform.scale(mAntiScaleRatio, mAntiScaleRatio); antiScaleTransform.scale(mAntiScaleRatio, mAntiScaleRatio);
mCloseSvgItem->setTransform(antiScaleTransform); mCloseSvgItem->setTransform(antiScaleTransform);
mHFlipSvgItem->setTransform(antiScaleTransform); mHFlipSvgItem->setTransform(antiScaleTransform);
mVFlipSvgItem->setTransform(antiScaleTransform); mVFlipSvgItem->setTransform(antiScaleTransform);
mRotateSvgItem->setTransform(antiScaleTransform); mRotateSvgItem->setTransform(antiScaleTransform);
mCloseSvgItem->setPos(closeButtonRect().topLeft()); mCloseSvgItem->setPos(closeButtonRect().topLeft());
mHFlipSvgItem->setPos(hFlipRect().topLeft()); mHFlipSvgItem->setPos(hFlipRect().topLeft());
mVFlipSvgItem->setPos(vFlipRect().topLeft()); mVFlipSvgItem->setPos(vFlipRect().topLeft());
mRotateSvgItem->setPos(rotateRect().topLeft()); mRotateSvgItem->setPos(rotateRect().topLeft());
if (mShowButtons || mResizing1 || mResizing2) if (mShowButtons || mResizing1 || mResizing2)
{ {
painter->setBrush(QColor(0, 0, 0)); painter->setBrush(QColor(0, 0, 0));
if (mShowButtons || mResizing1) if (mShowButtons || mResizing1)
painter->drawPolygon(resize1Polygon()); painter->drawPolygon(resize1Polygon());
if (mShowButtons || mResizing2) if (mShowButtons || mResizing2)
painter->drawPolygon(resize2Polygon()); painter->drawPolygon(resize2Polygon());
} }
} }
void UBGraphicsTriangle::paintGraduations(QPainter *painter) void UBGraphicsTriangle::paintGraduations(QPainter *painter)
@ -289,29 +289,29 @@ void UBGraphicsTriangle::paintGraduations(QPainter *painter)
((0 == millimeters % millimetersPerHalfCentimeter) ? ((0 == millimeters % millimetersPerHalfCentimeter) ?
halfCentimeterGraduationHeight : millimeterGraduationHeight); halfCentimeterGraduationHeight : millimeterGraduationHeight);
// Check that grad. line inside triangle // Check that grad. line inside triangle
qreal dx = (kx > 0) ? rect().width() - graduationX : graduationX - rect().x(); qreal dx = (kx > 0) ? rect().width() - graduationX : graduationX - rect().x();
qreal lineY = rotationCenter().y() - ky * rect().height()/rect().width() * dx; qreal lineY = rotationCenter().y() - ky * rect().height()/rect().width() * dx;
if (mOrientation == BottomLeft || mOrientation == BottomRight) if (mOrientation == BottomLeft || mOrientation == BottomRight)
{ {
if (lineY >= rotationCenter().y() - ky * graduationHeight) if (lineY >= rotationCenter().y() - ky * graduationHeight)
break; break;
} }
else else
{ {
if (lineY <= rotationCenter().y() - ky * graduationHeight) if (lineY <= rotationCenter().y() - ky * graduationHeight)
break; break;
} }
painter->drawLine(QLine(graduationX, rotationCenter().y(), graduationX, rotationCenter().y() - ky * graduationHeight)); painter->drawLine(QLine(graduationX, rotationCenter().y(), graduationX, rotationCenter().y() - ky * graduationHeight));
if (0 == millimeters % millimetersPerCentimeter) if (0 == millimeters % millimetersPerCentimeter)
{ {
QString text = QString("%1").arg((int)(millimeters / millimetersPerCentimeter)); QString text = QString("%1").arg((int)(millimeters / millimetersPerCentimeter));
int textXRight = graduationX + fontMetrics.width(text) / 2; int textXRight = graduationX + fontMetrics.width(text) / 2;
qreal textWidth = fontMetrics.width(text); qreal textWidth = fontMetrics.width(text);
qreal textHeight = fontMetrics.tightBoundingRect(text).height() + 5; qreal textHeight = fontMetrics.tightBoundingRect(text).height() + 5;
int textY = (ky > 0) ? rotationCenter().y() - 5 - centimeterGraduationHeight - textHeight int textY = (ky > 0) ? rotationCenter().y() - 5 - centimeterGraduationHeight - textHeight
: rotationCenter().y() + 5 + centimeterGraduationHeight; : rotationCenter().y() + 5 + centimeterGraduationHeight;
bool bText = false; bool bText = false;
@ -342,7 +342,7 @@ void UBGraphicsTriangle::paintGraduations(QPainter *painter)
if (bText) if (bText)
painter->drawText( painter->drawText(
QRectF(graduationX - textWidth / 2, QRectF(graduationX - textWidth / 2,
textY, textWidth, textHeight), textY, textWidth, textHeight),
Qt::AlignVCenter, text); Qt::AlignVCenter, text);
} }
@ -369,7 +369,7 @@ void UBGraphicsTriangle::rotateAroundCenter(QTransform& transform, QPointF cente
} }
QPointF UBGraphicsTriangle::rotationCenter() const QPointF UBGraphicsTriangle::rotationCenter() const
{ {
switch(mOrientation) switch(mOrientation)
{ {
@ -383,30 +383,30 @@ QPointF UBGraphicsTriangle::rotationCenter() const
return QPointF(0, 0); return QPointF(0, 0);
} }
QRectF UBGraphicsTriangle::closeButtonRect() const QRectF UBGraphicsTriangle::closeButtonRect() const
{ {
switch(mOrientation) switch(mOrientation)
{ {
case BottomLeft: case BottomLeft:
return QRectF(B2.x() - mCloseSvgItem->boundingRect().width() - 5, return QRectF(B2.x() - mCloseSvgItem->boundingRect().width() - 5,
B2.y() - mCloseSvgItem->boundingRect().height() - 5, B2.y() - mCloseSvgItem->boundingRect().height() - 5,
mCloseSvgItem->boundingRect().width(), mCloseSvgItem->boundingRect().width(),
mCloseSvgItem->boundingRect().height()); mCloseSvgItem->boundingRect().height());
case TopLeft: case TopLeft:
return QRectF(B2.x() - mCloseSvgItem->boundingRect().width() - 5, return QRectF(B2.x() - mCloseSvgItem->boundingRect().width() - 5,
B2.y() + 5, B2.y() + 5,
mCloseSvgItem->boundingRect().width(), mCloseSvgItem->boundingRect().width(),
mCloseSvgItem->boundingRect().height()); mCloseSvgItem->boundingRect().height());
case TopRight: case TopRight:
return QRectF(B2.x() + 5, return QRectF(B2.x() + 5,
B2.y() + 5, B2.y() + 5,
mCloseSvgItem->boundingRect().width(), mCloseSvgItem->boundingRect().width(),
mCloseSvgItem->boundingRect().height()); mCloseSvgItem->boundingRect().height());
case BottomRight: case BottomRight:
return QRectF(B2.x() + 5, return QRectF(B2.x() + 5,
B2.y() - mCloseSvgItem->boundingRect().height() - 5, B2.y() - mCloseSvgItem->boundingRect().height() - 5,
mCloseSvgItem->boundingRect().width(), mCloseSvgItem->boundingRect().width(),
mCloseSvgItem->boundingRect().height()); mCloseSvgItem->boundingRect().height());
} }
return QRectF(0,0,0,0); return QRectF(0,0,0,0);
} }
@ -435,9 +435,9 @@ QPolygonF UBGraphicsTriangle::resize1Polygon() const
} }
QPointF P1(C1.x() + x1 * sArrowLength, C1.y()); QPointF P1(C1.x() + x1 * sArrowLength, C1.y());
QPointF P2(C1.x() + x1 * sArrowLength * rect().width()/C, C1.y() + y1 * sArrowLength * rect().height() / C); QPointF P2(C1.x() + x1 * sArrowLength * rect().width()/C, C1.y() + y1 * sArrowLength * rect().height() / C);
QPolygonF p; QPolygonF p;
p << C1 << P1 << P2; p << C1 << P1 << P2;
return p; return p;
} }
QPolygonF UBGraphicsTriangle::resize2Polygon() const QPolygonF UBGraphicsTriangle::resize2Polygon() const
@ -465,70 +465,70 @@ QPolygonF UBGraphicsTriangle::resize2Polygon() const
QPointF P1(A1.x(), A1.y() + y1 * sArrowLength); QPointF P1(A1.x(), A1.y() + y1 * sArrowLength);
QPointF P2(A1.x() + x1 * sArrowLength * rect().width()/C, QPointF P2(A1.x() + x1 * sArrowLength * rect().width()/C,
A1.y() + y1 * sArrowLength * rect().height() / C); A1.y() + y1 * sArrowLength * rect().height() / C);
QPolygonF p; QPolygonF p;
p << A1 << P1 << P2; p << A1 << P1 << P2;
return p; return p;
} }
QRectF UBGraphicsTriangle::hFlipRect() const QRectF UBGraphicsTriangle::hFlipRect() const
{ {
qreal dy = mVFlipSvgItem->boundingRect().height() + mCloseSvgItem->boundingRect().height() + 10; qreal dy = mVFlipSvgItem->boundingRect().height() + mCloseSvgItem->boundingRect().height() + 10;
switch(mOrientation) switch(mOrientation)
{ {
case BottomLeft: case BottomLeft:
return QRectF(B2.x() - mHFlipSvgItem->boundingRect().width() - 5, return QRectF(B2.x() - mHFlipSvgItem->boundingRect().width() - 5,
B2.y() - mHFlipSvgItem->boundingRect().height() - 5 - dy, B2.y() - mHFlipSvgItem->boundingRect().height() - 5 - dy,
mHFlipSvgItem->boundingRect().width(), mHFlipSvgItem->boundingRect().width(),
mHFlipSvgItem->boundingRect().height()); mHFlipSvgItem->boundingRect().height());
case TopLeft: case TopLeft:
return QRectF(B2.x() - mHFlipSvgItem->boundingRect().width() - 5, return QRectF(B2.x() - mHFlipSvgItem->boundingRect().width() - 5,
B2.y() + 5 + dy, B2.y() + 5 + dy,
mHFlipSvgItem->boundingRect().width(), mHFlipSvgItem->boundingRect().width(),
mHFlipSvgItem->boundingRect().height()); mHFlipSvgItem->boundingRect().height());
case TopRight: case TopRight:
return QRectF(B2.x() + 5, return QRectF(B2.x() + 5,
B2.y() + 5 + dy, B2.y() + 5 + dy,
mHFlipSvgItem->boundingRect().width(), mHFlipSvgItem->boundingRect().width(),
mHFlipSvgItem->boundingRect().height()); mHFlipSvgItem->boundingRect().height());
case BottomRight: case BottomRight:
return QRectF(B2.x() + 5, return QRectF(B2.x() + 5,
B2.y() - mHFlipSvgItem->boundingRect().height() - 5 - dy, B2.y() - mHFlipSvgItem->boundingRect().height() - 5 - dy,
mHFlipSvgItem->boundingRect().width(), mHFlipSvgItem->boundingRect().width(),
mHFlipSvgItem->boundingRect().height()); mHFlipSvgItem->boundingRect().height());
} }
return QRectF(0,0,0,0); return QRectF(0,0,0,0);
} }
QRectF UBGraphicsTriangle::vFlipRect() const QRectF UBGraphicsTriangle::vFlipRect() const
{ {
qreal dy = mCloseSvgItem->boundingRect().height() + 5; qreal dy = mCloseSvgItem->boundingRect().height() + 5;
switch(mOrientation) switch(mOrientation)
{ {
case BottomLeft: case BottomLeft:
return QRectF(B2.x() - mVFlipSvgItem->boundingRect().width() - 5, return QRectF(B2.x() - mVFlipSvgItem->boundingRect().width() - 5,
B2.y() - mVFlipSvgItem->boundingRect().height() - 5 - dy, B2.y() - mVFlipSvgItem->boundingRect().height() - 5 - dy,
mVFlipSvgItem->boundingRect().width(), mVFlipSvgItem->boundingRect().width(),
mVFlipSvgItem->boundingRect().height()); mVFlipSvgItem->boundingRect().height());
case TopLeft: case TopLeft:
return QRectF(B2.x() - mVFlipSvgItem->boundingRect().width() - 5, return QRectF(B2.x() - mVFlipSvgItem->boundingRect().width() - 5,
B2.y() + 5 + dy, B2.y() + 5 + dy,
mVFlipSvgItem->boundingRect().width(), mVFlipSvgItem->boundingRect().width(),
mVFlipSvgItem->boundingRect().height()); mVFlipSvgItem->boundingRect().height());
case TopRight: case TopRight:
return QRectF(B2.x() + 5, return QRectF(B2.x() + 5,
B2.y() + 5 + dy, B2.y() + 5 + dy,
mVFlipSvgItem->boundingRect().width(), mVFlipSvgItem->boundingRect().width(),
mVFlipSvgItem->boundingRect().height()); mVFlipSvgItem->boundingRect().height());
case BottomRight: case BottomRight:
return QRectF(B2.x() + 5, return QRectF(B2.x() + 5,
B2.y() - mVFlipSvgItem->boundingRect().height() - 5 - dy, B2.y() - mVFlipSvgItem->boundingRect().height() - 5 - dy,
mVFlipSvgItem->boundingRect().width(), mVFlipSvgItem->boundingRect().width(),
mVFlipSvgItem->boundingRect().height()); mVFlipSvgItem->boundingRect().height());
} }
return QRectF(0,0,0,0); return QRectF(0,0,0,0);
} }
QRectF UBGraphicsTriangle::rotateRect() const QRectF UBGraphicsTriangle::rotateRect() const
{ {
QPointF p(C2); QPointF p(C2);
switch(mOrientation) switch(mOrientation)
@ -546,122 +546,124 @@ QRectF UBGraphicsTriangle::rotateRect() const
p += QPointF(-20 - mRotateSvgItem->boundingRect().width(), 5); p += QPointF(-20 - mRotateSvgItem->boundingRect().width(), 5);
break; break;
} }
return QRectF(p, QSizeF(mRotateSvgItem->boundingRect().size())); return QRectF(p, QSizeF(mRotateSvgItem->boundingRect().size()));
} }
QCursor UBGraphicsTriangle::resizeCursor1() const QCursor UBGraphicsTriangle::resizeCursor1() const
{ {
return mResizeCursor1; return mResizeCursor1;
} }
QCursor UBGraphicsTriangle::resizeCursor2() const QCursor UBGraphicsTriangle::resizeCursor2() const
{ {
return mResizeCursor2; return mResizeCursor2;
} }
QCursor UBGraphicsTriangle::flipCursor() const QCursor UBGraphicsTriangle::flipCursor() const
{ {
return Qt::ArrowCursor; return Qt::ArrowCursor;
} }
void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) lastRect = rect().toRect();
lastPos = event->screenPos();
if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
{ {
mResizing1 = true; mResizing1 = true;
event->accept(); event->accept();
} }
else if (resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) else
if (resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
{
mResizing2 = true;
event->accept();
}
else
if(rotateRect().contains(event->pos()))
{ {
mResizing2 = true; mRotating = true;
event->accept(); event->accept();
} }
else if(rotateRect().contains(event->pos()))
{
mRotating = true;
event->accept();
}
else else
{ {
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
} }
mShowButtons = false; mShowButtons = false;
mCloseSvgItem->setVisible(false); mCloseSvgItem->setVisible(false);
mHFlipSvgItem->setVisible(false); mHFlipSvgItem->setVisible(false);
mVFlipSvgItem->setVisible(false); mVFlipSvgItem->setVisible(false);
mRotateSvgItem->setVisible(mRotating); mRotateSvgItem->setVisible(mRotating);
update(); update();
} }
void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
QPoint currPos = event->screenPos();
// qDebug() << QString(" X: %1 ").arg(currPos.x());
// qDebug() << QString(" Y: %1 ").arg(currPos.y());
if (!mResizing1 && !mResizing2 && !mRotating) if (!mResizing1 && !mResizing2 && !mRotating)
{ {
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
} }
else else
{ {
if (mResizing1)
{ //-----------------------------------------------//
QPointF delta = event->pos() - event->lastPos();
if (mResizing1)
{
if (mOrientation == TopLeft || mOrientation == BottomLeft) if (mOrientation == TopLeft || mOrientation == BottomLeft)
{ {
if (rect().width() + delta.x() < (qreal)sMinWidth) int deltaX = currPos.x() - lastPos.x();
delta.setX((qreal)sMinWidth - rect().width()); if (lastRect.width() + deltaX < sMinWidth)
deltaX = sMinWidth - lastRect.width();
setRect(QRectF(lastRect.left(), lastRect.top(),
lastRect.width() + deltaX, lastRect.height()), mOrientation);
} }
else else
{ {
if (rect().width() - delta.x() < (qreal)sMinWidth) int deltaX = lastPos.x() - currPos.x();
delta.setX((qreal)sMinWidth - rect().width()); if (lastRect.width() + deltaX < sMinWidth)
deltaX = sMinWidth - lastRect.width();
setRect(QRectF(lastRect.left() - deltaX, lastRect.top(),
lastRect.width() + deltaX, lastRect.height()), mOrientation);
} }
if (mOrientation == TopLeft || mOrientation == BottomLeft) }
{
setRect(QRectF( //-----------------------------------------------//
rect().topLeft(),
QSizeF(rect().width() + delta.x(), if (mResizing2)
rect().height())), {
mOrientation);
}
else
{
setRect(QRectF(
rect().left() + delta.x(),
rect().top(),
rect().width() - delta.x(),
rect().height()),
mOrientation
);
}
}
if (mResizing2)
{
QPointF delta = event->pos() - event->lastPos();
if (mOrientation == BottomRight || mOrientation == BottomLeft) if (mOrientation == BottomRight || mOrientation == BottomLeft)
{ {
if (rect().height() - delta.y() < (qreal)sMinHeight) int deltaY = lastPos.y() - currPos.y();
delta.setY((qreal)sMinHeight - rect().height()); if (lastRect.height() + deltaY < sMinHeight)
deltaY = sMinHeight - lastRect.height();
setRect(QRectF(lastRect.left(), lastRect.top() - deltaY,
lastRect.width(), lastRect.height() + deltaY), mOrientation);
} }
else else
{ {
if (rect().height() + delta.y() < (qreal)sMinHeight) int deltaY = currPos.y() - lastPos.y();
delta.setY((qreal)sMinHeight - rect().height()); if (lastRect.height() + deltaY < sMinHeight)
deltaY = sMinHeight - lastRect.height();
setRect(QRectF(lastRect.left(), lastRect.top(),
lastRect.width(), lastRect.height() + deltaY), mOrientation);
} }
if (mOrientation == BottomRight || mOrientation == BottomLeft)
setRect(QRectF( }
rect().left(),
rect().top() + delta.y(), //-----------------------------------------------//
rect().width(),
rect().height() - delta.y()),
mOrientation);
else
setRect(QRectF(
rect().left(),
rect().top(),
rect().width(),
rect().height() + delta.y()),
mOrientation);
}
if (mRotating) if (mRotating)
{ {
QLineF currentLine(rotationCenter(), event->pos()); QLineF currentLine(rotationCenter(), event->pos());
@ -669,104 +671,106 @@ void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
rotateAroundCenter(currentLine.angleTo(lastLine)); rotateAroundCenter(currentLine.angleTo(lastLine));
} }
//-----------------------------------------------//
event->accept(); event->accept();
} }
} }
void UBGraphicsTriangle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTriangle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mResizing1 || mResizing2 || mRotating) if (mResizing1 || mResizing2 || mRotating)
{ {
if (mRotating) if (mRotating)
updateResizeCursor(); updateResizeCursor();
mResizing1 = false; mResizing1 = false;
mResizing2 = false; mResizing2 = false;
mRotating = false; mRotating = false;
event->accept(); event->accept();
} }
else if (closeButtonRect().contains(event->pos())) else if (closeButtonRect().contains(event->pos()))
{ {
hide(); hide();
emit hidden(); emit hidden();
event->accept(); event->accept();
} }
else if (hFlipRect().contains(event->pos())) else if (hFlipRect().contains(event->pos()))
{ {
switch(mOrientation) switch(mOrientation)
{ {
case BottomLeft: case BottomLeft:
setOrientation(BottomRight); setOrientation(BottomRight);
break; break;
case BottomRight: case BottomRight:
setOrientation(BottomLeft); setOrientation(BottomLeft);
break; break;
case TopLeft: case TopLeft:
setOrientation(TopRight); setOrientation(TopRight);
break; break;
case TopRight: case TopRight:
setOrientation(TopLeft); setOrientation(TopLeft);
break; break;
} }
} }
else if (vFlipRect().contains(event->pos())) else if (vFlipRect().contains(event->pos()))
{ {
switch(mOrientation) switch(mOrientation)
{ {
case BottomLeft: case BottomLeft:
setOrientation(TopLeft); setOrientation(TopLeft);
break; break;
case BottomRight: case BottomRight:
setOrientation(TopRight); setOrientation(TopRight);
break; break;
case TopLeft: case TopLeft:
setOrientation(BottomLeft); setOrientation(BottomLeft);
break; break;
case TopRight: case TopRight:
setOrientation(BottomRight); setOrientation(BottomRight);
break; break;
} }
} }
else else
{ {
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
mShowButtons = true; mShowButtons = true;
update(); update();
if (scene()) if (scene())
scene()->setModified(true); scene()->setModified(true);
} }
void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector)
{ {
mCloseSvgItem->setParentItem(this); mCloseSvgItem->setParentItem(this);
mShowButtons = true; mShowButtons = true;
mCloseSvgItem->setVisible(true); mCloseSvgItem->setVisible(true);
mHFlipSvgItem->setVisible(true); mHFlipSvgItem->setVisible(true);
mVFlipSvgItem->setVisible(true); mVFlipSvgItem->setVisible(true);
mRotateSvgItem->setVisible(true); mRotateSvgItem->setVisible(true);
if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
setCursor(resizeCursor1()); setCursor(resizeCursor1());
else if(resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) else if(resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
setCursor(resizeCursor2()); setCursor(resizeCursor2());
else if (closeButtonRect().contains(event->pos())) else if (closeButtonRect().contains(event->pos()))
setCursor(closeCursor()); setCursor(closeCursor());
else if (hFlipRect().contains(event->pos()) else if (hFlipRect().contains(event->pos())
|| vFlipRect().contains(event->pos())) || vFlipRect().contains(event->pos()))
setCursor(flipCursor()); setCursor(flipCursor());
else if (rotateRect().contains(event->pos())) else if (rotateRect().contains(event->pos()))
setCursor(rotateCursor()); setCursor(rotateCursor());
else else
setCursor(moveCursor()); setCursor(moveCursor());
event->accept(); event->accept();
update(); update();
} }
} }
void UBGraphicsTriangle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsTriangle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
@ -774,8 +778,8 @@ void UBGraphicsTriangle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mShowButtons = false; mShowButtons = false;
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
mCloseSvgItem->setVisible(false); mCloseSvgItem->setVisible(false);
mVFlipSvgItem->setVisible(false); mVFlipSvgItem->setVisible(false);
mHFlipSvgItem->setVisible(false); mHFlipSvgItem->setVisible(false);
mRotateSvgItem->setVisible(false); mRotateSvgItem->setVisible(false);
event->accept(); event->accept();
update(); update();
@ -783,29 +787,29 @@ void UBGraphicsTriangle::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsTriangle::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsTriangle::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (currentTool == UBStylusTool::Selector) if (currentTool == UBStylusTool::Selector)
{ {
mCloseSvgItem->setVisible(mShowButtons); mCloseSvgItem->setVisible(mShowButtons);
mVFlipSvgItem->setVisible(mShowButtons); mVFlipSvgItem->setVisible(mShowButtons);
mHFlipSvgItem->setVisible(mShowButtons); mHFlipSvgItem->setVisible(mShowButtons);
mRotateSvgItem->setVisible(mShowButtons); mRotateSvgItem->setVisible(mShowButtons);
if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
setCursor(resizeCursor1()); setCursor(resizeCursor1());
else if (resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) else if (resize2Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill))
setCursor(resizeCursor2()); setCursor(resizeCursor2());
else if (closeButtonRect().contains(event->pos())) else if (closeButtonRect().contains(event->pos()))
setCursor(closeCursor()); setCursor(closeCursor());
else if (hFlipRect().contains(event->pos()) else if (hFlipRect().contains(event->pos())
|| vFlipRect().contains(event->pos())) || vFlipRect().contains(event->pos()))
setCursor(flipCursor()); setCursor(flipCursor());
else if (rotateRect().contains(event->pos())) else if (rotateRect().contains(event->pos()))
setCursor(rotateCursor()); setCursor(rotateCursor());
else else
setCursor(moveCursor()); setCursor(moveCursor());
event->accept(); event->accept();
} }
} }

@ -36,7 +36,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
UBGraphicsTriangle(); UBGraphicsTriangle();
virtual ~UBGraphicsTriangle(); virtual ~UBGraphicsTriangle();
enum { Type = UBGraphicsItemType::TriangleItemType }; enum { Type = UBGraphicsItemType::TriangleItemType };
virtual int type() const virtual int type() const
{ {
@ -44,64 +44,64 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
} }
virtual UBItem* deepCopy(void) const; virtual UBItem* deepCopy(void) const;
enum UBGraphicsTriangleOrientation enum UBGraphicsTriangleOrientation
{ {
BottomLeft = 0, BottomLeft = 0,
BottomRight, BottomRight,
TopLeft, TopLeft,
TopRight TopRight
}; };
static UBGraphicsTriangleOrientation orientationFromStr(QStringRef& str) static UBGraphicsTriangleOrientation orientationFromStr(QStringRef& str)
{ {
if (str == "BottomLeft") return BottomLeft; if (str == "BottomLeft") return BottomLeft;
if (str == "BottomRight") return BottomRight; if (str == "BottomRight") return BottomRight;
if (str == "TopLeft") return TopLeft; if (str == "TopLeft") return TopLeft;
if (str == "TopRight") return TopRight; if (str == "TopRight") return TopRight;
return sDefaultOrientation; return sDefaultOrientation;
} }
void setRect(const QRectF &rect, UBGraphicsTriangleOrientation orientation) void setRect(const QRectF &rect, UBGraphicsTriangleOrientation orientation)
{ {
setRect(rect.x(), rect.y(), rect.width(), rect.height(), orientation); setRect(rect.x(), rect.y(), rect.width(), rect.height(), orientation);
} }
void setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation); void setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation);
void setOrientation(UBGraphicsTriangleOrientation orientation); void setOrientation(UBGraphicsTriangleOrientation orientation);
QRectF rect() const {return boundingRect();} QRectF rect() const {return boundingRect();}
UBGraphicsScene* scene() const; UBGraphicsScene* scene() const;
protected: protected:
void updateResizeCursor(); void updateResizeCursor();
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget); virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget);
virtual void rotateAroundCenter(qreal angle); virtual void rotateAroundCenter(qreal angle);
virtual QPointF rotationCenter() const; virtual QPointF rotationCenter() const;
virtual QRectF closeButtonRect() const; virtual QRectF closeButtonRect() const;
QPolygonF resize1Polygon() const; QPolygonF resize1Polygon() const;
QPolygonF resize2Polygon() const; QPolygonF resize2Polygon() const;
QRectF hFlipRect() const; QRectF hFlipRect() const;
QRectF vFlipRect() const; QRectF vFlipRect() const;
QRectF rotateRect() const; QRectF rotateRect() const;
QCursor resizeCursor1() const; QCursor resizeCursor1() const;
QCursor resizeCursor2() const; QCursor resizeCursor2() const;
QCursor flipCursor() const; QCursor flipCursor() const;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
private: private:
QCursor mResizeCursor1; QCursor mResizeCursor1;
QCursor mResizeCursor2; QCursor mResizeCursor2;
@ -110,21 +110,23 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
qreal angle; qreal angle;
void rotateAroundCenter(QTransform& transform, QPointF center); void rotateAroundCenter(QTransform& transform, QPointF center);
bool mResizing1; bool mResizing1;
bool mResizing2; bool mResizing2;
bool mRotating; bool mRotating;
QRect lastRect;
QPoint lastPos;
QGraphicsSvgItem* mHFlipSvgItem; QGraphicsSvgItem* mHFlipSvgItem;
QGraphicsSvgItem* mVFlipSvgItem; QGraphicsSvgItem* mVFlipSvgItem;
QGraphicsSvgItem* mRotateSvgItem; QGraphicsSvgItem* mRotateSvgItem;
static const QRect sDefaultRect; static const QRect sDefaultRect;
static const UBGraphicsTriangleOrientation sDefaultOrientation; static const UBGraphicsTriangleOrientation sDefaultOrientation;
void paintGraduations(QPainter *painter); void paintGraduations(QPainter *painter);
UBGraphicsTriangleOrientation mOrientation; UBGraphicsTriangleOrientation mOrientation;
QPointF A1, B1, C1, A2, B2, C2; // coordinates of points in ext and int triangles QPointF A1, B1, C1, A2, B2, C2; // coordinates of points in ext and int triangles
qreal C; qreal C;
@ -132,10 +134,10 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
QPointF CC; // Hyp. fillining gradient - top point QPointF CC; // Hyp. fillining gradient - top point
void calculatePoints(const QRectF& rect); void calculatePoints(const QRectF& rect);
static const int d = 70; // width of triangle border static const int d = 70; // width of triangle border
static const int sArrowLength = 30; static const int sArrowLength = 30;
static const int sMinWidth = 380; static const int sMinWidth = 380;
static const int sMinHeight = 200; static const int sMinHeight = 200;
}; };
#endif /* UBGRAPHICSTRIANGLE_H_ */ #endif /* UBGRAPHICSTRIANGLE_H_ */

Loading…
Cancel
Save