Branding/it: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(Updating to match new version of source page)
Line 1: Line 1:
This article describes the '''Branding''' of FreeCAD. Branding means to start your own application on base of FreeCAD. That can be only your own executable or [[Splash screen|splash screen]] till a complete reworked program. On base of the flexible architecture of FreeCAD it's easy to use it as base for your own special purpose program.
== Marchiatura - Personalizzazione ==


=== General ===
Questo articolo descrive la personalizzazione o '''Marchiatura''' di FreeCAD.
Most of the branding is done in the '''MainCmd.cpp'' or ''MainGui.cpp'''. These Projects generate the executable files of FreeCAD. To make your own Brand just copy the Main or MainGui projects and give the executable an own name, e.g. FooApp.exe.
The most important settings for a new look can be made in one place in the main() function. Here is the code section that controls the branding:


<syntaxhighlight>
Marchiare (Branding) significa avviare la realizzazione di una propria applicazione basata su FreeCAD. La personalizzazione può riguardare solo il proprio eseguibile oppure andare dalla [[Splash screen/it|schermata iniziale]] fino alla rielaborazione completa del programma.

L'architettura flessibile di FreeCAD è facile da usare come base per realizzare dei programmi personali per impieghi particolari.

___TOC___

==== Generale ====

La maggior parte della marchiatura avviene in '''MainCmd.cpp''' oppure in '''MainGui.cpp'''. Questi Progetti generano i file eseguibili di FreeCAD. Per costruire il proprio marchio è sufficiente copiare i progetti Main o MainGui e dare all'eseguibile un nome diverso, ad esempio, FooApp.exe.

Le impostazioni più importanti per dare all'applicazione un nuovo aspetto possono essere fatte all'interno della funzione main().

Ecco la sezione di codice che controlla la marchiatura:

<code cpp>
int main( int argc, char ** argv )
int main( int argc, char ** argv )
{
{
// Name and Version of the Application
// Name and Version of the Application
App::Application::Config()["ExeName"] = "FooApp.exe";
App::Application::Config()["ExeName"] = "FooApp";
App::Application::Config()["ExeVersion"] = "0.7";
App::Application::Config()["ExeVersion"] = "0.7";
// set the banner (for loging and console)
// set the banner (for loging and console)
App::Application::Config()["ConsoleBanner"] = sBanner;
App::Application::Config()["CopyrightInfo"] = sBanner;
App::Application::Config()["AppIcon"] = "FCIcon";
App::Application::Config()["AppIcon"] = "FooAppIcon";
App::Application::Config()["SplashPicture"] = "FooAppSplasher";
App::Application::Config()["SplashScreen"] = "FooAppSplasher";
App::Application::Config()["StartWorkbench"] = "Part design";
App::Application::Config()["StartWorkbench"] = "Part design";
App::Application::Config()["HiddenDockWindow"] = "Property editor";
App::Application::Config()["HiddenDockWindow"] = "Property editor";
Line 45: Line 33:
return 0;
return 0;
}
}
</syntaxhighlight>
</code>
The first Config entry defines the program name. This is not the executable name, which can be changed by renaming or by compiler settings, but the name that is displayed in the task bar on windows or in the program list on Unix systems.


The next lines define the Config entries of your FooApp Application. A description of the Config and its entries you find in [[Start up and Configuration]].
La prima voce Config definisce il nome del programma. Questo nome non è il nome del file eseguibile, il quale può essere modificato rinominandolo o tramite le impostazioni del compilatore, ma è il nome che viene visualizzato nella barra delle applicazioni su Windows o nell'elenco dei programmi sui sistemi Unix.


