kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #31187
Re: Datasheet confusion
I tested the GetAssociatedDocument, works much better and has more
features so i took the freedom of updating the dialog windows to use
that instead of the wxLaunchDefaultBrowser as well
attaching patch :)
- Kristoffer
On 10/19/2017 02:07 PM, Wayne Stambaugh wrote:
On 10/19/2017 7:09 AM, Kristoffer Ödmark wrote:
Yes indeed it breaks that, I would argue that having an "invisible"
field opened when using the context field is the source of the
confusion. So I am aware it breaks the context menu for old schematics
but think it is necessary anyway.
I'm OK with this change. I'm not sure why we would use the document
field from the library symbol rather the schematic symbol. AFAIK, we
don't do that for any other schematic symbol fields.
I can of course use GetAssociatedDocument instead.
On Oct 19, 2017 12:54 PM, "jp charras" <jp.charras@xxxxxxxxxx
<mailto:jp.charras@xxxxxxxxxx>> wrote:
Le 18/10/2017 à 20:20, Kristoffer Ödmark a écrit :
> Glad to hear it, I fixed a patch up that will highlight the
differences a bit better than I explain it.
>
> Basically it will fill the field from the properties if the field
is empty when adding components to
> the schematic.
>
> It will also use the Field to determine when to show the context
menu instead of relying on the
> library.
>
> - Kristoffer
>
Unfortunately, it breaks access to the associated document for
existing schematics, that can have a
datasheet name set in library, but not in schematic.
and calling:
::wxLaunchDefaultBrowser( text ); is incorrect
(text is not always a .pdf doc with a full absolute path or URI)
see:
GetAssociatedDocument()
--
Jean-Pierre CHARRAS
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
<https://launchpad.net/~kicad-developers>
Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
<mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
Unsubscribe : https://launchpad.net/~kicad-developers
<https://launchpad.net/~kicad-developers>
More help : https://help.launchpad.net/ListHelp
<https://help.launchpad.net/ListHelp>
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help : https://help.launchpad.net/ListHelp
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help : https://help.launchpad.net/ListHelp
>From fdefde7fa970feed57ce22ea478b7d81cd66167f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= <kristoffer.odmark90@xxxxxxxxx>
Date: Wed, 18 Oct 2017 20:09:08 +0200
Subject: [PATCH] Use the Component Field when determining when to choose the
"Show Documentation" context menu
This instead of using the library alias property. But to not break any library. When adding
new compononents to the schematic, copy the value from the library into the Field variable
only if the field variable would otherwise be empty.
This way, the context menu for showing the docs is more understandable for users, and is
also changeable from the schematic without having to modify the actual libraries.
Fixed: lp:1723104
---
eeschema/dialogs/dialog_edit_component_in_schematic.cpp | 3 ++-
eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp | 3 ++-
eeschema/getpart.cpp | 12 ++++++++++++
eeschema/onrightclick.cpp | 2 +-
eeschema/schedit.cpp | 13 ++++---------
5 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp
index 0804f8bba..e9500d830 100644
--- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp
+++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp
@@ -54,6 +54,7 @@
#endif /* KICAD_SPICE */
#include "common.h"
+#include "eda_doc.h"
#include <list>
@@ -590,7 +591,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& even
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
datasheet_uri = resolveUriByEnvVars( datasheet_uri );
- ::wxLaunchDefaultBrowser( datasheet_uri );
+ GetAssociatedDocument( this, datasheet_uri );
}
else if( fieldNdx == FOOTPRINT )
{
diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
index d70f05a86..23341a5bd 100644
--- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
+++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
@@ -45,6 +45,7 @@
#include <sch_validators.h>
#include <bitmaps.h>
+#include "eda_doc.h"
#include <dialog_edit_libentry_fields_in_lib_base.h>
#ifdef KICAD_SPICE
@@ -501,7 +502,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler( wxCommandEvent& even
if( fieldNdx == DATASHEET )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
- ::wxLaunchDefaultBrowser( datasheet_uri );
+ GetAssociatedDocument( this, datasheet_uri );
}
else if( fieldNdx == FOOTPRINT )
{
diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp
index ac7deec23..8e8401add 100644
--- a/eeschema/getpart.cpp
+++ b/eeschema/getpart.cpp
@@ -254,6 +254,18 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component(
// Set the component value that can differ from component name in lib, for aliases
component->GetField( VALUE )->SetText( sel.Name );
+ // If there is no field defined in the component, copy one over from the library
+ // ( from the .dcm file )
+ // This way the Datasheet field will not be empty and can be changed from the schematic
+ auto libs = Prj().SchLibs();
+ if( component->GetField( DATASHEET )->GetText().IsEmpty() )
+ {
+ LIB_ALIAS* entry = libs->FindLibraryAlias( component->GetLibId() );
+
+ if( entry && !!entry->GetDocFileName() )
+ component->GetField( DATASHEET )->SetText( entry->GetDocFileName() );
+ }
+
MSG_PANEL_ITEMS items;
component->SetCurrentSheetPath( &GetCurrentSheet() );
diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp
index e84e44246..ab2c712e1 100644
--- a/eeschema/onrightclick.cpp
+++ b/eeschema/onrightclick.cpp
@@ -397,7 +397,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS*
msg = AddHotkeyName( _( "Autoplace Fields" ), g_Schematic_Hokeys_Descr, HK_AUTOPLACE_FIELDS );
AddMenuItem( PopMenu, ID_AUTOPLACE_FIELDS, msg, KiBitmap( autoplace_fields_xpm ) );
- if( libEntry && !libEntry->GetDocFileName().IsEmpty() )
+ if( !Component->GetFieldText("Datasheet").IsEmpty() )
AddMenuItem( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Open Documentation" ), KiBitmap( datasheet_xpm ) );
}
diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp
index 23d4bdafa..906a129da 100644
--- a/eeschema/schedit.cpp
+++ b/eeschema/schedit.cpp
@@ -302,16 +302,11 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// Ensure the struct is a component (could be a piece of a component, like Field, text..)
if( item && item->Type() == SCH_COMPONENT_T )
{
- if( PART_LIBS* libs = Prj().SchLibs() )
- {
- LIB_ALIAS* entry = libs->FindLibraryAlias( ( (SCH_COMPONENT*) item )->GetLibId() );
-
- if( entry && !!entry->GetDocFileName() )
- {
- SEARCH_STACK* lib_search = Prj().SchSearchS();
+ auto text = static_cast<SCH_COMPONENT*>( item )->GetFieldText( "Datasheet" );
- GetAssociatedDocument( this, entry->GetDocFileName(), lib_search );
- }
+ if( !text.IsEmpty() )
+ {
+ GetAssociatedDocument( this, text );
}
}
break;
--
2.14.2
Follow ups
References
-
Datasheet confusion
From: Kristoffer Ödmark, 2017-10-12
-
Re: Datasheet confusion
From: Kristoffer Ödmark, 2017-10-12
-
Re: Datasheet confusion
From: Wayne Stambaugh, 2017-10-12
-
Re: Datasheet confusion
From: Kristoffer Ödmark, 2017-10-12
-
Re: Datasheet confusion
From: Wayne Stambaugh, 2017-10-12
-
Re: Datasheet confusion
From: jp charras, 2017-10-13
-
Re: Datasheet confusion
From: Kristoffer Ödmark, 2017-10-13
-
Re: Datasheet confusion
From: Wayne Stambaugh, 2017-10-13
-
Re: Datasheet confusion
From: Kristoffer Ödmark, 2017-10-13
-
Re: Datasheet confusion
From: Fabrizio Tappero, 2017-10-16
-
Re: Datasheet confusion
From: Kristoffer Ödmark, 2017-10-18
-
Re: Datasheet confusion
From: jp charras, 2017-10-19
-
Re: Datasheet confusion
From: Kristoffer Ödmark, 2017-10-19
-
Re: Datasheet confusion
From: Wayne Stambaugh, 2017-10-19