Rename the old "Import / Assemble" feature to "Link / Assemble".

This better reflects what it does and avoids clashes with the new
DXF import feature.
This commit is contained in:
whitequark 2016-05-07 05:27:54 +00:00
parent d05e9a938b
commit febe0f5282
16 changed files with 83 additions and 83 deletions

View File

@ -613,7 +613,7 @@ int ShowContextMenu(void) {
int id_ = [sender tag];
if(id_ >= RECENT_OPEN && id_ < (RECENT_OPEN + MAX_RECENT))
SolveSpace::SolveSpaceUI::MenuFile(id_);
else if(id_ >= RECENT_IMPORT && id_ < (RECENT_IMPORT + MAX_RECENT))
else if(id_ >= RECENT_LINK && id_ < (RECENT_LINK + MAX_RECENT))
SolveSpace::Group::MenuGroup(id_);
}
@end
@ -718,7 +718,7 @@ static void RefreshRecentMenu(int id_, int base) {
void RefreshRecentMenus(void) {
RefreshRecentMenu(GraphicsWindow::MNU_OPEN_RECENT, RECENT_OPEN);
RefreshRecentMenu(GraphicsWindow::MNU_GROUP_RECENT, RECENT_IMPORT);
RefreshRecentMenu(GraphicsWindow::MNU_GROUP_RECENT, RECENT_LINK);
}
void ToggleMenuBar(void) {
@ -869,7 +869,7 @@ SolveSpace::DialogChoice SolveSpace::LocateImportedFileYesNoCancel(
const std::string &filename, bool canCancel) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:[NSString stringWithUTF8String:
("The imported file " + filename + " is not present.").c_str()]];
("The linked file " + filename + " is not present.").c_str()]];
[alert setInformativeText:
@"Do you want to locate it manually?\n"
"If you select \"No\", any geometry that depends on "

View File

@ -588,7 +588,7 @@ void GraphicsWindow::Paint(void) {
}
ssglDepthRangeOffset(0);
// Nasty case when we're reloading the imported files; could be that
// Nasty case when we're reloading the linked files; could be that
// we get an error, so a dialog pops up, and a message loop starts, and
// we have to get called to paint ourselves. If the sketch is screwed
// up, then we could trigger an oops trying to draw.

View File

@ -263,7 +263,7 @@ void Entity::CalculateNumerical(bool forExport) {
actNormal = Quaternion::From(0, n.x, n.y, n.z);
}
if(forExport) {
// Visibility in copied import entities follows source file
// Visibility in copied linked entities follows source file
actVisible = IsVisible();
} else {
// Copied entities within a file are always visible

View File

@ -116,8 +116,8 @@ const SolveSpaceUI::SaveTable SolveSpaceUI::SAVED[] = {
{ 'g', "Group.allDimsReference", 'b', &(SS.sv.g.allDimsReference) },
{ 'g', "Group.scale", 'f', &(SS.sv.g.scale) },
{ 'g', "Group.remap", 'M', &(SS.sv.g.remap) },
{ 'g', "Group.impFile", 'S', &(SS.sv.g.impFile) },
{ 'g', "Group.impFileRel", 'S', &(SS.sv.g.impFileRel) },
{ 'g', "Group.impFile", 'S', &(SS.sv.g.linkFile) },
{ 'g', "Group.impFileRel", 'S', &(SS.sv.g.linkFileRel) },
{ 'p', "Param.h.v.", 'x', &(SS.sv.p.h.v) },
{ 'p', "Param.val", 'f', &(SS.sv.p.val) },
@ -256,8 +256,8 @@ void SolveSpaceUI::SaveUsingTable(int type) {
bool SolveSpaceUI::SaveToFile(const std::string &filename) {
// Make sure all the entities are regenerated up to date, since they
// will be exported. We reload the imported files because that rewrites
// the impFileRel for our possibly-new filename.
// will be exported. We reload the linked files because that rewrites
// the linkFileRel for our possibly-new filename.
SS.ScheduleShowTW();
SS.ReloadAllImported();
SS.GenerateAll(SolveSpaceUI::GENERATE_ALL);
@ -458,9 +458,9 @@ bool SolveSpaceUI::LoadFromFile(const std::string &filename) {
char *key = line, *val = e+1;
LoadUsingTable(key, val);
} else if(strcmp(line, "AddGroup")==0) {
// legacy files have a spurious dependency between imported groups
// legacy files have a spurious dependency between linked groups
// and their parent groups, remove
if(sv.g.type == Group::IMPORTED)
if(sv.g.type == Group::LINKED)
sv.g.opA.v = 0;
SK.group.Add(&(sv.g));
@ -653,7 +653,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const std::string &filename, EntityList
}
//-----------------------------------------------------------------------------
// Handling of the relative-absolute path transformations for imports
// Handling of the relative-absolute path transformations for links
//-----------------------------------------------------------------------------
static std::vector<std::string> Split(const std::string &haystack, const std::string &needle)
{
@ -781,79 +781,79 @@ static std::string PathSepUNIXToPlatform(const std::string &filename)
bool SolveSpaceUI::ReloadAllImported(bool canCancel)
{
std::map<std::string, std::string> importMap;
std::map<std::string, std::string> linkMap;
allConsistent = false;
int i;
for(i = 0; i < SK.group.n; i++) {
Group *g = &(SK.group.elem[i]);
if(g->type != Group::IMPORTED) continue;
if(g->type != Group::LINKED) continue;
if(isalpha(g->impFile[0]) && g->impFile[1] == ':') {
// Make sure that g->impFileRel always contains a relative path
if(isalpha(g->linkFile[0]) && g->linkFile[1] == ':') {
// Make sure that g->linkFileRel always contains a relative path
// in an UNIX format, even after we load an old file which had
// the path in Windows format
PathSepNormalize(g->impFileRel);
PathSepNormalize(g->linkFileRel);
}
g->impEntity.Clear();
g->impMesh.Clear();
g->impShell.Clear();
if(importMap.count(g->impFile)) {
std::string newPath = importMap[g->impFile];
if(linkMap.count(g->linkFile)) {
std::string newPath = linkMap[g->linkFile];
if(!newPath.empty())
g->impFile = newPath;
g->linkFile = newPath;
}
FILE *test = ssfopen(g->impFile, "rb");
FILE *test = ssfopen(g->linkFile, "rb");
if(test) {
fclose(test); // okay, exists
} else {
// It doesn't exist. Perhaps the entire tree has moved, and we
// can use the relative filename to get us back.
if(!SS.saveFile.empty()) {
std::string rel = PathSepUNIXToPlatform(g->impFileRel);
std::string rel = PathSepUNIXToPlatform(g->linkFileRel);
std::string fromRel = MakePathAbsolute(SS.saveFile, rel);
test = ssfopen(fromRel, "rb");
if(test) {
fclose(test);
// It worked, this is our new absolute path
g->impFile = fromRel;
g->linkFile = fromRel;
}
}
}
try_load_file:
if(LoadEntitiesFromFile(g->impFile, &(g->impEntity), &(g->impMesh), &(g->impShell)))
if(LoadEntitiesFromFile(g->linkFile, &(g->impEntity), &(g->impMesh), &(g->impShell)))
{
if(!SS.saveFile.empty()) {
// Record the imported file's name relative to our filename;
// Record the linked file's name relative to our filename;
// if the entire tree moves, then everything will still work
std::string rel = MakePathRelative(SS.saveFile, g->impFile);
g->impFileRel = PathSepPlatformToUNIX(rel);
std::string rel = MakePathRelative(SS.saveFile, g->linkFile);
g->linkFileRel = PathSepPlatformToUNIX(rel);
} else {
// We're not yet saved, so can't make it absolute.
// This will only be used for display purposes, as SS.saveFile
// is always nonempty when we are actually writing anything.
g->impFileRel = g->impFile;
g->linkFileRel = g->linkFile;
}
} else if(!importMap.count(g->impFile)) {
switch(LocateImportedFileYesNoCancel(g->impFileRel, canCancel)) {
} else if(!linkMap.count(g->linkFile)) {
switch(LocateImportedFileYesNoCancel(g->linkFileRel, canCancel)) {
case DIALOG_YES: {
std::string oldImpFile = g->impFile;
if(!GetOpenFile(&g->impFile, "", SlvsFileFilter)) {
std::string oldImpFile = g->linkFile;
if(!GetOpenFile(&g->linkFile, "", SlvsFileFilter)) {
if(canCancel)
return false;
break;
} else {
importMap[oldImpFile] = g->impFile;
linkMap[oldImpFile] = g->linkFile;
goto try_load_file;
}
}
case DIALOG_NO:
importMap[g->impFile] = "";
linkMap[g->linkFile] = "";
/* Geometry will be pruned by GenerateAll(). */
break;
@ -862,7 +862,7 @@ try_load_file:
}
} else {
// User was already asked to and refused to locate a missing
// imported file.
// linked file.
}
}

View File

@ -100,8 +100,8 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
{ 1, "E&xtrude", MNU_GROUP_EXTRUDE, S|'X', TN, mGrp },
{ 1, "&Lathe", MNU_GROUP_LATHE, S|'L', TN, mGrp },
{ 1, NULL, 0, 0, TN, NULL },
{ 1, "Import / Assemble...", MNU_GROUP_IMPORT, S|'I', TN, mGrp },
{ 1, "Import Recent", MNU_GROUP_RECENT, 0, TN, mGrp },
{ 1, "Link / Assemble...", MNU_GROUP_LINK, S|'I', TN, mGrp },
{ 1, "Link Recent", MNU_GROUP_RECENT, 0, TN, mGrp },
{ 0, "&Sketch", 0, 0, TN, NULL },
{ 1, "In &Workplane", MNU_SEL_WORKPLANE, '2', TR, mReq },
@ -859,9 +859,9 @@ void GraphicsWindow::MenuEdit(int id) {
hGroup hg = e ? e->group : SS.GW.activeGroup;
Group *g = SK.GetGroup(hg);
if(g->type != Group::IMPORTED) {
if(g->type != Group::LINKED) {
Error("To use this command, select a point or other "
"entity from an imported part, or make an import "
"entity from an linked part, or make a link "
"group the active group.");
break;
}

View File

@ -77,9 +77,9 @@ void Group::MenuGroup(int id) {
g.color = RGBi(100, 100, 100);
g.scale = 1;
if(id >= RECENT_IMPORT && id < (RECENT_IMPORT + MAX_RECENT)) {
g.impFile = RecentFile[id-RECENT_IMPORT];
id = GraphicsWindow::MNU_GROUP_IMPORT;
if(id >= RECENT_LINK && id < (RECENT_LINK + MAX_RECENT)) {
g.linkFile = RecentFile[id-RECENT_LINK];
id = GraphicsWindow::MNU_GROUP_LINK;
}
SS.GW.GroupSelection();
@ -205,15 +205,15 @@ void Group::MenuGroup(int id) {
g.name = "translate";
break;
case GraphicsWindow::MNU_GROUP_IMPORT: {
g.type = IMPORTED;
if(g.impFile.empty()) {
if(!GetOpenFile(&g.impFile, "", SlvsFileFilter)) return;
case GraphicsWindow::MNU_GROUP_LINK: {
g.type = LINKED;
if(g.linkFile.empty()) {
if(!GetOpenFile(&g.linkFile, "", SlvsFileFilter)) return;
}
// Assign the default name of the group based on the name of
// the imported file.
std::string groupName = g.impFile;
// the linked file.
std::string groupName = g.linkFile;
size_t pos;
pos = groupName.rfind(PATH_SEP);
@ -234,7 +234,7 @@ void Group::MenuGroup(int id) {
if(groupName.length() > 0) {
g.name = groupName;
} else {
g.name = "import";
g.name = "link";
}
g.meshCombine = COMBINE_AS_ASSEMBLE;
@ -269,7 +269,7 @@ void Group::MenuGroup(int id) {
SK.group.AddAndAssignId(&g);
Group *gg = SK.GetGroup(g.h);
if(gg->type == IMPORTED) {
if(gg->type == LINKED) {
SS.ReloadAllImported();
}
gg->clean = false;
@ -287,7 +287,7 @@ void Group::MenuGroup(int id) {
}
void Group::TransformImportedBy(Vector t, Quaternion q) {
if(type != IMPORTED) oops();
if(type != LINKED) oops();
hParam tx, ty, tz, qw, qx, qy, qz;
tx = h.param(0);
@ -323,7 +323,7 @@ std::string Group::DescriptionString(void) {
}
void Group::Activate(void) {
if(type == EXTRUDE || type == IMPORTED || type == LATHE || type == TRANSLATE || type == ROTATE) {
if(type == EXTRUDE || type == LINKED || type == LATHE || type == TRANSLATE || type == ROTATE) {
SS.GW.showFaces = true;
} else {
SS.GW.showFaces = false;
@ -529,7 +529,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
}
break;
}
case IMPORTED:
case LINKED:
// The translation vector
AddParam(param, h.param(0), gp.x);
AddParam(param, h.param(1), gp.y);
@ -566,7 +566,7 @@ void Group::AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index) {
}
void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
if(type == IMPORTED) {
if(type == LINKED) {
// Normalize the quaternion
ExprQuaternion q = {
Expr::From(h.param(3)),
@ -895,9 +895,9 @@ void Group::CopyEntity(IdList<Entity,hEntity> *el,
}
}
// If the entity came from an imported file where it was invisible then
// If the entity came from an linked file where it was invisible then
// ep->actiVisble will be false, and we should hide it. Or if the entity
// came from a copy (e.g. step and repeat) of a force-hidden imported
// came from a copy (e.g. step and repeat) of a force-hidden linked
// entity, then we also want to hide it.
en.forceHidden = (!ep->actVisible) || ep->forceHidden;

View File

@ -59,7 +59,7 @@ void Group::GenerateLoops(void) {
bezierOpens.Clear();
if(type == DRAWING_3D || type == DRAWING_WORKPLANE ||
type == ROTATE || type == TRANSLATE || type == IMPORTED)
type == ROTATE || type == TRANSLATE || type == LINKED)
{
bool allClosed = false, allCoplanar = false, allNonZeroLen = false;
AssembleLoops(&allClosed, &allCoplanar, &allNonZeroLen);
@ -285,7 +285,7 @@ void Group::GenerateShellAndMesh(void) {
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
thisShell.MakeFromRevolutionOf(sbls, pt, axis, color, this);
}
} else if(type == IMPORTED) {
} else if(type == LINKED) {
// The imported shell or mesh are copied over, with the appropriate
// transformation applied. We also must remap the face entities.
Vector offset = {

View File

@ -1019,7 +1019,7 @@ protected:
virtual void on_activate() {
if(_id >= RECENT_OPEN && _id < (RECENT_OPEN + MAX_RECENT))
SolveSpaceUI::MenuFile(_id);
else if(_id >= RECENT_IMPORT && _id < (RECENT_IMPORT + MAX_RECENT))
else if(_id >= RECENT_LINK && _id < (RECENT_LINK + MAX_RECENT))
Group::MenuGroup(_id);
}
@ -1053,7 +1053,7 @@ static void RefreshRecentMenu(int id, int base) {
void RefreshRecentMenus(void) {
RefreshRecentMenu(GraphicsWindow::MNU_OPEN_RECENT, RECENT_OPEN);
RefreshRecentMenu(GraphicsWindow::MNU_GROUP_RECENT, RECENT_IMPORT);
RefreshRecentMenu(GraphicsWindow::MNU_GROUP_RECENT, RECENT_LINK);
}
/* Save/load */
@ -1223,7 +1223,7 @@ DialogChoice LoadAutosaveYesNo(void) {
DialogChoice LocateImportedFileYesNoCancel(const std::string &filename,
bool canCancel) {
Glib::ustring message =
"The imported file " + filename + " is not present.\n"
"The linked file " + filename + " is not present.\n"
"Do you want to locate it manually?\n"
"If you select \"No\", any geometry that depends on "
"the missing file will be removed.";

View File

@ -1421,15 +1421,15 @@ void GraphicsWindow::SpaceNavigatorMoved(double tx, double ty, double tz,
double aam = aa.Magnitude();
if(aam > 0.0) aa = aa.WithMagnitude(1);
// This can either transform our view, or transform an imported part.
// This can either transform our view, or transform a linked part.
GroupSelection();
Entity *e = NULL;
Group *g = NULL;
if(gs.points == 1 && gs.n == 1) e = SK.GetEntity(gs.point [0]);
if(gs.entities == 1 && gs.n == 1) e = SK.GetEntity(gs.entity[0]);
if(e) g = SK.GetGroup(e->group);
if(g && g->type == Group::IMPORTED && !shiftDown) {
// Apply the transformation to an imported part. Gain down the Z
if(g && g->type == Group::LINKED && !shiftDown) {
// Apply the transformation to a linked part. Gain down the Z
// axis, since it's hard to see what you're doing on that one since
// it's normal to the screen.
Vector t = projRight.ScaledBy(tx/scale).Plus(

View File

@ -99,7 +99,7 @@ public:
LATHE = 5101,
ROTATE = 5200,
TRANSLATE = 5201,
IMPORTED = 5300
LINKED = 5300
};
int type;
@ -191,8 +191,8 @@ public:
enum { REMAP_PRIME = 19477 };
int remapCache[REMAP_PRIME];
std::string impFile;
std::string impFileRel;
std::string linkFile;
std::string linkFileRel;
SMesh impMesh;
SShell impShell;
EntityList impEntity;
@ -464,12 +464,12 @@ public:
dogd(), beziers(), edges(), edgesChordTol(), screenBBox(),
screenBBoxValid() {};
// An imported entity that was hidden in the source file ends up hidden
// A linked entity that was hidden in the source file ends up hidden
// here too.
bool forceHidden;
// All points/normals/distances have their numerical value; this is
// a convenience, to simplify the import/assembly code, so that the
// a convenience, to simplify the link/assembly code, so that the
// part is entirely described by the entities.
Vector actPoint;
Quaternion actNormal;

View File

@ -376,7 +376,7 @@ bool SolveSpaceUI::GetFilenameAndSave(bool saveAs) {
if(saveAs || saveFile.empty()) {
if(!GetSaveFile(&saveFile, "", SlvsFileFilter)) return false;
// need to get new filename directly into saveFile, since that
// determines impFileRel path
// determines linkFileRel path
}
if(SaveToFile(saveFile)) {

View File

@ -139,7 +139,7 @@ void ssremove(const std::string &filename);
#define MAX_RECENT 8
#define RECENT_OPEN (0xf000)
#define RECENT_IMPORT (0xf100)
#define RECENT_LINK (0xf100)
extern std::string RecentFile[MAX_RECENT];
void RefreshRecentMenus(void);
@ -787,7 +787,7 @@ public:
void Exit(void);
// File load/save routines, including the additional files that get
// loaded when we have import groups.
// loaded when we have link groups.
FILE *fh;
void AfterNewFile(void);
static void RemoveFromRecentList(const std::string &filename);

View File

@ -328,9 +328,9 @@ void TextWindow::ShowGroupInfo(void) {
times, times == 1 ? "" : "s",
g->h.v, &TextWindow::ScreenChangeExprA);
}
} else if(g->type == Group::IMPORTED) {
Printf(true, " %Ftimport geometry from file%E");
Printf(false, "%Ba '%s'", g->impFileRel.c_str());
} else if(g->type == Group::LINKED) {
Printf(true, " %Ftlink geometry from file%E");
Printf(false, "%Ba '%s'", g->linkFileRel.c_str());
Printf(false, "%Bd %Ftscaled by%E %# %Fl%Ll%f%D[change]%E",
g->scale,
&TextWindow::ScreenChangeGroupScale, g->h.v);
@ -345,12 +345,12 @@ void TextWindow::ShowGroupInfo(void) {
if(g->type == Group::EXTRUDE ||
g->type == Group::LATHE ||
g->type == Group::IMPORTED)
g->type == Group::LINKED)
{
bool un = (g->meshCombine == Group::COMBINE_AS_UNION);
bool diff = (g->meshCombine == Group::COMBINE_AS_DIFFERENCE);
bool asy = (g->meshCombine == Group::COMBINE_AS_ASSEMBLE);
bool asa = (g->type == Group::IMPORTED);
bool asa = (g->type == Group::LINKED);
Printf(false, " %Ftsolid model as");
Printf(false, "%Ba %f%D%Lc%Fd%s union%E "
@ -378,7 +378,7 @@ void TextWindow::ShowGroupInfo(void) {
Printf(false, "%Bd %Ftopacity%E %@ %f%Lf%Fl[change]%E",
g->color.alphaF(),
&TextWindow::ScreenOpacity);
} else if(g->type == Group::IMPORTED) {
} else if(g->type == Group::LINKED) {
Printf(false, " %Fd%f%LP%s suppress this group's solid model",
&TextWindow::ScreenChangeGroupOption,
g->suppress ? CHECK_TRUE : CHECK_FALSE);

View File

@ -46,7 +46,7 @@ static const struct {
{ Icon_step_translate, GraphicsWindow::MNU_GROUP_TRANS, "New group step and repeat translating" },
{ Icon_sketch_in_plane, GraphicsWindow::MNU_GROUP_WRKPL, "New group in new workplane (thru given entities)" },
{ Icon_sketch_in_3d, GraphicsWindow::MNU_GROUP_3D, "New group in 3d" },
{ Icon_assemble, GraphicsWindow::MNU_GROUP_IMPORT, "New group importing / assembling file" },
{ Icon_assemble, GraphicsWindow::MNU_GROUP_LINK, "New group linking / assembling file" },
{ SPACER, 0, 0 },
{ Icon_in3d, GraphicsWindow::MNU_NEAREST_ISO, "Nearest isometric view" },

View File

@ -402,7 +402,7 @@ public:
MNU_GROUP_LATHE,
MNU_GROUP_ROT,
MNU_GROUP_TRANS,
MNU_GROUP_IMPORT,
MNU_GROUP_LINK,
MNU_GROUP_RECENT,
// Constrain
MNU_DISTANCE_DIA,

View File

@ -956,7 +956,7 @@ LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
SolveSpaceUI::MenuFile(id);
break;
}
if((id >= RECENT_IMPORT && id < (RECENT_IMPORT + MAX_RECENT))) {
if((id >= RECENT_LINK && id < (RECENT_LINK + MAX_RECENT))) {
Group::MenuGroup(id);
break;
}
@ -1116,7 +1116,7 @@ DialogChoice SolveSpace::LocateImportedFileYesNoCancel(const std::string &filena
EnableWindow(TextWnd, false);
std::string message =
"The imported file " + filename + " is not present.\n\n"
"The linked file " + filename + " is not present.\n\n"
"Do you want to locate it manually?\n\n"
"If you select \"No\", any geometry that depends on "
"the missing file will be removed.";
@ -1209,7 +1209,7 @@ static void DoRecent(HMENU m, int base)
void SolveSpace::RefreshRecentMenus(void)
{
DoRecent(RecentOpenMenu, RECENT_OPEN);
DoRecent(RecentImportMenu, RECENT_IMPORT);
DoRecent(RecentImportMenu, RECENT_LINK);
}
HMENU CreateGraphicsWindowMenus(void)