=== Images ===
Le righe successive definiscono le voci di configurazione della vostra applicazione FooApp. Una descrizione di Config e delle sue voci si trova in [[Start up and Configuration/it|Avvio e Configurazione]].
Image resources are compiled into FreeCAD using [http://qt-project.org/doc/qt-4.8/resources.html Qt's resource system]. Therefore you have to write a .qrc file, an XML-based file format that lists image files on the disk but also any other kind of resource files. To load the compiled resources inside the application you have to add a line

<syntaxhighlight>
==== Immagini ====
Q_INIT_RESOURCE(FooApp);

</syntaxhighlight>
In FreeCAD tutte le risorse immagine vengono compilate. Questo riduce il tempo di caricamento e mantiene l'installazione compatta.
into the main() function. Alternatively, if you have an image in XPM format you can directly include it into your main.cpp and add the following line to register it:

<syntaxhighlight>
Le immagini sono incluse nel formato XPM il quale è fondamentalmente un formato di testo che utilizza la sintassi C.

Praticamente è possibile disegnare queste immagini con un editor di testo, ma è più comodo creare le immagini con il proprio programma di grafica preferito e convertirle successivamente in formato XPM.

Il programma di immagini di GNU [http://gimp.org/ Gimp] può salvare in file XPM.

Per la conversione si può utilizzare lo strumento ''[[ImageConv/it|ImageConv/it]]'' che è incluso in FreeCAD. Lo trovate in:

/trunk/src/Tools/ImageTools/ImageConv

Oltre a convertire le immagini, ImageConv può anche aggiornare automaticamente il file ''BmpFactoryIcons.cpp'', dove sono registrate le immagini. Così come si vede nel seguente esempio il suo utilizzo tipico è molto semplice:

ImageConv -i InputImage.png -o OutputImage.xpm

Questo comando converte il file ''InputImage.png'' in formato XPM e scrive il risultato in un file ''OutputImage.xpm''.

La riga:
Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);
Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);
</syntaxhighlight>
=== Branding XML ===
In FreeCAD there is also a method supported without writing a customized main() function. For this method you must write a file name called branding.xml and put it into the installation directory of FreeCAD. Here is an example with all supported tags:
<syntaxhighlight>
<?xml version="1.0" encoding="utf-8"?>
<Branding>
<Application>FooApp</Application>
<WindowTitle>Foo App in title bar</WindowTitle>
<BuildVersionMajor>1</BuildVersionMajor>
<BuildVersionMinor>0</BuildVersionMinor>
<BuildRevision>1234</BuildRevision>
<BuildRevisionDate>2014/1/1</BuildRevisionDate>
<CopyrightInfo>(c) My copyright</CopyrightInfo>
<MaintainerUrl>Foo App URL</MaintainerUrl>
<ProgramLogo>Path to logo (appears in bottom right corner)</ProgramLogo>
<WindowIcon>Path to icon file</WindowIcon>
<ProgramIcons>Path to program icons</ProgramIcons>
<SplashScreen>splashscreen.png</SplashScreen>
<SplashAlignment>Bottom|Left</SplashAlignment>
<SplashTextColor>#ffffff</SplashTextColor>
<SplashInfoColor>#c8c8c8</SplashInfoColor>
<StartWorkbench>PartDesignWorkbench</StartWorkbench>
</Branding>
</syntaxhighlight>
All of the listed tags are optional.


{{docnav|Testing|Localisation}}
include quindi nella funzione main() l'immagine nel BitmapFactory di FreeCAD.

===== Icone =====

L'icona principale dell'applicazione ''FCIcon'' che appare nei titoli delle finestre e in altri luoghi è definita in:

/trunk/src/Gui/Icons/images.cpp

e inizia con la riga

