Beispiel #1
0
    def plot(self, roll, gz):
        """ Plot the GZ curve.

        Position arguments:
        roll -- List of roll angles (in degrees).
        gz -- List of GZ values (in meters).
        """
        try:
            from freecad.plot import Plot
            plt = Plot.figure('GZ')
        except ImportError:
            msg = QtGui.QApplication.translate(
                "ship_console",
                "Plot module is disabled, so I cannot perform the plot", None)
            FreeCAD.Console.PrintWarning(msg + '\n')
            return True

        gz_plot = Plot.plot(roll, gz, 'GZ curve')
        gz_plot.line.set_linestyle('-')
        gz_plot.line.set_linewidth(1.0)
        gz_plot.line.set_color((0.0, 0.0, 0.0))

        ax = Plot.axes()
        Plot.xlabel(r'$\phi \; [\mathrm{deg}]$')
        Plot.ylabel(r'$GZ \; [\mathrm{m}]$')
        ax.xaxis.label.set_fontsize(20)
        ax.yaxis.label.set_fontsize(20)

        Plot.grid(True)
        plt.update()
        return False
Beispiel #2
0
 def plot(self, x, y, disp, xcb, ship):
     """ Perform the areas curve plot.
     @param x X coordinates.
     @param y Transversal areas.
     @param disp Ship displacement.
     @param xcb Buoyancy center length.
     @param ship Active ship instance.
     @return True if error happens.
     """
     try:
         from freecad.plot import Plot
         plt = Plot.figure('Areas curve')
     except ImportError:
         msg = QtGui.QApplication.translate(
             "ship_console",
             "Plot module is disabled, so I cannot perform the plot", None)
         FreeCAD.Console.PrintWarning(msg + '\n')
         return True
     # Plot areas curve
     areas = Plot.plot(x, y, 'Transversal areas')
     areas.line.set_linestyle('-')
     areas.line.set_linewidth(2.0)
     areas.line.set_color((0.0, 0.0, 0.0))
     # Get perpendiculars data
     Lpp = ship.Length.getValueAs('m').Value
     FPx = 0.5 * Lpp
     APx = -0.5 * Lpp
     maxArea = max(y)
     # Plot perpendiculars
     FP = Plot.plot([FPx, FPx], [0.0, maxArea])
     FP.line.set_linestyle('-')
     FP.line.set_linewidth(1.0)
     FP.line.set_color((0.0, 0.0, 0.0))
     AP = Plot.plot([APx, APx], [0.0, maxArea])
     AP.line.set_linestyle('-')
     AP.line.set_linewidth(1.0)
     AP.line.set_color((0.0, 0.0, 0.0))
     # Add annotations for prependiculars
     ax = Plot.axes()
     ax.annotate('AP', xy=(APx + 0.01 * Lpp, 0.01 * maxArea), size=15)
     ax.annotate('AP', xy=(APx + 0.01 * Lpp, 0.95 * maxArea), size=15)
     ax.annotate('FP', xy=(FPx + 0.01 * Lpp, 0.01 * maxArea), size=15)
     ax.annotate('FP', xy=(FPx + 0.01 * Lpp, 0.95 * maxArea), size=15)
     # Add some additional data
     addInfo = ("$XCB = {0} \\; \\mathrm{{m}}$\n"
                "$Area_{{max}} = {1} \\; \\mathrm{{m}}^2$\n"
                "$\\bigtriangleup = {2} \\; \\mathrm{{tons}}$".format(
                    xcb.getValueAs("m").Value, maxArea,
                    disp.getValueAs("kg").Value / 1000.0))
     ax.text(0.0,
             0.01 * maxArea,
             addInfo,
             verticalalignment='bottom',
             horizontalalignment='center',
             fontsize=20)
     # Write axes titles
     Plot.xlabel(r'$x \; \mathrm{m}$')
     Plot.ylabel(r'$Area \; \mathrm{m}^2$')
     ax.xaxis.label.set_fontsize(20)
     ax.yaxis.label.set_fontsize(20)
     # Show grid
     Plot.grid(True)
     # End
     plt.update()
     return False