<nowiki>static const char *FCIcon[]={</nowiki>

Sostituitela con la propria icona preferita, ricompilate FreeCAD e il successivo passo per creare la propria applicazione marchiata è fatto.

In questo file ci sono molte altre icone che si possono cambiare a proprio gusto.

Se è necessario aggiungere nuove icone, bisogna registrarle in:

/trunk/src/Gui/Icons/BmpFactoryIcons.cpp

in modo da poter accedere ad esse da FreeCAD.

===== Immagine di sfondo =====

L'immagine di sfondo appare quando non è aperta nessuna finestra di documento. Come la [[Splash screen/it|schermata iniziale]], essa è definita in ''developers.h'' nella sezione che inizia con:

static const char* const background[]={

Per lo sfondo si consiglia di scegliere un'immagine a basso contrasto. In caso contrario l'immagine potrebbe infastidire l'utente.

{{docnav/it|[[Testing/it|Provare FreeCAD]]|[[Localisation/it|Localizzazione]]}}

{{languages/it | {{en|Branding}} {{es|Branding/es}} {{fr|Branding/fr}} {{ru|Branding/ru}} {{se|Branding/se}} }}


[[Category:Developer Documentation/it]]
[[Category:Developer Documentation]]
{{clear}}
<languages/>

Revision as of 19:56, 14 October 2014

This article describes the Branding of FreeCAD. Branding means to start your own application on base of FreeCAD. That can be only your own executable or splash screen till a complete reworked program. On base of the flexible architecture of FreeCAD it's easy to use it as base for your own special purpose program.

General

Most of the branding is done in the MainCmd.cpp or MainGui.cpp. These Projects generate the executable files of FreeCAD. To make your own Brand just copy the Main or MainGui projects and give the executable an own name, e.g. FooApp.exe. The most important settings for a new look can be made in one place in the main() function. Here is the code section that controls the branding:

 int main( int argc, char ** argv )
 {
   // Name and Version of the Application
   App::Application::Config()["ExeName"] = "FooApp";
   App::Application::Config()["ExeVersion"] = "0.7";
 
   // set the banner (for loging and console)
   App::Application::Config()["CopyrightInfo"] = sBanner;
   App::Application::Config()["AppIcon"] = "FooAppIcon";
   App::Application::Config()["SplashScreen"] = "FooAppSplasher";
   App::Application::Config()["StartWorkbench"] = "Part design";
   App::Application::Config()["HiddenDockWindow"] = "Property editor";
   App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
   App::Application::Config()["SplashTextColor" ] = "#000000"; // black
 
   // Inits the Application 
   App::Application::Config()["RunMode"] = "Gui";
   App::Application::init(argc,argv);
 
   Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);
 
   Gui::Application::initApplication();
   Gui::Application::runApplication();
   App::Application::destruct();
 
   return 0;
 }

The first Config entry defines the program name. This is not the executable name, which can be changed by renaming or by compiler settings, but the name that is displayed in the task bar on windows or in the program list on Unix systems.

The next lines define the Config entries of your FooApp Application. A description of the Config and its entries you find in Start up and Configuration.

Images

Image resources are compiled into FreeCAD using Qt's resource system. Therefore you have to write a .qrc file, an XML-based file format that lists image files on the disk but also any other kind of resource files. To load the compiled resources inside the application you have to add a line

 Q_INIT_RESOURCE(FooApp);

into the main() function. Alternatively, if you have an image in XPM format you can directly include it into your main.cpp and add the following line to register it:

 Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);

Branding XML

In FreeCAD there is also a method supported without writing a customized main() function. For this method you must write a file name called branding.xml and put it into the installation directory of FreeCAD. Here is an example with all supported tags:

 <?xml version="1.0" encoding="utf-8"?>
 <Branding>
 	<Application>FooApp</Application>
 	<WindowTitle>Foo App in title bar</WindowTitle>
 	<BuildVersionMajor>1</BuildVersionMajor>
 	<BuildVersionMinor>0</BuildVersionMinor>
 	<BuildRevision>1234</BuildRevision>
 	<BuildRevisionDate>2014/1/1</BuildRevisionDate>
 	<CopyrightInfo>(c) My copyright</CopyrightInfo>
 	<MaintainerUrl>Foo App URL</MaintainerUrl>
 	<ProgramLogo>Path to logo (appears in bottom right corner)</ProgramLogo>
 	<WindowIcon>Path to icon file</WindowIcon>
 	<ProgramIcons>Path to program icons</ProgramIcons>
 	<SplashScreen>splashscreen.png</SplashScreen>
 	<SplashAlignment>Bottom|Left</SplashAlignment>
 	<SplashTextColor>#ffffff</SplashTextColor>
 	<SplashInfoColor>#c8c8c8</SplashInfoColor>
 	<StartWorkbench>PartDesignWorkbench</StartWorkbench>
 </Branding>

All of the listed tags are optional.

Testing
Localisation